From fdbb6888ea00ca5f6450015ea70bb3d5f89edfc9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 23 Jan 2017 13:25:55 +0100 Subject: [PATCH] Lieferschein: Kunden-/Lieferantenpicker nutzen --- bin/mozilla/do.pl | 51 +++++++++++--------------- templates/webpages/do/form_header.html | 34 +++++------------ 2 files changed, 31 insertions(+), 54 deletions(-) diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 209d37558..0eaf86b1f 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -172,9 +172,6 @@ sub order_links { my $form = $main::form; my %myconfig = %main::myconfig; - # get customer/vendor - $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP"); - # retrieve order/quotation my $editing = $form->{id}; @@ -197,17 +194,6 @@ sub order_links { $form->restore_vars(qw(taxincluded)) if $form->{id}; $form->restore_vars(qw(salesman_id)) if $editing; - if ($form->{"all_$form->{vc}"}) { - unless ($form->{"$form->{vc}_id"}) { - $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id}; - } - } - - ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} }; - $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - - $form->{employee} = "$form->{employee}--$form->{employee_id}"; - $main::lxdebug->leave_sub(); } @@ -259,12 +245,14 @@ sub form_header { my $form = $main::form; my %myconfig = %main::myconfig; + my $class = "SL::DB::" . ($form->{vc} eq 'customer' ? 'Customer' : 'Vendor'); + $form->{VC_OBJ} = $class->load_cached($form->{ $form->{vc} . '_id' }); + $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; my $vc = $form->{vc} eq "customer" ? "customers" : "vendors"; - $form->get_lists($vc => "ALL_VC", - "price_factors" => "ALL_PRICE_FACTORS", + $form->get_lists("price_factors" => "ALL_PRICE_FACTORS", "business_types" => "ALL_BUSINESS_TYPES", ); $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all; @@ -302,13 +290,6 @@ sub form_header { ] ]); - map { $_->{value} = "$_->{name}--$_->{id}" } @{ $form->{ALL_VC} }; - - $form->{SHOW_VC_DROP_DOWN} = $myconfig{vclimit} > scalar @{ $form->{ALL_VC} }; - - $form->{oldvcname} = $form->{"old$form->{vc}"}; - $form->{oldvcname} =~ s/--.*//; - my $dispatch_to_popup = ''; if ($form->{resubmit} && ($form->{format} eq "html")) { $dispatch_to_popup = "window.open('about:blank','Beleg'); document.do.target = 'Beleg';"; @@ -320,10 +301,7 @@ sub form_header { $::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});"); - my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' }; - $follow_up_vc =~ s/--\d*\s*$//; - - $form->{follow_up_trans_info} = $form->{donumber} .'('. $follow_up_vc .')'; + $form->{follow_up_trans_info} = $form->{donumber} .'('. $form->{VC_OBJ}->name .')'; $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part)); @@ -383,7 +361,14 @@ sub update_delivery_order { my $payment_id; $payment_id = $form->{payment_id} if $form->{payment_id}; - check_name($form->{vc}); + my $vc = $form->{vc}; + if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) { + $::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id}; + + IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; + IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + } + $form->{discount} = $form->{"$form->{vc}_discount"} if defined $form->{"$form->{vc}_discount"}; # Problem: Wenn man ohne Erneuern einen Kunden/Lieferanten # wechselt, wird der entsprechende Kunden/ Lieferantenrabatt @@ -725,7 +710,7 @@ sub save { $form->{donumber} =~ s/\s*$//g; my $msg = ucfirst $form->{vc}; - $form->isblank($form->{vc}, $locale->text($msg . " missing!")); + $form->isblank($form->{vc} . "_id", $locale->text($msg . " missing!")); # $locale->text('Customer missing!'); # $locale->text('Vendor missing!'); @@ -734,7 +719,13 @@ sub save { validate_items(); # if the name changed get new values - if (check_name($form->{vc})) { + my $vc = $form->{vc}; + if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) { + $::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id}; + + IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; + IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + update(); $::dispatcher->end_request; } diff --git a/templates/webpages/do/form_header.html b/templates/webpages/do/form_header.html index 277181e4f..326db490a 100644 --- a/templates/webpages/do/form_header.html +++ b/templates/webpages/do/form_header.html @@ -1,15 +1,13 @@ [%- USE T8 %] [%- USE HTML %] [%- USE LxERP %] -[%- USE L %] +[%- USE L %][%- USE P -%]

[% title %]

- - @@ -22,18 +20,12 @@ [%- IF vc == 'customer' %] - [%- SET vc = 'customer' %] - [%- SET the_vc_id = customer_id %] - [%- SET the_vc = customer %] - [%- SET the_oldvc = oldcustomer %] [%- SET is_customer = '1' %] [%- ELSE %] [%- SET vc = 'vendor' %] - [%- SET the_vc_id = vendor_id %] - [%- SET the_vc = vendor %] - [%- SET the_oldvc = oldvendor %] [%- SET is_customer = '0' %] [%- END %] + [%- SET vc_id = vc _ "_id" %] [%- IF delivered %] [%- SET DISABLED = ' disabled' %] [%- END %] @@ -120,22 +112,16 @@ - - - [%- IF ALL_CONTACTS.size %] -- 2.20.1
[% IF is_customer %][% 'Customer' | $T8 %][% ELSE %][% 'Vendor' | $T8 %][% END %] - [%- UNLESS !delivered && SHOW_VC_DROP_DOWN %] - - [%- ELSE %] - - - [%- END %] - + [% IF RO %] + [% P.hidden_tag(vc_id, $vc_id) %] + [% HTML.escape(VC_OBJ.name) %] + [% ELSE %] + [% P.customer_vendor_picker(vc_id, $vc_id, type=vc, class="fixed_width") %] + [% END %] + [% P.hidden_tag("previous_" _ vc_id, $vc_id) %] + [% P.button_tag("show_vc_details('" _ HTML.escape(vc) _ "')", LxERP.t8("Details (one letter abbreviation)")) %]