241 |
241 |
|
242 |
242 |
check_oe_access();
|
243 |
243 |
|
244 |
|
# get customer/vendor
|
245 |
|
$form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
|
246 |
|
|
247 |
244 |
# retrieve order/quotation
|
248 |
245 |
my $editing = $form->{id};
|
249 |
246 |
|
... | ... | |
256 |
253 |
if $form->{rowcount} && $form->{type} eq 'sales_order'
|
257 |
254 |
&& defined $form->{customer} && $form->{customer} eq '';
|
258 |
255 |
|
259 |
|
$form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"};
|
260 |
|
|
261 |
256 |
$form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes shipto_id delivery_term_id currency));
|
262 |
257 |
|
263 |
258 |
# get customer / vendor
|
... | ... | |
271 |
266 |
$form->{forex} = $form->{exchangerate};
|
272 |
267 |
$form->{employee} = "$form->{employee}--$form->{employee_id}";
|
273 |
268 |
|
274 |
|
# build vendor/customer drop down comatibility... don't ask
|
275 |
|
if (@{ $form->{"all_$form->{vc}"} || [] }) {
|
276 |
|
$form->{"select$form->{vc}"} = 1;
|
277 |
|
$form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
|
278 |
|
}
|
279 |
|
|
280 |
|
$form->{"old$form->{vc}"} = $form->{$form->{vc}};
|
281 |
|
|
282 |
|
if ($form->{"old$form->{vc}"} !~ m/--\d+$/ && $form->{"$form->{vc}_id"}) {
|
283 |
|
$form->{"old$form->{vc}"} .= qq|--$form->{"$form->{vc}_id"}|
|
284 |
|
}
|
285 |
|
|
286 |
269 |
$main::lxdebug->leave_sub();
|
287 |
270 |
}
|
288 |
271 |
|
... | ... | |
354 |
337 |
|
355 |
338 |
$form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
|
356 |
339 |
"currencies" => "ALL_CURRENCIES",
|
357 |
|
$vc => { key => "ALL_" . uc($vc),
|
358 |
|
limit => $myconfig{vclimit} + 1 },
|
359 |
340 |
"price_factors" => "ALL_PRICE_FACTORS");
|
360 |
341 |
$form->{ALL_PAYMENTS} = SL::DB::Manager::PaymentTerm->get_all( where => [ or => [ obsolete => 0, id => $form->{payment_id} || undef ] ]);
|
361 |
342 |
|
... | ... | |
399 |
380 |
]);
|
400 |
381 |
$TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
|
401 |
382 |
|
402 |
|
# vendor/customer
|
403 |
|
$TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
|
404 |
|
$TMPL_VAR{vclimit} = $myconfig{vclimit};
|
405 |
|
$TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('$form->{vc}', '', @{[ $form->{vc} eq 'vendor' ? 1 : 0 ]}, 0)";
|
406 |
|
push @custom_hiddens, "$form->{vc}_id";
|
407 |
|
push @custom_hiddens, "old$form->{vc}";
|
408 |
|
push @custom_hiddens, "select$form->{vc}";
|
409 |
|
|
410 |
383 |
# currencies and exchangerate
|
411 |
384 |
my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
|
412 |
385 |
my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
|
... | ... | |
604 |
577 |
|
605 |
578 |
$form->{update} = 1;
|
606 |
579 |
|
607 |
|
&check_name($form->{vc});
|
|
580 |
my $vc = $form->{vc};
|
|
581 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
|
|
582 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
|
|
583 |
|
|
584 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
|
|
585 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor';
|
|
586 |
}
|
608 |
587 |
|
609 |
588 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden)
|
610 |
589 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate) unless $recursive_call;
|
... | ... | |
774 |
753 |
}
|
775 |
754 |
|
776 |
755 |
# setup vendor / customer data
|
777 |
|
$form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
|
778 |
756 |
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
|
779 |
|
"$form->{vc}s" => "ALL_VC",
|
780 |
757 |
"taxzones" => "ALL_TAXZONES",
|
781 |
758 |
"business_types" => "ALL_BUSINESS_TYPES",);
|
782 |
759 |
$form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
|
... | ... | |
1182 |
1159 |
$form->{$idx} =~ s/\s*$//g;
|
1183 |
1160 |
|
1184 |
1161 |
my $msg = ucfirst $form->{vc};
|
1185 |
|
$form->isblank($form->{vc}, $locale->text($msg . " missing!"));
|
|
1162 |
$form->isblank($form->{vc} . '_id', $locale->text($msg . " missing!"));
|
1186 |
1163 |
|
1187 |
1164 |
# $locale->text('Customer missing!');
|
1188 |
1165 |
# $locale->text('Vendor missing!');
|
... | ... | |
1192 |
1169 |
|
1193 |
1170 |
&validate_items;
|
1194 |
1171 |
|
1195 |
|
my $payment_id;
|
1196 |
|
if($form->{payment_id}) {
|
1197 |
|
$payment_id = $form->{payment_id};
|
1198 |
|
}
|
|
1172 |
my $vc = $form->{vc};
|
|
1173 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
|
|
1174 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
|
1199 |
1175 |
|
1200 |
|
# if the name changed get new values
|
1201 |
|
if (&check_name($form->{vc})) {
|
1202 |
|
if($form->{payment_id} eq "") {
|
1203 |
|
$form->{payment_id} = $payment_id;
|
1204 |
|
}
|
1205 |
|
&update;
|
|
1176 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
|
|
1177 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor';
|
|
1178 |
|
|
1179 |
update();
|
1206 |
1180 |
$::dispatcher->end_request;
|
1207 |
1181 |
}
|
1208 |
1182 |
|
... | ... | |
1289 |
1263 |
$form->{$idx} =~ s/\s*$//g;
|
1290 |
1264 |
|
1291 |
1265 |
my $msg = ucfirst $form->{vc};
|
1292 |
|
$form->isblank($form->{vc}, $locale->text($msg . " missing!"));
|
|
1266 |
$form->isblank($form->{vc} . '_id', $locale->text($msg . " missing!"));
|
1293 |
1267 |
|
1294 |
1268 |
# $locale->text('Customer missing!');
|
1295 |
1269 |
# $locale->text('Vendor missing!');
|
... | ... | |
1300 |
1274 |
remove_emptied_rows();
|
1301 |
1275 |
&validate_items;
|
1302 |
1276 |
|
1303 |
|
my $payment_id;
|
1304 |
|
if($form->{payment_id}) {
|
1305 |
|
$payment_id = $form->{payment_id};
|
1306 |
|
}
|
|
1277 |
my $vc = $form->{vc};
|
|
1278 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
|
|
1279 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
|
1307 |
1280 |
|
1308 |
|
# if the name changed get new values
|
1309 |
|
if (&check_name($form->{vc})) {
|
1310 |
|
if($form->{payment_id} eq "") {
|
1311 |
|
$form->{payment_id} = $payment_id;
|
1312 |
|
}
|
1313 |
|
&update;
|
|
1281 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
|
|
1282 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor';
|
|
1283 |
|
|
1284 |
update();
|
1314 |
1285 |
$::dispatcher->end_request;
|
1315 |
1286 |
}
|
1316 |
1287 |
|
... | ... | |
1453 |
1424 |
$form->{quodate} = $form->{transdate};
|
1454 |
1425 |
}
|
1455 |
1426 |
|
1456 |
|
my $payment_id;
|
1457 |
|
if ($form->{payment_id}) {
|
1458 |
|
$payment_id = $form->{payment_id};
|
1459 |
|
}
|
|
1427 |
my $vc = $form->{vc};
|
|
1428 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
|
|
1429 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
|
|
1430 |
|
|
1431 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
|
|
1432 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor';
|
1460 |
1433 |
|
1461 |
|
# if the name changed get new values
|
1462 |
|
if (&check_name($form->{vc})) {
|
1463 |
|
$form->{payment_id} = $payment_id if $form->{payment_id} eq "";
|
1464 |
|
&update;
|
|
1434 |
update();
|
1465 |
1435 |
$::dispatcher->end_request;
|
1466 |
1436 |
}
|
1467 |
1437 |
|
Angebote/Aufträge: Kunden-/Lieferantenwahl via Picker