IR->get_vendor(\%myconfig, \%$form);
$form->{$_} = $saved{$_} for keys %saved;
- $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
$form->{rowcount} = 1;
$form->{AP_chart_id} = $form->{acc_trans} && $form->{acc_trans}->{AP} ? $form->{acc_trans}->{AP}->[0]->{chart_id} : $form->{AP_links}->{AP}->[0]->{chart_id};
# currencies
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- # vendors
- if (@{ $form->{all_vendor} || [] }) {
- $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
- map { my $quoted = H($_->{name} . "--" . $_->{id}); $form->{selectvendor} .= "<option value=\"${quoted}\">${quoted}\n" }
- (@{ $form->{all_vendor} });
- }
-
- $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
+ $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
$form->{employee} = "$form->{employee}--$form->{employee_id}";
$::form->{invoice_obj} = SL::DB::PurchaseInvoice->new(id => $::form->{id})->load if $::form->{id};
- $form->{initial_focus} = !($form->{amount_1} * 1) ? 'vendor' : 'row_' . $form->{rowcount};
+ $form->{initial_focus} = !($form->{amount_1} * 1) ? 'vendor_id' : 'row_' . $form->{rowcount};
$form->{title_} = $form->{title};
$form->{title} = $form->{title} eq 'Add' ? $locale->text('Add Accounts Payables Transaction') : $locale->text('Edit Accounts Payables Transaction');
# type=submit $locale->text('Add Accounts Payables Transaction')
# type=submit $locale->text('Edit Accounts Payables Transaction')
- # set option selected
- foreach my $item (qw(vendor)) {
- my $to_replace = H($form->{$item});
- $form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~ s/>\Q${to_replace}\E/ selected>${to_replace}/;
- }
my $readonly = $form->{id} ? "readonly" : "";
$form->{radier} = ($::instance_conf->get_ap_changeable == 2)
$charts{$item->{accno}} = $item;
}
- my $follow_up_vc = $form->{vendor};
- $follow_up_vc =~ s/--.*?//;
+ my $follow_up_vc = $form->{vendor_id} ? SL::DB::Vendor->load_cached($form->{vendor_id})->name : '';
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
- $::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js");
+ $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js");
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
my $first_taxchart;
$form->{invdate} = $form->{transdate};
- my $vendor_changed = &check_name("vendor");
+ if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
+ IR->get_vendor(\%::myconfig, $form);
+ }
$form->{rowcount} = $count + 1;
# check if there is a vendor, invoice, due date and invnumber
$form->isblank("transdate", $locale->text("Invoice Date missing!"));
$form->isblank("duedate", $locale->text("Due Date missing!"));
- $form->isblank("vendor", $locale->text('Vendor missing!'));
+ $form->isblank("vendor_id", $locale->text('Vendor missing!'));
$form->isblank("invnumber", $locale->text('Invoice Number missing!'));
if ($myconfig{mandatory_departments} && !$form->{department_id}) {
}
# if old vendor ne vendor redo form
- my ($vendor) = split /--/, $form->{vendor};
- if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
+ if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) {
&update;
$::dispatcher->end_request;
}
<form method="post" action="[% script | html %]">
-<input type="hidden" name="selectvendor" value="[% selectvendor | html %]">
-
-<input type="hidden" name="oldvendor" value="[% oldvendor | html %]">
-<input type="hidden" name="vendor_id" value="[% vendor_id | html %]">
<input type="hidden" name="terms" value="[% terms | html %]">
<input type="hidden" name="creditlimit" value="[% creditlimit | html %]">
<tr>
<th align="right" nowrap>[% 'Vendor' | $T8 %]</th>
<td colspan="3">
- [% IF ( selectvendor ) %]
- <select name="vendor" onchange="document.getElementById('update_button').click();"[% IF initial_focus == 'vendor' %] class="initial_focus"[% END %]>[% selectvendor %]</select>
- [% ELSE %]
- <input name=vendor value="[% vendor | html %]" size="35"[% IF initial_focus == 'vendor' %] class="initial_focus"[% END %]>
- [% END %]
- <input type="button" value="D" onclick="show_vc_details('vendor')">
+ [% P.customer_vendor_picker("vendor_id", vendor_id, type="vendor", style="width: 300px") %]
+ [% L.button_tag("show_vc_details('vendor')", LxERP.t8('Details (one letter abbreviation)')) %]
+ [% L.hidden_tag("previous_vendor_id", vendor_id) %]
</td>
</tr>