From: Moritz Bunkus Date: Thu, 14 Jun 2007 15:45:12 +0000 (+0000) Subject: Die Berichte über offene Forderungen und offene Verbindlichkeiten auf die Verwendung... X-Git-Tag: release-2.4.3^2~119 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8365e092eb2088a8c2ebba604783555a13dc2a57;p=kivitendo-erp.git Die Berichte über offene Forderungen und offene Verbindlichkeiten auf die Verwendung des ReportGenerators umgestellt. --- diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index da1a265ac..a5f9a72bc 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -35,13 +35,17 @@ # #====================================================================== -require "bin/mozilla/arap.pl"; -require "bin/mozilla/common.pl"; +use POSIX qw(strftime); use SL::PE; use SL::RP; use SL::USTVA; use SL::Iconv; +use SL::ReportGenerator; + +require "bin/mozilla/arap.pl"; +require "bin/mozilla/common.pl"; +require "bin/mozilla/report_generator.pl"; 1; @@ -1515,17 +1519,14 @@ sub generate_ar_aging { # split customer ($form->{customer}) = split(/--/, $form->{customer}); - $customer = $form->escape($form->{customer}, 1); - $title = $form->escape($form->{title}, 1); $form->{ct} = "customer"; $form->{arap} = "ar"; - $form->{callback} = - qq|$form->{script}?action=generate_ar_aging&login=$form->{login}&password=$form->{password}&todate=$form->{todate}&customer=$customer&title=$title|; + $form->{callback} = build_std_url('action=generate_ar_aging', qw(todate customer title)); RP->aging(\%myconfig, \%$form); - &aging; + aging(); $lxdebug->leave_sub(); } @@ -1535,295 +1536,148 @@ sub generate_ap_aging { # split vendor ($form->{vendor}) = split(/--/, $form->{vendor}); - $vendor = $form->escape($form->{vendor}, 1); - $title = $form->escape($form->{title}, 1); $form->{ct} = "vendor"; $form->{arap} = "ap"; - $form->{callback} = - qq|$form->{script}?action=generate_ap_aging&login=$form->{login}&password=$form->{password}&todate=$form->{todate}&vendor=$vendor&title=$title|; + $form->{callback} = build_std_url('action=generate_ap_aging', qw(todate vendor title)); RP->aging(\%myconfig, \%$form); - &aging; + aging(); $lxdebug->leave_sub(); } -sub aging { +sub create_aging_subtotal_row { $lxdebug->enter_sub(); - $form->header; + my ($subtotals, $columns, $periods, $class) = @_; - $column_header{statement} = qq| |; - $column_header{ct} = - qq|| - . $locale->text(ucfirst $form->{ct}) - . qq||; - $column_header{invnumber} = - qq|| . $locale->text('Invoice') . qq||; - $column_header{transdate} = - qq|| . $locale->text('Date') . qq||; - $column_header{duedate} = - qq|| . $locale->text('Due') . qq||; - $column_header{c0} = - qq|| . $locale->text('Current') . qq||; - $column_header{c30} = qq|30|; - $column_header{c60} = qq|60|; - $column_header{c90} = qq|90|; - - @column_index = - (qw(statement ct invnumber transdate duedate c0 c30 c60 c90)); + my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => 'right' } } @{ $columns } }; - if ($form->{department}) { - $option .= "\n
" if $option; - ($department) = split /--/, $form->{department}; - $option .= $locale->text('Department') . " : $department"; - $department = $form->escape($form->{department}, 1); - $form->{callback} .= "&department=$department"; + foreach (@{ $periods }) { + $row->{"c$_"}->{data} = $subtotals->{$_} != 0 ? $form->format_amount(\%myconfig, $subtotals->{$_}, 2) : ''; + $subtotals->{$_} = 0; } - if ($form->{arap} eq 'ar') { - if ($form->{customer}) { - $option .= "\n
" if $option; - $option .= $form->{customer}; - } - } - if ($form->{arap} eq 'ap') { - shift @column_index; - if ($form->{vendor}) { - $option .= "\n
" if $option; - $option .= $form->{vendor}; - } - } - - $todate = $locale->date(\%myconfig, $form->{todate}, 1); - $option .= "\n
" if $option; - $option .= - $locale->text('for Period') . " " . $locale->text('Bis') . " $todate"; + $lxdebug->leave_sub(); - print qq| - + return $row; +} -
{script}> +sub aging { + $lxdebug->enter_sub(); - - - - - - - - - - - - - - - - - -
$form->{title}
$option
- - -|; + my $report = SL::ReportGenerator->new(\%myconfig, $form); - map { print "$column_header{$_}\n" } @column_index; + my @columns = qw(statement ct invnumber transdate duedate c0 c30 c60 c90); - print qq| - -|; + my %column_defs = ( + 'statement' => { 'text' => '', 'visible' => $form->{ct} eq 'customer' ? 'HTML' : 0, }, + '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'), }, + 'c0' => { 'text' => $locale->text('Current'), }, + 'c30' => { 'text' => '30', }, + 'c60' => { 'text' => '60', }, + 'c90' => { 'text' => '90', }, + ); - $ctid = 0; - $subtotal = 0; - $i = 0; + my %column_alignment = ('statement' => 'center', + map { $_ => 'right' } qw(c0 c30 c60 c90)); - foreach $ref (@{ $form->{AG} }) { + $report->set_options('std_column_visibility' => 1); + $report->set_columns(%column_defs); + $report->set_column_order(@columns); - if ($ctid != $ref->{ctid}) { + my @hidden_variables = qw(todate customer vendor arap title ct); + $report->set_export_options('generate_' . ($form->{arap} eq 'ar' ? 'ar' : 'ap') . '_aging', @hidden_variables); - $i++; + my @options; - if ($subtotal) { - $c0subtotal = ($c0subtotal != 0) ? - $form->format_amount(\%myconfig, $c0subtotal, 2, " ") : ""; - $c30subtotal = ($c30subtotal != 0) ? - $form->format_amount(\%myconfig, $c30subtotal, 2, " ") : ""; - $c60subtotal = ($c60subtotal != 0) ? - $form->format_amount(\%myconfig, $c60subtotal, 2, " ") : ""; - $c90subtotal = ($c90subtotal != 0) ? - $form->format_amount(\%myconfig, $c90subtotal, 2, " ") : ""; - } + if ($form->{department}) { + my ($department) = split /--/, $form->{department}; + push @options, $locale->text('Department') . " : $department"; + $form->{callback} .= "&department=" . E($department); + } - $column_data{ct} = qq||; - $column_data{invnumber} = qq||; - $column_data{transdate} = qq||; - $column_data{duedate} = qq||; - $column_data{c0} = - qq||; - $column_data{c30} = - qq||; - $column_data{c60} = - qq||; - $column_data{c90} = - qq||; - - if ($subtotal) { - - # print subtotals - print qq| - -|; + if (($form->{arap} eq 'ar') && $form->{customer}) { + push @options, $form->{customer}; + } - map { print "$column_data{$_}\n" } @column_index; + if (($form->{arap} eq 'ap') && $form->{vendor}) { + push @options, $form->{vendor}; + } - $column_data{statement} = qq||; + push @options, $locale->text('for Period') . " " . $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{todate}, 1); - print qq| - -|; - } + my $attachment_basename = $form->{ct} eq 'customer' ? $locale->text('ar_aging_list') : $locale->text('ap_aging_list'); - $subtotal = 1; + $report->set_options('top_info_text' => join("\n", @options), + 'output_format' => 'HTML', + 'title' => $form->{title}, + 'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time), + ); - $c0subtotal = 0; - $c30subtotal = 0; - $c60subtotal = 0; - $c90subtotal = 0; + my $previous_ctid = 0; + my $row_idx = 0; + my @periods = qw(0 30 60 90); + my %subtotals = map { $_ => 0 } @periods; + my %totals = map { $_ => 0 } @periods; - $column_data{ct} = qq||; - $column_data{statement} = - qq||; + foreach $ref (@{ $form->{AG} }) { + if ($row_idx && ($previous_ctid != $ref->{ctid})) { + $report->add_data(create_aging_subtotal_row(\%subtotals, \@columns, \@periods, 'listsubtotal')); } - $c0subtotal += $ref->{c0}; - $c30subtotal += $ref->{c30}; - $c60subtotal += $ref->{c60}; - $c90subtotal += $ref->{c90}; - - $c0total += $ref->{c0}; - $c30total += $ref->{c30}; - $c60total += $ref->{c60}; - $c90total += $ref->{c90}; - - $ref->{c0} = ($ref->{c0} != 0) ? $form->format_amount(\%myconfig, $ref->{c0}, 2, " ") : ""; - $ref->{c30} = ($ref->{c30} != 0) ? $form->format_amount(\%myconfig, $ref->{c30}, 2, " ") : ""; - $ref->{c60} = ($ref->{c60} != 0) ? $form->format_amount(\%myconfig, $ref->{c60}, 2, " ") : ""; - $ref->{c90} = ($ref->{c90} != 0) ? $form->format_amount(\%myconfig, $ref->{c90}, 2, " ") : ""; + foreach my $key (@periods) { + $subtotals{$key} += $ref->{"c${key}"}; + $totals{$key} += $ref->{"c${key}"}; + $ref->{"c${key}"} = $ref->{"c${key}"} != 0 ? $form->format_amount(\%myconfig, $ref->{"c${key}"}, 2) : ''; + } - $href = - qq|$ref->{module}.pl?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=| - . $form->escape($form->{callback}); + my $row = { }; - $column_data{invnumber} = qq||; - $column_data{transdate} = qq||; - $column_data{duedate} = qq||; - $column_data{c0} = qq||; - $column_data{c30} = qq||; - $column_data{c60} = qq||; - $column_data{c90} = qq||; - - $j++; - $j %= 2; - print qq| - -|; + foreach my $column (@columns) { + $row->{$column} = { + 'data' => (($column eq 'ct') || ($column eq 'statement')) ? '' : $ref->{$column}, + 'align' => $column_alignment{$column}, + 'valign' => $column eq 'statement' ? 'center' : '', + }; + } - map { print "$column_data{$_}\n" } @column_index; + $row->{invnumber}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'callback', 'id=' . E($ref->{id})); - print qq| - -|; + if ($previous_ctid != $ref->{ctid}) { + $row->{statement}->{raw_data} = + $cgi->hidden('-name' => "customer_id_${row_idx}", '-value' => $ref->{ctid}) + . $cgi->checkbox('-name' => "statement_${row_idx}", '-value' => 1, '-label' => '', 'checked' => $ref->{checked}); + $row->{ct}->{data} = $ref->{name}; - $column_data{ct} = qq||; - $column_data{statement} = qq||; + $row_idx++; + } - $ctid = $ref->{ctid}; + $previous_ctid = $ref->{ctid}; + $report->add_data($row); } - # print subtotals - $c0subtotal = $form->format_amount(\%myconfig, $c0subtotal, 2, " "); - $c30subtotal = $form->format_amount(\%myconfig, $c30subtotal, 2, " "); - $c60subtotal = $form->format_amount(\%myconfig, $c60subtotal, 2, " "); - $c90subtotal = $form->format_amount(\%myconfig, $c90subtotal, 2, " "); - - print qq| - -|; - - map { $column_data{$_} = qq|| } @column_index; - - $column_data{c0} = qq||; - $column_data{c30} = qq||; - $column_data{c60} = qq||; - $column_data{c90} = qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - - -|; - - $c0total = $form->format_amount(\%myconfig, $c0total, 2, " "); - $c30total = $form->format_amount(\%myconfig, $c30total, 2, " "); - $c60total = $form->format_amount(\%myconfig, $c60total, 2, " "); - $c90total = $form->format_amount(\%myconfig, $c90total, 2, " "); - - $column_data{c0} = qq||; - $column_data{c30} = qq||; - $column_data{c60} = qq||; - $column_data{c90} = qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - - -
    $c0subtotal$c30subtotal$c60subtotal$c90subtotal
 
$ref->{name}{checked}> - {ctid}> - $ref->{invnumber}$ref->{transdate}$ref->{duedate} $ref->{c0}$ref->{c30}$ref->{c60}$ref->{c90}
  
 $c0subtotal$c30subtotal$c60subtotal$c90subtotal
$c0total$c30total$c60total$c90total
-
-|; - - &print_options if ($form->{arap} eq 'ar'); + $report->add_data(create_aging_subtotal_row(\%subtotals, \@columns, \@periods, 'listsubtotal')) if ($row_idx); - print qq| -

-|; + $report->add_data(create_aging_subtotal_row(\%totals, \@columns, \@periods, 'listtotal')); if ($form->{arap} eq 'ar') { - print qq| -{todate}> - - - -{arap}> -{ct}> -{ct} value="$form->{$form->{ct}}"> - - - -{login}> -{password}> - -
- - -|; -} + $raw_top_info_text = $form->parse_html_template('rp/aging_ar_top'); + $raw_bottom_info_text = $form->parse_html_template('rp/aging_ar_bottom', { 'row_idx' => $row_idx, + 'PRINT_OPTIONS' => print_options(1), }); + $report->set_options('raw_top_info_text' => $raw_top_info_text, + 'raw_bottom_info_text' => $raw_bottom_info_text); + } -print qq| -
+ $report->set_options_from_form(); - - -|; + $report->generate_with_headers(); $lxdebug->leave_sub(); } @@ -2615,6 +2469,8 @@ sub winston_export { sub print_options { $lxdebug->enter_sub(); + my ($dont_print) = @_; + $form->{sendmode} = "attachment"; $form->{"format"} = @@ -2668,7 +2524,7 @@ sub print_options { } } - print qq| + my $output = qq| @@ -2677,18 +2533,22 @@ sub print_options { |; if ($myconfig{printer} && $latex_templates && $form->{media} ne 'email') { - print qq| + $output .= qq| |; } - print qq| + $output .= qq|
| . $locale->text('Copies') . qq| {copies}>
|; + print $output unless $dont_print; + $lxdebug->leave_sub(); + + return $output; } sub generate_bwa { diff --git a/locale/de/all b/locale/de/all index 3c5b99a19..3da22ebbe 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1262,6 +1262,8 @@ aktualisieren wollen?', 'Zipcode' => 'PLZ', 'Zusatz' => 'Zusatz', 'accrual' => 'Bilanzierung (Soll-Versteuerung)', + 'ap_aging_list' => 'liste_offene_verbindlichkeiten', + 'ar_aging_list' => 'liste_offene_forderungen', 'as at' => 'zum Stand', 'back' => 'zurück', 'bin_list' => 'Lagerliste', diff --git a/locale/de/rp b/locale/de/rp index 12441f1be..15551adbd 100644 --- a/locale/de/rp +++ b/locale/de/rp @@ -20,11 +20,16 @@ $self->{texts} = { 'Bin List' => 'Lagerliste', 'Bis' => 'bis', 'CANCELED' => 'Storniert', + 'CSV export -- options' => 'CSV-Export -- Optionen', 'Cc' => 'Cc', 'Compare to' => 'Gegenüberstellen zu', 'Confirmation' => 'Auftragsbestätigung', 'Continue' => 'Weiter', 'Copies' => 'Kopien', + 'Could not spawn html2ps or GhostScript.' => 'html2ps oder GhostScript konnte nicht gestartet werden.', + 'Could not spawn the printer command.' => 'Die Druckanwendung konnte nicht gestartet werden.', + 'Could not write the html2ps config file.' => 'Die temporäre html2ps-Konfigurationsdatei konnte nicht geschrieben werden.', + 'Could not write the temporary HTML file.' => 'Eine temporäre HTML-Datei konnte nicht geschrieben werden.', 'Credit' => 'Haben', 'Credit Note' => 'Gutschrift', 'Current' => 'Betrag', @@ -105,6 +110,7 @@ $self->{texts} = { 'October' => 'Oktober', 'PAYMENT POSTED' => 'Rechung gebucht', 'PDF' => 'PDF', + 'PDF export -- options' => 'PDF-Export -- Optionen', 'POSTED' => 'Gebucht', 'POSTED AS NEW' => 'Als neu gebucht', 'PRINTED' => 'Gedruckt', @@ -157,6 +163,7 @@ $self->{texts} = { 'Tax collected' => 'vereinnahmte Steuer', 'Tax paid' => 'Vorsteuer', 'The \'tag\' field must only consist of alphanumeric characters or the carachters - _ ( )' => 'Das Feld \'tag\' darf nur aus alphanumerischen Zeichen und den Zeichen - _ ( ) bestehen.', + 'The list has been printed.' => 'Die Liste wurde ausgedruckt.', 'Total' => 'Summe', 'Trial Balance' => 'Saldenbilanz', 'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.', @@ -172,6 +179,8 @@ $self->{texts} = { 'Year' => 'Jahr', 'Yearly' => 'jährlich', 'Zeitraum' => 'Zeitraum', + 'ap_aging_list' => 'liste_offene_verbindlichkeiten', + 'ar_aging_list' => 'liste_offene_forderungen', 'as at' => 'zum Stand', 'bin_list' => 'Lagerliste', 'bis' => 'bis', @@ -185,6 +194,8 @@ $self->{texts} = { 'pick_list' => 'Entnahmeliste', 'proforma' => 'Proforma', 'purchase_order' => 'Auftrag', + 'report_generator_dispatch_to is not defined.' => 'report_generator_dispatch_to ist nicht definiert.', + 'report_generator_nextsub is not defined.' => 'report_generator_nextsub ist nicht definiert.', 'request_quotation' => 'Angebotsanforderung', 'sales_order' => 'Kundenauftrag', 'sales_quotation' => 'Verkaufsangebot', @@ -210,6 +221,7 @@ $self->{subs} = { 'check_project' => 'check_project', 'config' => 'config', 'continue' => 'continue', + 'create_aging_subtotal_row' => 'create_aging_subtotal_row', 'debug' => 'debug', 'delivery_customer_selection' => 'delivery_customer_selection', 'e_mail' => 'e_mail', @@ -238,6 +250,11 @@ $self->{subs} = { 'project_selection_internal' => 'project_selection_internal', 'reformat_numbers' => 'reformat_numbers', 'report' => 'report', + 'report_generator_back' => 'report_generator_back', + 'report_generator_dispatcher' => 'report_generator_dispatcher', + 'report_generator_do' => 'report_generator_do', + 'report_generator_export_as_csv' => 'report_generator_export_as_csv', + 'report_generator_export_as_pdf' => 'report_generator_export_as_pdf', 'sales_invoice' => 'sales_invoice', 'select_all' => 'select_all', 'select_employee' => 'select_employee', diff --git a/templates/webpages/rp/aging_ar_bottom_de.html b/templates/webpages/rp/aging_ar_bottom_de.html new file mode 100644 index 000000000..6360b77a9 --- /dev/null +++ b/templates/webpages/rp/aging_ar_bottom_de.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + Sammelrechnung +
+ + + + + diff --git a/templates/webpages/rp/aging_ar_bottom_master.html b/templates/webpages/rp/aging_ar_bottom_master.html new file mode 100644 index 000000000..2e9849760 --- /dev/null +++ b/templates/webpages/rp/aging_ar_bottom_master.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + Statement +
+ + + + + diff --git a/templates/webpages/rp/aging_ar_top_de.html b/templates/webpages/rp/aging_ar_top_de.html new file mode 100644 index 000000000..066ac9838 --- /dev/null +++ b/templates/webpages/rp/aging_ar_top_de.html @@ -0,0 +1 @@ +
diff --git a/templates/webpages/rp/aging_ar_top_master.html b/templates/webpages/rp/aging_ar_top_master.html new file mode 100644 index 000000000..066ac9838 --- /dev/null +++ b/templates/webpages/rp/aging_ar_top_master.html @@ -0,0 +1 @@ +