my $form = $main::form;
my %myconfig = %main::myconfig;
- # get customer/vendor
- $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
-
# retrieve order/quotation
my $editing = $form->{id};
$form->restore_vars(qw(taxincluded)) if $form->{id};
$form->restore_vars(qw(salesman_id)) if $editing;
- if ($form->{"all_$form->{vc}"}) {
- unless ($form->{"$form->{vc}_id"}) {
- $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
- }
- }
-
- ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
- $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
-
- $form->{employee} = "$form->{employee}--$form->{employee_id}";
-
$main::lxdebug->leave_sub();
}
my $form = $main::form;
my %myconfig = %main::myconfig;
+ my $class = "SL::DB::" . ($form->{vc} eq 'customer' ? 'Customer' : 'Vendor');
+ $form->{VC_OBJ} = $class->load_cached($form->{ $form->{vc} . '_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};
my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
- $form->get_lists($vc => "ALL_VC",
- "price_factors" => "ALL_PRICE_FACTORS",
+ $form->get_lists("price_factors" => "ALL_PRICE_FACTORS",
"business_types" => "ALL_BUSINESS_TYPES",
);
$form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
]
]);
- map { $_->{value} = "$_->{name}--$_->{id}" } @{ $form->{ALL_VC} };
-
- $form->{SHOW_VC_DROP_DOWN} = $myconfig{vclimit} > scalar @{ $form->{ALL_VC} };
-
- $form->{oldvcname} = $form->{"old$form->{vc}"};
- $form->{oldvcname} =~ s/--.*//;
-
my $dispatch_to_popup = '';
if ($form->{resubmit} && ($form->{format} eq "html")) {
$dispatch_to_popup = "window.open('about:blank','Beleg'); document.do.target = 'Beleg';";
$::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});");
- my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' };
- $follow_up_vc =~ s/--\d*\s*$//;
-
- $form->{follow_up_trans_info} = $form->{donumber} .'('. $follow_up_vc .')';
+ $form->{follow_up_trans_info} = $form->{donumber} .'('. $form->{VC_OBJ}->name .')';
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part));
my $payment_id;
$payment_id = $form->{payment_id} if $form->{payment_id};
- 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';
+ }
+
$form->{discount} = $form->{"$form->{vc}_discount"} if defined $form->{"$form->{vc}_discount"};
# Problem: Wenn man ohne Erneuern einen Kunden/Lieferanten
# wechselt, wird der entsprechende Kunden/ Lieferantenrabatt
$form->{donumber} =~ 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();
# if the name changed get new values
- if (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';
+
update();
$::dispatcher->end_request;
}
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
-[%- USE L %]
+[%- USE L %][%- USE P -%]
<h1>[% title %]</h1>
<script type="text/javascript" src="js/show_form_details.js"></script>
<script type="text/javascript" src="js/show_history.js"></script>
<script type="text/javascript" src="js/show_vc_details.js"></script>
- <script type="text/javascript" src="js/common.js"></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/stock_in_out.js"></script>
<script type="text/javascript" src="js/follow_up.js"></script>
</style>
[%- IF vc == 'customer' %]
- [%- SET vc = 'customer' %]
- [%- SET the_vc_id = customer_id %]
- [%- SET the_vc = customer %]
- [%- SET the_oldvc = oldcustomer %]
[%- SET is_customer = '1' %]
[%- ELSE %]
[%- SET vc = 'vendor' %]
- [%- SET the_vc_id = vendor_id %]
- [%- SET the_vc = vendor %]
- [%- SET the_oldvc = oldvendor %]
[%- SET is_customer = '0' %]
[%- END %]
+ [%- SET vc_id = vc _ "_id" %]
[%- IF delivered %]
[%- SET DISABLED = ' disabled' %]
[%- END %]
<td>
<table width="100%">
<tr>
- <input type="hidden" name="[% vc %]_id" value="[% HTML.escape(the_vc_id) %]">
- <input type="hidden" name="old[% vc %]" value="[% HTML.escape(the_oldvc) %]">
- <input type="hidden" name="tradediscount" value="[% HTML.escape(tradediscount) %]">
<th align="right">[% IF is_customer %][% 'Customer' | $T8 %][% ELSE %][% 'Vendor' | $T8 %][% END %]</th>
<td>
- [%- UNLESS !delivered && SHOW_VC_DROP_DOWN %]
- <input type="text" value="[% HTML.escape(oldvcname) %]" name="[% HTML.escape(vc) %]"[% RO %]>
- [%- ELSE %]
- <select name="[% vc %]" class="fixed_width" onchange="document.do.update_button.click();"[% RO %]>
- [%- FOREACH row = ALL_VC %]
- <option value="[% HTML.escape(row.value) %]" [% IF the_oldvc == row.value %] selected[% END %]>[% HTML.escape(row.name) %]</option>
- [%- END %]
- </select>
- <input type="hidden" name="select[% vc %]" value="1">
- [%- END %]
- <input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('[% vc %]')">
+ [% IF RO %]
+ [% P.hidden_tag(vc_id, $vc_id) %]
+ [% HTML.escape(VC_OBJ.name) %]
+ [% ELSE %]
+ [% P.customer_vendor_picker(vc_id, $vc_id, type=vc, class="fixed_width") %]
+ [% END %]
+ [% P.hidden_tag("previous_" _ vc_id, $vc_id) %]
+ [% P.button_tag("show_vc_details('" _ HTML.escape(vc) _ "')", LxERP.t8("Details (one letter abbreviation)")) %]
</td>
[%- IF ALL_CONTACTS.size %]