X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=ee77c822472979bf01d347700a039ec46b22ce4c;hb=599030d5e26bcef0f9850ddbbedba106ded70ebb;hp=50c602b408e778bdee621f7f8c4a15000c199a5e;hpb=d63831cbaf332f5280fd92e6134229fa4c109e00;p=kivitendo-erp.git
diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl
index 50c602b40..ee77c8224 100644
--- a/bin/mozilla/dn.pl
+++ b/bin/mozilla/dn.pl
@@ -36,8 +36,8 @@ use SL::PE;
use SL::DN;
use Data::Dumper;
-require "$form->{path}/io.pl";
-require "$form->{path}/arap.pl";
+require "bin/mozilla/io.pl";
+require "bin/mozilla/arap.pl";
1;
@@ -51,10 +51,10 @@ sub edit_config {
$form->{title} = $locale->text('Edit Dunning Process Config');
$form->{callback} =
- "$form->{script}?action=edit_config&path=$form->{path}&login=$form->{login}&password=$form->{password}"
+ "$form->{script}?action=edit_config&login=$form->{login}&password=$form->{password}"
unless $form->{callback};
- @column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest template);
+ @column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest_rate template);
$column_header{dunning_level} =
qq|
|
@@ -88,7 +88,7 @@ sub edit_config {
qq| | |
. $locale->text('Fee')
. qq| | |;
- $column_header{interest} =
+ $column_header{interest_rate} =
qq||
. $locale->text('Interest Rate')
. qq| | |;
@@ -105,7 +105,7 @@ sub edit_config {
- $form->{title} |
+ $form->{title} |
|;
@@ -141,7 +141,7 @@ sub edit_config {
$column_data{payment_terms} = qq| | |;
$column_data{terms} = qq| | |;
$column_data{fee} = qq| | |;
- $column_data{interest} = qq|% | |;
+ $column_data{interest_rate} = qq|% | |;
$column_data{template} = qq| | |;
@@ -163,9 +163,8 @@ sub edit_config {
$column_data{dunning_level} =
qq|$i | |;
$column_data{dunning_description} = qq| | |;
- my $active = "";
$column_data{active} =
- qq| | |;
+ qq| | |;
my $email = "";
$column_data{email} =
qq| | |;
@@ -175,7 +174,7 @@ sub edit_config {
$column_data{payment_terms} = qq| | |;
$column_data{terms} = qq| | |;
$column_data{fee} = qq| | |;
- $column_data{interest} = qq|% | |;
+ $column_data{interest_rate} = qq|% | |;
$column_data{template} = qq| | |;
@@ -202,19 +201,11 @@ sub edit_config {
-{path}>
{login}>
{password}>
|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
+ . $locale->text('Save') . qq|">
@@ -269,34 +260,21 @@ sub add {
|
| if $form->{selectdepartment};
- $form->{title} = $locale->text('Start Dunning Process');
- $form->{nextsub} = "show_invoices";
- # use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
- $jsscript = "";
- if ($form->{jsscript}) {
+ $form->{title} = $locale->text('Start Dunning Process');
+ $form->{nextsub} = "show_invoices";
- # with JavaScript Calendar
- $button1 = qq|
-
- text('button') . qq|> |
- |;
+ $form->{jsscript} = 1;
+ $form->{fokus} = "search.customer";
+ $form->{javascript} .= qq||;
+ $form->header();
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "1", "paymentuntil", "BR", "trigger1");
- } else {
+ $onload = qq|focus()|;
+ $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
- # without JavaScript Calendar
- $button1 =
- qq| | |;
- }
- $form->{fokus} = "search.customer";
- $form->header;
print qq|
-
+
@@ -353,7 +326,6 @@ sub add {
{nextsub}>
-{path}>
{login}>
{password}>
@@ -389,24 +361,33 @@ sub show_invoices {
$form->{nextsub} = "save_dunning";
-
+
+ $form->{jsscript} = 1;
+ $form->{javascript} .= qq||;
+
$form->{callback} =
- "$form->{script}?action=show_invoices&path=$form->{path}&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&paymentuntil=$form->{paymentuntil}&groupinvoices=$form->{groupinvoices}&minamount=$form->{minamount}&dunning_level=$form->{dunning_level}¬es=$form->{notes}"
+ "$form->{script}?action=show_invoices&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&paymentuntil=$form->{paymentuntil}&groupinvoices=$form->{groupinvoices}&minamount=$form->{minamount}&dunning_level=$form->{dunning_level}¬es=$form->{notes}"
unless $form->{callback};
- @column_index = qw(dunning_description active email customername invnumber invdate inv_duedate invamount next_duedate fee interest );
+ @column_index = qw(dunning_description dunning_description_next active email customername invnumber invdate inv_duedate amount next_duedate fee interest );
$column_header{dunning_description} =
- qq||
+ qq| | |
. $locale->text('Current / Next Level')
. qq| | |;
$column_header{active} =
qq||
- . $locale->text('Active?')
+ . NTI($cgi->checkbox('-name' => 'selectall_active',
+ '-label' => $locale->text('Active?'),
+ '-checked' => 0,
+ '-onclick' => "checkbox_check_all('selectall_active', 'active_', 1, " . scalar(@{ $form->{DUNNINGS} }) . ")"))
. qq| | |;
$column_header{email} =
qq||
- . $locale->text('eMail?')
+ . NTI($cgi->checkbox('-name' => 'selectall_email',
+ '-label' => $locale->text('eMail?'),
+ '-checked' => 0,
+ '-onclick' => "checkbox_check_all('selectall_email', 'email_', 1, " . scalar(@{ $form->{DUNNINGS} }) . ")"))
. qq| | |;
$column_header{customername} =
qq||
@@ -428,7 +409,7 @@ sub show_invoices {
qq| | |
. $locale->text('Invdate')
. qq| | |;
- $column_header{invamount} =
+ $column_header{amount} =
qq||
. $locale->text('Amount')
. qq| | |;
@@ -438,7 +419,7 @@ sub show_invoices {
. qq||;
$column_header{interest} =
qq||
- . $locale->text('Total Interest')
+ . $locale->text('Interest')
. qq| | |;
$form->header;
@@ -453,11 +434,11 @@ sub show_invoices {
|;
-&print_options;
-print qq|
+ print_options();
+ print qq|
@@ -569,6 +545,13 @@ sub save {
}
DN->save_config(\%myconfig, \%$form);
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
+ $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,61 +563,71 @@ sub save_dunning {
my $active=1;
my @rows = ();
undef($form->{DUNNING_PDFS});
+
if ($form->{groupinvoices}) {
- while ($active) {
- $lastcustomer = 0;
- $form->{inv_ids} = "";
- $active = 0;
- @rows = ();
- for my $i (1 .. $form->{rowcount}) {
- $form->{"active_$i"} *= 1;
- $lastcustomer = $form->{"customer_id_$i"} unless ($lastcustomer);
- 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"}|;
- }
- $form->{"active_$i"} = 0;
- $form->{"customer_id_$i"} = 0;
- push(@rows, $i);
- } elsif ($form->{"active_$i"}) {
- $active = 1;
- } else {
- $form->{"customer_id_$i"} = 0;
- }
- }
- if ($form->{inv_ids} ne "") {
- $form->{inv_ids} .= ")";
- DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath,$spool, $sendmail);
+ my %dunnings_for;
+
+ for my $i (1 .. $form->{rowcount}) {
+ next unless ($form->{"active_$i"});
+
+ $dunnings_for{$form->{"customer_id_$i"}} ||= {};
+ my $dunning_levels = $dunnings_for{$form->{"customer_id_$i"}};
+
+ $dunning_levels->{$form->{"next_dunning_config_id_$i"}} ||= [];
+ my $level = $dunning_levels->{$form->{"next_dunning_config_id_$i"}};
+
+ push @{ $level }, { "row" => $i,
+ "invoice_id" => $form->{"inv_id_$i"},
+ "customer_id" => $form->{"customer_id_$i"},
+ "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
+ "email" => $form->{"email_$i"}, };
+ }
+
+ foreach my $levels (values %dunnings_for) {
+ foreach my $level (values %{ $levels }) {
+ next unless scalar @{ $level };
+
+ DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail);
}
}
+
} else {
for my $i (1 .. $form->{rowcount}) {
- if ($form->{"active_$i"}) {
- @rows = ();
- $form->{inv_ids} = qq|($form->{"inv_id_$i"})|;
- push(@rows, $i);
- DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath,$spool, $sendmail);
- }
+ next unless $form->{"active_$i"};
+
+ my $level = [ { "row" => $i,
+ "invoice_id" => $form->{"inv_id_$i"},
+ "customer_id" => $form->{"customer_id_$i"},
+ "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
+ "email" => $form->{"email_$i"}, } ];
+ DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail);
}
}
+
if($form->{DUNNING_PDFS}) {
DN->melt_pdfs(\%myconfig, \%$form,$spool);
}
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
+ $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();
}
-
+
sub set_email {
$lxdebug->enter_sub();
my $callback = "$form->{script}?action=set_email&";
map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
- (qw(login path password name input_subject input_body input_attachment email_subject email_body email_attachment), grep({ /^[fl]_/ } keys %$form)));
+ (qw(login password name input_subject input_body input_attachment email_subject email_body email_attachment), grep({ /^[fl]_/ } keys %$form)));
if ($form->{email_attachment}) {
$form->{email_attachment} = "checked";
@@ -700,22 +693,22 @@ sub search {
# with JavaScript Calendar
$button1 = qq|
-
+ |
text('button') . qq|> |
|;
$button2 = qq|
-
+ |
text('button') . qq|> |
|;
$button3 = qq|
-
+ |
text('button') . qq|> |
|;
$button4 = qq|
-
+ |
text('button') . qq|> |
|;
@@ -727,19 +720,24 @@ sub search {
# without JavaScript Calendar
$button1 =
- qq| | |;
+ qq| | |;
$button2 =
- qq| | |;
- $button1 =
- qq| | |;
- $button1 =
- qq| | |;
+ qq| | |;
+ $button3 =
+ qq| | |;
+ $button4 =
+ qq| | |;
}
$form->{fokus} = "search.customer";
+ $form->{javascript} .= qq||;
$form->header;
+ $onload = qq|focus()|;
+ $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
+
print qq|
-
+