IS->get_customer(\%myconfig, \%$form);
$form->{$_} = $saved{$_} for keys %saved;
- $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
$form->{rowcount} = 1;
$form->{AR_chart_id} = $form->{acc_trans} && $form->{acc_trans}->{AR} ? $form->{acc_trans}->{AR}->[0]->{chart_id} : $form->{AR_links}->{AR}->[0]->{chart_id};
# currencies
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- # customers
- if (@{ $form->{all_customer} || [] }) {
- $form->{customer} = "$form->{customer}--$form->{customer_id}";
- map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
- (@{ $form->{all_customer} });
- }
-
$form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
# build the popup menus
$form->{invoice_obj} = _retrieve_invoice_object();
my ($title, $readonly, $exchangerate, $rows);
- my ($notes, $customer, $amount, $project);
+ my ($notes, $amount, $project);
- $form->{initial_focus} = !($form->{amount_1} * 1) ? 'customer' : 'row_' . $form->{rowcount};
+ $form->{initial_focus} = !($form->{amount_1} * 1) ? 'customer_id' : 'row_' . $form->{rowcount};
$title = $form->{title};
# $locale->text('Add Accounts Receivables Transaction')
: ($::instance_conf->get_ar_changeable == 1);
$readonly = ($form->{radier}) ? "" : $readonly;
- # set option selected
- foreach my $item (qw(customer)) {
- $form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
- }
-
$form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy');
$form->{exchangerate} = $form->{forex} if $form->{forex};
}
}
- my $follow_up_vc = $form->{customer};
- $follow_up_vc =~ s/--.*?//;
+ my $follow_up_vc = $form->{customer_id} ? SL::DB::Customer->load_cached($form->{customer_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};
- &check_name("customer");
+ if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) {
+ IS->get_customer(\%myconfig, $form);
+ }
$form->{invtotal} =
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
# check if there is an invoice number, invoice and due date
$form->isblank("transdate", $locale->text('Invoice Date missing!'));
$form->isblank("duedate", $locale->text('Due Date missing!'));
- $form->isblank("customer", $locale->text('Customer missing!'));
+ $form->isblank("customer_id", $locale->text('Customer missing!'));
if ($myconfig{mandatory_departments} && !$form->{department_id}) {
$form->{saved_message} = $::locale->text('You have to specify a department.');
}
# if oldcustomer ne customer redo form
- my ($customer) = split /--/, $form->{customer};
- if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
+ if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) {
update();
$::dispatcher->end_request;
}
<tr>
<th align="right" nowrap>[% 'Customer' | $T8 %]</th>
<td colspan=3>
-[%- IF selectcustomer %]
- <select id='customer' name="customer" onchange="document.getElementById('update_button').click();"[% IF initial_focus == 'customer'%] class="initial_focus"[% END %]>[% selectcustomer %]</select>
-[%- ELSE %]
- <input id='customer' name=customer value="[% customer | html %]" size=35[% IF initial_focus == 'customer'%] class="initial_focus"[% END %]>
-[%- END %]
- <input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('customer')"></td>
- [% L.hidden_tag('selectcustomer', selectcustomer) %]
- [% L.hidden_tag('oldcustomer', oldcustomer) %]
- [% L.hidden_tag('customer_id', customer_id) %]
- [% L.hidden_tag('terms', terms) %]
+ [% P.customer_vendor_picker("customer_id", customer_id, type="customer", style="width: 300px", class=(initial_focus == 'customer_id' ? "initial_focus" : "")) %]
+ [% L.button_tag("show_vc_details('customer')", LxERP.t8('Details (one letter abbreviation)')) %]
+ [% L.hidden_tag("previous_customer_id", customer_id) %]
+ [% L.hidden_tag('terms', terms) %]
+ </td>
</tr>
[%- IF max_dunning_level || invoice_obj.dunning_config_id %]
<tr>