X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=1992ce8108cec2916c09750db8aa363cd7a40239;hb=8299e7bc0d4463d5ba08e1feaccd8faa60f5c5ae;hp=e79283a6dde98b0eb41e2faaa37b28642e825665;hpb=54e4131e091831e00a861fe2c4f53e344b87ddca;p=kivitendo-erp.git
diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl
index e79283a6d..1992ce810 100644
--- a/bin/mozilla/dn.pl
+++ b/bin/mozilla/dn.pl
@@ -105,7 +105,7 @@ sub edit_config {
@@ -448,12 +439,12 @@ sub show_invoices {
-
@@ -566,6 +550,12 @@ sub save {
}
DN->save_config(\%myconfig, \%$form);
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{addition} = "SAVED FOR DUNNING";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
$form->redirect($locale->text('Dunning Process Config saved!'));
$lxdebug->leave_sub();
@@ -580,19 +570,14 @@ sub save_dunning {
if ($form->{groupinvoices}) {
while ($active) {
$lastcustomer = 0;
- $form->{inv_ids} = "";
+ $form->{inv_ids} = [];
$active = 0;
@rows = ();
for my $i (1 .. $form->{rowcount}) {
$form->{"active_$i"} *= 1;
$lastcustomer = $form->{"customer_id_$i"} unless ($lastcustomer);
- #print(STDERR qq|LASTCUSTOMER $lastcustomer AKTUELL $form->{"customer_id_$i"} ACTIVE? $form->{"active_$i"} active $active\n Zeile $i|);
if ($form->{"active_$i"} && ($form->{"customer_id_$i"} == $lastcustomer)) {
- if ($form->{inv_ids}) {
- $form->{inv_ids} .= qq|,$form->{"inv_id_$i"}|;
- } else {
- $form->{inv_ids} = qq|($form->{"inv_id_$i"}|;
- }
+ push(@{ $form->{inv_ids} }, $form->{"inv_id_$i"});
$form->{"active_$i"} = 0;
$form->{"customer_id_$i"} = 0;
push(@rows, $i);
@@ -602,28 +587,29 @@ sub save_dunning {
$form->{"customer_id_$i"} = 0;
}
}
- if ($form->{inv_ids} ne "") {
- $form->{inv_ids} .= ")";
- #print(STDERR "Rufe save_dunning_auf für Zeile $form->{inv_ids} von Kunde $lastcustomer\n");
- DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath,$spool, $sendmail);
+ if (scalar(@{ $form->{inv_ids} }) != 0) {
+ DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail);
}
}
} else {
for my $i (1 .. $form->{rowcount}) {
if ($form->{"active_$i"}) {
@rows = ();
- $form->{inv_ids} = qq|($form->{"inv_id_$i"})|;
+ $form->{inv_ids} = [ $form->{"inv_id_$i"} ];
push(@rows, $i);
- #print(STDERR "Rufe save_dunning_auf für Zeile $i\n");
- DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath,$spool, $sendmail);
+ DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail);
}
}
}
- #print(STDERR Dumper($form->{DUNNING_PDFS}));
if($form->{DUNNING_PDFS}) {
DN->melt_pdfs(\%myconfig, \%$form,$spool);
}
-
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{addition} = "DUNNING STARTED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
$form->redirect($locale->text('Dunning Process started for selected invoices!'));
$lxdebug->leave_sub();
@@ -781,7 +767,6 @@ sub search {
$button4
-
@@ -892,7 +877,7 @@ sub show_dunning {
- $form->{title} |
+ $form->{title} |
|;
@@ -901,11 +886,28 @@ sub show_dunning {
print qq|
|;
+
+ my %columns = (
+ "dunning_duedate" => "next_duedate",
+ "duedate" => "inv_duedate",
+ "transdate" => "invdate",
+ "amount" => "invamount",
+ );
+
my $i = 0;
+ my $j = 0;
+ my ($previous_dunning_id, $first_row_for_dunning);
foreach $ref (@{ $form->{DUNNINGS} }) {
-
$i++;
- my $j = $i % 2;
+
+ if ($previous_dunning_id != $ref->{dunning_id}) {
+ $j++;
+ $j = $j % 2;
+ $first_row_for_dunning = 1;
+ } else {
+ $first_row_for_dunning = 0;
+ }
+ $previous_dunning_id = $ref->{dunning_id};
print qq|
@@ -913,23 +915,28 @@ sub show_dunning {
- $dunning = qq||;
-
-
- $column_data{dunning_description} = qq|$ref->{dunning_description} | |;
- my $active = "checked";
- $column_data{dunning_date} = qq|$ref->{dunning_date} | |;
- $column_data{next_duedate} = qq|$ref->{dunning_duedate} | |;
-
- $column_data{inv_duedate} = qq|$ref->{duedate} | |;
- $column_data{invdate} = qq|$ref->{transdate} | |;
- $column_data{invnumber} = qq|{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$form->{callback}>$ref->{invnumber} | |;
- $column_data{customername} = qq|$ref->{customername} | |;
- $column_data{invamount} = qq|$ref->{amount} | |;
- $column_data{fee} = qq|$ref->{fee} | |;
- $column_data{interest} = qq|$ref->{interest} | |;
+ foreach (qw(dunning_date dunning_duedate duedate transdate customername
+ amount fee interest)) {
+ my $col = $columns{$_} ? $columns{$_} : $_;
+ $column_data{$col} = "" . H($ref->{$_}) . " | ";
+ }
+ if ($first_row_for_dunning) {
+ $column_data{dunning_description} =
+ qq|{$_}) } qw(login path password callback))) .
+ qq|">| . H($ref->{dunning_description}) . qq| | |;
+ } else {
+ $column_data{dunning_description} = qq| | |;
+ $column_data{customername} = qq| | |;
+ }
+ $column_data{invnumber} =
+ qq|{id}) .
+ join(map({ "&${_}=" . E($form->{$_}) } qw(login path password callback))) .
+ qq|">| . H($ref->{invnumber}) . qq| | |;
map { print "$column_data{$_}\n" } @column_index;
@@ -960,14 +967,6 @@ sub show_dunning {
{path}>
{login}>
{password}>
-|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
@@ -979,5 +978,21 @@ sub show_dunning {
$lxdebug->leave_sub();
}
+
+sub print_dunning {
+ $lxdebug->enter_sub();
+
+ DN->print_dunning(\%myconfig, \%$form, $form->{dunning_id}, $userspath, $spool, $sendmail);
+
+ if($form->{DUNNING_PDFS}) {
+ DN->melt_pdfs(\%myconfig, \%$form,$spool);
+ } else {
+ $form->redirect($locale->text('Could not create dunning copy!'));
+ }
+
+ $lxdebug->leave_sub();
+
+}
+
# end of main