From 9cb9a44803b42042fbec121e832ca82e29d1c8e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 2 Sep 2020 16:08:35 +0200 Subject: [PATCH] =?utf8?q?Auftrags-Controller:=20Workflow=20VK->EK:=20Lief?= =?utf8?q?eradresse=20f=C3=BCr=20direkte=20Lieferung?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Falls beim Workflow Kundenauftrag->Lieferantenauftrag eine Lieferadresse ausgewählt oder eine indiv. Lieferadresse eingetragen ist, wir gefragt, ob diese Lieferadresse als (indiv.) Lieferadresse in den Lieferantenauftrag übernommen werden soll. --- SL/Controller/Order.pm | 21 ++++++++++++-- js/kivi.Order.js | 65 ++++++++++++++++++++++++++++++++++++++++++ js/locale/de.js | 3 ++ js/locale/en.js | 3 ++ 4 files changed, 90 insertions(+), 2 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index fc05b2d16..4227ca036 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -1692,6 +1692,14 @@ sub workflow_sales_or_purchase_order { : $::form->{type} eq sales_order_type() ? purchase_order_type() : ''; + # check for direct delivery + # copy shipto in custom shipto (custom shipto will be copied by new_from() in case) + my $custom_shipto; + if ( $::form->{type} eq sales_order_type() && $destination_type eq purchase_order_type() + && $::form->{use_shipto} && $self->order->shipto) { + $custom_shipto = $self->order->shipto->clone('SL::DB::Order'); + } + $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type)); $self->{converted_from_oe_id} = delete $::form->{id}; @@ -1700,6 +1708,15 @@ sub workflow_sales_or_purchase_order { $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); } + if ($::form->{type} eq sales_order_type() && $destination_type eq purchase_order_type()) { + if ($::form->{use_shipto}) { + $self->order->custom_shipto($custom_shipto) if $custom_shipto; + } else { + # remove any custom shipto if not wanted + $self->order->custom_shipto(SL::DB::Shipto->new(module => 'OE', custom_variables => [])); + } + } + # change form type $::form->{type} = $destination_type; $self->type($self->init_type); @@ -1825,8 +1842,8 @@ sub setup_edit_action_bar { ], action => [ t8('Save and Purchase Order'), - submit => [ '#order_form', { action => "Order/purchase_order" } ], - only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), + call => [ 'kivi.Order.purchase_order_check_for_direct_delivery' ], + only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), ], action => [ t8('Save and Delivery Order'), diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 580ff50d7..a62be8838 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -852,6 +852,71 @@ namespace('kivi.Order', function(ns) { 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 }}); + }; + }); $(function() { diff --git a/js/locale/de.js b/js/locale/de.js index 277d1c0cd..21880ae81 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -16,6 +16,7 @@ namespace("kivi").setupLocale({ "Assign invoice":"Rechnung zuweisen", "Basic settings actions":"Aktionen zu Grundeinstellungen", "Cancel":"Abbrechen", +"Carry over shipping address":"Lieferadresse übernehmen", "Chart picker":"Kontenauswahl", "Copy":"Kopieren", "Copy requirement spec":"Pflichtenheft kopieren", @@ -48,6 +49,7 @@ namespace("kivi").setupLocale({ "Do you really want to save?":"Möchten Sie wirklich speichern?", "Do you really want to send by mail?":"Wollen Sie den Beleg wirklich per Mail verschicken?", "Do you really want to unimport the selected documents?":"Möchten Sie wirklich diese Dateien an die Quelle zurückgeben?", +"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?":"Möchten Sie diese Lieferadresse in den neuen Lieferantenauftrag übernehmen, damit der Händler die Waren direkt an Ihren Kunden liefern kann?", "Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"Soll die Kontonummer \"#1\" zu \"#2\" und den Name \"#3\" zu \"#4\" geändert werden?", "Download picture":"Bild herunterladen", "Due Date missing!":"Fälligkeitsdatum fehlt!", @@ -144,6 +146,7 @@ namespace("kivi").setupLocale({ "Wrong time format (#1)":"Falsches Zeitformat (#1)", "Yes":"Ja", "You have changed the currency or exchange rate. Please check prices.":"Die Währung oder der Wechselkurs hat sich geändert. Bitte überprüfen Sie die Preise.", +"You have entered or selected the following shipping address for this customer:":"Sie haben die folgende Lieferadresse eingegeben oder 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/js/locale/en.js b/js/locale/en.js index 107bd3439..e395e4fc0 100644 --- a/js/locale/en.js +++ b/js/locale/en.js @@ -16,6 +16,7 @@ namespace("kivi").setupLocale({ "Assign invoice":"", "Basic settings actions":"", "Cancel":"", +"Carry over shipping address":"", "Chart picker":"", "Copy":"", "Copy requirement spec":"", @@ -48,6 +49,7 @@ namespace("kivi").setupLocale({ "Do you really want to save?":"", "Do you really want to send by mail?":"", "Do you really want to unimport the selected documents?":"", +"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?":"", "Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"", "Download picture":"", "Due Date missing!":"", @@ -144,6 +146,7 @@ namespace("kivi").setupLocale({ "Wrong time format (#1)":"", "Yes":"", "You have changed the currency or exchange rate. Please check prices.":"", +"You have entered or selected the following shipping address for this customer:":"", "filename has not uploadable characters ":"", "filesize too big: ":"", "flat-rate position":"", -- 2.20.1