use SL::IS;
use SL::PE;
use SL::DN;
+use SL::ReportGenerator;
require "bin/mozilla/common.pl";
+require "bin/mozilla/report_generator.pl";
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
$form->{addition} = "SAVED FOR DUNNING";
$form->save_history($form->dbconnect(\%myconfig));
}
- # /saving the history
+ # /saving the history
$form->redirect($locale->text('Dunning Process Config saved!'));
$lxdebug->leave_sub();
sub show_dunning {
$lxdebug->enter_sub();
- DN->get_dunning(\%myconfig, \%$form);
-
- my $odd_even = 0;
- my ($previous_dunning_id, $first_row_for_dunning);
+ my @filter_field_list = qw(customer_id customer dunning_level department_id invnumber ordnumber
+ transdatefrom transdateto dunningfrom dunningto notes showold);
- foreach $ref (@{ $form->{DUNNINGS} }) {
- if ($previous_dunning_id != $ref->{dunning_id}) {
- $odd_even = ($odd_even + 1) % 2;
- $ref->{first_row_for_dunning} = 1;
-
- } else {
- $ref->{first_row_for_dunning} = 0;
- }
-
- $previous_dunning_id = $ref->{dunning_id};
- $ref->{listrow_odd_even} = $odd_even;
- }
+ DN->get_dunning(\%myconfig, \%$form);
if (!$form->{callback}) {
- $form->{callback} =
- build_std_url("action=show_dunning", qw(customer_id customer dunning_level department_id invnumber ordnumber
- transdatefrom transdateto dunningfrom dunningto notes showold));
+ $form->{callback} = build_std_url("action=show_dunning", @filter_field_list);
}
$form->get_lists('printers' => 'printers',
'no_opendocument' => 1, });
$form->{title} = $locale->text('Dunning overview');
- $form->header();
+ my $report = SL::ReportGenerator->new(\%myconfig, $form);
+
+ $report->set_options('std_column_visibility' => 1,
+ 'title' => $form->{title});
+ $report->set_export_options('show_dunning', @filter_field_list);
+
+ $report->set_columns(
+ 'checkbox' => { 'text' => '', 'visible' => 'HTML' },
+ 'dunning_description' => { 'text' => $locale->text('Dunning Level') },
+ 'customername' => { 'text' => $locale->text('Customername') },
+ 'invnumber' => { 'text' => $locale->text('Invnumber') },
+ 'transdate' => { 'text' => $locale->text('Invdate') },
+ 'duedate' => { 'text' => $locale->text('Invoice Duedate') },
+ 'amount' => { 'text' => $locale->text('Amount') },
+ 'dunning_date' => { 'text' => $locale->text('Dunning Date') },
+ 'dunning_duedate' => { 'text' => $locale->text('Dunning Duedate') },
+ 'fee' => { 'text' => $locale->text('Total Fees') },
+ 'interest' => { 'text' => $locale->text('Interest') },
+ );
+
+ $report->set_column_order(qw(checkbox dunning_description customername invnumber transdate
+ duedate amount dunning_date dunning_duedate fee interest));
+
+ my $edit_url = build_std_url('script=is.pl', 'action=edit', 'callback') . '&id=';
+ my $print_url = build_std_url('action=print_dunning', 'format=pdf', 'media=screen') . '&dunning_id=';
+
+ my %alignment = map { $_ => 'right' } qw(transdate duedate amount dunning_date dunning_duedate fee interest);
+
+ my ($current_dunning_rows, $previous_dunning_id, $first_row_for_dunning);
+
+ $current_dunning_rows = [];
+ $first_row_for_dunning = 1;
+ $form->{rowcount} = scalar @{ $form->{DUNNINGS} };
- print $form->parse_html_template("dunning/show_dunning");
+ my $i = 0;
+
+ foreach $ref (@{ $form->{DUNNINGS} }) {
+ $i++;
+
+ if ($previous_dunning_id != $ref->{dunning_id}) {
+ $report->add_data($current_dunning_rows) if (scalar @{ $current_dunning_rows });
+ $current_dunning_rows = [];
+ $first_row_for_dunning = 1;
+ }
+
+ my $row = { };
+ foreach my $column (keys %{ $ref }) {
+ $row->{$column} = {
+ 'data' => $first_row_for_dunning || (($column ne 'dunning_description') && ($column ne 'customername')) ? $ref->{$column} : '',
+
+ 'align' => $alignment{$column},
+
+ 'link' => ($column eq 'invnumber' ? $edit_url . E($ref->{id}) :
+ $column eq 'dunning_description' ? $print_url . E($ref->{dunning_id}) : ''),
+ };
+ }
+
+ $row->{checkbox} = {
+ 'raw_data' => $cgi->hidden('-name' => "dunning_id_$i", '-value' => $ref->{dunning_id})
+ . $cgi->checkbox('-name' => "selected_$i", '-value' => 1, '-label' => ''),
+ 'valign' => 'center',
+ 'align' => 'center',
+ };
+
+ push @{ $current_dunning_rows }, $row;
+
+ $previous_dunning_id = $ref->{dunning_id};
+ $first_row_for_dunning = 0;
+ }
+
+ $report->add_data($current_dunning_rows) if (scalar @{ $current_dunning_rows });
+
+ $report->set_options('raw_top_info_text' => $form->parse_html_template('dunning/show_dunning_top'),
+ 'raw_bottom_info_text' => $form->parse_html_template('dunning/show_dunning_bottom'),
+ 'output_format' => 'HTML',
+ 'attachment_basename' => strftime('dunning_report_%Y%m%d', localtime time),
+ );
+
+ $report->set_options_from_form();
+
+ $report->generate_with_headers();
$lxdebug->leave_sub();
}
# end of main
-
'Add Request for Quotation' => 'Anfrage erfassen',
'Add Sales Order' => 'Auftrag erfassen',
'Address' => 'Adresse',
+ 'Amount' => 'Betrag',
'Apr' => 'Apr',
'April' => 'April',
'Attachment' => 'als Anhang',
'Bin' => 'Lagerplatz',
'Bin List' => 'Lagerliste',
'CANCELED' => 'Storniert',
+ 'CSV export -- options' => 'CSV-Export -- Optionen',
'City' => 'Stadt',
'Company Name' => 'Firmenname',
'Confirmation' => 'Auftragsbestätigung',
'Continue' => 'Weiter',
'Could not print dunning.' => 'Die Mahnungen konnten nicht gedruckt werden.',
'Could not spawn ghostscript.' => 'Die Anwendung "ghostscript" konnte nicht gestartet werden.',
+ '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.',
'Country' => 'Land',
'Credit Note' => 'Gutschrift',
'Customer Number' => 'Kundennummer',
'Customer details' => 'Kundendetails',
'Customer not on file or locked!' => 'Dieser Kunde existiert nicht oder ist gesperrt.',
'Customer not on file!' => 'Kunde ist nicht in der Datenbank!',
+ 'Customername' => 'Kundenname',
'DELETED' => 'Gelöscht',
'DUNNING STARTED' => 'Mahnprozess gestartet',
'Dataset upgrade' => 'Datenbankaktualisierung',
'Dependency loop detected:' => 'Schleife in den Abhängigkeiten entdeckt:',
'Description' => 'Beschreibung',
'Discount' => 'Rabatt',
+ 'Dunning Date' => 'Mahndatum',
'Dunning Description missing in row ' => 'Mahnstufenbeschreibung fehlt in Zeile ',
+ 'Dunning Duedate' => 'Zahlbar bis',
+ 'Dunning Level' => 'Mahnlevel',
'Dunning Level missing in row ' => 'Mahnlevel fehlt in ',
'Dunning Process Config saved!' => 'Mahnwesenkonfiguration gespeichert!',
'Dunning Process started for selected invoices!' => 'Mahnprozess für selektierte Rechnungen gestartet',
'Group' => 'Warengruppe',
'History' => 'Historie',
'In-line' => 'im Text',
+ 'Interest' => 'Zinsen',
+ 'Invdate' => 'Rechnungsdatum',
+ 'Invnumber' => 'Rechnungsnummer',
'Invoice' => 'Rechnung',
'Invoice Date missing!' => 'Rechnungsdatum fehlt!',
+ 'Invoice Duedate' => 'Fälligkeitsdatum',
'Invoice Number missing!' => 'Rechnungsnummer fehlt!',
'Item not on file!' => 'Dieser Artikel ist nicht in der Datenbank!',
'Jan' => 'Jan',
'PAYMENT POSTED' => 'Rechung gebucht',
'PDF' => 'PDF',
'PDF (OpenDocument/OASIS)' => 'PDF (OpenDocument/OASIS)',
+ 'PDF export -- options' => 'PDF-Export -- Optionen',
'POSTED' => 'Gebucht',
'POSTED AS NEW' => 'Als neu gebucht',
'PRINTED' => 'Gedruckt',
'Terms missing in row ' => '+Tage fehlen in Zeile ',
'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 dunnings have been printed.' => 'Die Mahnung(en) wurden gedruckt.',
+ 'Total Fees' => 'Kumulierte Gebühren',
'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
'Unit' => 'Einheit',
'Unknown dependency \'%s\'.' => 'Unbekannte Abhängigkeit \'%s\'.',
'pick_list' => 'Entnahmeliste',
'proforma' => 'Proforma',
'purchase_order' => 'Auftrag',
+ 'report_generator_nextsub is not defined.' => 'report_generator_nextsub ist nicht definiert.',
'request_quotation' => 'Angebotsanforderung',
'sales_order' => 'Kundenauftrag',
'sales_quotation' => 'Verkaufsangebot',
'edit_config' => 'edit_config',
'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
+ 'export_as_csv' => 'export_as_csv',
+ 'export_as_pdf' => 'export_as_pdf',
'format_dates' => 'format_dates',
'gl_transaction' => 'gl_transaction',
'invoicetotal' => 'invoicetotal',
'quotation' => 'quotation',
'reformat_numbers' => 'reformat_numbers',
'relink_accounts' => 'relink_accounts',
+ 'report_generator_do' => 'report_generator_do',
'request_for_quotation' => 'request_for_quotation',
'sales_invoice' => 'sales_invoice',
'save' => 'save',
'vendor_invoice' => 'vendor_invoice',
'vendor_selection' => 'vendor_selection',
'weiter' => 'continue',
+ 'als_csv_exportieren' => 'export_as_csv',
+ 'als_pdf_exportieren' => 'export_as_pdf',
'drucken' => 'print',
'speichern' => 'save',
};
--- /dev/null
+ <input type="hidden" name="rowcount" value="<TMPL_VAR rowcount>">
+
+ <p><TMPL_VAR PRINT_OPTIONS></p>
+
+ <p>
+ Mahnungen<br>
+ <input type="hidden" name="print_nextsub" value="print_multiple">
+ <input type="submit" class="submit" name="action" value="Drucken">
+ </p>
+
+ </form>
--- /dev/null
+ <input type="hidden" name="rowcount" value="<TMPL_VAR rowcount>">
+
+ <p><TMPL_VAR PRINT_OPTIONS></p>
+
+ <p>
+ <translate>Dunnings</translate><br>
+ <input type="hidden" name="print_nextsub" value="print_multiple">
+ <input type="submit" class="submit" name="action" value="<translate>Print</translate>">
+ </p>
+
+ </form>
+++ /dev/null
-<body>
-
- <script type="text/javascript" src="js/common.js"></script>
- <script type="text/javascript" src="js/dunning.js"></script>
-
- <div class="listtop" width="100%"><TMPL_VAR title></div>
-
- <form method="post" action="dn.pl">
-
- <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
- <input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
-
- <p>
- <table width="100%">
- <tr>
- <th class="listheading"> </th>
- <th class="listheading">Mahnlevel</th>
- <th class="listheading">Kundenname</th>
- <th class="listheading">Rechnungsnummer</th>
- <th class="listheading">Rechnungsdatum</th>
- <th class="listheading">Fälligkeitsdatum</th>
- <th class="listheading">Betrag</th>
- <th class="listheading">Mahndatum</th>
- <th class="listheading">Zahlbar bis</th>
- <th class="listheading">Kumulierte Gebühren</th>
- <th class="listheading">Zinsen</th>
- </tr>
-
- <!-- Ausgabe der einzelnen Zeilen -->
-
- <TMPL_LOOP DUNNINGS>
- <tr class="listrow<TMPL_VAR listrow_odd_even>">
- <td>
- <TMPL_IF first_row_for_dunning>
- <input type="checkbox" name="selected_<TMPL_VAR __counter__>" value="1">
- <input type="hidden" name="dunning_id_<TMPL_VAR __counter__>" value="<TMPL_VAR dunning_id ESCAPE=HTML>">
- </TMPL_IF>
- </td>
-
- <td>
- <TMPL_IF first_row_for_dunning>
- <a href="dn.pl?action=print_dunning&format=pdf&media=screen&dunning_id=<TMPL_VAR dunning_id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>">
- <TMPL_VAR dunning_description ESCAPE=HTML>
- </a>
- <TMPL_ELSE>
-
- </TMPL_IF>
- </td>
-
- <td><TMPL_IF first_row_for_dunning><TMPL_VAR customername ESCAPE=HTML><TMPL_ELSE> </TMPL_IF></td>
-
- <td><a href="is.pl?action=edit&id=<TMPL_VAR id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>"><TMPL_VAR invnumber ESCAPE=HTML></a></td>
-
- <td align="right"><TMPL_VAR transdate ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR duedate ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR amount ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR dunning_date ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR dunning_duedate ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR fee ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR interest ESCAPE=HTML></td>
- </tr>
-
- <TMPL_IF __last__><input type="hidden" name="rowcount" value="<TMPL_VAR __counter__>"></TMPL_IF>
- </TMPL_LOOP>
- <tr><td colspan="11"><hr size="3" noshade></td></tr>
- </table>
- </p>
-
-
- <p><TMPL_VAR PRINT_OPTIONS></p>
-
- <p>
- <input type="hidden" name="print_nextsub" value="print_multiple">
- <input type="submit" class="submit" name="action" value="Drucken">
- </p>
-
- </form>
-
-</body>
+++ /dev/null
-<body>
-
- <script type="text/javascript" src="js/common.js"></script>
- <script type="text/javascript" src="js/dunning.js"></script>
-
- <div class="listtop" width="100%"><TMPL_VAR title></div>
-
- <form method="post" action="dn.pl">
-
- <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
- <input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
-
- <p>
- <table width="100%">
- <tr>
- <th class="listheading"> </th>
- <th class="listheading"><translate>Dunning Level</translate></th>
- <th class="listheading"><translate>Customername</translate></th>
- <th class="listheading"><translate>Invnumber</translate></th>
- <th class="listheading"><translate>Invdate</translate></th>
- <th class="listheading"><translate>Invoice Duedate</translate></th>
- <th class="listheading"><translate>Amount</translate></th>
- <th class="listheading"><translate>Dunning Date</translate></th>
- <th class="listheading"><translate>Dunning Duedate</translate></th>
- <th class="listheading"><translate>Total Fees</translate></th>
- <th class="listheading"><translate>Interest</translate></th>
- </tr>
-
- <!-- Ausgabe der einzelnen Zeilen -->
-
- <TMPL_LOOP DUNNINGS>
- <tr class="listrow<TMPL_VAR listrow_odd_even>">
- <td>
- <TMPL_IF first_row_for_dunning>
- <input type="checkbox" name="selected_<TMPL_VAR __counter__>" value="1">
- <input type="hidden" name="dunning_id_<TMPL_VAR __counter__>" value="<TMPL_VAR dunning_id ESCAPE=HTML>">
- </TMPL_IF>
- </td>
-
- <td>
- <TMPL_IF first_row_for_dunning>
- <a href="dn.pl?action=print_dunning&format=pdf&media=screen&dunning_id=<TMPL_VAR dunning_id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>">
- <TMPL_VAR dunning_description ESCAPE=HTML>
- </a>
- <TMPL_ELSE>
-
- </TMPL_IF>
- </td>
-
- <td><TMPL_IF first_row_for_dunning><TMPL_VAR customername ESCAPE=HTML><TMPL_ELSE> </TMPL_IF></td>
-
- <td><a href="is.pl?action=edit&id=<TMPL_VAR id ESCAPE=URL>&login=<TMPL_VAR login ESCAPE=URL>&password=<TMPL_VAR password ESCAPE=URL>&callback=<TMPL_VAR callback ESCAPE=URL>"><TMPL_VAR invnumber ESCAPE=HTML></a></td>
-
- <td align="right"><TMPL_VAR transdate ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR duedate ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR amount ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR dunning_date ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR dunning_duedate ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR fee ESCAPE=HTML></td>
- <td align="right"><TMPL_VAR interest ESCAPE=HTML></td>
- </tr>
-
- <TMPL_IF __last__><input type="hidden" name="rowcount" value="<TMPL_VAR __counter__>"></TMPL_IF>
- </TMPL_LOOP>
- <tr><td colspan="11"><hr size="3" noshade></td></tr>
- </table>
- </p>
-
-
- <p><TMPL_VAR PRINT_OPTIONS></p>
-
- <p>
- <input type="hidden" name="print_nextsub" value="print_multiple">
- <input type="submit" class="submit" name="action" value="<translate>Print</translate>">
- </p>
-
- </form>
-
-</body>
--- /dev/null
+ <script type="text/javascript" src="js/common.js"></script>
+ <script type="text/javascript" src="js/dunning.js"></script>
+
+ <form method="post" action="dn.pl">
+
+ <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
+ <input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
+
--- /dev/null
+ <script type="text/javascript" src="js/common.js"></script>
+ <script type="text/javascript" src="js/dunning.js"></script>
+
+ <form method="post" action="dn.pl">
+
+ <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
+ <input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
+