X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fap.pl;h=7b06ed74a6e0c0bc809e3983e2b32539feb96958;hb=8c7e44938a661e035f62840e1e177353240ace5d;hp=1b2f652066315a6f955c5703a109ccf5c2817617;hpb=f5e4c22be81f5deb2affdb09b1524f9e9890498b;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 1b2f65206..7b06ed74a 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -42,7 +42,7 @@ use SL::ReportGenerator; 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; @@ -79,13 +79,13 @@ require "bin/mozilla/report_generator.pl"; sub add { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + return $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" unless $form->{callback}; AP->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; @@ -99,6 +99,8 @@ sub add { sub edit { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{title} = "Edit"; &create_links; @@ -110,6 +112,8 @@ sub edit { sub display_form { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + &form_header; &form_footer; @@ -119,6 +123,8 @@ sub display_form { sub create_links { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->create_links("AP", \%myconfig, "vendor"); $taxincluded = $form->{taxincluded}; $duedate = $form->{duedate}; @@ -174,6 +180,8 @@ sub create_links { sub form_header { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $title = $form->{title}; $form->{title} = $locale->text("$title Accounts Payables Transaction"); @@ -743,13 +751,12 @@ $jsscript sub form_footer { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + print qq| - -{login}> -{password}> | . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]) @@ -780,8 +787,8 @@ sub form_footer { } # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it - print qq| | - if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap') && !$form->{paid_1}); + print qq| | + if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id})); print qq| @@ -793,13 +800,12 @@ sub form_footer { } # button for saving history if($form->{id} ne "") { - print qq| |; + print qq| |; } # /button for saving history # mark_as_paid button if($form->{id} ne "") { - print qq||; + print qq| |; } # /mark_as_paid button print " @@ -814,13 +820,19 @@ sub form_footer { sub mark_as_paid { $lxdebug->enter_sub(); + + $auth->assert('general_ledger'); + &mark_as_paid_common(\%myconfig,"ap"); + $lxdebug->leave_sub(); } sub update { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + my $display = shift; $form->{invtotal} = 0; @@ -912,6 +924,8 @@ sub update { sub post_payment { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); for $i (1 .. $form->{paidaccounts}) { @@ -946,6 +960,8 @@ sub post_payment { sub post { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + # check if there is a vendor, invoice and due date $form->isblank("transdate", $locale->text("Invoice Date missing!")); $form->isblank("duedate", $locale->text("Due Date missing!")); @@ -1023,6 +1039,8 @@ sub post { sub post_as_new { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{postasnew} = 1; # saving the history if(!exists $form->{addition} && $form->{id} ne "") { @@ -1039,6 +1057,8 @@ sub post_as_new { sub use_as_template { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); $form->{paidaccounts} = 1; $form->{rowcount}--; @@ -1051,6 +1071,8 @@ sub use_as_template { sub delete { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{title} = $locale->text('Confirm!'); $form->header; @@ -1064,6 +1086,7 @@ sub delete { |; foreach $key (keys %$form) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); $form->{$key} =~ s/\"/"/g; print qq|\n|; } @@ -1088,6 +1111,9 @@ sub delete { sub yes { $lxdebug->enter_sub(); + + $auth->assert('general_ledger'); + if (AP->delete_transaction(\%myconfig, \%$form, $spool)) { # saving the history if(!exists $form->{addition}) { @@ -1106,6 +1132,8 @@ sub yes { sub search { $lxdebug->enter_sub(); + $auth->assert('general_ledger | vendor_invoice_edit'); + # setup vendor selection $form->all_vc(\%myconfig, "vendor", "AP"); @@ -1298,8 +1326,6 @@ $jsscript
{nextsub}> -{login}> -{password}> @@ -1333,6 +1359,8 @@ sub create_subtotal_row { sub ap_transactions { $lxdebug->enter_sub(); + $auth->assert('general_ledger | vendor_invoice_edit'); + ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor}); $form->{sort} ||= 'transdate'; @@ -1492,31 +1520,14 @@ sub ap_transactions { sub storno { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + if (IS->has_storno(\%myconfig, $form, 'ap')) { $form->{title} = $locale->text("Cancel Accounts Payables Transaction"); $form->error($locale->text("Transaction has already been cancelled!")); } - # negate amount/taxes - for my $i (1 .. $form->{rowcount}) { - $form->{"amount_$i"} *= -1; - $form->{"tax_$i"} *= -1; - } - - # format things - for my $i (1 .. $form->{rowcount}) { - for (qw(amount tax)) { - $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"}; - } - } - - $form->{storno} = 1; - $form->{storno_id} = $form->{id}; - $form->{id} = 0; - - $form->{invnumber} = "Storno-" . $form->{invnumber}; - - post(); + AP->storno($form, \%myconfig, $form->{id}); # saving the history if(!exists $form->{addition} && $form->{id} ne "") { @@ -1526,5 +1537,7 @@ sub storno { } # /saving the history + $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); + $lxdebug->leave_sub(); }