X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fdn.pl;h=01658ab10edf0dc9b0b56868ee5f6768707e4425;hb=9be50d3a150fde70377e0f10bc25d10cd155557b;hp=52f6cd55d058c3c8864ff03819c76738167e6a58;hpb=fa654209d149de56340fa28d3f57678bb81562c9;p=kivitendo-erp.git
diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl
index 52f6cd55d..01658ab10 100644
--- a/bin/mozilla/dn.pl
+++ b/bin/mozilla/dn.pl
@@ -31,35 +31,69 @@
#
#======================================================================
+use POSIX;
+
use SL::IS;
use SL::PE;
use SL::DN;
-use Data::Dumper;
+use SL::ReportGenerator;
require "bin/mozilla/common.pl";
+require "bin/mozilla/reportgenerator.pl";
require "bin/mozilla/io.pl";
-require "bin/mozilla/arap.pl";
+
+use strict;
1;
sub edit_config {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $main::auth->assert('config');
DN->get_config(\%myconfig, \%$form);
+ $form->get_lists('charts' => { 'key' => 'ALL_CHARTS',
+ 'transdate' => 'current_date' });
+
+ $form->{SELECT_AR_AMOUNT} = [];
+ $form->{SELECT_AR} = [];
+
+ foreach my $chart (@{ $form->{ALL_CHARTS} }) {
+ $chart->{LINKS} = { map { $_, 1 } split m/:/, $chart->{link} };
+
+ if ($chart->{LINKS}->{AR}) {
+ $chart->{AR_selected} = "selected" if $chart->{id} == $form->{AR};
+ push @{ $form->{SELECT_AR} }, $chart;
+ }
+
+ if ($chart->{LINKS}->{AR_amount}) {
+ $chart->{AR_amount_fee_selected} = "selected" if $chart->{id} == $form->{AR_amount_fee};
+ $chart->{AR_amount_interest_selected} = "selected" if $chart->{id} == $form->{AR_amount_interest};
+ push @{ $form->{SELECT_AR_AMOUNT} }, $chart;
+ }
+ }
- $form->{title} = $locale->text('Edit Dunning Process Config');
- $form->{callback} ||= build_std_url("action=edit_config");
- $form->{rowcount} = 1 + scalar @{ $form->{DUNNING} };
- $form->{rowcount_odd} = $form->{rowcount} % 2;
+ $form->{title} = $locale->text('Edit Dunning Process Config');
+ $form->{callback} ||= build_std_url("action=edit_config");
$form->header();
print $form->parse_html_template("dunning/edit_config");
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub add {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $main::auth->assert('dunning_edit');
# setup customer selection
$form->all_vc(\%myconfig, "customer", "AR");
@@ -68,20 +102,24 @@ sub add {
$form->{SHOW_CUSTOMER_SELECTION} = $form->{all_customer} && scalar @{ $form->{all_customer} };
$form->{SHOW_DUNNING_LEVEL_SELECTION} = $form->{DUNNING} && scalar @{ $form->{DUNNING} };
- $form->{SHOW_DEPARTMENT_SELECTION} = $form->{all_departments} && scalar @{ $form->{all_departments} };
+ $form->{SHOW_DEPARTMENT_SELECTION} = $form->{all_departments} && scalar @{ $form->{all_departments} || [] };
$form->{title} = $locale->text('Start Dunning Process');
- $form->{jsscript} = 1;
- $form->{fokus} = "search.customer";
$form->header();
print $form->parse_html_template("dunning/add");
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub show_invoices {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $main::auth->assert('dunning_edit');
DN->get_invoices(\%myconfig, \%$form);
$form->{title} = $locale->text('Start Dunning Process');
@@ -92,23 +130,40 @@ sub show_invoices {
if ($row->{next_dunning_config_id}) {
map { $_->{SELECTED} = $_->{id} == $row->{next_dunning_config_id} } @{ $row->{DUNNING_CONFIG } };
}
- map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, -2) } qw(amount fee interest);
+ map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, -2) } qw(amount open_amount fee interest);
+
+ if ($row->{'language_id'}) {
+ $row->{language} = SL::DB::Manager::Language->find_by_or_create('id' => $row->{'language_id'})->{'description'};
+ }
}
+ $form->get_lists('printers' => 'printers',
+ 'languages' => 'languages');
+
+ $form->{type} = 'dunning';
$form->{rowcount} = scalar @{ $form->{DUNNINGS} };
- $form->{jsscript} = 1;
- $form->{callback} ||= build_std_url("action=show_invoices", qw(login password customer invnumber ordnumber groupinvoices minamount dunning_level notes));
+ $form->{callback} ||= build_std_url("action=show_invoices", qw(customer invnumber ordnumber groupinvoices minamount dunning_level notes));
- $form->{PRINT_OPTIONS} = print_options(1);
+ $form->{PRINT_OPTIONS} = print_options('inline' => 1,
+ 'no_queue' => 1,
+ 'no_postscript' => 1,
+ 'no_html' => 1,
+ 'no_opendocument' => 1,);
$form->header();
print $form->parse_html_template("dunning/show_invoices");
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub save {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $main::auth->assert('config');
for my $i (1 .. $form->{rowcount}) {
if ($form->{"dunning_description_$i"} ne "") {
@@ -122,23 +177,31 @@ 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->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
$form->{addition} = "SAVED FOR DUNNING";
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->save_history;
}
- # /saving the history
+ # /saving the history
$form->redirect($locale->text('Dunning Process Config saved!'));
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub save_dunning {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $main::auth->assert('dunning_edit');
my $active=1;
my @rows = ();
undef($form->{DUNNING_PDFS});
+ my $saved_language_id = $form->{language_id};
+
if ($form->{groupinvoices}) {
my %dunnings_for;
@@ -154,6 +217,7 @@ sub save_dunning {
push @{ $level }, { "row" => $i,
"invoice_id" => $form->{"inv_id_$i"},
"customer_id" => $form->{"customer_id_$i"},
+ "language_id" => $form->{"language_id_$i"},
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
"email" => $form->{"email_$i"}, };
}
@@ -161,8 +225,10 @@ sub save_dunning {
foreach my $levels (values %dunnings_for) {
foreach my $level (values %{ $levels }) {
next unless scalar @{ $level };
-
- DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail);
+ if (!$form->{force_lang}) {
+ $form->{language_id} = @{$level}[0]->{language_id};
+ }
+ DN->save_dunning(\%myconfig, $form, $level);
}
}
@@ -173,409 +239,289 @@ sub save_dunning {
my $level = [ { "row" => $i,
"invoice_id" => $form->{"inv_id_$i"},
"customer_id" => $form->{"customer_id_$i"},
+ "language_id" => $form->{"language_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->{force_lang}) {
+ $form->{language_id} = @{$level}[0]->{language_id};
+ }
+ DN->save_dunning(\%myconfig, $form, $level);
}
}
+ $form->{language_id} = $saved_language_id;
+
if($form->{DUNNING_PDFS}) {
- DN->melt_pdfs(\%myconfig, \%$form,$spool);
+ DN->melt_pdfs(\%myconfig, $form, $form->{copies});
}
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
+ $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
$form->{addition} = "DUNNING STARTED";
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->save_history;
}
# /saving the history
- $form->redirect($locale->text('Dunning Process started for selected invoices!'));
+ if ($form->{media} eq 'printer') {
+ delete $form->{callback};
+ $form->redirect($locale->text('Dunning Process started for selected invoices!'));
+ }
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub set_email {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+ my $form = $main::form;
+ my $locale = $main::locale;
- my $callback = "$form->{script}?action=set_email&";
- map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
- (qw(login password name input_subject input_body input_attachment email_subject email_body email_attachment), grep({ /^[fl]_/ } keys %$form)));
+ $main::auth->assert('dunning_edit');
- if ($form->{email_attachment}) {
- $form->{email_attachment} = "checked";
- }
$form->{"title"} = $locale->text("Set eMail text");
- $form->header();
+ $form->header(no_layout => 1);
print($form->parse_html_template("dunning/set_email"));
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub search {
- $lxdebug->enter_sub();
- # setup customer selection
- $form->all_vc(\%myconfig, "customer", "AR");
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $main::auth->assert('dunning_edit');
+
+ $form->get_lists("customers" => "ALL_CUSTOMERS",
+ "departments" => "ALL_DEPARTMENTS");
+ $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
DN->get_config(\%myconfig, \%$form);
- if (@{ $form->{all_customer} }) {
- map { $customer .= "