X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=e0571633dc5c39b34e009331a796623d8df35ca2;hb=cd92cf1c19785cdcd5812735185676c9ad982175;hp=ae15aed9ad6c87b18b986423faa6b8d8c3106391;hpb=8c7e44938a661e035f62840e1e177353240ace5d;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index ae15aed9a..e0571633d 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -32,8 +32,10 @@ #====================================================================== use POSIX qw(strftime); +use List::Util qw(sum); use SL::AR; +use SL::FU; use SL::IS; use SL::PE; use SL::ReportGenerator; @@ -259,13 +261,8 @@ sub form_header { s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, 'buy' - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; # format amounts $form->{exchangerate} = @@ -431,9 +428,14 @@ sub form_header { qq||; } + my $follow_up_vc = $form->{customer}; + $follow_up_vc =~ s/--.*?//; + my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; + $form->{javascript} .= qq|| . - qq||; + qq|| . + qq||; $form->header; $onload = qq|focus()|; @@ -449,6 +451,10 @@ sub form_header { {closedto}> {locked}> + + + + | . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| @@ -800,8 +806,20 @@ sub form_footer { my ($transdate, $closedto); + my $follow_ups_block; + if ($form->{id}) { + my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); + + if (@{ $follow_ups} ) { + my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; + $follow_ups_block = qq|

| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|

|; + } + } + print qq| +$follow_ups_block + @@ -842,7 +860,10 @@ sub form_footer { |; } print qq| - |; + + |; } else { if ($transdate > $closedto) { @@ -935,13 +956,8 @@ sub update { $form->{rowcount} = $count + 1; map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount}); - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, 'buy' - ))); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; $form->{invdate} = $form->{transdate}; my $save_AR = $form->{AR}; @@ -960,13 +976,8 @@ sub update { $totalpaid += $form->{"paid_$i"}; - $form->{"exchangerate_$i"} = $exchangerate - if ( - $form->{"forex_$i"} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy' - ))); + $form->{"forex_$i"} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); + $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; } } @@ -998,7 +1009,7 @@ sub post_payment { $form->isblank("datepaid_$i", $locale->text('Payment date missing!')); -# $form->error($locale->text('Cannot post payment for a closed period!')) if ($datepaid <= $closedto); + $form->error($locale->text('Cannot post payment for a closed period!')) if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig)); if ($form->{currency} ne $form->{defaultcurrency}) { # $form->{"exchangerate_$i"} = $form->{exchangerate} if ($invdate == $datepaid); @@ -1039,7 +1050,7 @@ sub post { my $closedto = $form->datetonum($form->{closedto}, \%myconfig); my $transdate = $form->datetonum($form->{transdate}, \%myconfig); - $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto); + $form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig)); $form->error($locale->text('Zero amount posting!')) unless grep $_*1, map $form->parse_amount(\%myconfig, $form->{"amount_$_"}), 1..$form->{rowcount}; @@ -1056,7 +1067,7 @@ sub post { $form->isblank("datepaid_$i", $locale->text('Payment date missing!')); $form->error($locale->text('Cannot post payment for a closed period!')) - if ($datepaid <= $closedto); + if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig)); if ($form->{currency} ne $form->{defaultcurrency}) { $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid); @@ -1366,7 +1377,7 @@ sub search { | . $locale->text('Notes') . qq| - + | . $locale->text('Salesperson') . qq| | . $locale->text('Shipping Point') . qq| @@ -1374,10 +1385,12 @@ sub search { | . $locale->text('Ship via') . qq| - | - . $locale->text('Ertrag') . qq| - | - . $locale->text('Ertrag prozentual') . qq| + + | . $locale->text('Ertrag') . qq| + + | . $locale->text('Ertrag prozentual') . qq| + + | . $locale->text('Employee') . qq| @@ -1444,7 +1457,7 @@ sub ar_transactions { $form->{customer} = $form->unescape($form->{customer}); ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer}); - $form->{sort} ||= 'transdate'; + report_generator_set_default_sort('transdate', 1); AR->ar_transactions(\%myconfig, \%$form); @@ -1454,7 +1467,7 @@ sub ar_transactions { @columns = qw(transdate id type invnumber ordnumber name netamount tax amount paid - datepaid due duedate transaction_description notes employee shippingpoint shipvia + datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia marge_total marge_percent globalprojectnumber); my @hidden_variables = map { "l_${_}" } @columns; @@ -1478,7 +1491,8 @@ sub ar_transactions { 'duedate' => { 'text' => $locale->text('Due Date'), }, 'transaction_description' => { 'text' => $locale->text('Transaction description'), }, 'notes' => { 'text' => $locale->text('Notes'), }, - 'employee' => { 'text' => $locale->text('Salesperson'), }, + 'salesman' => { 'text' => $locale->text('Salesperson'), }, + 'employee' => { 'text' => $locale->text('Employee'), }, 'shippingpoint' => { 'text' => $locale->text('Shipping Point'), }, 'shipvia' => { 'text' => $locale->text('Ship via'), }, 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), }, @@ -1486,9 +1500,9 @@ sub ar_transactions { 'marge_percent' => { 'text' => $locale->text('Ertrag prozentual'), }, ); - foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid - employee shippingpoint shipvia)) { - $column_defs{$name}->{link} = $href . "&sort=$name"; + foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia)) { + my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } my %column_alignment = map { $_ => 'right' } qw(netamount tax amount paid due); @@ -1501,7 +1515,7 @@ sub ar_transactions { $report->set_export_options('ar_transactions', @hidden_variables); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); my @options; if ($form->{customer}) {