X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDN.pm;h=0ac071c6f93d6c6d9ece8df12063b360df31ca7d;hb=8f64093b4d58bd4bd72cd7465b7e402ad949eaf1;hp=6486455910186427fca79d71dd24032731d43ef2;hpb=6ff01fdb61880344c2826c86955ef4c1e8f47db4;p=kivitendo-erp.git diff --git a/SL/DN.pm b/SL/DN.pm index 648645591..0ac071c6f 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -41,6 +41,8 @@ use SL::Mailer; use SL::MoreCommon; use SL::Template; +use strict; + sub get_config { $main::lxdebug->enter_sub(); @@ -457,7 +459,7 @@ sub get_invoices { push(@values, $form->{minamount}); } - $query = + my $query = qq|SELECT id FROM dunning_config WHERE dunning_level = (SELECT MAX(dunning_level) FROM dunning_config)|; @@ -512,7 +514,7 @@ sub get_invoices { $form->{DUNNINGS} = []; - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { next if ($ref->{pastdue} < $ref->{terms}); $ref->{interest} = $form->round_amount($ref->{interest}, 2); @@ -537,7 +539,7 @@ sub get_dunning { # connect to database my $dbh = $form->dbconnect($myconfig); - $where = qq| WHERE (da.trans_id = a.id)|; + my $where = qq| WHERE (da.trans_id = a.id)|; my @values; @@ -616,9 +618,11 @@ sub get_dunning { qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount, ct.name AS customername, ct.id AS customer_id, a.duedate, da.fee, da.interest, dn.dunning_description, da.transdate AS dunning_date, - da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id + da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id, + e2.name AS salesman FROM ar a - JOIN customer ct ON (a.customer_id = ct.id), dunning da + JOIN customer ct ON (a.customer_id = ct.id) + LEFT JOIN employee e2 ON (a.salesman_id = e2.id), dunning da LEFT JOIN dunning_config dn ON (da.dunning_config_id = dn.id) $where ORDER BY $sortorder|; @@ -663,9 +667,10 @@ sub melt_pdfs { $form->error($main::locale->text('Could not spawn the printer command.')) unless $out; } else { + my $dunning_filename = $form->get_formname_translation('dunning'); $out = IO::File->new('>-'); $out->print(qq|Content-Type: Application/PDF\n| . - qq|Content-Disposition: attachment; filename="dunning_${dunning_id}.pdf"\n\n|); + qq|Content-Disposition: attachment; filename="${dunning_filename}_${dunning_id}.pdf"\n\n|); } while (my $line = <$in>) { @@ -712,7 +717,7 @@ sub print_dunning { my $sth = prepare_execute_query($form, $dbh, $query, $dunning_id); my $first = 1; - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { if ($first) { $form->{TEMPLATE_ARRAYS} = {}; map({ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} = []; } keys(%{$ref})); @@ -726,9 +731,10 @@ sub print_dunning { $query = qq|SELECT - c.id AS customer_id, c.name, c.street, c.zipcode, c.city, - c.country, c.department_1, c.department_2, c.email, c.customernumber, - -- contact information + c.id AS customer_id, c.name, c.street, c.zipcode, c.city, + c.country, c.department_1, c.department_2, c.email, c.customernumber, + c.greeting, c.contact, c.phone, c.fax, c.homepage, + c.email, c.taxincluded, c.business_id, c.taxnumber, c.iban, co.* FROM dunning d LEFT JOIN ar ON (d.trans_id = ar.id) @@ -736,7 +742,7 @@ sub print_dunning { LEFT JOIN contacts co ON (ar.cp_id = co.cp_id) WHERE (d.dunning_id = ?) LIMIT 1|; - $ref = selectfirst_hashref_query($form, $dbh, $query, $dunning_id); + my $ref = selectfirst_hashref_query($form, $dbh, $query, $dunning_id); map { $form->{$_} = $ref->{$_} } keys %{ $ref }; $query = @@ -831,7 +837,7 @@ sub print_invoice_for_fees { FROM ar LEFT JOIN customer c ON (ar.customer_id = c.id) WHERE ar.id = ?|; - $ref = selectfirst_hashref_query($form, $dbh, $query, $ar_id); + my $ref = selectfirst_hashref_query($form, $dbh, $query, $ar_id); map { $form->{$_} = $ref->{$_} } keys %{ $ref }; $query = qq|SELECT * FROM employee WHERE login = ?|;