]> wagnertech.de Git - mfinanz.git/blobdiff - templates/webpages/order/tabs/basic_data.html
Auftrags-Controller: linetotal nach Ändern von Menge/Preis/Rabatt neu berechnen.
[mfinanz.git] / templates / webpages / order / tabs / basic_data.html
index ea9710ba4993e79a137923ae65779d98cd25e561..2c9598d52c99a61ad6ec3a13360bd99619e4200c 100644 (file)
               </tr>
             </thead>
 
-            <tbody>
-              [%- FOREACH item = SELF.order.items_sorted %]
-                [%- PROCESS order/tabs/_row.html ITEM=item %]
-              [%- END %]
-            </tbody>
+            [%- FOREACH item = SELF.order.items_sorted %]
+              [%- PROCESS order/tabs/_row.html ITEM=item %]
+            [%- END %]
 
           </table>
         </div>
 </div>
 
 
-[% L.sortable_element('#row_table_id tbody') %]
+[% L.sortable_element('#row_table_id') %]
 
 <script type='text/javascript'>
 function reload_cv_dependend_selections() {
@@ -204,10 +202,10 @@ function add_item() {
 }
 
 function delete_order_item_row(clicked) {
-  var row = $(clicked).parents("tr").first();
+  var row = $(clicked).parents("tbody").first();
   $(row).remove();
 
-  recalc_amounts_and_taxes()
+  recalc_amounts_and_taxes();
 }
 
 function recalc_amounts_and_taxes() {
@@ -218,10 +216,48 @@ function recalc_amounts_and_taxes() {
   $.post("controller.pl", data, kivi.eval_json_result);
 }
 
+function redisplay_linetotals(data) {
+  $('.row_entry [name="linetotal"]').each(function(idx, elt) {
+    $(elt).html(data[idx]);    
+  });
+}
+
 function row_table_scroll_down() {
   $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
 }
 
+function row_set_keyboard_events_by_id(item_id) {
+  var row = $('#item_' + item_id).parents("tbody").first();
+
+  row_set_keyboard_events(row);
+}
+
+function row_set_keyboard_events(rows) {
+  $(rows).keydown(function(event) {
+    if(event.keyCode == 40 && event.shiftKey == true) {
+      // shift arrow down
+      event.preventDefault();
+      var row = $(event.target).parents(".row_entry").first();
+      $(row).children().not(':first').show();
+      return false;
+    }
+    if(event.keyCode == 38 && event.shiftKey == true) {
+      // shift arrow up
+      event.preventDefault();
+      var row = $(event.target).parents(".row_entry").first();
+      $(row).children().not(':first').hide();
+      return false;
+    }
+  });
+
+  $(rows).dblclick(function(event) {
+      event.preventDefault();
+      var row = $(event.target).parents(".row_entry").first();
+      $(row).children().not(':first').toggle();
+      return false;
+  });
+}
+
 $(function(){
   $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
@@ -233,6 +269,8 @@ $(function(){
       return false;
     }
   });
+  row_set_keyboard_events($('.row_entry'));
+  $('.recalc').change(recalc_amounts_and_taxes);
 });
 
 </script>