X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=3d4fe26649274218c5fc0d053ee13fa96def30d7;hb=8c204ce48aa9ecc1e3eb6a99ff9e444716633a90;hp=699cb7deeccab105d7fb172b6559926fe3bb0417;hpb=4d8a65151cff0399654ea47c196ab38361a976e8;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 699cb7dee..38a667e95 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -32,26 +32,22 @@ #====================================================================== use POSIX qw(strftime); +use List::Util qw(sum first max); use SL::AR; +use SL::FU; use SL::IS; use SL::PE; +use SL::DB::Default; use SL::ReportGenerator; -# use strict; -#use warnings; - -# imports -our ($cgi, $form, $lxdebug, $locale, %myconfig); - require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/drafts.pl"; -require "bin/mozilla/report_generator.pl"; +require "bin/mozilla/reportgenerator.pl"; -1; - -# end of main +use strict; +#use warnings; # this is for our long dates # $locale->text('January') @@ -82,107 +78,119 @@ require "bin/mozilla/report_generator.pl"; # $locale->text('Dec') sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - return $lxdebug->leave_sub() if (load_draft_maybe()); + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + return $main::lxdebug->leave_sub() if (load_draft_maybe()); # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; - $form->{addition} = "ADDED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->{addition} = "ADDED"; + $form->save_history; } - # /saving the history - + # /saving the history + $form->{title} = "Add"; - $form->{callback} = - "$form->{script}?action=add&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "ar.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; AR->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(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + # show history button $form->{javascript} = qq||; #/show hhistory button $form->{javascript} .= qq||; $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(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; &form_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub create_links { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); - my ($duedate, $taxincluded, @curr); + my %params = @_; + my $form = $main::form; + my %myconfig = %main::myconfig; $form->create_links("AR", \%myconfig, "customer"); - $duedate = $form->{duedate}; - $taxincluded = $form->{taxincluded}; - my $id = $form->{id}; + my %saved; + if (!$params{dont_save}) { + %saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded); + $saved{duedate} = $form->{duedate} if $form->{duedate}; + } + IS->get_customer(\%myconfig, \%$form); - $form->{taxincluded} = $taxincluded; - $form->{id} = $id; - $form->{duedate} = $duedate if $duedate; + $form->{$_} = $saved{$_} for keys %saved; $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; $form->{rowcount} = 1; - # 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} .= "