Revision fde1df0b
Von Sven Schöling vor fast 11 Jahren hinzugefügt
SL/DO.pm | ||
---|---|---|
728 | 728 |
my $subtotal_header = 0; |
729 | 729 |
my $subposition = 0; |
730 | 730 |
|
731 |
my (@project_ids, %projectnumbers, %projectdescriptions);
|
|
731 |
my (@project_ids); |
|
732 | 732 |
|
733 | 733 |
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); |
734 | 734 |
|
... | ... | |
742 | 742 |
push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"}); |
743 | 743 |
} |
744 | 744 |
|
745 |
my $projects = []; |
|
746 |
my %projects_by_id; |
|
745 | 747 |
if (@project_ids) { |
746 |
$query = "SELECT id, projectnumber, description FROM project WHERE id IN (" . |
|
747 |
join(", ", map("?", @project_ids)) . ")"; |
|
748 |
$sth = prepare_execute_query($form, $dbh, $query, @project_ids); |
|
749 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
750 |
$projectnumbers{$ref->{id}} = $ref->{projectnumber}; |
|
751 |
$projectdescriptions{$ref->{id}} = $ref->{description}; |
|
752 |
} |
|
753 |
$sth->finish(); |
|
748 |
$projects = SL::DB::Manager::Project->get_all(query => [ id => \@project_ids ]); |
|
749 |
%projects_by_id = map { $_->id => $_ } @$projects; |
|
754 | 750 |
} |
755 | 751 |
|
756 |
$form->{"globalprojectnumber"} = |
|
757 |
$projectnumbers{$form->{"globalproject_id"}}; |
|
758 |
$form->{"globalprojectdescription"} = |
|
759 |
$projectdescriptions{$form->{"globalproject_id"}}; |
|
752 |
$form->{globalprojectnumber} = $projects_by_id{$form->{"globalproject_id"}}->projectnumber; |
|
753 |
$form->{globalprojectdescription} = $projects_by_id{$form->{"globalproject_id"}}->description; |
|
754 |
|
|
755 |
if ($projects_by_id{$form->{"globalproject_id"}}) { |
|
756 |
for (@{ $projects_by_id{$form->{"globalproject_id"}}->cvars_by_config }) { |
|
757 |
$form->{"project_cvar_" . $_->config->name} = $_->value_as_text; |
|
758 |
} |
|
759 |
} |
|
760 | 760 |
|
761 | 761 |
my $q_pg = qq|SELECT p.partnumber, p.description, p.unit, a.qty, pg.partsgroup |
762 | 762 |
FROM assembly a |
... | ... | |
775 | 775 |
my $num_si = 0; |
776 | 776 |
|
777 | 777 |
my $ic_cvar_configs = CVar->get_configs(module => 'IC'); |
778 |
my $project_cvar_configs = CVar->get_configs(module => 'Projects'); |
|
778 | 779 |
|
779 | 780 |
$form->{TEMPLATE_ARRAYS} = { }; |
780 | 781 |
IC->prepare_parts_for_printing(myconfig => $myconfig, form => $form); |
... | ... | |
788 | 789 |
map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays); |
789 | 790 |
|
790 | 791 |
push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; |
792 |
push @arrays, map { "project_cvar_$_->{name}" } @{ $project_cvar_configs }; |
|
791 | 793 |
|
792 | 794 |
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); |
793 | 795 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
... | ... | |
824 | 826 |
} |
825 | 827 |
|
826 | 828 |
my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; |
829 |
my $project = $projects_by_id{$form->{"project_id_$i"}} || SL::DB::Project->new; |
|
827 | 830 |
|
828 | 831 |
push @{ $form->{TEMPLATE_ARRAYS}{runningnumber} }, $position; |
829 | 832 |
push @{ $form->{TEMPLATE_ARRAYS}{number} }, $form->{"partnumber_$i"}; |
... | ... | |
835 | 838 |
push @{ $form->{TEMPLATE_ARRAYS}{partnotes} }, $form->{"partnotes_$i"}; |
836 | 839 |
push @{ $form->{TEMPLATE_ARRAYS}{serialnumber} }, $form->{"serialnumber_$i"}; |
837 | 840 |
push @{ $form->{TEMPLATE_ARRAYS}{reqdate} }, $form->{"reqdate_$i"}; |
838 |
push @{ $form->{TEMPLATE_ARRAYS}{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}}; |
|
839 |
push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} }, |
|
840 |
$projectdescriptions{$form->{"project_id_$i"}}; |
|
841 |
push @{ $form->{TEMPLATE_ARRAYS}{projectnumber} }, $project->projectnumber; |
|
842 |
push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} }, $project->description; |
|
841 | 843 |
|
842 | 844 |
if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) { |
843 | 845 |
$subtotal_header = 0; |
... | ... | |
901 | 903 |
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, |
902 | 904 |
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) |
903 | 905 |
for @{ $ic_cvar_configs }; |
906 |
|
|
907 |
push @{ $form->{TEMPLATE_ARRAYS}->{"project_cvar_" . $_->config->name} }, $_->value_as_text for @{ $project->cvars_by_config }; |
|
904 | 908 |
} |
905 | 909 |
|
906 | 910 |
$form->{totalweight} = $form->format_amount($myconfig, $totalweight, 3); |
Auch abrufbar als: Unified diff
project cvars als project_cvar_* im Ausdruck von Belegen verfügbar
behebt #2237