From 4cb932aba73b8d72df10a1c0095228a10692536c Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 5 Jan 2017 10:32:48 +0100 Subject: [PATCH] =?utf8?q?ActionBar:=20Angebote/Auftr=C3=A4ge:=20Lieferadr?= =?utf8?q?esse=20via=20Popup=20bearbeiten?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/oe.pl | 8 +- js/kivi.SalesPurchase.js | 74 +++++++++ js/locale/de.js | 1 + locale/de/all | 3 + .../webpages/common/_ship_to_dialog.html | 154 ++++++++++++++++++ templates/webpages/oe/form_footer.html | 5 + templates/webpages/oe/form_header.html | 6 +- 7 files changed, 245 insertions(+), 6 deletions(-) create mode 100644 templates/webpages/common/_ship_to_dialog.html diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 1fdc6d2a9..bc01dbbc4 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -51,6 +51,7 @@ use Data::Dumper; use SL::DB::Customer; use SL::DB::TaxZone; use SL::DB::PaymentTerm; +use SL::DB::Vendor; require "bin/mozilla/common.pl"; require "bin/mozilla/io.pl"; @@ -451,6 +452,8 @@ sub form_header { if ($form->{id}) { $TMPL_VAR{oe_obj} = SL::DB::Order->new(id => $form->{id})->load; } + $TMPL_VAR{vc_obj} = SL::DB::Customer->new(id => $form->{customer_id})->load if $form->{customer_id}; + $TMPL_VAR{vc_obj} = SL::DB::Vendor->new(id => $form->{vendor_id})->load if $form->{vendor_id}; $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -592,9 +595,8 @@ sub form_header { $TMPL_VAR{HIDDENS} = [ map { name => $_, value => $form->{$_} }, qw(id action type vc formname media format proforma queued printed emailed title creditlimit creditremaining tradediscount business - max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode - CFDD_shipto CFDD_shipto_id shiptocity shiptocountry shiptogln shiptocontact shiptophone shiptofax - shiptodepartment_1 shiptodepartment_2 shiptoemail shiptocp_gender + max_dunning_level dunning_amount + CFDD_shipto CFDD_shipto_id message email subject cc bcc taxpart taxservice taxaccounts cursor_fokus show_details useasnew), @custom_hiddens, diff --git a/js/kivi.SalesPurchase.js b/js/kivi.SalesPurchase.js index 402ae73e0..69fec6d8b 100644 --- a/js/kivi.SalesPurchase.js +++ b/js/kivi.SalesPurchase.js @@ -134,4 +134,78 @@ namespace('kivi.SalesPurchase', function(ns) { $.post('is.pl', data, kivi.eval_json_result); }); }; + + // Functions dialog with entering shipping addresses. + this.shipto_addresses = []; + + this.copy_shipto_address = function () { + var shipto = this.shipto_addresses[ $('#shipto_to_copy').val() ]; + for (var key in shipto) + $('#' + key).val(shipto[key]); + }; + + this.clear_shipto_fields = function() { + var shipto = this.shipto_addresses[0]; + for (var key in shipto) + $('#' + key).val(''); + $('#shiptocp_gender').val('m'); + }; + + this.clear_shipto_id_before_submit = function() { + var shipto = this.shipto_addresses[0]; + for (var key in shipto) + if ((key != 'shiptocp_gender') && ($('#' + key).val() !== '')) { + $('#shipto_id').val(''); + break; + } + }; + + this.setup_shipto_dialog = function() { + var $dlg = $('#shipto_dialog'); + + $('#shipto_dialog [name^="shipto"]').each(function(idx, elt) { + $dlg.data("original-" + $(elt).prop("name"), $(elt).val()); + }); + + $dlg.data('confirmed', false); + + $('#shiptoname').focus(); + }; + + this.submit_custom_shipto = function() { + $('#shipto_id').val(''); + $('#shipto_dialog').data('confirmed', true); + $('#shipto_dialog').dialog('close'); + }; + + this.reset_shipto_fields = function() { + var $dlg = $('#shipto_dialog'); + + $('#shipto_dialog [name^="shipto"]').each(function(idx, elt) { + $(elt).val($dlg.data("original-" + $(elt).prop("name"))); + }); + }; + + this.finish_shipto_dialog = function() { + if (!$('#shipto_dialog').data('confirmed')) + kivi.SalesPurchase.reset_shipto_fields(); + + $('#shipto_dialog').children().remove().appendTo('#shipto_inputs'); + + return true; + }; + + this.edit_custom_shipto = function() { + $('#shipto_inputs').children().remove().appendTo('#shipto_dialog'); + + kivi.popup_dialog({ + id: 'shipto_dialog', + dialog: { + height: 600, + title: kivi.t8('Edit custom shipto'), + open: kivi.SalesPurchase.setup_shipto_dialog, + close: kivi.SalesPurchase.finish_shipto_dialog, + } + }); + }; }); diff --git a/js/locale/de.js b/js/locale/de.js index 113a5fa98..d7db4951f 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -48,6 +48,7 @@ namespace("kivi").setupLocale({ "Download picture":"Bild herunterladen", "Edit":"Bearbeiten", "Edit article/section assignments":"Zuweisung Artikel/Abschnitte bearbeiten", +"Edit custom shipto":"Individuelle Lieferadresse bearbeiten", "Edit picture":"Bild bearbeiten", "Edit project link":"Projektverknüpfung bearbeiten", "Edit text block":"Textblock bearbeiten", diff --git a/locale/de/all b/locale/de/all index e8d8b6594..0c4409f2b 100755 --- a/locale/de/all +++ b/locale/de/all @@ -286,6 +286,7 @@ $self->{texts} = { 'Ap aging on %s' => 'Offene Verbindlichkeiten an %s', 'Application Error. No Format given' => 'Fehler in der Anwendung. Das Ausgabeformat fehlt.', 'Application Error. Wrong Format' => 'Fehler in der Anwendung. Falsches Format: ', + 'Apply' => 'Anwenden', 'Apply to all parts' => 'Bei allen Artikeln setzen', 'Apply to all transfers' => 'Bei allen Lagerbewegungen setzen', 'Apply to parts without booking group' => 'Bei allen Artikeln ohne gültige Buchungsgruppe setzen', @@ -765,6 +766,7 @@ $self->{texts} = { 'Current year' => 'Aktuelles Jahr', 'Currently #1 delivery orders can be converted into invoices and printed.' => 'Momentan können #1 Lieferscheine in Rechnungen umgewandelt werden.', 'Custom Variables' => 'Benutzerdefinierte Variablen', + 'Custom shipto' => 'Individuelle Lieferadresse', 'Custom variables for module' => 'Benutzerdefinierte Variablen für Modul', 'Customer' => 'Kunde', 'Customer (database ID)' => 'Kunde (Datenbank-ID)', @@ -1116,6 +1118,7 @@ $self->{texts} = { 'Edit booking group' => 'Buchungsgruppe bearbeiten', 'Edit business' => 'Kunden-/Lieferantentyp bearbeiten', 'Edit complexity' => 'Komplexitätsgrad bearbeiten', + 'Edit custom shipto' => 'Individuelle Lieferadresse bearbeiten', 'Edit custom variable' => 'Benutzerdefinierte Variable bearbeiten', 'Edit delivery term' => 'Lieferbedingungen bearbeiten', 'Edit department' => 'Abteilung bearbeiten', diff --git a/templates/webpages/common/_ship_to_dialog.html b/templates/webpages/common/_ship_to_dialog.html new file mode 100644 index 000000000..be4bcee49 --- /dev/null +++ b/templates/webpages/common/_ship_to_dialog.html @@ -0,0 +1,154 @@ +[% USE HTML %][% USE L %][% USE LxERP %][%- USE JavaScript -%] + + + +[% select_options = [ [ 0, LxERP.t8("Billing Address") ] ] ; + FOREACH shipto = vc_obj.shipto ; + tmpcity = shipto.shiptozipcode _ ' ' _ shipto.shiptocity ; + tmptitle = [ shipto.shiptoname, shipto.shiptostreet, tmpcity ] ; + CALL select_options.import([ [ loop.count, tmptitle.grep('\S').join("; ") ] ]) ; + END ; + '' %] + +

+ [% LxERP.t8("Copy address from master data") %]: + [% L.select_tag("", select_options, id="shipto_to_copy", style="width: 300px") %] + [% L.button_tag("kivi.SalesPurchase.copy_shipto_address()", LxERP.t8("Copy")) %] +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[% FOREACH var = cvars %] + + + + + +[% END %] +
[% LxERP.t8('Billing Address') %][% LxERP.t8('Shipping Address') %]
[%- IF vc == "customer" %][%- LxERP.t8('Customer Number') %][%- ELSE %][%- LxERP.t8('Vendor Number') %][%- END %][%- IF vc == "customer" %][%- HTML.escape(vc_obj.customernumber) %][%- ELSE %][%- HTML.escape(vc_obj.vendornumber) %][%- END %]
[% LxERP.t8('Company Name') %][% HTML.escape(vc_obj.name) %][% L.input_tag("shiptoname", shiptoname, "size", "35") %]
[% LxERP.t8('Department') %][% HTML.escape(vc_obj.department_1) %][% L.input_tag("shiptodepartment_1", shiptodepartment_1, "size", "35") %]
 [% HTML.escape(vc_obj.department_2) %][% L.input_tag("shiptodepartment_2", shiptodepartment_2, "size", "35") %]
[% LxERP.t8('Street') %][% HTML.escape(vc_obj.street) %][% L.input_tag("shiptostreet", shiptostreet, "size", "35") %]
[% LxERP.t8('Zipcode') %][% HTML.escape(vc_obj.zipcode) %][% L.input_tag("shiptozipcode", shiptozipcode, "size", "35") %]
[% LxERP.t8('City') %][% HTML.escape(vc_obj.city) %][% L.input_tag("shiptocity", shiptocity, "size", "35") %]
[% LxERP.t8('Country') %][% HTML.escape(vc_obj.country) %][% L.input_tag("shiptocountry", shiptocountry, "size", "35") %]
[% LxERP.t8('GLN') %][% HTML.escape(vc_obj.gln) %][% L.input_tag("shiptogln", shiptogln, "size", "35") %]
[% LxERP.t8('Contact') %][% HTML.escape(vc_obj.contact) %][% L.input_tag("shiptocontact", shiptocontact, "size", "35") %]
[% LxERP.t8('Gender') %] + [% L.select_tag('shiptocp_gender', [ [ 'm', LxERP.t8('male') ], [ 'f', LxERP.t8('female') ] ], 'default' = shiptocp_gender) %] +
[% LxERP.t8('Phone') %][% HTML.escape(vc_obj.phone) %][% L.input_tag("shiptophone", shiptophone, "size", "35") %]
[% LxERP.t8('Fax') %][% HTML.escape(vc_obj.fax) %][% L.input_tag("shiptofax", shiptofax, "size", "35") %]
[% LxERP.t8('E-mail') %][% HTML.escape(vc_obj.email) %][% L.input_tag("shiptoemail", shiptoemail, "size", "35") %]
[% HTML.escape(var.config.description) %][% INCLUDE 'common/render_cvar_input.html' cvar_name_prefix='shiptocvar_' %]
+ +

+ [% L.button_tag("kivi.SalesPurchase.submit_custom_shipto()", LxERP.t8("Apply")) %] + [% L.button_tag("kivi.SalesPurchase.reset_shipto_fields()", LxERP.t8("Reset")) %] + [% L.button_tag("kivi.SalesPurchase.clear_shipto_fields()", LxERP.t8("Clear fields")) %] + [% L.button_tag("\$('#shipto_dialog').dialog('close');", LxERP.t8("Abort")) %] +

diff --git a/templates/webpages/oe/form_footer.html b/templates/webpages/oe/form_footer.html index 4e0d6e328..aad73eb13 100644 --- a/templates/webpages/oe/form_footer.html +++ b/templates/webpages/oe/form_footer.html @@ -143,4 +143,9 @@ [% END %] + + + diff --git a/templates/webpages/oe/form_header.html b/templates/webpages/oe/form_header.html index d4fc7c061..6482185b2 100644 --- a/templates/webpages/oe/form_header.html +++ b/templates/webpages/oe/form_header.html @@ -73,16 +73,16 @@ [%- END %] -[%- IF ALL_SHIPTO.size %] [% 'Shipping Address' | $T8 %] +[%- IF ALL_SHIPTO.size %] [% shiptos = [ [ "", LxERP.t8("No/individual shipping address") ] ] ; L.select_tag('shipto_id', shiptos.import(ALL_SHIPTO), default=shipto_id, value_key='shipto_id', title_key='displayable_id', style='width: 250px') %] - [% L.submit_tag('action_ship_to', LxERP.t8('Ship to')) %] +[%- END %] + [% L.button_tag("kivi.SalesPurchase.edit_custom_shipto()", LxERP.t8("Custom shipto")) %] -[%- END %] [%- IF is_order %] [% 'Credit Limit' | $T8 %] -- 2.20.1