From: Moritz Bunkus Date: Mon, 23 Jan 2017 10:30:12 +0000 (+0100) Subject: Angebote/Aufträge: Kunden-/Lieferantenwahl via Picker X-Git-Tag: release-3.5.4~1667^2~17 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=baf226d0b65e64f9475dea46b35d88d52fed1cc6;p=kivitendo-erp.git Angebote/Aufträge: Kunden-/Lieferantenwahl via Picker --- diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index e1f7f3a22..ebbc997b9 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -241,9 +241,6 @@ sub order_links { check_oe_access(); - # get customer/vendor - $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP"); - # retrieve order/quotation my $editing = $form->{id}; @@ -256,8 +253,6 @@ sub order_links { if $form->{rowcount} && $form->{type} eq 'sales_order' && defined $form->{customer} && $form->{customer} eq ''; - $form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"}; - $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes shipto_id delivery_term_id currency)); # get customer / vendor @@ -271,18 +266,6 @@ sub order_links { $form->{forex} = $form->{exchangerate}; $form->{employee} = "$form->{employee}--$form->{employee_id}"; - # build vendor/customer drop down comatibility... don't ask - if (@{ $form->{"all_$form->{vc}"} || [] }) { - $form->{"select$form->{vc}"} = 1; - $form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - } - - $form->{"old$form->{vc}"} = $form->{$form->{vc}}; - - if ($form->{"old$form->{vc}"} !~ m/--\d+$/ && $form->{"$form->{vc}_id"}) { - $form->{"old$form->{vc}"} .= qq|--$form->{"$form->{vc}_id"}| - } - $main::lxdebug->leave_sub(); } @@ -354,8 +337,6 @@ sub form_header { $form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"), "currencies" => "ALL_CURRENCIES", - $vc => { key => "ALL_" . uc($vc), - limit => $myconfig{vclimit} + 1 }, "price_factors" => "ALL_PRICE_FACTORS"); $form->{ALL_PAYMENTS} = SL::DB::Manager::PaymentTerm->get_all( where => [ or => [ obsolete => 0, id => $form->{payment_id} || undef ] ]); @@ -399,14 +380,6 @@ sub form_header { ]); $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} }; - # vendor/customer - $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" }; - $TMPL_VAR{vclimit} = $myconfig{vclimit}; - $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('$form->{vc}', '', @{[ $form->{vc} eq 'vendor' ? 1 : 0 ]}, 0)"; - push @custom_hiddens, "$form->{vc}_id"; - push @custom_hiddens, "old$form->{vc}"; - push @custom_hiddens, "select$form->{vc}"; - # currencies and exchangerate my @values = map { $_ } @{ $form->{ALL_CURRENCIES} }; my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} }; @@ -604,7 +577,13 @@ sub update { $form->{update} = 1; - &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'; + } if (!$form->{forex}) { # read exchangerate from input field (not hidden) map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate) unless $recursive_call; @@ -774,9 +753,7 @@ sub search { } # setup vendor / customer data - $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP"); $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, - "$form->{vc}s" => "ALL_VC", "taxzones" => "ALL_TAXZONES", "business_types" => "ALL_BUSINESS_TYPES",); $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]); @@ -1182,7 +1159,7 @@ sub save_and_close { $form->{$idx} =~ 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!'); @@ -1192,17 +1169,14 @@ sub save_and_close { &validate_items; - my $payment_id; - if($form->{payment_id}) { - $payment_id = $form->{payment_id}; - } + 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}; - # if the name changed get new values - if (&check_name($form->{vc})) { - if($form->{payment_id} eq "") { - $form->{payment_id} = $payment_id; - } - &update; + IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; + IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + + update(); $::dispatcher->end_request; } @@ -1289,7 +1263,7 @@ sub save { $form->{$idx} =~ 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!'); @@ -1300,17 +1274,14 @@ sub save { remove_emptied_rows(); &validate_items; - my $payment_id; - if($form->{payment_id}) { - $payment_id = $form->{payment_id}; - } + 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}; - # if the name changed get new values - if (&check_name($form->{vc})) { - if($form->{payment_id} eq "") { - $form->{payment_id} = $payment_id; - } - &update; + IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; + IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + + update(); $::dispatcher->end_request; } @@ -1453,15 +1424,14 @@ sub invoice { $form->{quodate} = $form->{transdate}; } - my $payment_id; - if ($form->{payment_id}) { - $payment_id = $form->{payment_id}; - } + 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'; - # if the name changed get new values - if (&check_name($form->{vc})) { - $form->{payment_id} = $payment_id if $form->{payment_id} eq ""; - &update; + update(); $::dispatcher->end_request; } diff --git a/templates/webpages/oe/form_header.html b/templates/webpages/oe/form_header.html index 497be459f..83d1b6527 100644 --- a/templates/webpages/oe/form_header.html +++ b/templates/webpages/oe/form_header.html @@ -1,14 +1,12 @@ [%- USE T8 %] [%- USE HTML %] [%- USE LxERP %] -[%- USE L %] +[%- USE L %][%- USE P -%]
- - [%- IF is_sales_ord %] [% L.javascript_tag("js/edit_periodic_invoices_config") %] @@ -54,18 +52,10 @@ [% IF vc == 'customer' %][% 'Customer' | $T8 %][% ELSE %][% 'Vendor' | $T8 %][% END %] - [%- INCLUDE 'generic/multibox.html' - name = vc, - style = 'width: 250px', - class = 'initial_focus', - DATA = vc == 'customer' ? ALL_CUSTOMERS : ALL_VENDORS, - id_sub = 'vc_keys', - label_key = 'name', - select = vc_select, - limit = vclimit, - allow_textbox = 1, - onChange = "document.getElementById('update_button').click();" -%] - + [%- SET vc_id = vc _ "_id" %] + [% P.customer_vendor_picker(vc_id, $vc_id, type=vc, style="width: 250px", class="initial_focus") %] + [% P.button_tag("show_vc_details('" _ HTML.escape(vc) _ "')", LxERP.t8("Details (one letter abbreviation)")) %] + [% P.hidden_tag("previous_" _ vc_id, $vc_id) %] [%- IF ALL_CONTACTS.size %]