Revision fdbb6888
Von Moritz Bunkus vor mehr als 7 Jahren hinzugefügt
bin/mozilla/do.pl | ||
---|---|---|
172 | 172 |
my $form = $main::form; |
173 | 173 |
my %myconfig = %main::myconfig; |
174 | 174 |
|
175 |
# get customer/vendor |
|
176 |
$form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP"); |
|
177 |
|
|
178 | 175 |
# retrieve order/quotation |
179 | 176 |
my $editing = $form->{id}; |
180 | 177 |
|
... | ... | |
197 | 194 |
$form->restore_vars(qw(taxincluded)) if $form->{id}; |
198 | 195 |
$form->restore_vars(qw(salesman_id)) if $editing; |
199 | 196 |
|
200 |
if ($form->{"all_$form->{vc}"}) { |
|
201 |
unless ($form->{"$form->{vc}_id"}) { |
|
202 |
$form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id}; |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} }; |
|
207 |
$form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; |
|
208 |
|
|
209 |
$form->{employee} = "$form->{employee}--$form->{employee_id}"; |
|
210 |
|
|
211 | 197 |
$main::lxdebug->leave_sub(); |
212 | 198 |
} |
213 | 199 |
|
... | ... | |
259 | 245 |
my $form = $main::form; |
260 | 246 |
my %myconfig = %main::myconfig; |
261 | 247 |
|
248 |
my $class = "SL::DB::" . ($form->{vc} eq 'customer' ? 'Customer' : 'Vendor'); |
|
249 |
$form->{VC_OBJ} = $class->load_cached($form->{ $form->{vc} . '_id' }); |
|
250 |
|
|
262 | 251 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; |
263 | 252 |
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; |
264 | 253 |
|
265 | 254 |
my $vc = $form->{vc} eq "customer" ? "customers" : "vendors"; |
266 |
$form->get_lists($vc => "ALL_VC", |
|
267 |
"price_factors" => "ALL_PRICE_FACTORS", |
|
255 |
$form->get_lists("price_factors" => "ALL_PRICE_FACTORS", |
|
268 | 256 |
"business_types" => "ALL_BUSINESS_TYPES", |
269 | 257 |
); |
270 | 258 |
$form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all; |
... | ... | |
302 | 290 |
] |
303 | 291 |
]); |
304 | 292 |
|
305 |
map { $_->{value} = "$_->{name}--$_->{id}" } @{ $form->{ALL_VC} }; |
|
306 |
|
|
307 |
$form->{SHOW_VC_DROP_DOWN} = $myconfig{vclimit} > scalar @{ $form->{ALL_VC} }; |
|
308 |
|
|
309 |
$form->{oldvcname} = $form->{"old$form->{vc}"}; |
|
310 |
$form->{oldvcname} =~ s/--.*//; |
|
311 |
|
|
312 | 293 |
my $dispatch_to_popup = ''; |
313 | 294 |
if ($form->{resubmit} && ($form->{format} eq "html")) { |
314 | 295 |
$dispatch_to_popup = "window.open('about:blank','Beleg'); document.do.target = 'Beleg';"; |
... | ... | |
320 | 301 |
$::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});"); |
321 | 302 |
|
322 | 303 |
|
323 |
my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' }; |
|
324 |
$follow_up_vc =~ s/--\d*\s*$//; |
|
325 |
|
|
326 |
$form->{follow_up_trans_info} = $form->{donumber} .'('. $follow_up_vc .')'; |
|
304 |
$form->{follow_up_trans_info} = $form->{donumber} .'('. $form->{VC_OBJ}->name .')'; |
|
327 | 305 |
|
328 | 306 |
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part)); |
329 | 307 |
|
... | ... | |
383 | 361 |
my $payment_id; |
384 | 362 |
$payment_id = $form->{payment_id} if $form->{payment_id}; |
385 | 363 |
|
386 |
check_name($form->{vc}); |
|
364 |
my $vc = $form->{vc}; |
|
365 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) { |
|
366 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id}; |
|
367 |
|
|
368 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; |
|
369 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; |
|
370 |
} |
|
371 |
|
|
387 | 372 |
$form->{discount} = $form->{"$form->{vc}_discount"} if defined $form->{"$form->{vc}_discount"}; |
388 | 373 |
# Problem: Wenn man ohne Erneuern einen Kunden/Lieferanten |
389 | 374 |
# wechselt, wird der entsprechende Kunden/ Lieferantenrabatt |
... | ... | |
725 | 710 |
$form->{donumber} =~ s/\s*$//g; |
726 | 711 |
|
727 | 712 |
my $msg = ucfirst $form->{vc}; |
728 |
$form->isblank($form->{vc}, $locale->text($msg . " missing!")); |
|
713 |
$form->isblank($form->{vc} . "_id", $locale->text($msg . " missing!"));
|
|
729 | 714 |
|
730 | 715 |
# $locale->text('Customer missing!'); |
731 | 716 |
# $locale->text('Vendor missing!'); |
... | ... | |
734 | 719 |
validate_items(); |
735 | 720 |
|
736 | 721 |
# if the name changed get new values |
737 |
if (check_name($form->{vc})) { |
|
722 |
my $vc = $form->{vc}; |
|
723 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) { |
|
724 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id}; |
|
725 |
|
|
726 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; |
|
727 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; |
|
728 |
|
|
738 | 729 |
update(); |
739 | 730 |
$::dispatcher->end_request; |
740 | 731 |
} |
Auch abrufbar als: Unified diff
Lieferschein: Kunden-/Lieferantenpicker nutzen