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};
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
$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();
}
$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 ] ]);
]);
$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} };
$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;
}
# 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 ]);
$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!');
&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;
}
$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!');
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;
}
$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;
}
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
-[%- USE L %]
+[%- USE L %][%- USE P -%]
<form method="post" name="oe" action="[% script %]">
<script type="text/javascript" src="js/delivery_customer_selection.js"></script>
- <script type="text/javascript" src="js/vendor_selection.js"></script>
<script type="text/javascript" src="js/calculate_qty.js"></script>
- <script type="text/javascript" src="js/customer_or_vendor_selection.js"></script>
<script type="text/javascript" src="js/follow_up.js"></script>
[%- IF is_sales_ord %]
[% L.javascript_tag("js/edit_periodic_invoices_config") %]
<tr>
<th align="right">[% IF vc == 'customer' %][% 'Customer' | $T8 %][% ELSE %][% 'Vendor' | $T8 %][% END %]</th>
<td>
- [%- 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();" -%]
- <input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('[% HTML.escape(vc) %]')">
+ [%- 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) %]
</td>
</tr>
[%- IF ALL_CONTACTS.size %]