X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Frp.pl;h=630a2b5bddbd795f5ab664200736f0d1bacac4b2;hb=e9b11e128378926d08c0e468603627aa7617ce10;hp=5d8b86616f707dba26a11f3bcbf1065daa62d324;hpb=d659dc180a0bc187c802e7b55135949ef37b74eb;p=kivitendo-erp.git diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 5d8b86616..630a2b5bd 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -43,11 +43,12 @@ use SL::DB::Project; use SL::DB::Customer; use SL::RP; use SL::Iconv; +use SL::Locale::String qw(t8); +use SL::Presenter::Tag; use SL::ReportGenerator; use Data::Dumper; use List::MoreUtils qw(any); -require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/reportgenerator.pl"; @@ -97,6 +98,7 @@ use strict; # $locale->text('Payments') # $locale->text('Project Transactions') # $locale->text('Business evaluation') +# $locale->text('Final Invoice, please use mark as paid manually') # $form->parse_html_template('rp/html_report_susa') @@ -143,7 +145,7 @@ sub report { ); $::form->{title} = $title{$::form->{report}}; - $::request->{layout}->add_javascripts('autocomplete_customer.js'); + $::request->{layout}->add_javascripts('kivi.CustomerVendor.js'); $::request->{layout}->add_javascripts('autocomplete_project.js'); $::form->{fromdate} = DateTime->today->truncate(to => 'year')->to_kivitendo; $::form->{todate} = DateTime->today->truncate(to => 'year')->add(years => 1)->add(days => -1)->to_kivitendo; @@ -165,6 +167,7 @@ sub report { my $is_trial_balance = $::form->{report} eq "trial_balance"; my $is_aging = $::form->{report} =~ /^a[rp]_aging$/; my $is_payments = $::form->{report} =~ /(receipts|payments)$/; + my $format = 'html'; my ($label, $nextsub, $vc); if ($is_aging) { @@ -175,6 +178,8 @@ sub report { $nextsub = "generate_$::form->{report}"; $vc = qq|{vc} size=35 class="initial_focus">|; + + $format = 'pdf'; } my ($selection, $paymentaccounts); @@ -190,6 +195,8 @@ sub report { } } + setup_rp_report_action_bar(); + $::form->header; print $::form->parse_html_template('rp/report', { paymentaccounts => $paymentaccounts, @@ -207,6 +214,7 @@ sub report { is_income_statement => $is_income_statement, is_erfolgsrechnung => $is_erfolgsrechnung, is_projects => $is_projects, + format => $format, }); $::lxdebug->leave_sub; @@ -623,7 +631,7 @@ sub generate_trial_balance { my $attachment_basename = $locale->text('trial_balance'); my $report = SL::ReportGenerator->new(\%myconfig, $form); - my @hidden_variables = qw(fromdate todate year method); + my @hidden_variables = qw(fromdate todate year method department_id all_accounts); my $href = build_std_url('action=generate_trial_balance', grep { $form->{$_} } @hidden_variables); @@ -999,26 +1007,27 @@ sub aging { my $report = SL::ReportGenerator->new(\%myconfig, $form); - my @columns = qw(statement ct invnumber transdate duedate amount open); - + my @columns = qw(statement ct invnumber transdate duedate amount open datepaid current_open type); my %column_defs = ( - 'statement' => { 'text' => '', 'visible' => $form->{ct} eq 'customer' ? 'HTML' : 0, }, + 'statement' => { raw_header_data => SL::Presenter::Tag::checkbox_tag("checkall", checkall => '[name^=statement_]'), 'visible' => $form->{ct} eq 'customer' ? 'HTML' : 0, align => "center" }, 'ct' => { 'text' => $form->{ct} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), }, 'invnumber' => { 'text' => $locale->text('Invoice'), }, 'transdate' => { 'text' => $locale->text('Date'), }, 'duedate' => { 'text' => $locale->text('Due'), }, 'amount' => { 'text' => $locale->text('Amount'), }, 'open' => { 'text' => $locale->text('Open'), }, + 'datepaid' => { 'text' => $locale->text('Date of Last Payment'), visible => ($form->{reporttype} eq 'custom') }, + 'current_open' => { 'text' => $locale->text('Open Amount at Last Payment Date'), visible => ($form->{reporttype} eq 'custom') }, + 'type' => { 'text' => $locale->text('Note'), }, ); my %column_alignment = ('statement' => 'center', - map { $_ => 'right' } qw(open amount)); + map { $_ => 'right' } qw(open amount current_open datepaid)); $report->set_options('std_column_visibility' => 1); $report->set_columns(%column_defs); $report->set_column_order(@columns); - - my @hidden_variables = qw(todate customer vendor arap title ct fordate reporttype department); + my @hidden_variables = qw(todate customer vendor arap title ct fordate reporttype department fromdate); $report->set_export_options('generate_' . ($form->{arap} eq 'ar' ? 'ar' : 'ap') . '_aging', @hidden_variables); my @options; @@ -1042,10 +1051,20 @@ sub aging { $form->{title} = sprintf($locale->text('Ap aging on %s'), $form->{todate}); } - if ($form->{fromdate}) { - push @options, $locale->text('for Period') . " " . $locale->text('From') . " " .$locale->date(\%myconfig, $form->{fromdate}, 1) . " " . $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{todate}, 1); + $form->{callback} .= "&reporttype=" . E($form->{reporttype}); + if ($form->{reporttype} eq 'free') { + if ($form->{fromdate}) { + push @options, $locale->text('for Period') . " " . $locale->text('From') . " " . + $locale->date(\%myconfig, $form->{fromdate}, 1) . " " . + $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{todate}, 1); + } else { + push @options, $locale->text('for Period') . " " . $locale->text('Bis') . " " . + $locale->date(\%myconfig, $form->{todate}, 1); + } + } elsif ($form->{reporttype} eq 'custom') { + push @options, $locale->text('Reference day') . " " . $locale->date(\%myconfig, $form->{fordate}, 1); } else { - push @options, $locale->text('for Period') . " " . $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{todate}, 1); + die "Unknown reporttype for aging"; } $attachment_basename = $form->{ct} eq 'customer' ? $locale->text('ar_aging_list') : $locale->text('ap_aging_list'); @@ -1060,7 +1079,7 @@ sub aging { my $previous_ctid = 0; my $row_idx = 0; - my @periods = qw(open amount); + my @periods = qw(open amount current_open); my %subtotals = map { $_ => 0 } @periods; my %totals = map { $_ => 0 } @periods; @@ -1086,6 +1105,12 @@ sub aging { } $row->{invnumber}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'callback', 'id=' . E($ref->{id})); + if ($row->{type}->{data} eq 'final_invoice') { + $row->{type}->{data} = $locale->text('Final Invoice, please use mark as paid manually'); + $row->{type}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'callback', 'id=' . E($ref->{id})); + } else { + $row->{type}->{data} = ''; + } if ($previous_ctid != $ref->{ctid}) { $row->{statement}->{raw_data} = @@ -1113,62 +1138,12 @@ sub aging { 'raw_bottom_info_text' => $raw_bottom_info_text); } + setup_rp_aging_action_bar(arap => $form->{arap}); $report->generate_with_headers(); $main::lxdebug->leave_sub(); } -sub select_all { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - RP->aging(\%myconfig, \%$form); - - map { $_->{checked} = "checked" } @{ $form->{AG} }; - - &aging; - - $main::lxdebug->leave_sub(); -} - -sub e_mail { - $::lxdebug->enter_sub; - $::auth->assert('general_ledger'); - - # get name and email addresses - my $selected = 0; - for my $i (1 .. $::form->{rowcount}) { - next unless $::form->{"statement_$i"}; - $::form->{"$::form->{ct}_id"} = $::form->{"$::form->{ct}_id_$i"}; - RP->get_customer(\%::myconfig, $::form); - $selected = 1; - last; - } - - $::form->error($::locale->text('Nothing selected!')) unless $selected; - - $::form->{media} = "email"; - - # save all other variables - my @hidden_values; - for my $key (keys %$::form) { - next if any { $key eq $_ } qw(login password action email cc bcc subject message type sendmode format header); - next unless '' eq ref $::form->{$key}; - push @hidden_values, $key; - } - - $::form->header; - print $::form->parse_html_template('rp/e_mail', { - print_options => print_options(inline => 1), - hidden_values => \@hidden_values, - }); - - $::lxdebug->leave_sub; -} - sub send_email { $main::lxdebug->enter_sub(); @@ -1183,8 +1158,11 @@ sub send_email { RP->aging(\%myconfig, \%$form); - $form->{"statement_1"} = 1; + my $email_form = delete $form->{email_form}; + my %field_names = (to => 'email'); + + $form->{ $field_names{$_} // $_ } = $email_form->{$_} for keys %{ $email_form }; $form->{media} = 'email'; print_form(); @@ -1911,4 +1889,42 @@ sub hotfix_reformat_date { $main::lxdebug->leave_sub(); } + +sub setup_rp_aging_action_bar { + my %params = @_; + + return unless $params{arap} eq 'ar'; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + combobox => [ + action => [ + t8('Print'), + call => [ 'kivi.SalesPurchase.show_print_dialog' ], + checks => [ [ 'kivi.check_if_entries_selected', '[name^=statement_]' ] ], + ], + action => [ + t8('E Mail'), + call => [ 'kivi.SalesPurchase.show_email_dialog', 'send_email' ], + checks => [ [ 'kivi.check_if_entries_selected', '[name^=statement_]' ] ], + ], + ], + ); + } +} + +sub setup_rp_report_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Continue'), + submit => [ '#form', { action => 'continue' } ], + accesskey => 'enter', + ], + ); + } +} + 1;