From aacd66960ed7b1f4430c7e623e516e26cad9752d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 13 Mar 2018 13:18:16 +0100 Subject: [PATCH] Auftrags-Controller: Kunden-/Lieferantendetails ("D") Hier sollte die alte Makse auch umgestellt werden, erstens auf Dialog und zweitens damit via Rose zugegriffen wird. --- SL/Controller/Order.pm | 36 +++++++++++++++++-- js/kivi.Order.js | 32 +++++++++++++++++ js/locale/de.js | 2 ++ templates/webpages/order/tabs/basic_data.html | 5 ++- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 92ef60c8c..864cc674f 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -619,6 +619,40 @@ sub action_customer_vendor_changed { $self->js->render(); } +# open the dialog for customer/vendor details +sub action_show_customer_vendor_details_dialog { + my ($self) = @_; + + my $is_customer = 'customer' eq $::form->{vc}; + my $cv; + if ($is_customer) { + $cv = SL::DB::Customer->new(id => $::form->{vc_id})->load; + } else { + $cv = SL::DB::Vendor->new(id => $::form->{vc_id})->load; + } + + my %details = map { $_ => $cv->$_ } @{$cv->meta->columns}; + $details{discount_as_percent} = $cv->discount_as_percent; + $details{creditlimt} = $cv->creditlimit_as_number; + $details{business} = $cv->business->description if $cv->business; + $details{language} = $cv->language_obj->description if $cv->language_obj; + $details{delivery_terms} = $cv->delivery_term->description if $cv->delivery_term; + $details{payment_terms} = $cv->payment->description if $cv->payment; + $details{pricegroup} = $cv->pricegroup->pricegroup if $cv->pricegroup; + + foreach my $entry (@{ $cv->shipto }) { + push @{ $details{SHIPTO} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} }; + } + foreach my $entry (@{ $cv->contacts }) { + push @{ $details{CONTACTS} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} }; + } + + $_[0]->render('common/show_vc_details', { layout => 0 }, + is_customer => $is_customer, + %details); + +} + # called if a unit in an existing item row is changed sub action_unit_changed { my ($self) = @_; @@ -1761,8 +1795,6 @@ java script functions =item * currency -=item * customer/vendor details ('D'-button) - =item * credit limit =item * more workflows (save as new, quotation, purchase order) diff --git a/js/kivi.Order.js b/js/kivi.Order.js index ef30e1303..441a3dcce 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -591,6 +591,38 @@ namespace('kivi.Order', function(ns) { return true; }; + ns.show_vc_details_dialog = function() { + if (!ns.check_cv()) return; + var vc; + var vc_id; + var title; + if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation' ) { + vc = 'customer'; + vc_id = $('#order_customer_id').val(); + title = kivi.t8('Customer details'); + } else { + vc = 'vendor'; + vc_id = $('#order_vendor_id').val(); + title = kivi.t8('Vendor details'); + } + + kivi.popup_dialog({ + url: 'controller.pl', + data: { action: 'Order/show_customer_vendor_details_dialog', + type : $('#type').val(), + vc : vc, + vc_id : vc_id + }, + id: 'jq_customer_vendor_details_dialog', + dialog: { + title: title, + width: 800, + height: 650 + } + }); + return true; + }; + }); $(function(){ diff --git a/js/locale/de.js b/js/locale/de.js index a72965920..7447111c9 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -29,6 +29,7 @@ namespace("kivi").setupLocale({ "Create new quotation/order":"Neues Angebot/neuen Auftrag anlegen", "Create new qutoation/order":"Neues Angebot/neuen Auftrag anlegen", "Create new version":"Neue Version anlegen", +"Customer details":"Kundendetails", "Customer missing!":"Kundenname fehlt!", "Database Connection Test":"Test der Datenbankverbindung", "Delete":"Löschen", @@ -130,6 +131,7 @@ namespace("kivi").setupLocale({ "Transaction description":"Vorgangsbezeichnung", "Update":"Erneuern", "Update quotation/order":"Auftrag/Angebot aktualisieren", +"Vendor details":"Lieferantendetails", "Vendor missing!":"Lieferant fehlt!", "Version actions":"Aktionen für Versionen", "Wrong date format (#1)":"Falsches Datumsformat (#1)", diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index c74019a63..c968a9473 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -14,7 +14,10 @@ [% SELF.cv | $T8 %] [% SET cv_id = SELF.cv _ '_id' %] - [% P.customer_vendor.picker("order.${SELF.cv}" _ '_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %] + + [% P.customer_vendor.picker("order.${SELF.cv}" _ '_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %] + [% P.button_tag("kivi.Order.show_vc_details_dialog()", LxERP.t8("Details (one letter abbreviation)")) %] + -- 2.20.1