Telefonnotizen Angebot/Auftrag
[kivitendo-erp.git] / js / kivi.Order.js
index b82358b..9ef6ef5 100644 (file)
@@ -558,7 +558,7 @@ namespace('kivi.Order', function(ns) {
     $.post("controller.pl", data, kivi.eval_json_result);
   };
 
-  ns.update_price_source = function(item_id, source, descr, price_str, price_editable) {
+  ns.set_price_and_source_text = function(item_id, source, descr, price_str, price_editable) {
     var row        = $('#item_' + item_id).parents("tbody").first();
     var source_elt = $(row).find('[name="order.orderitems[].active_price_source"]');
     var button_elt = $(row).find('[name="price_chooser_button"]');
@@ -587,13 +587,17 @@ namespace('kivi.Order', function(ns) {
       var html_elt  = $(row).find('[name="sellprice_text"]');
       price_elt.val(price_str);
       html_elt.html(price_str);
-      ns.recalc_amounts_and_taxes();
     }
+  };
+
+  ns.update_price_source = function(item_id, source, descr, price_str, price_editable) {
+    ns.set_price_and_source_text(item_id, source, descr, price_str, price_editable);
 
+    if (price_str) ns.recalc_amounts_and_taxes();
     kivi.io.close_dialog();
   };
 
-  ns.update_discount_source = function(item_id, source, descr, discount_str, price_editable) {
+  ns.set_discount_and_source_text = function(item_id, source, descr, discount_str, price_editable) {
     var row        = $('#item_' + item_id).parents("tbody").first();
     var source_elt = $(row).find('[name="order.orderitems[].active_discount_source"]');
     var button_elt = $(row).find('[name="price_chooser_button"]');
@@ -622,9 +626,13 @@ namespace('kivi.Order', function(ns) {
       var html_elt     = $(row).find('[name="discount_text"]');
       discount_elt.val(discount_str);
       html_elt.html(discount_str);
-      ns.recalc_amounts_and_taxes();
     }
+  };
 
+  ns.update_discount_source = function(item_id, source, descr, discount_str, price_editable) {
+    ns.set_discount_and_source_text(item_id, source, descr, discount_str, price_editable);
+
+    if (discount_str) ns.recalc_amounts_and_taxes();
     kivi.io.close_dialog();
   };
 
@@ -870,7 +878,6 @@ namespace('kivi.Order', function(ns) {
   ns.create_part = function() {
     var data = $('#order_form').serializeArray();
     data.push({ name: 'action', value: 'Order/create_part' });
-
     $.post("controller.pl", data, kivi.eval_json_result);
   };
 
@@ -898,6 +905,38 @@ namespace('kivi.Order', function(ns) {
     return true;
   };
 
+  ns.load_phone_note = function(id, subject, body) {
+    $('#phone_note_edit_text').html(kivi.t8('Edit note'));
+    $('#phone_note_id').val(id);
+    $('#phone_note_subject').val(subject);
+    $('#phone_note_body').val(body);
+    $('#phone_note_delete_button').show();
+  };
+
+  ns.cancel_phone_note = function() {
+    $('#phone_note_edit_text').html(kivi.t8('Add note'));
+    $('#phone_note_id').val('');
+    $('#phone_note_subject').val('');
+    $('#phone_note_body').val('');
+    $('#phone_note_delete_button').hide();
+  };
+
+  ns.save_phone_note = function() {
+    var data = $('#order_form').serializeArray();
+    data.push({ name: 'action', value: 'Order/save_phone_note' });
+
+    $.post("controller.pl", data, kivi.eval_json_result);
+  };
+
+  ns.delete_phone_note = function() {
+    if ($('#phone_note_id').val() === '') return;
+
+    var data = $('#order_form').serializeArray();
+    data.push({ name: 'action', value: 'Order/delete_phone_note' });
+
+    $.post("controller.pl", data, kivi.eval_json_result);
+  };
+
 });
 
 $(function() {