Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0ce671d4

Von Cem Aydin vor 2 Monaten hinzugefügt

  • ID 0ce671d4ba74162f33e5da256b9730aadb9fbfe3
  • Vorgänger 9ad6dd6e

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.

Unterschiede anzeigen:

SL/Controller/Reclamation.pm
2163 2163
  }
2164 2164
}
2165 2165

  
2166
sub _map_keys_to_arrays {
2167
  my ($items, $keys, $array) = @_;
2168

  
2169
  for my $key (@$keys) {
2170
    # handle nested keys
2171
    if ($key =~ /\./) {
2172
      my ($k1, $k2) = split /\./, $key;
2173
      $array->{$key} = [ map { $_->{$k1}->{$k2} } @$items ];
2174
    } else {
2175
      $array->{$key} = [ map { $_->{$key} } @$items ];
2176
    }
2177
  }
2178
}
2179

  
2180
sub add_legacy_template_arrays {
2181
  my ($print_form) = @_;
2182

  
2183
  # extract loop variables (items and taxes) from the rose db object
2184
  # and add them to the form, in the format that the built-in template parser expects
2185
  #
2186
  # using the keys that are used in the latex template: template/print/marei/sales_reclamation.tex
2187

  
2188
  my $items_sorted = $print_form->{reclamation}->items_sorted;
2189

  
2190
  my @keys = qw( position part.partnumber description longdescription reqdate serialnumber projectnumber reason.description
2191
    reason_description_ext qty_as_number unit sellprice_as_number discount_as_number discount_as_percent linetotal );
2192
  # (nested keys: part.partnumber, reason.description)
2193

  
2194
  my %template_arrays;
2195
  _map_keys_to_arrays($items_sorted, \@keys, \%template_arrays);
2196

  
2197
  my $tax_items = $print_form->{reclamation}->taxes;
2198
  my @tax_keys = qw( tax.taxdescription amount );
2199
  _map_keys_to_arrays($tax_items, \@tax_keys, \%template_arrays);
2200

  
2201
  $print_form->{TEMPLATE_ARRAYS} = \%template_arrays;
2202
}
2203

  
2166 2204
sub generate_pdf {
2167 2205
  my ($reclamation, $pdf_ref, $params) = @_;
2168 2206

  
......
2183 2221
  # Make reclamation available in template
2184 2222
  $print_form->{reclamation} = $reclamation;
2185 2223

  
2224
  # add variables for printing with the built-in parser
2225
  $reclamation->flatten_to_form($print_form, format_amounts => 1);
2226
  add_legacy_template_arrays($print_form);
2227

  
2186 2228
  my $template_ext;
2187 2229
  my $template_type;
2188 2230
  if ($print_form->{format} =~ /(opendocument|oasis)/i) {

Auch abrufbar als: Unified diff