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); |
SL/IS.pm | ||
---|---|---|
68 | 68 |
my $query = qq|SELECT date | . conv_dateq($form->{duedate}) . qq| - date | . conv_dateq($form->{invdate}) . qq| AS terms|; |
69 | 69 |
($form->{terms}) = selectrow_query($form, $dbh, $query); |
70 | 70 |
|
71 |
my (@project_ids, %projectnumbers, %projectdescriptions);
|
|
71 |
my (@project_ids); |
|
72 | 72 |
$form->{TEMPLATE_ARRAYS} = {}; |
73 | 73 |
|
74 | 74 |
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); |
... | ... | |
92 | 92 |
push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"}); |
93 | 93 |
} |
94 | 94 |
|
95 |
my $projects = []; |
|
96 |
my %projects_by_id; |
|
95 | 97 |
if (@project_ids) { |
96 |
$query = "SELECT id, projectnumber, description FROM project WHERE id IN (" . |
|
97 |
join(", ", map({ "?" } @project_ids)) . ")"; |
|
98 |
$sth = $dbh->prepare($query); |
|
99 |
$sth->execute(@project_ids) || |
|
100 |
$form->dberror($query . " (" . join(", ", @project_ids) . ")"); |
|
101 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
102 |
$projectnumbers{$ref->{id}} = $ref->{projectnumber}; |
|
103 |
$projectdescriptions{$ref->{id}} = $ref->{description}; |
|
104 |
} |
|
105 |
$sth->finish(); |
|
98 |
$projects = SL::DB::Manager::Project->get_all(query => [ id => \@project_ids ]); |
|
99 |
%projects_by_id = map { $_->id => $_ } @$projects; |
|
106 | 100 |
} |
107 | 101 |
|
108 |
$form->{"globalprojectnumber"} = |
|
109 |
$projectnumbers{$form->{"globalproject_id"}}; |
|
110 |
$form->{"globalprojectdescription"} = |
|
111 |
$projectdescriptions{$form->{"globalproject_id"}}; |
|
102 |
$form->{globalprojectnumber} = $projects_by_id{$form->{"globalproject_id"}}->projectnumber; |
|
103 |
$form->{globalprojectdescription} = $projects_by_id{$form->{"globalproject_id"}}->description; |
|
104 |
|
|
105 |
if ($projects_by_id{$form->{"globalproject_id"}}) { |
|
106 |
for (@{ $projects_by_id{$form->{"globalproject_id"}}->cvars_by_config }) { |
|
107 |
$form->{"project_cvar_" . $_->config->name} = $_->value_as_text; |
|
108 |
} |
|
109 |
} |
|
112 | 110 |
|
113 | 111 |
my $tax = 0; |
114 | 112 |
my $item; |
... | ... | |
146 | 144 |
IC->prepare_parts_for_printing(myconfig => $myconfig, form => $form); |
147 | 145 |
|
148 | 146 |
my $ic_cvar_configs = CVar->get_configs(module => 'IC'); |
147 |
my $project_cvar_configs = CVar->get_configs(module => 'Projects'); |
|
149 | 148 |
|
150 | 149 |
my @arrays = |
151 | 150 |
qw(runningnumber number description longdescription qty ship unit bin |
... | ... | |
156 | 155 |
price_factor price_factor_name partsgroup weight lineweight); |
157 | 156 |
|
158 | 157 |
push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; |
158 |
push @arrays, map { "project_cvar_$_->{name}" } @{ $project_cvar_configs }; |
|
159 | 159 |
|
160 | 160 |
my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber); |
161 | 161 |
|
... | ... | |
277 | 277 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2); |
278 | 278 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal_nofmt} }, $nodiscount_linetotal; |
279 | 279 |
|
280 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}}); |
|
281 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectdescription} }, $projectdescriptions{$form->{"project_id_$i"}}); |
|
280 |
my $project = $projects_by_id{$form->{"project_id_$i"}} || SL::DB::Project->new; |
|
281 |
|
|
282 |
push @{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $project->projectnumber; |
|
283 |
push @{ $form->{TEMPLATE_ARRAYS}->{projectdescription} }, $project->description; |
|
282 | 284 |
|
283 | 285 |
my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"}; |
284 | 286 |
$totalweight += $lineweight; |
... | ... | |
370 | 372 |
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, |
371 | 373 |
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) |
372 | 374 |
for @{ $ic_cvar_configs }; |
375 |
|
|
376 |
push @{ $form->{TEMPLATE_ARRAYS}->{"project_cvar_" . $_->config->name} }, $_->value_as_text for @{ $project->cvars_by_config }; |
|
373 | 377 |
} |
374 | 378 |
} |
375 | 379 |
|
SL/OE.pm | ||
---|---|---|
1032 | 1032 |
my $tax_rate; |
1033 | 1033 |
my $taxamount; |
1034 | 1034 |
|
1035 |
my (@project_ids, %projectnumbers, %projectdescriptions);
|
|
1035 |
my (@project_ids); |
|
1036 | 1036 |
|
1037 | 1037 |
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); |
1038 | 1038 |
|
... | ... | |
1063 | 1063 |
push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"}); |
1064 | 1064 |
} |
1065 | 1065 |
|
1066 |
my $projects = []; |
|
1067 |
my %projects_by_id; |
|
1066 | 1068 |
if (@project_ids) { |
1067 |
$query = "SELECT id, projectnumber, description FROM project WHERE id IN (" . |
|
1068 |
join(", ", map("?", @project_ids)) . ")"; |
|
1069 |
$sth = prepare_execute_query($form, $dbh, $query, @project_ids); |
|
1070 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
1071 |
$projectnumbers{$ref->{id}} = $ref->{projectnumber}; |
|
1072 |
$projectdescriptions{$ref->{id}} = $ref->{description}; |
|
1073 |
} |
|
1074 |
$sth->finish(); |
|
1069 |
$projects = SL::DB::Manager::Project->get_all(query => [ id => \@project_ids ]); |
|
1070 |
%projects_by_id = map { $_->id => $_ } @$projects; |
|
1075 | 1071 |
} |
1076 | 1072 |
|
1077 |
$form->{"globalprojectnumber"} = $projectnumbers{$form->{"globalproject_id"}}; |
|
1078 |
$form->{"globalprojectdescription"} = $projectdescriptions{$form->{"globalproject_id"}}; |
|
1073 |
$form->{globalprojectnumber} = $projects_by_id{$form->{"globalproject_id"}}->projectnumber; |
|
1074 |
$form->{globalprojectdescription} = $projects_by_id{$form->{"globalproject_id"}}->description; |
|
1075 |
|
|
1076 |
if ($projects_by_id{$form->{"globalproject_id"}}) { |
|
1077 |
for (@{ $projects_by_id{$form->{"globalproject_id"}}->cvars_by_config }) { |
|
1078 |
$form->{"project_cvar_" . $_->config->name} = $_->value_as_text; |
|
1079 |
} |
|
1080 |
} |
|
1079 | 1081 |
|
1080 | 1082 |
$form->{discount} = []; |
1081 | 1083 |
|
... | ... | |
1083 | 1085 |
IC->prepare_parts_for_printing(myconfig => $myconfig, form => $form); |
1084 | 1086 |
|
1085 | 1087 |
my $ic_cvar_configs = CVar->get_configs(module => 'IC'); |
1088 |
my $project_cvar_configs = CVar->get_configs(module => 'Projects'); |
|
1086 | 1089 |
|
1087 | 1090 |
my @arrays = |
1088 | 1091 |
qw(runningnumber number description longdescription qty ship unit bin |
... | ... | |
1092 | 1095 |
price_factor price_factor_name partsgroup weight lineweight); |
1093 | 1096 |
|
1094 | 1097 |
push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; |
1098 |
push @arrays, map { "project_cvar_$_->{name}" } @{ $project_cvar_configs }; |
|
1095 | 1099 |
|
1096 | 1100 |
my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber); |
1097 | 1101 |
|
... | ... | |
1205 | 1209 |
$nodiscount += $linetotal; |
1206 | 1210 |
} |
1207 | 1211 |
|
1212 |
my $project = $projects_by_id{$form->{"project_id_$i"}} || SL::DB::Project->new; |
|
1213 |
|
|
1208 | 1214 |
push @{ $form->{TEMPLATE_ARRAYS}->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2); |
1209 | 1215 |
push @{ $form->{TEMPLATE_ARRAYS}->{linetotal_nofmt} }, $linetotal_exact; |
1210 | 1216 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2); |
1211 | 1217 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal_nofmt} }, $nodiscount_linetotal; |
1212 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
|
|
1213 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectdescription} }, $projectdescriptions{$form->{"project_id_$i"}});
|
|
1218 |
push @{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $project->projectnumber;
|
|
1219 |
push @{ $form->{TEMPLATE_ARRAYS}->{projectdescription} }, $project->description;
|
|
1214 | 1220 |
|
1215 | 1221 |
my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"}; |
1216 | 1222 |
$totalweight += $lineweight; |
... | ... | |
1282 | 1288 |
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, |
1283 | 1289 |
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) |
1284 | 1290 |
for @{ $ic_cvar_configs }; |
1291 |
|
|
1292 |
push @{ $form->{TEMPLATE_ARRAYS}->{"project_cvar_" . $_->config->name} }, $_->value_as_text for @{ $project->cvars_by_config }; |
|
1285 | 1293 |
} |
1286 | 1294 |
} |
1287 | 1295 |
|
Auch abrufbar als: Unified diff
project cvars als project_cvar_* im Ausdruck von Belegen verfügbar
behebt #2237