X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fap.pl;h=dc48e3d70c854f593a335c448f7381d5a1e676c3;hb=b8ee6b6ed46e55095b955ee1800b8a4b8d8ccc3f;hp=c84b6146e5d3d641bee163014b9e1bbaa5e503bc;hpb=ce47a2340ef118b494854deae1b0ddc74b1d1c5a;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index c84b6146e..dc48e3d70 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -31,14 +31,23 @@ # #====================================================================== +use POSIX qw(strftime); +use List::Util qw(sum); + use SL::AP; +use SL::FU; use SL::IR; use SL::IS; use SL::PE; +use SL::ReportGenerator; +use SL::DB::Default; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/drafts.pl"; +require "bin/mozilla/reportgenerator.pl"; + +use strict; 1; @@ -73,87 +82,98 @@ require "bin/mozilla/drafts.pl"; # $locale->text('Dec') sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('general_ledger'); - return $lxdebug->leave_sub() if (load_draft_maybe()); + return $main::lxdebug->leave_sub() if (load_draft_maybe()); $form->{title} = "Add"; - $form->{callback} = - "$form->{script}?action=add&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "ap.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; AP->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; - &create_links; + create_links(dont_save => 1); $form->{transdate} = $form->{initial_transdate}; &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub edit { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + $main::auth->assert('general_ledger'); $form->{title} = "Edit"; - &create_links; + create_links(); &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub display_form { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + $main::auth->assert('general_ledger'); &form_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub create_links { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my %params = @_; + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('general_ledger'); $form->create_links("AP", \%myconfig, "vendor"); - $taxincluded = $form->{taxincluded}; - $duedate = $form->{duedate}; + my %saved; + if (!$params{dont_save}) { + %saved = map { ($_ => $form->{$_}) } qw(direct_debit taxincluded); + $saved{duedate} = $form->{duedate} if $form->{duedate}; + } IR->get_vendor(\%myconfig, \%$form); - $form->{taxincluded} = $taxincluded; - $form->{duedate} = $duedate if $duedate; + + $form->{$_} = $saved{$_} for keys %saved; $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}"; $form->{rowcount} = 1; # build the popup menus $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked"; - # notes - $form->{notes} = $form->{intnotes} unless $form->{notes}; - # currencies - @curr = split(/:/, $form->{currencies}); - chomp $curr[0]; - $form->{defaultcurrency} = $curr[0]; + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - map { $form->{selectcurrency} .= "