X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Far.pl;h=cd30053ed5bce3dad0518d7cf8e7a5b31cb087e3;hb=c800572add49de8c07dbe913cfc8c06085a68c27;hp=e2777bd49f5c021e5d0bc70ef381bd7682aa22c1;hpb=6a8787147ad643549eb26cb4f9a373b5b354b8b9;p=kivitendo-erp.git
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index e2777bd49..cd30053ed 100644
--- a/bin/mozilla/ar.pl
+++ b/bin/mozilla/ar.pl
@@ -95,7 +95,7 @@ sub add {
# /saving the history
$form->{title} = "Add";
- $form->{callback} = "ar.pl?action=add" 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};
@@ -215,7 +215,7 @@ sub form_header {
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($title, $readonly, $exchangerate, $rows);
my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project);
@@ -271,17 +271,9 @@ sub form_header {
$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");
$exchangerate = qq|
{forex}>
@@ -444,6 +436,12 @@ sub form_header {
qq|| .
qq||;
+ my $globalprojectnumber =
+ NTI($cgi->popup_menu('-name' => "globalproject_id",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"globalproject_id"} ));
+
$form->header;
$onload = qq|focus()|;
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
@@ -531,6 +529,10 @@ sub form_header {
| . $locale->text('Due Date') . qq| |
$button2
+
+ | . $locale->text('Project Number') . qq| |
+ $globalprojectnumber |
+
@@ -725,11 +727,23 @@ $jsscript
$form->{"paid_$i"} =
$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| |;
@@ -738,8 +752,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"}|;
+ }
}
}
@@ -747,33 +766,78 @@ $jsscript
{"forex_$i"}>
|;
- $column_data{paid} =
- qq| | |;
- $column_data{AR_paid} =
- qq|${selectAR_paid} | |;
- $column_data{exchangerate} = qq|$exchangerate | |;
- $column_data{datepaid} =
- qq|
+ my $datepaid;
+ if ($changeable) {
+ $datepaid = qq| |
| |;
- $column_data{source} =
- qq| | |;
- $column_data{memo} =
- qq| | |;
+ } else {
+ $datepaid = qq|$form->{"datepaid_$i"} | |.
+ qq|{"datepaid_$i"}>|;
+ }
- $column_data{paid_project_id} =
+ 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 $AR_paid;
+ if ($changeable) {
+ $AR_paid = qq|${selectAR_paid} | |;
+ } else {
+ $AR_paid = qq|$form->{"AR_paid_$i"} | |.
+ qq|{"AR_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} = $paid;
+ $column_data{AR_paid} = $AR_paid;
+ $column_data{exchangerate} = qq|$exchangerate | |;
+ $column_data{datepaid} = $datepaid;
+ $column_data{source} = $source;
+ $column_data{memo} = $memo;
+ $column_data{paid_project_id} = $paid_project_id;
map { print qq|$column_data{$_}\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};
@@ -815,7 +879,7 @@ sub form_footer {
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($transdate, $closedto);
@@ -982,10 +1046,13 @@ sub update {
$form->{invdate} = $form->{transdate};
- my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1);
+ my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1 customer_id);
&check_name("customer");
+ # check_name loads customer notes into notes, but ar only knows intnotes, so copy them
+ $form->{notes} = $form->{intnotes} if $saved_variables{customer_id} != $form->{customer_id};
+
$form->{AR} = $saved_variables{AR};
if ($saved_variables{AR_amount_1} =~ m/.--./) {
map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1);
@@ -1179,7 +1246,7 @@ sub use_as_template {
my $form = $main::form;
my %myconfig = %main::myconfig;
- 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);
@@ -1264,7 +1331,7 @@ sub search {
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($customer, $department);
my ($jsscript, $button1, $button2, $onload);
@@ -1279,16 +1346,13 @@ sub search {
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
"departments" => "ALL_DEPARTMENTS",
"customers" => "ALL_VC",
- "employees" => "ALL_EMPLOYEES",
- "salesmen" => "ALL_SALESMEN",
"business_types" => "ALL_BUSINESS_TYPES");
+ $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
$form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
# constants and subs for template
$form->{jsscript} = 1;
$form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
- $form->{employee_labels} = sub { $_[0]->{"name"} || $_[0]->{"login"} };
- $form->{salesman_labels} = $form->{employee_labels};
$form->header;
print $form->parse_html_template('ar/search', { %myconfig });
@@ -1328,7 +1392,6 @@ sub ar_transactions {
my ($callback, $href, @columns);
- $form->{customer} = $form->unescape($form->{customer});
($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
report_generator_set_default_sort('transdate', 1);
@@ -1342,10 +1405,10 @@ sub ar_transactions {
@columns =
qw(transdate id type invnumber ordnumber name netamount tax amount paid
datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia
- marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts);
+ marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype);
my @hidden_variables = map { "l_${_}" } @columns;
- push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto);
+ push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id);
$href = build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables);
@@ -1369,7 +1432,7 @@ sub ar_transactions {
'employee' => { 'text' => $locale->text('Employee'), },
'shippingpoint' => { 'text' => $locale->text('Shipping Point'), },
'shipvia' => { 'text' => $locale->text('Ship via'), },
- 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), },
+ 'globalprojectnumber' => { 'text' => $locale->text('Document Project Number'), },
'marge_total' => { 'text' => $locale->text('Ertrag'), },
'marge_percent' => { 'text' => $locale->text('Ertrag prozentual'), },
'customernumber' => { 'text' => $locale->text('Customer Number'), },
@@ -1378,6 +1441,7 @@ sub ar_transactions {
'taxzone' => { 'text' => $locale->text('Steuersatz'), },
'payment_terms' => { 'text' => $locale->text('Payment Terms'), },
'charts' => { 'text' => $locale->text('Buchungskonto'), },
+ 'customertype' => { 'text' => $locale->text('Customer type'), },
);
foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) {
@@ -1429,6 +1493,14 @@ sub ar_transactions {
if ($form->{open}) {
push @options, $locale->text('Open');
}
+ if ($form->{employee_id}) {
+ my $employee = SL::DB::Employee->new(id => $form->{employee_id})->load;
+ push @options, $locale->text('Employee') . ' : ' . $employee->name;
+ }
+ if ($form->{salesman_id}) {
+ my $salesman = SL::DB::Employee->new(id => $form->{salesman_id})->load;
+ push @options, $locale->text('Salesman') . ' : ' . $salesman->name;
+ }
if ($form->{closed}) {
push @options, $locale->text('Closed');
}