my $template = SL::Template::create(type => 'PlainText', form => $form, myconfig => $myconfig);
my $mail = Mailer->new();
my $template = SL::Template::create(type => 'PlainText', form => $form, myconfig => $myconfig);
my $mail = Mailer->new();
$mail->{from} = $myconfig->{email};
$mail->{to} = $ref->{recipient};
$mail->{subject} = $template->parse_block($ref->{email_subject});
$mail->{from} = $myconfig->{email};
$mail->{to} = $ref->{recipient};
$mail->{subject} = $template->parse_block($ref->{email_subject});
c.greeting, c.contact, c.phone, c.fax, c.homepage,
c.email, c.taxincluded, c.business_id, c.taxnumber, c.iban,
c.ustid,
c.greeting, c.contact, c.phone, c.fax, c.homepage,
c.email, c.taxincluded, c.business_id, c.taxnumber, c.iban,
c.ustid,
- cfg.interest_rate, cfg.template AS formname,
+ cfg.interest_rate, cfg.template AS formname, cfg.dunning_level,
cfg.email_subject, cfg.email_body, cfg.email_attachment,
d.transdate AS dunning_date,
(SELECT SUM(fee)
cfg.email_subject, cfg.email_body, cfg.email_attachment,
d.transdate AS dunning_date,
(SELECT SUM(fee)
'name' => $form->get_formname_translation('dunning') . "_${dunning_id}.pdf" };
$form->get_employee_data('prefix' => 'employee', 'id' => $form->{employee_id});
$form->get_employee_data('prefix' => 'salesman', 'id' => $form->{salesman_id});
'name' => $form->get_formname_translation('dunning') . "_${dunning_id}.pdf" };
$form->get_employee_data('prefix' => 'employee', 'id' => $form->{employee_id});
$form->get_employee_data('prefix' => 'salesman', 'id' => $form->{salesman_id});
+ $form->{attachment_type} = "dunning";
+ if ( $form->{dunning_level} ) {
+ $form->{attachment_type} .= $form->{dunning_level} if $form->{dunning_level} < 4;
+ }
+ $form->{attachment_filename} = $form->get_formname_translation($form->{attachment_type}) . "_${dunning_id}.pdf";
+ $form->{attachment_id} = $form->{invoice_id};
- my ($ar_id, $template) = selectrow_query($form, $dbh, $query, $dunning_id);
+ my ($ar_id, $invoice_id, $template, $dunning_level) = selectrow_query($form, $dbh, $query, $dunning_id);
translation_type => 'greetings::' . ($form->{cp_gender} eq 'f' ? 'female' : 'male'),
language_id => $form->{language_id},
allow_fallback => 1);
translation_type => 'greetings::' . ($form->{cp_gender} eq 'f' ? 'female' : 'male'),
language_id => $form->{language_id},
allow_fallback => 1);