X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.Order.js;h=d74e3470d61a378857a2748ce1564b3d5c11678b;hb=6ceacc682f9c760e654f5aacde9b8480760d8b36;hp=907e15bd3c99c26319b096ab78707cabbef0c8dc;hpb=e70a89d293b3296da1c106fa9c1ee203b4956ece;p=kivitendo-erp.git diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 907e15bd3..d74e3470d 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -28,7 +28,7 @@ namespace('kivi.Order', function(ns) { } if (pos.length > 0) { - question = question || kivi.t8("Do you really want to save?"); + question = question || kivi.t8("Do you really want to continue?"); return confirm(kivi.t8("There are duplicate parts at positions") + "\n" + pos.join(', ') + "\n" + question); @@ -51,7 +51,6 @@ namespace('kivi.Order', function(ns) { if (warn_on_reqdate && !ns.check_valid_reqdate()) return; var data = $('#order_form').serializeArray(); - data.push({ name: 'order.language_id', value: $('#language_id').val() }); // language from print options data.push({ name: 'action', value: 'Order/' + action }); $.post("controller.pl", data, kivi.eval_json_result); @@ -83,23 +82,11 @@ namespace('kivi.Order', function(ns) { var data = $('#order_form').serializeArray(); data = data.concat($('#print_options_form').serializeArray()); - data.push({ name: 'order.language_id', value: $('#language_id').val() }); // language from print options data.push({ name: 'action', value: 'Order/print' }); $.post("controller.pl", data, kivi.eval_json_result); }; - ns.email = function(warn_on_duplicates) { - if (warn_on_duplicates && !ns.check_duplicate_parts(kivi.t8("Do you really want to send by mail?"))) return; - if (!ns.check_cv()) return; - - var data = $('#order_form').serializeArray(); - data.push({ name: 'order.language_id', value: $('#language_id').val() }); // language from print options - data.push({ name: 'action', value: 'Order/show_email_dialog' }); - - $.post("controller.pl", data, kivi.eval_json_result); - }; - var email_dialog; ns.setup_send_email_dialog = function() { @@ -150,7 +137,6 @@ namespace('kivi.Order', function(ns) { var data = $('#order_form').serializeArray(); data = data.concat($('[name^="email_form."]').serializeArray()); data = data.concat($('[name^="print_options."]').serializeArray()); - data.push({ name: 'order.language_id', value: $('#language_id').val() }); // language from print options data.push({ name: 'action', value: 'Order/send_email' }); $.post("controller.pl", data, kivi.eval_json_result); }; @@ -164,6 +150,7 @@ namespace('kivi.Order', function(ns) { }; ns.reload_cv_dependent_selections = function() { + $('#order_shipto_id').val(''); var data = $('#order_form').serializeArray(); data.push({ name: 'action', value: 'Order/customer_vendor_changed' }); @@ -174,6 +161,13 @@ namespace('kivi.Order', function(ns) { $(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2)); }; + ns.reformat_number_as_null_number = function(event) { + if ($(event.target).val() === '') { + return; + } + ns.reformat_number(event); + }; + ns.update_exchangerate = function(event) { if (!ns.check_cv()) { $('#order_currency_id').val($('#old_currency_id').val()); @@ -181,7 +175,15 @@ namespace('kivi.Order', function(ns) { } var rate_input = $('#order_exchangerate_as_null_number'); - rate_input.prop('disabled', true); + // unset exchangerate if currency changed + if ($('#order_currency_id').val() !== $('#old_currency_id').val()) { + rate_input.val(''); + } + + // only set exchangerate if unset + if (rate_input.val() !== '') { + return; + } var data = $('#order_form').serializeArray(); data.push({ name: 'action', value: 'Order/update_exchangerate' }); @@ -194,17 +196,14 @@ namespace('kivi.Order', function(ns) { success: function(data){ if (!data.is_standard) { $('#currency_name').text(data.currency_name); - var rate_text = $('#exchangerate_text'); if (data.exchangerate) { - rate_text.text(data.exchangerate); - rate_input.hide(); + rate_input.val(data.exchangerate); } else { - rate_text.text(''); - rate_input.prop('disabled', false); - rate_input.show().val(''); + rate_input.val(''); } $('#exchangerate_settings').show(); } else { + rate_input.val(''); $('#exchangerate_settings').hide(); } if ($('#order_currency_id').val() != $('#old_currency_id').val() || @@ -581,40 +580,15 @@ namespace('kivi.Order', function(ns) { var position = $(row).find('[name="position"]').html(); var partnumber = $(row).find('[name="partnumber"]').html(); var description_elt = $(row).find('[name="order.orderitems[].description"]'); - var description = description_elt.val(); var longdescription_elt = $(row).find('[name="order.orderitems[].longdescription"]'); - var longdescription; - - if (!longdescription_elt.length) { - var data = [ - { name: 'action', value: 'Order/get_item_longdescription' }, - { name: 'type', value: $('#type').val() }, - { name: 'item_id', value: $(row).find('[name="order.orderitems[+].id"]').val() }, - { name: 'parts_id', value: $(row).find('[name="order.orderitems[].parts_id"]').val() } - ]; - - $.ajax({ - url: 'controller.pl', - data: data, - method: "GET", - async: false, - dataType: 'text', - success: function(val) { - longdescription = val; - } - }); - } else { - longdescription = longdescription_elt.val(); - } var params = { runningnumber: position, partnumber: partnumber, - description: description, - default_longdescription: longdescription, + description: description_elt.val(), + default_longdescription: longdescription_elt.val(), set_function: function(val) { - longdescription_elt.remove(); - $('').insertAfter(description_elt).val(val); + longdescription_elt.val(val); } }; @@ -833,6 +807,107 @@ namespace('kivi.Order', function(ns) { return true; }; + ns.edit_custom_shipto = function() { + if (!ns.check_cv()) return; + + kivi.SalesPurchase.edit_custom_shipto(); + }; + + ns.purchase_order_check_for_direct_delivery = function() { + if ($('#type').val() != 'sales_order') { + kivi.submit_form_with_action($('#order_form'), 'Order/purchase_order'); + } + + var empty = true; + var shipto; + if ($('#order_shipto_id').val() !== '') { + empty = false; + shipto = $('#order_shipto_id option:selected').text(); + } else { + $('#shipto_inputs [id^="shipto"]').each(function(idx, elt) { + if (!empty) return true; + if (/^shipto_to_copy/.test($(elt).prop('id'))) return true; + if (/^shiptocp_gender/.test($(elt).prop('id'))) return true; + if (/^shiptocvar_/.test($(elt).prop('id'))) return true; + if ($(elt).val() !== '') { + empty = false; + return false; + } + }); + var shipto_elements = []; + $([$('#shiptoname').val(), $('#shiptostreet').val(), $('#shiptozipcode').val(), $('#shiptocity').val()]).each(function(idx, elt) { + if (elt !== '') shipto_elements.push(elt); + }); + shipto = shipto_elements.join('; '); + } + + var use_it = false; + if (!empty) { + ns.direct_delivery_dialog(shipto); + } else { + kivi.submit_form_with_action($('#order_form'), 'Order/purchase_order'); + } + }; + + ns.direct_delivery_callback = function(accepted) { + $('#direct-delivery-dialog').dialog('close'); + + if (accepted) { + $('').appendTo('#order_form').val('1'); + } + + kivi.submit_form_with_action($('#order_form'), 'Order/purchase_order'); + }; + + ns.direct_delivery_dialog = function(shipto) { + $('#direct-delivery-dialog').remove(); + + var text1 = kivi.t8('You have entered or selected the following shipping address for this customer:'); + var text2 = kivi.t8('Do you want to carry this shipping address over to the new purchase order so that the vendor can deliver the goods directly to your customer?'); + var html = '

' + text1 + '

' + shipto + '

' + text2 + '

'; + html = html + '

'; + html = html + ''; + html = html + ' '; + html = html + ''; + html = html + '

'; + $(html).hide().appendTo('#order_form'); + + kivi.popup_dialog({id: 'direct-delivery-dialog', + dialog: {title: kivi.t8('Carry over shipping address'), + height: 300, + width: 500 }}); + }; + + ns.follow_up_window = function() { + var id = $('#id').val(); + var type = $('#type').val(); + + var number_info = ''; + if ($('#type').val() == 'sales_order' || $('#type').val() == 'purchase_order') { + number_info = $('#order_ordnumber').val(); + } else if ($('#type').val() == 'sales_quotation' || $('#type').val() == 'request_quotation') { + number_info = $('#order_quonumber').val(); + } + + var name_info = ''; + if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation') { + name_info = $('#order_customer_id_name').val(); + } else if ($('#type').val() == 'purchase_order' || $('#type').val() == 'request_quotation') { + name_info = $('#order_vendor_id_name').val(); + } + + var info = ''; + if (number_info !== '') { info += ' (' + number_info + ')' } + if (name_info !== '') { info += ' (' + name_info + ')' } + + $('').appendTo('#order_form').val(1); + $('').appendTo('#order_form').val(id); + $('').appendTo('#order_form').val(type); + $('').appendTo('#order_form').val(info); + + follow_up_window(); + }; + }); $(function() { @@ -892,4 +967,6 @@ $(function() { return false; }); + $('.reformat_number_as_null_number').change(kivi.Order.reformat_number_as_null_number); + });