commit 6a75dc1c3ddda3e78d77bc95ebdd72dbe5d858b1
Author: Moritz Bunkus <m.bunkus@linet.de>
Date:   Tue Feb 28 11:33:11 2017 +0100

    ActionBar: Verwendung beim Massendruck von Lieferscheinen

diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl
index 07988dbb2..e4aa85d86 100644
--- a/bin/mozilla/do.pl
+++ b/bin/mozilla/do.pl
@@ -376,10 +376,15 @@ sub setup_do_orders_action_bar {
     $bar->add(
       action => [
         t8('New invoice'),
-        submit    => [ '#orders_form' ],
-        checks    => [ [ 'kivi.check_if_entries_selected', '#orders_form tbody input[type=checkbox]' ] ],
+        submit    => [ '#form', { action => 'invoice_multi' } ],
+        checks    => [ [ 'kivi.check_if_entries_selected', '#form tbody input[type=checkbox]' ] ],
         accesskey => 'enter',
       ],
+      action => [
+        t8('Print'),
+        call   => [ 'kivi.SalesPurchase.show_print_dialog', 'js:kivi.MassDeliveryOrderPrint.submitMultiOrders' ],
+        checks => [ [ 'kivi.check_if_entries_selected', '#form tbody input[type=checkbox]' ] ],
+      ],
     );
   }
 }
@@ -659,7 +664,7 @@ sub orders {
   my $locale   = $main::locale;
   my $cgi      = $::request->{cgi};
 
-  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.MassDeliveryOrderPrint));
+  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.MassDeliveryOrderPrint kivi.SalesPurchase));
   ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = split(/--/, $form->{ $form->{vc} });
 
   report_generator_set_default_sort('transdate', 1);
@@ -801,9 +806,17 @@ sub orders {
       $form->{printer_id} = $pr->id;
   }
 
+  my $print_options = SL::Helper::PrintOptions->get_print_options(
+    options => {
+      hide_language_id => 1,
+      show_bothsided   => 1,
+      show_headers     => 1,
+    },
+  );
+
   $report->set_options('top_info_text'        => join("\n", @options),
                        'raw_top_info_text'    => $form->parse_html_template('do/orders_top'),
-                       'raw_bottom_info_text' => $form->parse_html_template('do/orders_bottom', { print_options => print_options(inline => 1,hide_language_id => 1) }),
+                       'raw_bottom_info_text' => $form->parse_html_template('do/orders_bottom', { print_options => $print_options }),
                        'output_format'        => 'HTML',
                        'title'                => $form->{title},
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
diff --git a/js/kivi.MassDeliveryOrderPrint.js b/js/kivi.MassDeliveryOrderPrint.js
index 426b4c116..e0b538761 100644
--- a/js/kivi.MassDeliveryOrderPrint.js
+++ b/js/kivi.MassDeliveryOrderPrint.js
@@ -1,5 +1,6 @@
 namespace('kivi.MassDeliveryOrderPrint', function(ns) {
-    
+  "use strict";
+
   ns.massConversionFinishProcess = function() {
     $('#mass_print_dialog').dialog('close');
   };
@@ -30,24 +31,6 @@ namespace('kivi.MassDeliveryOrderPrint', function(ns) {
   };
 
   ns.submitMultiOrders = function () {
-      $("#old_table_id").remove();
-      var checkboxes = $('input[type=checkbox]').filter(function () { return  $(this).prop('checked'); });
-      if (checkboxes.size() == 0) {
-          alert(kivi.t8("No delievery orders selected, please set one checkbox!"));
-          return false;
-      }
-      
-      var tmpform = $("#report_table_id").clone();
-      tmpform.hide();
-      tmpform.attr('id',"old_table_id");
-      tmpform.appendTo("#print_multi_id");
-      return kivi.submit_ajax_form('controller.pl?action=MassDeliveryOrderPrint/mass_mdo_print',$('#print_multi_id'));
-  };
-
-  ns.setup = function() {
-    $('#multi_all').checkall("input[name^='multi_id']");
-    $('#print_multi_button').click(kivi.MassDeliveryOrderPrint.submitMultiOrders);
+    return kivi.submit_ajax_form('controller.pl?action=MassDeliveryOrderPrint/mass_mdo_print', $('#form'));
   };
 });
-
-$(kivi.MassDeliveryOrderPrint.setup);
diff --git a/js/kivi.SalesPurchase.js b/js/kivi.SalesPurchase.js
index c19c10a68..2fcd2132e 100644
--- a/js/kivi.SalesPurchase.js
+++ b/js/kivi.SalesPurchase.js
@@ -311,7 +311,11 @@ namespace('kivi.SalesPurchase', function(ns) {
   this.print_record = function() {
     $('#print_dialog').dialog('close');
 
-    kivi.submit_form_with_action('#form', $('#form').data('print-action'));
+    var action = $('#form').data('print-action');
+    if (action.match("^js:"))
+      return kivi.run(action.substring(3));
+
+    kivi.submit_form_with_action('#form', action);
   };
 
   this.show_print_dialog = function(print_action) {
diff --git a/js/locale/de.js b/js/locale/de.js
index 2bdd17e3f..2fffd6fbf 100644
--- a/js/locale/de.js
+++ b/js/locale/de.js
@@ -69,7 +69,6 @@ namespace("kivi").setupLocale({
 "More than one file selected, please set only one checkbox!":"Mehr als ein Element selektiert, bitte nur eine Box anklicken",
 "No":"Nein",
 "No article has been selected yet.":"Es wurde noch kein Artikel ausgewählt.",
-"No delievery orders selected, please set one checkbox!":"Kein Lieferschein selektiert, bitte eine Box anklicken!",
 "No delivery orders have been selected.":"Es wurden keine Lieferscheine ausgewählt.",
 "No entries have been selected.":"Es wurden keine Einträge ausgewählt.",
 "No file selected, please set one checkbox!":"Kein Element selektiert,bitte eine Box anklicken",
diff --git a/locale/de/all b/locale/de/all
index 694ee9e5b..9bf27212d 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -1857,7 +1857,6 @@ $self->{texts} = {
   'No customer has been selected yet.' => 'Es wurde noch kein Kunde ausgewählt.',
   'No data was found.'          => 'Es wurden keine Daten gefunden.',
   'No default currency'         => 'Keine Standardwährung',
-  'No delievery orders selected, please set one checkbox!' => 'Kein Lieferschein selektiert, bitte eine Box anklicken!',
   'No delivery orders have been selected.' => 'Es wurden keine Lieferscheine ausgewählt.',
   'No delivery term has been created yet.' => 'Es wurden noch keine Lieferbedingungen angelegt',
   'No dunnings have been selected for printing.' => 'Es wurden keine Mahnungen zum Drucken ausgew&auml;hlt.',
@@ -2218,8 +2217,6 @@ $self->{texts} = {
   'Print list'                  => 'Liste ausdrucken',
   'Print options'               => 'Druckoptionen',
   'Print record'                => 'Beleg drucken',
-  'Print selected'              => 'Drucken',
-  'Print selected delivery orders both sided' => 'Ausgewählte Lieferscheine (ggf beidseitig)',
   'Print template base file name' => 'Druckvorlagen-Basisdateiname',
   'Print templates'             => 'Druckvorlagen',
   'Print templates to use'      => 'Zu verwendende Druckvorlagen',
diff --git a/templates/webpages/do/orders_bottom.html b/templates/webpages/do/orders_bottom.html
index be524f84e..e51ac704b 100644
--- a/templates/webpages/do/orders_bottom.html
+++ b/templates/webpages/do/orders_bottom.html
@@ -1,17 +1,15 @@
-[% USE HTML %][%- USE T8 -%]
- <input type="hidden" name="action" value="invoice_multi">
- <input type="hidden" name="type" value="[% HTML.escape(type) %]">
- <input type="hidden" name="vc" value="[% HTML.escape(vc) %]">
- <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
- <input type="hidden" name="rowcount" value="[% HTML.escape(rowcount) %]">
+[% USE HTML %][%- USE T8 -%][%- USE LxERP -%][%- USE P -%]
+ [% P.hidden_tag("type", type) %]
+ [% P.hidden_tag("vc", vc) %]
+ [% P.hidden_tag("rowcount", rowcount) %]
+ [% P.hidden_tag("callback", callback) %]
+
+ <div id="print_options" class="hidden">
+  [% print_options %]
+ </div>
 </form>
-<form method="post" id="print_multi_id">
-[% print_options %]
+
+<div id="print_dialog" class="hidden">
+ [%- PROCESS 'common/_print_dialog.html' %]
+</div>
 <div id="mass_print_dialog" style="display: none"></div>
-<table  width="100%">
-  <tr><td width="300px" align="right">[% 'Print selected delivery orders both sided' | $T8 %]</td>
-      <td><input type="checkbox" name="bothsided" value="1">
-<input type="hidden" name="type" value="[% HTML.escape(type) %]">
-<input type="hidden" name="rowcount" value="[% HTML.escape(rowcount) %]">
-<input class="submit" type="button" name="action" id="print_multi_button" value="[% 'Print selected' | $T8 %]">
-</td><td></td></tr></table></form>
diff --git a/templates/webpages/do/orders_top.html b/templates/webpages/do/orders_top.html
index d197c97d1..181f25a2c 100644
--- a/templates/webpages/do/orders_top.html
+++ b/templates/webpages/do/orders_top.html
@@ -1,2 +1,2 @@
 [%- INCLUDE 'common/flash.html' %]
-<form method="post" action="do.pl" id="orders_form">
+<form method="post" action="do.pl" id="form">
diff --git a/templates/webpages/generic/print_options.html b/templates/webpages/generic/print_options.html
index 5f1fd2c46..be8343f11 100644
--- a/templates/webpages/generic/print_options.html
+++ b/templates/webpages/generic/print_options.html
@@ -46,6 +46,11 @@
       <input name="[%- name_prefix %]groupitems" id="[% id_prefix %]groupitems" type="checkbox" class="checkbox" [% groupitems_checked %]>
      </td>
      [%- END %]
+     [%- IF display_bothsided %]
+     <td id="print_options_input_bothsided">[%- IF !show_headers %][% 'Both-sided' | $T8 %][%- END %]
+      <input name="[%- name_prefix %]bothsided" id="[% id_prefix %]bothsided" type="checkbox" class="checkbox" [% bothsided_checked %]>
+     </td>
+     [%- END %]
      [%- IF display_remove_draft %]
      <td id="print_options_input_remove_draft">[%- IF !show_headers %][% 'Remove Draft' | $T8 %][%- END %]
       <input name="[%- name_prefix %]remove_draft" id="[% id_prefix %]remove_draft" type="checkbox" class="checkbox" [% remove_draft_checked %]>
