use SL::DB::Default;
use SL::DB::Department;
use SL::DB::PurchaseInvoice;
+use SL::DB::Vendor;
use List::Util qw(max sum);
use List::UtilsBy qw(sort_by);
# create links
$form->create_links("AP", \%myconfig, "vendor");
- #quote all_vendor Bug 133
- foreach my $ref (@{ $form->{all_vendor} }) {
- $ref->{name} = $form->quote($ref->{name});
- }
-
- if ($form->{all_vendor}) {
- unless ($form->{vendor_id}) {
- $form->{vendor_id} = $form->{all_vendor}->[0]->{id};
- }
- }
-
$form->backup_vars(qw(payment_id language_id taxzone_id
currency delivery_term_id intnotes cp_id));
my @curr = $form->get_all_currencies();
map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
- $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
-
- # build vendor/customer drop down comatibility... don't ask
- if (@{ $form->{"all_vendor"} || [] }) {
- $form->{"selectvendor"} = 1;
- $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
- }
-
# forex
$form->{forex} = $form->{exchangerate};
my $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
my %TMPL_VAR = ();
my @custom_hiddens;
- $TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->new(id => $form->{id})->load if $form->{id};
+ $TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->load_cached($form->{id}) if $form->{id};
+ $TMPL_VAR{vendor_obj} = SL::DB::Vendor->load_cached($form->{vendor_id}) if $form->{vendor_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};
$form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
"currencies" => "ALL_CURRENCIES",
- "vendors" => "ALL_VENDORS",
"price_factors" => "ALL_PRICE_FACTORS");
$TMPL_VAR{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
]
]);
- # customer
- $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
- $TMPL_VAR{vclimit} = $myconfig{vclimit};
- $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('vendor', '', 1, 0)";
- push @custom_hiddens, "vendor_id";
- push @custom_hiddens, "oldvendor";
- push @custom_hiddens, "selectvendor";
-
# currencies and exchangerate
my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
$TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
$TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
- my $follow_up_vc = $form->{vendor};
- $follow_up_vc =~ s/--\d*\s*$//;
- $TMPL_VAR{vendor_name} = $follow_up_vc;
-
# set option selected
foreach my $item (qw(AP)) {
$form->{"select$item"} =~ s/ selected//;
$main::auth->assert('vendor_invoice_edit');
- &check_name('vendor');
+ if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
+ IR->get_vendor(\%myconfig, $form);
+ }
if (!$form->{forex}) { # read exchangerate from input field (not hidden)
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
- $form->isblank("vendor", $locale->text('Vendor missing!'));
+ $form->isblank("vendor_id", $locale->text('Vendor missing!'));
$form->isblank("invnumber", $locale->text('Invnumber missing!'));
$form->{invnumber} =~ s/^\s*//g;
$form->{invnumber} =~ s/\s*$//g;
# if the vendor changed get new values
- if (&check_name('vendor')) {
+ if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
&update;
$::dispatcher->end_request;
}
[%- USE L %][%- USE P -%]
<h1>[% title %]</h1>
-[%- SET follow_up_trans_info = invnumber _ ' (' _ vendor_name _ ')' %]
+[%- SET follow_up_trans_info = invnumber _ ' (' _ vendor_obj.name _ ')' %]
<script type="text/javascript" src="js/common.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/follow_up.js"></script>
-<script type="text/javascript" src="js/customer_or_vendor_selection.js"></script>
<form method="post" name="invoice" action="[% script %]">
<tr>
<th align="right">[% 'Vendor' | $T8 %]</th>
<td>
- [%- INCLUDE 'generic/multibox.html'
- id = 'vendor',
- name = 'vendor',
- style = 'width: 250px',
- class = 'initial_focus',
- DATA = 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('[% vc | html %]')">
+ [% P.customer_vendor_picker("vendor_id", vendor_id, type="vendor", style="width: 250px", class="initial_focus") %]
+ [% P.button_tag("show_vc_details('vendor')", LxERP.t8('Details (one letter abbreviation)')) %]
+ [% P.hidden_tag("previous_vendor_id", vendor_id) %]
</td>
- <input type="hidden" name="vendor_id" value="[% HTML.escape(vendor_id) %]">
- <input type="hidden" name="oldvendor" value="[% HTML.escape(oldvendor) %]">
- <input type="hidden" name="selectvendor" value="[% HTML.escape(selectvendor) %]">
</tr>
[%- IF ALL_CONTACTS.size %]
<tr>