Revision fde1df0b
Von Sven Schöling vor fast 11 Jahren hinzugefügt
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 |
|
Auch abrufbar als: Unified diff
project cvars als project_cvar_* im Ausdruck von Belegen verfügbar
behebt #2237