X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fap.pl;h=f62294eaa7d2372d25c99464dc30f8cac9b1ab5d;hb=4c9d45bf6dc8697327cc6e49f94c56426e67354f;hp=8b32585a0bce450a465ad0749e1f0d9a091b3148;hpb=a590a6518025280c2d6e76c87641764ca6198521;p=kivitendo-erp.git
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index 8b32585a0..f62294eaa 100644
--- a/bin/mozilla/ap.pl
+++ b/bin/mozilla/ap.pl
@@ -92,7 +92,7 @@ sub add {
$form->{title} = "Add";
- $form->{callback} = "ap.pl?action=add" 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};
@@ -195,7 +195,7 @@ sub form_header {
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
$main::auth->assert('general_ledger');
@@ -244,17 +244,10 @@ sub form_header {
$form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'sell');
$form->{exchangerate} = $form->{forex} if $form->{forex};
-
# format amounts
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
- if ($form->{exchangerate} == 0) {
- $form->{exchangerate} = "";
- }
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} =
- $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
+ $form->{exchangerate} = $form->{exchangerate} ? $form->format_amount(\%myconfig, $form->{exchangerate}) : '';
+ $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
+ $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
my $exchangerate = qq|
{forex}>
@@ -292,7 +285,8 @@ sub form_header {
my $notes =
qq||;
- my $department = qq|
+ my $department;
+ $department = qq|
| . $locale->text('Department') . qq| |
@@ -408,6 +402,12 @@ sub form_header {
$form->{javascript} .= qq||;
$form->{javascript} .= qq||;
+ my $globalprojectnumber =
+ NTI($cgi->popup_menu('-name' => "globalproject_id",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"globalproject_id"} ));
+
$form->header;
my $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
@@ -493,6 +493,10 @@ sub form_header {
| | . $locale->text('Due Date') . qq| |
$button2
+
+ | . $locale->text('Project Number') . qq| |
+ $globalprojectnumber |
+
@@ -681,12 +685,25 @@ $jsscript
# format amounts
if ($form->{"paid_$i"}) {
$form->{"paid_$i"} =
- $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+ $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
}
- $form->{"exchangerate_$i"} =
- $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
if ($form->{"exchangerate_$i"} == 0) {
$form->{"exchangerate_$i"} = "";
+ } else {
+ $form->{"exchangerate_$i"} =
+ $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ }
+
+ print qq|{"acc_trans_id_$i"}>\n|;
+ print qq|{"gldate_$i"}>\n|;
+ my $changeable = 1;
+ if ($::lx_office_conf{features}->{payments_changeable} == 0) {
+ # never
+ $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
+ }
+ if ($::lx_office_conf{features}->{payments_changeable} == 2) {
+ # on the same day
+ $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
}
$exchangerate = qq| |;
@@ -695,8 +712,13 @@ $jsscript
$exchangerate =
qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
} else {
- $exchangerate =
- qq|{"exchangerate_$i"}>|;
+ if ($changeable) {
+ $exchangerate =
+ qq|{"exchangerate_$i"}>|;
+ } else {
+ $exchangerate =
+ qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
+ }
}
}
@@ -704,32 +726,78 @@ $jsscript
{"forex_$i"}>
|;
- $column_data{"paid_$i"} =
- qq| | |;
- $column_data{"AP_paid_$i"} =
- qq|${selectAP_paid} | |;
- $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
- $column_data{"datepaid_$i"} =
- qq|
+ my $datepaid;
+ if ($changeable) {
+ $datepaid = qq| |
| |;
- $column_data{"source_$i"} =
- qq| | |;
- $column_data{"memo_$i"} =
- qq| | |;
- $column_data{"paid_project_id_$i"} =
+ } else {
+ $datepaid = qq|$form->{"datepaid_$i"} | |.
+ qq|{"datepaid_$i"}>|;
+ }
+
+ my $paid;
+ if ($changeable) {
+ $paid = qq| | |;
+ } else {
+ $paid = qq|$form->{"paid_$i"} | |.
+ qq|{"paid_$i"}>|;
+ }
+
+ my $source;
+ if ($changeable) {
+ $source = qq| | |;
+ } else {
+ $source = qq|$form->{"source_$i"} | |.
+ qq|{"source_$i"}>|;
+ }
+
+ my $memo;
+ if ($changeable) {
+ $memo = qq| | |;
+ } else {
+ $memo = qq|$form->{"memo_$i"} | |.
+ qq|{"memo_$i"}>|;
+ }
+
+ my $AP_paid;
+ if ($changeable) {
+ $AP_paid = qq|${selectAP_paid} | |;
+ } else {
+ $AP_paid = qq|$form->{"AP_paid_$i"} | |.
+ qq|{"AP_paid_$i"}>|;
+ }
+
+ my $paid_project_id;
+ if ($changeable) {
+ $paid_project_id =
qq||
. NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
'-values' => \@project_values,
'-labels' => \%project_labels,
'-default' => $form->{"paid_project_id_$i"} ))
. qq| | |;
+ } else {
+ my $projectnumber = $project_labels{$form->{"paid_project_id_$i"}};
+ $paid_project_id = qq|$projectnumber | |.
+ qq|{"paid_project_id_$i"}>|;
+ }
+
+ $column_data{"paid_$i"} = $paid;
+ $column_data{"AP_paid_$i"} = $AP_paid;
+ $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
+ $column_data{"datepaid_$i"} = $datepaid;
+ $column_data{"source_$i"} = $source;
+ $column_data{"memo_$i"} = $memo;
+ $column_data{"paid_project_id_$i"} = $paid_project_id;
map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
print "
";
- push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
+ if ($changeable) {
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
+ }
}
my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid};
@@ -769,7 +837,7 @@ sub form_footer {
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
$main::auth->assert('general_ledger');
@@ -1012,6 +1080,8 @@ sub post {
$main::auth->assert('general_ledger');
+ my ($inline) = @_;
+
# 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!"));
@@ -1086,7 +1156,7 @@ sub post {
# /saving the history
remove_draft() if $form->{remove_draft};
# Dieser Text wird niemals ausgegeben: Probleme beim redirect?
- $form->redirect($locale->text('Transaction posted!'));
+ $form->redirect($locale->text('Transaction posted!')) unless $inline;
} else {
$form->error($locale->text('Cannot post transaction!'));
}
@@ -1123,7 +1193,7 @@ sub use_as_template {
$main::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);
+ map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
$form->{paidaccounts} = 1;
$form->{rowcount}--;
$form->{invdate} = $form->current_date(\%myconfig);
@@ -1185,7 +1255,7 @@ sub yes {
$main::auth->assert('general_ledger');
- if (AP->delete_transaction(\%myconfig, \%$form, $main::spool)) {
+ if (AP->delete_transaction(\%myconfig, \%$form)) {
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
@@ -1203,7 +1273,7 @@ sub yes {
sub search {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger | invoice_edit');
+ $main::auth->assert('general_ledger | vendor_invoice_edit');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -1276,7 +1346,7 @@ sub ap_transactions {
vendornumber country ustid taxzone payment_terms charts);
my @hidden_variables = map { "l_${_}" } @columns;
- push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto);
+ push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto department);
my $href = build_std_url('action=ap_transactions', grep { $form->{$_} } @hidden_variables);
@@ -1297,7 +1367,7 @@ sub ap_transactions {
'transaction_description' => { 'text' => $locale->text('Transaction description'), },
'notes' => { 'text' => $locale->text('Notes'), },
'employee' => { 'text' => $locale->text('Employee'), },
- 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), },
+ 'globalprojectnumber' => { 'text' => $locale->text('Document Project Number'), },
'vendornumber' => { 'text' => $locale->text('Vendor Number'), },
'country' => { 'text' => $locale->text('Country'), },
'ustid' => { 'text' => $locale->text('USt-IdNr.'), },
@@ -1342,6 +1412,7 @@ sub ap_transactions {
'attachment_basename' => $locale->text('vendor_invoice_list') . strftime('_%Y%m%d', localtime time),
);
$report->set_options_from_form();
+ $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
# add sort and escape callback, this one we use for the add sub
$form->{callback} = $href .= "&sort=$form->{sort}";