Revision 9c63c160
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
714 | 714 |
my $first = 1; |
715 | 715 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
716 | 716 |
if ($first) { |
717 |
map({ $form->{"dn_$_"} = []; } keys(%{$ref})); |
|
717 |
$form->{TEMPLATE_ARRAYS} = {}; |
|
718 |
map({ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} = []; } keys(%{$ref})); |
|
718 | 719 |
$first = 0; |
719 | 720 |
} |
720 | 721 |
map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest linetotal); |
721 | 722 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
722 |
map { push @{ $form->{"dn_$_"} }, $ref->{$_}} keys %$ref;
|
|
723 |
map { push @{ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} }, $ref->{$_} } keys %$ref;
|
|
723 | 724 |
} |
724 | 725 |
$sth->finish(); |
725 | 726 |
|
SL/IS.pm | ||
---|---|---|
145 | 145 |
linetotal nodiscount_linetotal tax_rate projectnumber |
146 | 146 |
price_factor price_factor_name partsgroup); |
147 | 147 |
|
148 |
my @tax_arrays = |
|
149 |
qw(taxbase tax taxdescription taxrate taxnumber); |
|
148 |
my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber); |
|
149 |
|
|
150 |
my @payment_arrays = qw(payment paymentaccount paymentdate paymentsource paymentmemo); |
|
151 |
|
|
152 |
$form->{TEMPLATE_ARRAYS} = { map { $_ => [] } (@arrays, @tax_arrays, @payment_arrays) }; |
|
150 | 153 |
|
151 | 154 |
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) { |
152 | 155 |
$i = $item->[0]; |
153 | 156 |
|
154 | 157 |
if ($item->[1] ne $sameitem) { |
155 |
push(@{ $form->{description} }, qq|$item->[1]|); |
|
158 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, qq|$item->[1]|);
|
|
156 | 159 |
$sameitem = $item->[1]; |
157 | 160 |
|
158 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
161 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
159 | 162 |
} |
160 | 163 |
|
161 | 164 |
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); |
... | ... | |
179 | 182 |
|
180 | 183 |
my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; |
181 | 184 |
|
182 |
push @{ $form->{runningnumber} }, $position; |
|
183 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
184 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
185 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
186 |
push @{ $form->{"partnotes"} }, $form->{"partnotes_$i"}; |
|
187 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
188 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
189 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
190 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
191 |
push @{ $form->{deliverydate_oe} }, $form->{"deliverydate_$i"}; |
|
192 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
193 |
push @{ $form->{ordnumber_oe} }, $form->{"ordnumber_$i"}; |
|
194 |
push @{ $form->{transdate_oe} }, $form->{"transdate_$i"}; |
|
195 |
push @{ $form->{invnumber} }, $form->{"invnumber"}; |
|
196 |
push @{ $form->{invdate} }, $form->{"invdate"}; |
|
197 |
push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; |
|
198 |
push @{ $form->{price_factor_name} }, $price_factor->{description}; |
|
199 |
push @{ $form->{partsgroup} }, $form->{"partsgroup_$i"}; |
|
185 |
push @{ $form->{TEMPLATE_ARRAYS}->{runningnumber} }, $position; |
|
186 |
push @{ $form->{TEMPLATE_ARRAYS}->{number} }, $form->{"partnumber_$i"}; |
|
187 |
push @{ $form->{TEMPLATE_ARRAYS}->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
188 |
push @{ $form->{TEMPLATE_ARRAYS}->{bin} }, $form->{"bin_$i"}; |
|
189 |
push @{ $form->{TEMPLATE_ARRAYS}->{partnotes} }, $form->{"partnotes_$i"}; |
|
190 |
push @{ $form->{TEMPLATE_ARRAYS}->{description} }, $form->{"description_$i"}; |
|
191 |
push @{ $form->{TEMPLATE_ARRAYS}->{longdescription} }, $form->{"longdescription_$i"}; |
|
192 |
push @{ $form->{TEMPLATE_ARRAYS}->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
193 |
push @{ $form->{TEMPLATE_ARRAYS}->{unit} }, $form->{"unit_$i"}; |
|
194 |
push @{ $form->{TEMPLATE_ARRAYS}->{deliverydate_oe} }, $form->{"deliverydate_$i"}; |
|
195 |
push @{ $form->{TEMPLATE_ARRAYS}->{sellprice} }, $form->{"sellprice_$i"}; |
|
196 |
push @{ $form->{TEMPLATE_ARRAYS}->{ordnumber_oe} }, $form->{"ordnumber_$i"}; |
|
197 |
push @{ $form->{TEMPLATE_ARRAYS}->{transdate_oe} }, $form->{"transdate_$i"}; |
|
198 |
push @{ $form->{TEMPLATE_ARRAYS}->{invnumber} }, $form->{"invnumber"}; |
|
199 |
push @{ $form->{TEMPLATE_ARRAYS}->{invdate} }, $form->{"invdate"}; |
|
200 |
push @{ $form->{TEMPLATE_ARRAYS}->{price_factor} }, $price_factor->{formatted_factor}; |
|
201 |
push @{ $form->{TEMPLATE_ARRAYS}->{price_factor_name} }, $price_factor->{description}; |
|
202 |
push @{ $form->{TEMPLATE_ARRAYS}->{partsgroup} }, $form->{"partsgroup_$i"}; |
|
203 |
push @{ $form->{TEMPLATE_ARRAYS}->{reqdate} }, $form->{"reqdate_$i"}; |
|
200 | 204 |
|
201 | 205 |
if ($form->{lizenzen}) { |
202 | 206 |
if ($form->{"licensenumber_$i"}) { |
203 | 207 |
$query = qq|SELECT licensenumber, validuntil FROM license WHERE id = ?|; |
204 | 208 |
my ($licensenumber, $validuntil) = selectrow_query($form, $dbh, $query, conv_i($form->{"licensenumber_$i"})); |
205 |
push(@{ $form->{licensenumber} }, $licensenumber); |
|
206 |
push(@{ $form->{validuntil} }, $locale->date($myconfig, $validuntil, 0)); |
|
209 |
push(@{ $form->{TEMPLATE_ARRAYS}->{licensenumber} }, $licensenumber);
|
|
210 |
push(@{ $form->{TEMPLATE_ARRAYS}->{validuntil} }, $locale->date($myconfig, $validuntil, 0));
|
|
207 | 211 |
|
208 | 212 |
} else { |
209 |
push(@{ $form->{licensenumber} }, ""); |
|
210 |
push(@{ $form->{validuntil} }, ""); |
|
213 |
push(@{ $form->{TEMPLATE_ARRAYS}->{licensenumber} }, "");
|
|
214 |
push(@{ $form->{TEMPLATE_ARRAYS}->{validuntil} }, "");
|
|
211 | 215 |
} |
212 | 216 |
} |
213 | 217 |
|
214 | 218 |
# listprice |
215 |
push(@{ $form->{listprice} }, $form->{"listprice_$i"}); |
|
219 |
push(@{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->{"listprice_$i"});
|
|
216 | 220 |
|
217 | 221 |
my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); |
218 | 222 |
my ($dec) = ($sellprice =~ /\.(\d+)/); |
... | ... | |
226 | 230 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2); |
227 | 231 |
$form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); |
228 | 232 |
|
229 |
push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : ''; |
|
233 |
push @{ $form->{TEMPLATE_ARRAYS}->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
|
|
230 | 234 |
|
231 | 235 |
$linetotal = ($linetotal != 0) ? $linetotal : ''; |
232 | 236 |
|
233 |
push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : ''; |
|
234 |
push @{ $form->{p_discount} }, $form->{"discount_$i"}; |
|
237 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : '';
|
|
238 |
push @{ $form->{TEMPLATE_ARRAYS}->{p_discount} }, $form->{"discount_$i"};
|
|
235 | 239 |
|
236 | 240 |
$form->{total} += $linetotal; |
237 | 241 |
$form->{nodiscount_total} += $nodiscount_linetotal; |
... | ... | |
243 | 247 |
} |
244 | 248 |
|
245 | 249 |
if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) { |
246 |
push @{ $form->{discount_sub} }, $form->format_amount($myconfig, $discount_subtotal, 2); |
|
247 |
push @{ $form->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2); |
|
250 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, $form->format_amount($myconfig, $discount_subtotal, 2);
|
|
251 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
|
|
248 | 252 |
|
249 | 253 |
$discount_subtotal = 0; |
250 | 254 |
$nodiscount_subtotal = 0; |
251 | 255 |
$subtotal_header = 0; |
252 | 256 |
|
253 | 257 |
} else { |
254 |
push @{ $form->{discount_sub} }, ""; |
|
255 |
push @{ $form->{nodiscount_sub} }, ""; |
|
258 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, "";
|
|
259 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, "";
|
|
256 | 260 |
} |
257 | 261 |
|
258 | 262 |
if (!$form->{"discount_$i"}) { |
259 | 263 |
$nodiscount += $linetotal; |
260 | 264 |
} |
261 | 265 |
|
262 |
push @{ $form->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2); |
|
263 |
push @{ $form->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2); |
|
266 |
push @{ $form->{TEMPLATE_ARRAYS}->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
|
|
267 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
|
|
264 | 268 |
|
265 |
push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}}); |
|
269 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
|
|
266 | 270 |
|
267 | 271 |
@taxaccounts = split(/ /, $form->{"taxaccounts_$i"}); |
268 | 272 |
$taxrate = 0; |
... | ... | |
304 | 308 |
} |
305 | 309 |
} |
306 | 310 |
my $tax_rate = $taxrate * 100; |
307 |
push(@{ $form->{tax_rate} }, qq|$tax_rate|); |
|
311 |
push(@{ $form->{TEMPLATE_ARRAYS}->{tax_rate} }, qq|$tax_rate|);
|
|
308 | 312 |
if ($form->{"assembly_$i"}) { |
309 | 313 |
$sameitem = ""; |
310 | 314 |
|
... | ... | |
327 | 331 |
|
328 | 332 |
while (my $ref = $sth->fetchrow_hashref('NAME_lc')) { |
329 | 333 |
if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) { |
330 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
334 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
331 | 335 |
$sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--"; |
332 |
push(@{ $form->{description} }, $sameitem); |
|
336 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $sameitem);
|
|
333 | 337 |
} |
334 | 338 |
|
335 | 339 |
map { $form->{"a_$_"} = $ref->{$_} } qw(partnumber description); |
336 | 340 |
|
337 |
push(@{ $form->{description} }, |
|
341 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} },
|
|
338 | 342 |
$form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"} |
339 | 343 |
) |
340 | 344 |
. qq| -- $form->{"a_partnumber"}, $form->{"a_description"}|); |
341 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
345 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
342 | 346 |
|
343 | 347 |
} |
344 | 348 |
$sth->finish; |
... | ... | |
347 | 351 |
} |
348 | 352 |
|
349 | 353 |
foreach my $item (sort keys %taxaccounts) { |
350 |
push(@{ $form->{taxbase} }, |
|
351 |
$form->format_amount($myconfig, $taxbase{$item}, 2)); |
|
352 |
|
|
353 | 354 |
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2); |
354 | 355 |
|
355 |
push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
|
356 |
push(@{ $form->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
|
|
357 |
push(@{ $form->{taxrate} },
|
|
358 |
$form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
|
359 |
push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
|
|
356 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxbase} }, $form->format_amount($myconfig, $taxbase{$item}, 2));
|
|
357 |
push(@{ $form->{TEMPLATE_ARRAYS}->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
|
358 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} }, $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
|
359 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
|
|
360 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} }, $form->{"${item}_taxnumber"});
|
|
360 | 361 |
} |
361 | 362 |
|
362 | 363 |
for my $i (1 .. $form->{paidaccounts}) { |
363 | 364 |
if ($form->{"paid_$i"}) { |
364 |
push(@{ $form->{payment} }, $form->{"paid_$i"}); |
|
365 | 365 |
my ($accno, $description) = split(/--/, $form->{"AR_paid_$i"}); |
366 |
push(@{ $form->{paymentaccount} }, $description); |
|
367 |
push(@{ $form->{paymentdate} }, $form->{"datepaid_$i"}); |
|
368 |
push(@{ $form->{paymentsource} }, $form->{"source_$i"}); |
|
369 |
push(@{ $form->{paymentmemo} }, $form->{"memo_$i"}); |
|
366 |
|
|
367 |
push(@{ $form->{TEMPLATE_ARRAYS}->{payment} }, $form->{"paid_$i"}); |
|
368 |
push(@{ $form->{TEMPLATE_ARRAYS}->{paymentaccount} }, $description); |
|
369 |
push(@{ $form->{TEMPLATE_ARRAYS}->{paymentdate} }, $form->{"datepaid_$i"}); |
|
370 |
push(@{ $form->{TEMPLATE_ARRAYS}->{paymentsource} }, $form->{"source_$i"}); |
|
371 |
push(@{ $form->{TEMPLATE_ARRAYS}->{paymentmemo} }, $form->{"memo_$i"}); |
|
370 | 372 |
|
371 | 373 |
$form->{paid} += $form->parse_amount($myconfig, $form->{"paid_$i"}); |
372 | 374 |
} |
SL/OE.pm | ||
---|---|---|
977 | 977 |
linetotal nodiscount_linetotal tax_rate projectnumber |
978 | 978 |
price_factor price_factor_name partsgroup); |
979 | 979 |
|
980 |
my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber); |
|
981 |
|
|
982 |
$form->{TEMPLATE_ARRAYS} = { map { $_ => [] } (@arrays, @tax_arrays) }; |
|
983 |
|
|
980 | 984 |
my $sameitem = ""; |
981 | 985 |
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) { |
982 | 986 |
$i = $item->[0]; |
983 | 987 |
|
984 | 988 |
if ($item->[1] ne $sameitem) { |
985 |
push(@{ $form->{description} }, qq|$item->[1]|); |
|
989 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, qq|$item->[1]|);
|
|
986 | 990 |
$sameitem = $item->[1]; |
987 | 991 |
|
988 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
992 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
989 | 993 |
} |
990 | 994 |
|
991 | 995 |
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); |
... | ... | |
1010 | 1014 |
|
1011 | 1015 |
my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; |
1012 | 1016 |
|
1013 |
push @{ $form->{runningnumber} }, $position; |
|
1014 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
1015 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
1016 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
1017 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
1018 |
push @{ $form->{ship} }, $form->format_amount($myconfig, $form->{"ship_$i"}); |
|
1019 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
1020 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
1021 |
push @{ $form->{partnotes} }, $form->{"partnotes_$i"}; |
|
1022 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
1023 |
push @{ $form->{reqdate} }, $form->{"reqdate_$i"}; |
|
1024 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
1025 |
push @{ $form->{listprice} }, $form->{"listprice_$i"}; |
|
1026 |
push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; |
|
1027 |
push @{ $form->{price_factor_name} }, $price_factor->{description}; |
|
1028 |
push @{ $form->{partsgroup} }, $form->{"partsgroup_$i"}; |
|
1017 |
push @{ $form->{TEMPLATE_ARRAYS}->{runningnumber} }, $position;
|
|
1018 |
push @{ $form->{TEMPLATE_ARRAYS}->{number} }, $form->{"partnumber_$i"};
|
|
1019 |
push @{ $form->{TEMPLATE_ARRAYS}->{description} }, $form->{"description_$i"};
|
|
1020 |
push @{ $form->{TEMPLATE_ARRAYS}->{longdescription} }, $form->{"longdescription_$i"};
|
|
1021 |
push @{ $form->{TEMPLATE_ARRAYS}->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"});
|
|
1022 |
push @{ $form->{TEMPLATE_ARRAYS}->{ship} }, $form->format_amount($myconfig, $form->{"ship_$i"});
|
|
1023 |
push @{ $form->{TEMPLATE_ARRAYS}->{unit} }, $form->{"unit_$i"};
|
|
1024 |
push @{ $form->{TEMPLATE_ARRAYS}->{bin} }, $form->{"bin_$i"};
|
|
1025 |
push @{ $form->{TEMPLATE_ARRAYS}->{partnotes} }, $form->{"partnotes_$i"};
|
|
1026 |
push @{ $form->{TEMPLATE_ARRAYS}->{serialnumber} }, $form->{"serialnumber_$i"};
|
|
1027 |
push @{ $form->{TEMPLATE_ARRAYS}->{reqdate} }, $form->{"reqdate_$i"};
|
|
1028 |
push @{ $form->{TEMPLATE_ARRAYS}->{sellprice} }, $form->{"sellprice_$i"};
|
|
1029 |
push @{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->{"listprice_$i"};
|
|
1030 |
push @{ $form->{TEMPLATE_ARRAYS}->{price_factor} }, $price_factor->{formatted_factor};
|
|
1031 |
push @{ $form->{TEMPLATE_ARRAYS}->{price_factor_name} }, $price_factor->{description};
|
|
1032 |
push @{ $form->{TEMPLATE_ARRAYS}->{partsgroup} }, $form->{"partsgroup_$i"};
|
|
1029 | 1033 |
|
1030 | 1034 |
my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); |
1031 | 1035 |
my ($dec) = ($sellprice =~ /\.(\d+)/); |
... | ... | |
1039 | 1043 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2); |
1040 | 1044 |
$form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); |
1041 | 1045 |
|
1042 |
push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : ''; |
|
1046 |
push @{ $form->{TEMPLATE_ARRAYS}->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
|
|
1043 | 1047 |
|
1044 | 1048 |
$linetotal = ($linetotal != 0) ? $linetotal : ''; |
1045 | 1049 |
|
1046 |
push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : ''; |
|
1047 |
push @{ $form->{p_discount} }, $form->{"discount_$i"}; |
|
1050 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : '';
|
|
1051 |
push @{ $form->{TEMPLATE_ARRAYS}->{p_discount} }, $form->{"discount_$i"};
|
|
1048 | 1052 |
|
1049 | 1053 |
$form->{ordtotal} += $linetotal; |
1050 | 1054 |
$form->{nodiscount_total} += $nodiscount_linetotal; |
... | ... | |
1056 | 1060 |
} |
1057 | 1061 |
|
1058 | 1062 |
if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) { |
1059 |
push @{ $form->{discount_sub} }, $form->format_amount($myconfig, $discount_subtotal, 2); |
|
1060 |
push @{ $form->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2); |
|
1063 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, $form->format_amount($myconfig, $discount_subtotal, 2);
|
|
1064 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
|
|
1061 | 1065 |
|
1062 | 1066 |
$discount_subtotal = 0; |
1063 | 1067 |
$nodiscount_subtotal = 0; |
1064 | 1068 |
$subtotal_header = 0; |
1065 | 1069 |
|
1066 | 1070 |
} else { |
1067 |
push @{ $form->{discount_sub} }, ""; |
|
1068 |
push @{ $form->{nodiscount_sub} }, ""; |
|
1071 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, "";
|
|
1072 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, "";
|
|
1069 | 1073 |
} |
1070 | 1074 |
|
1071 | 1075 |
if (!$form->{"discount_$i"}) { |
1072 | 1076 |
$nodiscount += $linetotal; |
1073 | 1077 |
} |
1074 | 1078 |
|
1075 |
push @{ $form->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2); |
|
1076 |
push @{ $form->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2); |
|
1079 |
push @{ $form->{TEMPLATE_ARRAYS}->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
|
|
1080 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
|
|
1077 | 1081 |
|
1078 |
push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}}); |
|
1082 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
|
|
1079 | 1083 |
|
1080 | 1084 |
my ($taxamount, $taxbase); |
1081 | 1085 |
my $taxrate = 0; |
... | ... | |
1100 | 1104 |
} |
1101 | 1105 |
|
1102 | 1106 |
$tax_rate = $taxrate * 100; |
1103 |
push(@{ $form->{tax_rate} }, qq|$tax_rate|); |
|
1107 |
push(@{ $form->{TEMPLATE_ARRAYS}->{tax_rate} }, qq|$tax_rate|);
|
|
1104 | 1108 |
|
1105 | 1109 |
if ($form->{"assembly_$i"}) { |
1106 | 1110 |
$sameitem = ""; |
... | ... | |
1126 | 1130 |
|
1127 | 1131 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
1128 | 1132 |
if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) { |
1129 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
1133 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
1130 | 1134 |
$sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--"; |
1131 |
push(@{ $form->{description} }, $sameitem); |
|
1135 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $sameitem);
|
|
1132 | 1136 |
} |
1133 | 1137 |
|
1134 |
push(@{ $form->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|); |
|
1135 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
1138 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|);
|
|
1139 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
1136 | 1140 |
} |
1137 | 1141 |
$sth->finish; |
1138 | 1142 |
} |
... | ... | |
1142 | 1146 |
|
1143 | 1147 |
my $tax = 0; |
1144 | 1148 |
foreach $item (sort keys %taxaccounts) { |
1145 |
push(@{ $form->{taxbase} }, |
|
1146 |
$form->format_amount($myconfig, $taxbase{$item}, 2)); |
|
1147 |
|
|
1148 | 1149 |
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2); |
1149 | 1150 |
|
1150 |
push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
|
1151 |
push(@{ $form->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
|
|
1152 |
push(@{ $form->{taxrate} },
|
|
1153 |
$form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
|
1154 |
push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
|
|
1151 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxbase} }, $form->format_amount($myconfig, $taxbase{$item}, 2));
|
|
1152 |
push(@{ $form->{TEMPLATE_ARRAYS}->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
|
1153 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} }, $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
|
1154 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
|
|
1155 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} }, $form->{"${item}_taxnumber"});
|
|
1155 | 1156 |
} |
1156 | 1157 |
|
1157 | 1158 |
$form->{nodiscount_subtotal} = $form->format_amount($myconfig, $form->{nodiscount_total}, 2); |
SL/Template.pm | ||
---|---|---|
79 | 79 |
return 0; |
80 | 80 |
} |
81 | 81 |
|
82 |
sub _get_loop_variable_value { |
|
83 |
my $self = shift; |
|
84 |
my $var = shift; |
|
85 |
my @indices = @_; |
|
82 |
sub _get_loop_variable { |
|
83 |
my $self = shift; |
|
84 |
my $var = shift; |
|
85 |
my $get_array = shift; |
|
86 |
my @indices = @_; |
|
86 | 87 |
|
87 |
my $form = $self->{form}; |
|
88 |
my $value = $form->{$var}; |
|
88 |
my $form = $self->{form}; |
|
89 |
my $value; |
|
90 |
|
|
91 |
if (($get_array || @indices) && (ref $form->{TEMPLATE_ARRAYS} eq 'HASH') && (ref $form->{TEMPLATE_ARRAYS}->{$var} eq 'ARRAY')) { |
|
92 |
$value = $form->{TEMPLATE_ARRAYS}->{$var}; |
|
93 |
} else { |
|
94 |
$value = $form->{$var}; |
|
95 |
} |
|
89 | 96 |
|
90 | 97 |
for (my $i = 0; $i < scalar(@indices); $i++) { |
91 | 98 |
last unless (ref($value) eq "ARRAY"); |
... | ... | |
104 | 111 |
my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]); |
105 | 112 |
my ($var, @options) = split(/\s+/, $1); |
106 | 113 |
|
107 |
my $value = $self->_get_loop_variable_value($var, @indices);
|
|
114 |
my $value = $self->_get_loop_variable($var, 0, @indices);
|
|
108 | 115 |
$value = $self->format_string($value) unless (grep(/^NOESCAPE$/, @options)); |
109 | 116 |
|
110 | 117 |
substr($text, $tag_pos, $tag_len, $value); |
... | ... | |
160 | 167 |
|
161 | 168 |
my ($form, $new_contents) = ($self->{"form"}, ""); |
162 | 169 |
|
163 |
my $ary = $form->{$var}; |
|
164 |
for (my $i = 0; $i < scalar(@indices); $i++) { |
|
165 |
last unless (ref($ary) eq "ARRAY"); |
|
166 |
$ary = $ary->[$indices[$i]]; |
|
167 |
} |
|
170 |
my $ary = $self->_get_loop_variable($var, 1, @indices); |
|
168 | 171 |
|
169 | 172 |
my $sum = 0; |
170 | 173 |
my $current_page = 1; |
... | ... | |
786 | 789 |
|
787 | 790 |
my ($form, $new_contents) = ($self->{"form"}, ""); |
788 | 791 |
|
789 |
my $ary = $form->{$var}; |
|
790 |
for (my $i = 0; $i < scalar(@indices); $i++) { |
|
791 |
last unless (ref($ary) eq "ARRAY"); |
|
792 |
$ary = $ary->[$indices[$i]]; |
|
793 |
} |
|
792 |
my $ary = $self->_get_loop_variable($var, 1, @indices); |
|
794 | 793 |
|
795 | 794 |
for (my $i = 0; $i < scalar(@{$ary}); $i++) { |
796 | 795 |
$form->{"__first__"} = $i == 0; |
Auch abrufbar als: Unified diff
Die Funktionen in Template.pm zum Ersetzen von Schleifenvariablen so erweitert, dass die Schleifenarrays auch in $form->{TEMPLATE_ARRAYS} gesucht werden. Weiterhin die Druckmechanismen in IS.pm, OE.pm und DN.pm so angepasst, dass sie diese Unterebene benutzen, um die Positionswerte zu speichern. Dadurch wird verhindert, dass Elemente direkt in $form sowohl als Skalar als auch als Array benutzt werden (z.B. $form->{reqdate} = ... und push @{ $form->{reqdate} }, ...).