Revision be42a450
Von Bernd Bleßmann vor fast 10 Jahren hinzugefügt
SL/CVar.pm | ||
---|---|---|
652 | 652 |
return $value; |
653 | 653 |
} |
654 | 654 |
|
655 |
sub get_non_editable_ic_cvars { |
|
656 |
$main::lxdebug->enter_sub(2); |
|
657 |
my $self = shift; |
|
658 |
my %params = @_; |
|
659 |
|
|
660 |
Common::check_params(\%params, qw(form dbh row sub_module may_converted_from)); |
|
661 |
my $form = $params{form}; |
|
662 |
my $dbh = $params{dbh}; |
|
663 |
my $row = $params{row}; |
|
664 |
my $sub_module = $params{sub_module}; |
|
665 |
my $may_converted_from = $params{may_converted_from}; |
|
666 |
|
|
667 |
my $cvars; |
|
668 |
if (! $form->{"${sub_module}_id_${row}"}) { |
|
669 |
my $conv_from = 0; |
|
670 |
foreach (@{ $may_converted_from }) { |
|
671 |
if ($form->{"converted_from_${_}_id_$row"}) { |
|
672 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
673 |
module => 'IC', |
|
674 |
sub_module => $_, |
|
675 |
trans_id => $form->{"converted_from_${_}_id_$row"}, |
|
676 |
); |
|
677 |
$conv_from = 1; |
|
678 |
last; |
|
679 |
} |
|
680 |
} |
|
681 |
# get values for CVars from master data for new items |
|
682 |
if (!$conv_from) { |
|
683 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
684 |
module => 'IC', |
|
685 |
trans_id => $form->{"id_$row"}, |
|
686 |
); |
|
687 |
} |
|
688 |
} else { |
|
689 |
# get values for CVars from custom_variables for existing items |
|
690 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
691 |
module => 'IC', |
|
692 |
sub_module => $sub_module, |
|
693 |
trans_id => $form->{"${sub_module}_id_${row}"}, |
|
694 |
); |
|
695 |
} |
|
696 |
# map only non-editable CVars to form |
|
697 |
foreach (@{ $cvars }) { |
|
698 |
next if $_->{flag_editable}; |
|
699 |
$form->{"ic_cvar_$_->{name}_$row"} = $_->{value} |
|
700 |
} |
|
701 |
|
|
702 |
$main::lxdebug->leave_sub(2); |
|
703 |
} |
|
704 |
|
|
655 | 705 |
1; |
656 | 706 |
|
657 | 707 |
__END__ |
SL/DO.pm | ||
---|---|---|
296 | 296 |
for my $i (1 .. $form->{rowcount}) { |
297 | 297 |
next if (!$form->{"id_$i"}); |
298 | 298 |
|
299 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
300 |
dbh => $dbh, |
|
301 |
row => $i, |
|
302 |
sub_module => 'delivery_order_items', |
|
303 |
may_converted_from => ['orderitems']); |
|
304 |
|
|
299 | 305 |
my $position = $i; |
300 | 306 |
|
301 |
my $cvars; |
|
302 | 307 |
if (!$form->{"delivery_order_items_id_$i"}) { |
303 | 308 |
# there is no persistent id, therefore create one with all necessary constraints |
304 | 309 |
my $q_item_id = qq|SELECT nextval('delivery_order_items_id')|; |
... | ... | |
309 | 314 |
do_query($form, $dbh, $query, conv_i($form->{"delivery_order_items_id_$i"}), |
310 | 315 |
conv_i($form->{"id"}), conv_i($position), conv_i($form->{"id_$i"})); |
311 | 316 |
$h_item_id->finish(); |
312 |
|
|
313 |
# get values for CVars from master data for new items |
|
314 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
315 |
module => 'IC', |
|
316 |
trans_id => $form->{"id_$i"}, |
|
317 |
); |
|
318 |
} else { |
|
319 |
# get values for CVars from custom_variables for existing items |
|
320 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
321 |
module => 'IC', |
|
322 |
sub_module => 'delivery_order_items', |
|
323 |
trans_id => $form->{"delivery_order_items_id_$i"}, |
|
324 |
); |
|
325 | 317 |
} |
326 |
# map only non-editable CVars to form (editable ones are already there) |
|
327 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
328 | 318 |
|
329 | 319 |
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); |
330 | 320 |
|
... | ... | |
1015 | 1005 |
} |
1016 | 1006 |
} |
1017 | 1007 |
|
1018 |
my $cvars; |
|
1019 |
if (! $form->{"delivery_order_items_id_$i"}) { |
|
1020 |
# get values for CVars from master data for new items |
|
1021 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
1022 |
module => 'IC', |
|
1023 |
trans_id => $form->{"id_$i"}, |
|
1024 |
); |
|
1025 |
} else { |
|
1026 |
# get values for CVars from custom_variables for existing items |
|
1027 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
1028 |
module => 'IC', |
|
1029 |
sub_module => 'delivery_order_items', |
|
1030 |
trans_id => $form->{"delivery_order_items_id_$i"}, |
|
1031 |
); |
|
1032 |
} |
|
1033 |
# map only non-editable CVars to form (editable ones are already there) |
|
1034 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
1008 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
1009 |
dbh => $dbh, |
|
1010 |
row => $i, |
|
1011 |
sub_module => 'delivery_order_items', |
|
1012 |
may_converted_from => ['orderitems']); |
|
1035 | 1013 |
|
1036 | 1014 |
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, |
1037 | 1015 |
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) |
... | ... | |
1289 | 1267 |
return $delivered ? 1 : 0; |
1290 | 1268 |
} |
1291 | 1269 |
|
1292 |
|
|
1293 | 1270 |
1; |
SL/IR.pm | ||
---|---|---|
369 | 369 |
|
370 | 370 |
next if $payments_only; |
371 | 371 |
|
372 |
my $cvars; |
|
372 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
373 |
dbh => $dbh, |
|
374 |
row => $i, |
|
375 |
sub_module => 'invoice', |
|
376 |
may_converted_from => ['delivery_order_items', 'orderitems']); |
|
377 |
|
|
373 | 378 |
if (!$form->{"invoice_id_$i"}) { |
374 | 379 |
# there is no persistent id, therefore create one with all necessary constraints |
375 | 380 |
my $q_invoice_id = qq|SELECT nextval('invoiceid')|; |
... | ... | |
380 | 385 |
do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), |
381 | 386 |
conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"})); |
382 | 387 |
$h_invoice_id->finish(); |
383 |
|
|
384 |
# get values for CVars from master data for new items |
|
385 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
386 |
module => 'IC', |
|
387 |
trans_id => $form->{"id_$i"}, |
|
388 |
); |
|
389 |
} else { |
|
390 |
# get values for CVars from custom_variables for existing items |
|
391 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
392 |
module => 'IC', |
|
393 |
sub_module => 'invoice', |
|
394 |
trans_id => $form->{"invoice_id_$i"}, |
|
395 |
); |
|
396 | 388 |
} |
397 |
# map only non-editable CVars to form (editable ones are already there) |
|
398 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
399 | 389 |
|
400 | 390 |
# save detail record in invoice table |
401 | 391 |
$query = <<SQL; |
... | ... | |
1656 | 1646 |
return $duedate; |
1657 | 1647 |
} |
1658 | 1648 |
|
1659 |
|
|
1660 | 1649 |
1; |
SL/IS.pm | ||
---|---|---|
373 | 373 |
$sth->finish; |
374 | 374 |
} |
375 | 375 |
|
376 |
my $cvars; |
|
377 |
if (! $form->{"invoice_id_$i"}) { |
|
378 |
# get values for CVars from master data for new items |
|
379 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
380 |
module => 'IC', |
|
381 |
trans_id => $form->{"id_$i"}, |
|
382 |
); |
|
383 |
} else { |
|
384 |
# get values for CVars from custom_variables for existing items |
|
385 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
386 |
module => 'IC', |
|
387 |
sub_module => 'invoice', |
|
388 |
trans_id => $form->{"invoice_id_$i"}, |
|
389 |
); |
|
390 |
} |
|
391 |
# map only non-editable CVars to form (editable ones are already there) |
|
392 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
376 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
377 |
dbh => $dbh, |
|
378 |
row => $i, |
|
379 |
sub_module => 'invoice', |
|
380 |
may_converted_from => ['delivery_order_items', 'orderitems', 'invoice']); |
|
393 | 381 |
|
394 | 382 |
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, |
395 | 383 |
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) |
... | ... | |
767 | 755 |
$pricegroup_id *= 1; |
768 | 756 |
$pricegroup_id = undef if !$pricegroup_id; |
769 | 757 |
|
770 |
my $cvars; |
|
758 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
759 |
dbh => $dbh, |
|
760 |
row => $i, |
|
761 |
sub_module => 'invoice', |
|
762 |
may_converted_from => ['delivery_order_items', 'orderitems', 'invoice']); |
|
763 |
|
|
771 | 764 |
if (!$form->{"invoice_id_$i"}) { |
772 | 765 |
# there is no persistent id, therefore create one with all necessary constraints |
773 | 766 |
my $q_invoice_id = qq|SELECT nextval('invoiceid')|; |
... | ... | |
778 | 771 |
do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), |
779 | 772 |
conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"})); |
780 | 773 |
$h_invoice_id->finish(); |
781 |
|
|
782 |
# get values for CVars from master data for new items |
|
783 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
784 |
module => 'IC', |
|
785 |
trans_id => $form->{"id_$i"}, |
|
786 |
); |
|
787 |
} else { |
|
788 |
# get values for CVars from custom_variables for existing items |
|
789 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
790 |
module => 'IC', |
|
791 |
sub_module => 'invoice', |
|
792 |
trans_id => $form->{"invoice_id_$i"}, |
|
793 |
); |
|
794 | 774 |
} |
795 |
# map only non-editable CVars to form (editable ones are already there) |
|
796 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
797 | 775 |
|
798 | 776 |
# save detail record in invoice table |
799 | 777 |
$query = <<SQL; |
SL/OE.pm | ||
---|---|---|
509 | 509 |
$pricegroup_id *= 1; |
510 | 510 |
$pricegroup_id = undef if !$pricegroup_id; |
511 | 511 |
|
512 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
513 |
dbh => $dbh, |
|
514 |
row => $i, |
|
515 |
sub_module => 'orderitems', |
|
516 |
may_converted_from => ['orderitems', 'invoice']); |
|
517 |
|
|
512 | 518 |
my $position = $i; |
513 | 519 |
|
514 | 520 |
# save detail record in orderitems table |
515 |
my $cvars; |
|
516 | 521 |
if (! $form->{"orderitems_id_$i"}) { |
517 | 522 |
$query = qq|SELECT nextval('orderitemsid')|; |
518 | 523 |
($form->{"orderitems_id_$i"}) = selectrow_query($form, $dbh, $query); |
519 | 524 |
|
520 | 525 |
$query = qq|INSERT INTO orderitems (id, position) VALUES (?, ?)|; |
521 | 526 |
do_query($form, $dbh, $query, $form->{"orderitems_id_$i"}, conv_i($position)); |
522 |
|
|
523 |
# get values for CVars from master data for new items |
|
524 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
525 |
module => 'IC', |
|
526 |
trans_id => $form->{"id_$i"}, |
|
527 |
); |
|
528 |
} else { |
|
529 |
# get values for CVars from custom_variables for existing items |
|
530 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
531 |
module => 'IC', |
|
532 |
sub_module => 'orderitems', |
|
533 |
trans_id => $form->{"orderitems_id_$i"}, |
|
534 |
); |
|
535 | 527 |
} |
536 |
# map only non-editable CVars to form (editable ones are already there) |
|
537 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
538 | 528 |
|
539 | 529 |
my $orderitems_id = $form->{"orderitems_id_$i"}; |
540 | 530 |
push @processed_orderitems, $orderitems_id; |
... | ... | |
1412 | 1402 |
$sth->finish; |
1413 | 1403 |
} |
1414 | 1404 |
|
1415 |
my $cvars; |
|
1416 |
if (! $form->{"orderitems_id_$i"}) { |
|
1417 |
# get values for CVars from master data for new items |
|
1418 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
1419 |
module => 'IC', |
|
1420 |
trans_id => $form->{"id_$i"}, |
|
1421 |
); |
|
1422 |
} else { |
|
1423 |
# get values for CVars from custom_variables for existing items |
|
1424 |
$cvars = CVar->get_custom_variables(dbh => $dbh, |
|
1425 |
module => 'IC', |
|
1426 |
sub_module => 'orderitems', |
|
1427 |
trans_id => $form->{"orderitems_id_$i"}, |
|
1428 |
); |
|
1429 |
} |
|
1430 |
# map only non-editable CVars to form (editable ones are already there) |
|
1431 |
map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; |
|
1405 |
CVar->get_non_editable_ic_cvars(form => $form, |
|
1406 |
dbh => $dbh, |
|
1407 |
row => $i, |
|
1408 |
sub_module => 'orderitems', |
|
1409 |
may_converted_from => ['orderitems', 'invoice']); |
|
1432 | 1410 |
|
1433 | 1411 |
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, |
1434 | 1412 |
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) |
Auch abrufbar als: Unified diff
Nicht-editierbare CVars auch im Workflow richtig setzen. ...
Zudem das Ermitteln der Werte in eine Subroutine ausgelagert.