2107 |
2107 |
}
|
2108 |
2108 |
}
|
2109 |
2109 |
|
|
2110 |
sub _map_keys_to_arrays {
|
|
2111 |
my ($items, $keys, $array) = @_;
|
|
2112 |
|
|
2113 |
for my $key (@$keys) {
|
|
2114 |
# handle nested keys
|
|
2115 |
if ($key =~ /\./) {
|
|
2116 |
my ($k1, $k2) = split /\./, $key;
|
|
2117 |
$array->{$key} = [ map { $_->{$k1}->{$k2} } @$items ];
|
|
2118 |
} else {
|
|
2119 |
$array->{$key} = [ map { $_->{$key} } @$items ];
|
|
2120 |
}
|
|
2121 |
}
|
|
2122 |
}
|
|
2123 |
|
|
2124 |
sub add_legacy_template_arrays {
|
|
2125 |
my ($print_form) = @_;
|
|
2126 |
|
|
2127 |
# extract loop variables (items and taxes) from the rose db object
|
|
2128 |
# and add them to the form, in the format that the built-in template parser expects
|
|
2129 |
#
|
|
2130 |
# using the keys that are used in the latex template: template/print/marei/sales_reclamation.tex
|
|
2131 |
|
|
2132 |
my $items_sorted = $print_form->{reclamation}->items_sorted;
|
|
2133 |
|
|
2134 |
my @keys = qw( position part.partnumber description longdescription reqdate serialnumber projectnumber reason.description
|
|
2135 |
reason_description_ext qty_as_number unit sellprice_as_number discount_as_number discount_as_percent linetotal );
|
|
2136 |
# (nested keys: part.partnumber, reason.description)
|
|
2137 |
|
|
2138 |
my %template_arrays;
|
|
2139 |
_map_keys_to_arrays($items_sorted, \@keys, \%template_arrays);
|
|
2140 |
|
|
2141 |
my $tax_items = $print_form->{reclamation}->taxes;
|
|
2142 |
my @tax_keys = qw( tax.taxdescription amount );
|
|
2143 |
_map_keys_to_arrays($tax_items, \@tax_keys, \%template_arrays);
|
|
2144 |
|
|
2145 |
$print_form->{TEMPLATE_ARRAYS} = \%template_arrays;
|
|
2146 |
}
|
|
2147 |
|
2110 |
2148 |
sub generate_pdf {
|
2111 |
2149 |
my ($reclamation, $pdf_ref, $params) = @_;
|
2112 |
2150 |
|
... | ... | |
2127 |
2165 |
# Make reclamation available in template
|
2128 |
2166 |
$print_form->{reclamation} = $reclamation;
|
2129 |
2167 |
|
|
2168 |
# add variables for printing with the built-in parser
|
|
2169 |
$reclamation->flatten_to_form($print_form, format_amounts => 1);
|
|
2170 |
add_legacy_template_arrays($print_form);
|
|
2171 |
|
2130 |
2172 |
my $template_ext;
|
2131 |
2173 |
my $template_type;
|
2132 |
2174 |
if ($print_form->{format} =~ /(opendocument|oasis)/i) {
|
Reclamation Controller: Support für Drucken via internem Kivi parser hinzugefügt
Dazu werden die benötigten Druck Variablen aus dem Rose DB objekt
ins template array geschrieben.