Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a2b43e37

Von Jan Büren vor etwa 4 Jahren hinzugefügt

  • ID a2b43e372e56297b9900c24145058d4124e5cbeb
  • Vorgänger eefbbed3
  • Nachfolger 15710f52

Mahnungen: Optional auch Original-Rechnung hinzufügen

Unterschiede anzeigen:

SL/DN.pm
51 51
use SL::Util qw(trim);
52 52
use SL::DB;
53 53

  
54
use File::Copy;
55

  
54 56
use strict;
55 57

  
56 58
sub get_config {
......
338 340

  
339 341
  my @invoice_ids;
340 342
  my ($next_dunning_config_id, $customer_id);
341
  my $send_email = 0;
343
  my ($send_email, $print_invoice) = (0, 0);
342 344

  
343 345
  foreach my $row (@{ $rows }) {
344 346
    push @invoice_ids, $row->{invoice_id};
......
348 350
    @values = ($row->{next_dunning_config_id}, $row->{invoice_id});
349 351
    do_statement($form, $h_update_ar, $q_update_ar, @values);
350 352

  
351
    $send_email |= $row->{email};
353
    $send_email       |= $row->{email};
354
    $print_invoice    |= $row->{print_invoice};
352 355

  
353 356
    my $next_config_id = conv_i($row->{next_dunning_config_id});
354 357
    my $invoice_id     = conv_i($row->{invoice_id});
......
371 374
  $self->print_invoice_for_fees($myconfig, $form, $dunning_id, $dbh);
372 375
  $self->print_dunning($myconfig, $form, $dunning_id, $dbh);
373 376

  
377
  if ($print_invoice) {
378
    $self->print_original_invoices($myconfig, $form, $_, $dbh) for @invoice_ids;
379
  }
374 380

  
375 381
  if ($send_email) {
376 382
    $self->send_email($myconfig, $form, $dunning_id, $dbh);
......
1076 1082

  
1077 1083
}
1078 1084

  
1085
sub print_original_invoices {
1086
  my ($self, $myconfig, $form, $invoice_id) = @_;
1087
  # get one invoice as object and print to pdf
1088
  my $invoice = SL::DB::Invoice->new(id => $invoice_id)->load;
1089

  
1090
  die "Invalid invoice object" unless ref($invoice) eq 'SL::DB::Invoice';
1091

  
1092
  my $print_form          = Form->new('');
1093
  $print_form->{type}     = 'invoice';
1094
  $print_form->{formname} = 'invoice',
1095
  $print_form->{format}   = 'pdf',
1096
  $print_form->{media}    = 'file';
1097
  # no language override, should always be the object's language
1098
  $invoice->flatten_to_form($print_form, format_amounts => 1);
1099
  $print_form->prepare_for_printing;
1100

  
1101
  my $filename = SL::Helper::CreatePDF->create_pdf(
1102
                   template  => 'invoice.tex',
1103
                   variables => $print_form,
1104
                   return    => 'file_name',
1105
  );
1106

  
1107
  my $spool       = $::lx_office_conf{paths}->{spool};
1108
  my ($volume, $directory, $file_name) = File::Spec->splitpath($filename);
1109
  my $full_file_name                   = File::Spec->catfile($spool, $file_name);
1110

  
1111
  move($filename, $full_file_name) or die "The move operation failed: $!";
1112

  
1113
  # form get_formname_translation should use language_id_$i
1114
  my $saved_reicpient_locale = $form->{recipient_locale};
1115
  $form->{recipient_locale}  = $invoice->language;
1116

  
1117
  push @{ $form->{DUNNING_PDFS} }, $file_name;
1118
  push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$file_name",
1119
                                           'name' => $form->get_formname_translation('invoice') . "_" . $invoice->invnumber . ".pdf" };
1120

  
1121
  $form->{recipient_locale}  = $saved_reicpient_locale;
1122
}
1123

  
1079 1124
1;
bin/mozilla/dn.pl
226 226
                          "customer_id"            => $form->{"customer_id_$i"},
227 227
                          "language_id"            => $form->{"language_id_$i"},
228 228
                          "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
229
                          "print_invoice"          => $form->{"include_invoice_$i"},
229 230
                          "email"                  => $form->{"email_$i"}, };
230 231
    }
231 232

  
locale/de/all
1653 1653
  'Include in drop-down menus'  => 'In Aufklappmenü aufnehmen',
1654 1654
  'Include invalid warehouses ' => 'Ungültige Lager berücksichtigen',
1655 1655
  'Include invoices with direct debit' => 'Inklusive Rechnungen mit Lastschrifteinzug',
1656
  'Include original Invoices?'  => 'Original-Rechnung hinzufügen?',
1656 1657
  'Includeable in reports'      => 'In Berichten anzeigbar',
1657 1658
  'Included in reports by default' => 'In Berichten standardmäßig enthalten',
1658 1659
  'Including'                   => 'Enthaltene',
templates/webpages/dunning/show_invoices.html
28 28
    [% L.checkbox_tag('selectall_email', checkall='INPUT[name*=email_]', checked=all_email) %]
29 29
    <label for="selectall_email">[% 'eMail?' | $T8 %]</label>
30 30
   </th>
31
   <th class="listheading">
32
    [% L.checkbox_tag('selectall_include_invoices', checkall='INPUT[name*=include_invoice_]', checked=all_include_invoices) %]
33
    <label for="selectall_include_invoices">[% 'Include original Invoices?' | $T8 %]</label>
34
   </th>
31 35

  
32 36
   <th class="listheading">[% 'Customername' | $T8 %]</th>
33 37
   <th class="listheading">[% 'Department' | $T8 %]</th>
......
63 67

  
64 68
     <td><input type="checkbox" name="active_[% loop.count %]" value="1" [% IF row.active %]checked[% END %]></td>
65 69
     <td><input type="checkbox" name="email_[% loop.count %]" value="1" [% IF row.email %]checked[% END %]></td>
70
     <td><input type="checkbox" name="include_invoice_[% loop.count %]" value="1" [% IF row.include_invoices %]checked[% END %]></td>
66 71
     <td><input type="hidden" name="customername_[% loop.count %]" size="6" value="[% HTML.escape(row.customername) %]">[% HTML.escape(row.customername) %]</td>
67 72
     <td><input type="hidden" name="department_[% loop.count %]" size="6" value="[% HTML.escape(row.departmentname) %]">[% HTML.escape(row.departmentname) %]</td>
68 73
     <td><input type="hidden" name="language_id_[% loop.count %]" size="6" value="[% HTML.escape(row.language_id) %]">[% HTML.escape(row.language) %]</td>

Auch abrufbar als: Unified diff