From 4a1b6455ee26aa2514c29b83f18e81febfd77418 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 11 Nov 2016 14:00:48 +0100 Subject: [PATCH] ActionBar: Verwendung in Berichtsfunktion in ar.pl --- bin/mozilla/ar.pl | 47 ++++++++++++++++++- js/kivi.MassInvoiceCreatePrint.js | 37 ++++++++++++++- locale/de/all | 1 + .../webpages/ar/ar_transactions_bottom.html | 39 +++++++-------- .../webpages/ar/ar_transactions_header.html | 2 +- templates/webpages/ar/search.html | 9 +--- 6 files changed, 104 insertions(+), 31 deletions(-) diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index ecd357eeb..a4f559034 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -909,6 +909,46 @@ sub yes { $main::lxdebug->leave_sub(); } +sub setup_ar_search_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + $::locale->text('Search'), + submit => [ '#form' ], + accesskey => 'enter', + ], + ); + } +} + +sub setup_ar_transactions_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + $::locale->text('Print'), + call => [ 'kivi.MassInvoiceCreatePrint.showMassPrintOptionsOrDownloadDirectly' ], + disabled => !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') : undef, + ], + + combobox => [ + action => [ $::locale->text('Create new') ], + action => [ + $::locale->text('AR Transaction'), + submit => [ '#create_new_form', { action => 'ar_transaction' } ], + ], + action => [ + $::locale->text('Sales Invoice'), + submit => [ '#create_new_form', { action => 'sales_invoice' } ], + ], + ], # end of combobox "Create new" + ); + } +} + sub search { $main::lxdebug->enter_sub(); @@ -936,6 +976,8 @@ sub search { $::request->layout->add_javascripts("autocomplete_project.js"); + setup_ar_search_action_bar(); + $form->header; print $form->parse_html_template('ar/search', { %myconfig }); @@ -1202,7 +1244,10 @@ sub ar_transactions { $report->add_separator(); $report->add_data(create_subtotal_row(\%totals, \@columns, \%column_alignment, \@subtotal_columns, 'listtotal')); - $report->generate_with_headers(); + $::request->layout->add_javascripts('kivi.MassInvoiceCreatePrint.js'); + setup_ar_transactions_action_bar(num_rows => scalar(@{ $form->{AR} })); + + $report->generate_with_headers(action_bar => 1); $main::lxdebug->leave_sub(); } diff --git a/js/kivi.MassInvoiceCreatePrint.js b/js/kivi.MassInvoiceCreatePrint.js index bfb215e80..d00e56ab9 100644 --- a/js/kivi.MassInvoiceCreatePrint.js +++ b/js/kivi.MassInvoiceCreatePrint.js @@ -12,6 +12,7 @@ namespace('kivi.MassInvoiceCreatePrint', function(ns) { alert(kivi.t8('No delivery orders have been selected.')); return false; }; + this.checkInvoiceSelection = function() { if ($("[data-checkall=1]:checked").size() > 0) return true; @@ -78,7 +79,41 @@ namespace('kivi.MassInvoiceCreatePrint', function(ns) { this.setup = function() { $('#create_button').click(kivi.MassInvoiceCreatePrint.submitMassCreationForm); $('#create_print_all_button').click(kivi.MassInvoiceCreatePrint.createPrintAllInitialize); - $('#action_print').click(kivi.MassInvoiceCreatePrint.checkInvoiceSelection); + }; + + ns.showMassPrintOptions = function() { + $('#printer_options_printer_id').val($('#printer_id').val()); + + kivi.popup_dialog({ + id: 'print_options', + dialog: { + title: kivi.t8('Print options'), + width: 600, + height: 200 + } + }); + + return true; + }; + + ns.showMassPrintOptionsOrDownloadDirectly = function() { + if (!kivi.MassInvoiceCreatePrint.checkInvoiceSelection()) + return false; + + if ($('#print_options_printer_id').length === 0) + return kivi.MassInvoiceCreatePrint.massPrint(); + return kivi.MassInvoiceCreatePrint.showMassPrintOptions(); + }; + + ns.massPrint = function() { + $('#print_options').dialog('close'); + + $('#printer_id').val($('#print_options_printer_id').val()); + $('#action').val('MassInvoiceCreatePrint/print'); + + $('#report_form').submit(); + + return true; }; }); diff --git a/locale/de/all b/locale/de/all index c1a3845e8..175f0cf97 100755 --- a/locale/de/all +++ b/locale/de/all @@ -3071,6 +3071,7 @@ $self->{texts} = { 'The recipient, subject or body is missing.' => 'Der Empfäger, der Betreff oder der Text ist leer.', 'The record template \'#1\' has been loaded.' => 'Die Belegvorlage »#1« wurde geladen.', 'The record template \'#1\' has been saved.' => 'Die Belegvorlage »#1« wurde gespeichert.', + 'The report doesn\'t contain entries.' => 'Der Bericht enthält keine Einträge.', 'The required information consists of the IBAN and the BIC.' => 'Die benötigten Informationen bestehen aus der IBAN und der BIC. Zusätzlich wird die SEPA-Kreditoren-Identifikation aus der Mandantenkonfiguration benötigt.', 'The required information consists of the IBAN, the BIC, the mandator ID and the mandate\'s date of signature.' => 'Die benötigten Informationen bestehen aus IBAN, BIC, Mandanten-ID und dem Unterschriftsdatum des Mandates. Zusätzlich wird die SEPA-Kreditoren-Identifikation aus der Mandantenkonfiguration benötigt.', 'The requirement spec has been deleted.' => 'Das Pflichtenheft wurde gelöscht.', diff --git a/templates/webpages/ar/ar_transactions_bottom.html b/templates/webpages/ar/ar_transactions_bottom.html index d2c0cdc1c..bb939a569 100644 --- a/templates/webpages/ar/ar_transactions_bottom.html +++ b/templates/webpages/ar/ar_transactions_bottom.html @@ -1,27 +1,24 @@ [% USE T8 %][% USE HTML %][%- USE LxERP -%][%- USE L -%] - [% IF ALL_PRINTERS.size %] -

- [% LxERP.t8("Print destination") %]: - [% SET printers = [ { description=LxERP.t8("Download PDF, do not print") } ] ; - CALL printers.import(ALL_PRINTERS); - L.select_tag("printer_id", printers, title_key="description", default=printer_id) %] -

- [% END %] - -

- [% L.hidden_tag("action", "MassInvoiceCreatePrint/dispatch") %] - [% L.submit_tag("action_print", LxERP.t8("Print")) %] -

+ [% L.hidden_tag("action", "MassInvoiceCreatePrint/dispatch") %] + [% L.hidden_tag("printer_id") %] -
- - - - [% 'Create new' | $T8 %]
+ + [% L.hidden_tag("callback", callback) %] +
- - +[% IF ALL_PRINTERS.size %] + +[% END %] diff --git a/templates/webpages/ar/ar_transactions_header.html b/templates/webpages/ar/ar_transactions_header.html index a583aa92a..fcb318483 100644 --- a/templates/webpages/ar/ar_transactions_header.html +++ b/templates/webpages/ar/ar_transactions_header.html @@ -1 +1 @@ -
+ diff --git a/templates/webpages/ar/search.html b/templates/webpages/ar/search.html index d3e606bb1..ceac6ce5a 100644 --- a/templates/webpages/ar/search.html +++ b/templates/webpages/ar/search.html @@ -3,7 +3,8 @@ [%- SET style="width: 250px" %]

[% title %]

- + + [% L.hidden_tag("action", nextsub) %] @@ -206,11 +207,5 @@
- -
- - -
-
-- 2.20.1