commit 31f989254ce9f2ab881af7aee5d07dd63df0e004
Author: Moritz Bunkus <m.bunkus@linet.de>
Date:   Fri Jan 13 15:49:37 2017 +0100

    ActionBar: Verwendung beim Massenerzeugen von Rechnungen aus Lieferscheinen

diff --git a/SL/Controller/MassInvoiceCreatePrint.pm b/SL/Controller/MassInvoiceCreatePrint.pm
index e5308d06b..54313a6a2 100644
--- a/SL/Controller/MassInvoiceCreatePrint.pm
+++ b/SL/Controller/MassInvoiceCreatePrint.pm
@@ -39,7 +39,7 @@ sub action_list_sales_delivery_orders {
 
   # if a filter is choosen, the filter info should be visible
   $self->make_filter_summary;
-  $self->sales_delivery_order_models->get;
+  $self->setup_list_sales_delivery_orders_action_bar(show_creation_buttons => $show, num_rows => scalar(@{ $self->sales_delivery_order_models->get }));
   $self->render('mass_invoice_create_print_from_do/list_sales_delivery_orders',
                 noshow  => $show,
                 title   => $::locale->text('Open sales delivery orders'));
@@ -347,7 +347,7 @@ sub setup_list_invoices_action_bar {
       ],
       action => [
         t8('Reset'),
-        call => [ 'kivi.Project.reset_search_form' ],
+        call => [ 'kivi.call_jquery', '#search_form', 'resetForm' ],
       ],
       action => [
         $::locale->text('Print'),
@@ -358,6 +358,46 @@ sub setup_list_invoices_action_bar {
   }
 }
 
+sub setup_list_sales_delivery_orders_action_bar {
+  my ($self, %params) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Search'),
+        submit    => [ '#search_form', { action => 'MassInvoiceCreatePrint/list_sales_delivery_orders' } ],
+        accesskey => 'enter',
+      ],
+      action => [
+        t8('Reset'),
+        call => [ 'kivi.call_jquery', '#search_form', 'resetForm' ],
+      ],
+
+      combobox => [
+        action => [
+          t8('Invoices'),
+          tooltip => t8("Create and print invoices")
+        ],
+        action => [
+          t8('for selected entries'),
+          call     => [ 'kivi.MassInvoiceCreatePrint.submitMassCreationForm' ],
+          tooltip  => t8("Create and print invoices for all selected delivery orders"),
+          disabled => !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') : undef,
+          only_if  => $params{show_creation_buttons},
+        ],
+
+        action => [
+          t8('for all entries'),
+          call     => [ 'kivi.MassInvoiceCreatePrint.createPrintAllInitialize' ],
+          tooltip  => t8("Create and print invoices for all delivery orders matching the filter"),
+          disabled => !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') : undef,
+          only_if  => $params{show_creation_buttons},
+        ],
+      ],
+    );
+  }
+}
+
 1;
 
 __END__
@@ -483,7 +523,7 @@ supported: Customer and date from/to of the Delivery Order (database field trans
 
 =head1 TODO
 
-Should be more generalized. Right now just one conversion (delivery order to invoice) is supported.
+pShould be more generalized. Right now just one conversion (delivery order to invoice) is supported.
 Using BackgroundJobs to mass create / transfer stuff is the way to do it. The original idea
 was taken from one client project (mosu) with some extra (maybe not standard compliant) customized
 stuff (using cvars for extra filters and a very compressed Controller for linking (ODSalesOrder.pm)).
diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl
index a3c82130a..026387616 100644
--- a/bin/mozilla/do.pl
+++ b/bin/mozilla/do.pl
@@ -377,7 +377,7 @@ sub setup_do_orders_action_bar {
       action => [
         t8('New invoice'),
         submit    => [ '#orders_form' ],
-        checks    => [ 'kivi.DeliveryOrder.multi_invoice_check_delivery_orders_selected' ],
+        checks    => [ [ 'kivi.check_if_entries_selected', '#orders_form tbody input[type=checkbox]' ] ],
         accesskey => 'enter',
       ],
     );
@@ -843,8 +843,6 @@ sub orders {
     $idx++;
   }
 
-  $::request->layout->add_javascripts('kivi.DeliveryOrder.js');
-
   setup_do_orders_action_bar();
 
   $report->generate_with_headers(action_bar => 1);
diff --git a/js/kivi.DeliveryOrder.js b/js/kivi.DeliveryOrder.js
deleted file mode 100644
index 171b30e4d..000000000
--- a/js/kivi.DeliveryOrder.js
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace('kivi.DeliveryOrder', function(ns) {
-  ns.multi_invoice_check_delivery_orders_selected = function() {
-    if ($('#orders_form tbody input[type=checkbox]:checked').length > 0)
-      return true;
-
-    alert(kivi.t8('You have not selected any delivery order.'));
-
-    return false;
-  };
-});
diff --git a/js/kivi.MassInvoiceCreatePrint.js b/js/kivi.MassInvoiceCreatePrint.js
index 0c188dcb2..93fa16261 100644
--- a/js/kivi.MassInvoiceCreatePrint.js
+++ b/js/kivi.MassInvoiceCreatePrint.js
@@ -25,7 +25,7 @@ namespace('kivi.MassInvoiceCreatePrint', function(ns) {
       return false;
 
     $('body').addClass('loading');
-    $('form').submit();
+    kivi.submit_form_with_action('form', 'MassInvoiceCreatePrint/create_invoices');
     return false;
   };
 
@@ -76,11 +76,6 @@ namespace('kivi.MassInvoiceCreatePrint', function(ns) {
     $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
   };
 
-  this.setup = function() {
-    $('#create_button').click(kivi.MassInvoiceCreatePrint.submitMassCreationForm);
-    $('#create_print_all_button').click(kivi.MassInvoiceCreatePrint.createPrintAllInitialize);
-  };
-
   ns.showMassPrintOptions = function() {
     $('#printer_options_printer_id').val($('#printer_id').val());
 
@@ -120,5 +115,3 @@ namespace('kivi.MassInvoiceCreatePrint', function(ns) {
     $("#filter_table input").val("");
   };
 });
-
-$(kivi.MassInvoiceCreatePrint.setup);
diff --git a/js/locale/de.js b/js/locale/de.js
index 2b3d4cea2..a4fedd7e2 100644
--- a/js/locale/de.js
+++ b/js/locale/de.js
@@ -121,7 +121,6 @@ namespace("kivi").setupLocale({
 "Update quotation/order":"Auftrag/Angebot aktualisieren",
 "Version actions":"Aktionen für Versionen",
 "Yes":"Ja",
-"You have not selected any delivery order.":"Sie haben keinen Lieferschein ausgewählt.",
 "filename has not uploadable characters ":"Bitte Dateinamen ändern. Er hat für den Upload nicht verwendbare Sonderzeichen ",
 "filesize too big: ":"Datei zu groß: ",
 "flat-rate position":"Pauschalposition",
diff --git a/locale/de/all b/locale/de/all
index a078d2476..72d157c44 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -700,6 +700,9 @@ $self->{texts} = {
   'Create and edit sales quotations' => 'Angebote erfassen und bearbeiten',
   'Create and edit vendor invoices' => 'Eingangsrechnungen erfassen und bearbeiten',
   'Create and print all invoices' => 'Alle Rechnungen erzeugen und ausdrucken',
+  'Create and print invoices'   => 'Rechnungen erzeugen und ausdrucken',
+  'Create and print invoices for all delivery orders matching the filter' => 'Rechnungen für alle den Suchkriterien entsprechenden Lieferscheine erzeugen und ausdrucken',
+  'Create and print invoices for all selected delivery orders' => 'Rechnungen für alle Lieferscheine erzeugen und ausdrucken',
   'Create bank collection'      => 'Bankeinzug erstellen',
   'Create bank collection via SEPA XML' => 'Bankeinzug via SEPA XML erstellen',
   'Create bank transfer'        => 'Überweisung erstellen',
@@ -709,7 +712,6 @@ $self->{texts} = {
   'Create first invoice on'     => 'Erste Rechnung erzeugen am',
   'Create invoice'              => 'Buchung erstellen',
   'Create invoice?'             => 'Rechnung erstellen?',
-  'Create invoices'             => 'Rechnungen erzeugen',
   'Create new'                  => 'Neu erfassen',
   'Create new background job'   => 'Neuen Hintergrund-Job anlegen',
   'Create new client #1'        => 'Neuen Mandanten #1 anlegen',
@@ -1359,7 +1361,6 @@ $self->{texts} = {
   'Font size'                   => 'Schriftgr&ouml;&szlig;e',
   'For AP transactions it will replace the sales taxkeys with input taxkeys with the same tax rate.' => 'Bei Kreditorenbuchungen werden die Umsatzsteuer-Steuerschlüssel durch Vorsteuer-Steuerschlüssel mit demselben Steuersatz ersetzt.',
   'For AR transactions it will replace the input taxkeys with sales taxkeys with the same tax rate.' => 'Bei Debitorenbuchungen werden die Vorsteuer-Steuerschlüssel durch Umsatzsteuer-Steuerschlüssel mit demselben Steuersatz ersetzt.',
-  'For all delivery orders create and print invoices' => 'Erstelle und drucke Rechnungen für alle Lieferscheine',
   'For changeing goto USTVA Config' => 'Zum Verändern bitte zu den UStVa Einstellungen gehen',
   'For further information read this: ' => 'Für weitere Informationen zu diesem Thema lesen Sie bitte: ',
   'For part "#1" there are missing #2 #3 in the default warehouse/bin "#4/#5".' => 'Es fehlen #2 #3 des Artikels "#1" im Standardlager "#4/#5".',
@@ -3678,7 +3679,9 @@ $self->{texts} = {
   'for Document types'          => 'für unterschiedliche ERP Dokumententypen',
   'for Period'                  => 'für den Zeitraum',
   'for all'                     => 'für alle',
+  'for all entries'             => 'für alle Einträge',
   'for date'                    => 'zum Stichtag',
+  'for selected entries'        => 'für ausgewählte Einträge',
   'found'                       => 'Gefunden',
   'found_br'                    => 'Gef.',
   'from \'#1\' imported Files'  => 'Von \'#1\' importierte Dateien',
diff --git a/templates/webpages/mass_invoice_create_print_from_do/list_sales_delivery_orders.html b/templates/webpages/mass_invoice_create_print_from_do/list_sales_delivery_orders.html
index 61bcd5fcf..5b8a14234 100644
--- a/templates/webpages/mass_invoice_create_print_from_do/list_sales_delivery_orders.html
+++ b/templates/webpages/mass_invoice_create_print_from_do/list_sales_delivery_orders.html
@@ -45,13 +45,6 @@
 
     [% L.paginate_controls %]
 
-    <hr size="3" noshade>
-
-    <p>
-     [% L.hidden_tag("action", "MassInvoiceCreatePrint/create_invoices") %]
-     [% L.button_tag("", LxERP.t8("Create invoices"), name="create_button") %]
-     [% L.button_tag("", LxERP.t8("For all delivery orders create and print invoices"), name="create_print_all_button") %]
-    </p>
     <div id="create_print_all_dialog" style="display: none;">
      [%- INCLUDE 'mass_invoice_create_print_from_do/_create_print_all_step_1.html' %]
     </div>
