X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=ee77c822472979bf01d347700a039ec46b22ce4c;hb=599030d5e26bcef0f9850ddbbedba106ded70ebb;hp=844abf5b588bd10d22f980ddcc4dac9252521ccf;hpb=cd3dc84b8687e1571c7012d91a5138b9444c246c;p=kivitendo-erp.git diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index 844abf5b5..ee77c8224 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -54,7 +54,7 @@ sub edit_config { "$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||; @@ -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||; @@ -174,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||; @@ -260,36 +260,19 @@ 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}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - |; - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "1", "paymentuntil", "BR", "trigger1"); - } else { + $form->{title} = $locale->text('Start Dunning Process'); + $form->{nextsub} = "show_invoices"; - # without JavaScript Calendar - $button1 = - qq||; - } - $form->{fokus} = "search.customer"; + $form->{jsscript} = 1; + $form->{fokus} = "search.customer"; $form->{javascript} .= qq||; - $form->header; + $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| @@ -319,10 +302,6 @@ sub add { | . $locale->text('Notes') . qq| - - | . $locale->text('Payment until') . qq| - $button1 - @@ -390,17 +369,17 @@ sub show_invoices { "$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|| . NTI($cgi->checkbox('-name' => 'selectall_active', '-label' => $locale->text('Active?'), - '-checked' => 1, + '-checked' => 0, '-onclick' => "checkbox_check_all('selectall_active', 'active_', 1, " . scalar(@{ $form->{DUNNINGS} }) . ")")) . qq||; $column_header{email} = @@ -430,7 +409,7 @@ sub show_invoices { qq|| . $locale->text('Invdate') . qq||; - $column_header{invamount} = + $column_header{amount} = qq|| . $locale->text('Amount') . qq||; @@ -440,7 +419,7 @@ sub show_invoices { . qq||; $column_header{interest} = qq|| - . $locale->text('Total Interest') + . $locale->text('Interest') . qq||; $form->header; @@ -455,11 +434,11 @@ sub show_invoices { - + |; - map { print "$column_header{$_}\n" } @column_index; + map { print "$column_header{$_}\n" if $column_header{$_}; } @column_index; print qq| @@ -474,33 +453,39 @@ sub show_invoices { |; - $form->{selectdunning} =~ s/ selected//g; - if ($ref->{next_dunning_config_id} ne "") { - $form->{selectdunning} =~ s/value=$ref->{next_dunning_config_id}/value=$ref->{next_dunning_config_id} selected/; - } - - - $dunning = qq||; - + $form->{selectdunning} =~ s/ selected//g; + if ($ref->{next_dunning_config_id} ne "") { + $form->{selectdunning} =~ s/value=$ref->{next_dunning_config_id}/value=$ref->{next_dunning_config_id} selected/; + } - $column_data{dunning_description} = qq||; + $column_data{dunning_description} = + qq||; + $column_data{dunning_description_next} = + qq||; my $active = ($ref->{active}) ? "checked" : ""; $column_data{active} = qq||; my $email = ($ref->{email}) ? "checked" : ""; - $column_data{email} = - qq||; - $column_data{next_duedate} = qq||; + $column_data{email} = + qq||; + $column_data{next_duedate} = qq||; $column_data{inv_duedate} = qq||; $column_data{invdate} = qq||; $column_data{invnumber} = qq||; $column_data{customername} = qq||; - $column_data{invamount} = qq||; - $column_data{fee} = qq||; - $column_data{interest} = qq||; - + map { $column_data{$_} = + qq|| + } qw(amount fee interest); map { print "$column_data{$_}\n" } @column_index; @@ -578,55 +563,64 @@ 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)) { - push(@{ $form->{inv_ids} }, $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 (scalar(@{ $form->{inv_ids} }) != 0) { - 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} = [ $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 + # /saving the history + $form->redirect($locale->text('Dunning Process started for selected invoices!')); $lxdebug->leave_sub(); } - + sub set_email { $lxdebug->enter_sub(); @@ -878,7 +872,7 @@ sub show_dunning { . qq||; $column_header{interest} = qq||; $form->header; @@ -931,8 +925,7 @@ sub show_dunning { - foreach (qw(dunning_date dunning_duedate duedate transdate customername - amount fee interest)) { + foreach (qw(dunning_date dunning_duedate duedate transdate customername amount fee interest)) { my $col = $columns{$_} ? $columns{$_} : $_; $column_data{$col} = ""; }
$form->{title}$form->{title}
$ref->{dunning_level}: $dunning| + . qq|| + . qq|| + . ($ref->{dunning_level} ? $ref->{dunning_level} : " ") + . qq|| + . qq|| + . qq|$ref->{next_duedate}$ref->{next_duedate}$ref->{duedate}$ref->{transdate}$ref->{invnumber}$ref->{customername}$ref->{amount}$ref->{fee}$ref->{interest}| + . H($form->format_amount(\%myconfig, $ref->{$_} * 1, -2)) + . qq|| - . $locale->text('Total Interest') + . $locale->text('Interest') . qq|" . H($ref->{$_}) . "