X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=f9485c554299bb2d7d2c066922bfc25bcd27aa7b;hb=bb5ee43d0ddff8f8b57ce0f15a5664b26c110d1f;hp=ee77c822472979bf01d347700a039ec46b22ce4c;hpb=fd6900cca59ac4a35d5fa4c20db91165f9310ea3;p=kivitendo-erp.git diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index ee77c8224..f9485c554 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -31,510 +31,121 @@ # #====================================================================== +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"; 1; sub edit_config { $lxdebug->enter_sub(); - # edit all dunning config data + $auth->assert('config'); - $form->header; DN->get_config(\%myconfig, \%$form); - $form->{title} = $locale->text('Edit Dunning Process Config'); - - $form->{callback} = - "$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_rate template); - - $column_header{dunning_level} = - qq|| - . $locale->text('Dunning Level') - . qq||; - $column_header{dunning_description} = - qq|| - . $locale->text('Dunning Description') - . qq||; - $column_header{active} = - qq|| - . $locale->text('Active?') - . qq||; - $column_header{auto} = - qq|| - . $locale->text('Auto Send?') - . qq||; - $column_header{email} = - qq|| - . $locale->text('eMail Send?') - . qq||; - $column_header{payment_terms} = - qq|| - . $locale->text('Fristsetzung') - . qq||; - $column_header{terms} = - qq|| - . $locale->text('Duedate +Days') - . qq||; - $column_header{fee} = - qq|| - . $locale->text('Fee') - . qq||; - $column_header{interest_rate} = - qq|| - . $locale->text('Interest Rate') - . qq||; - $column_header{template} = - qq|| - . $locale->text('Template') - . qq||; - print qq| - - - -
{script}> - - - - - - - - |; - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - my $i = 0; - foreach $ref (@{ $form->{DUNNING} }) { - - $i++; - my $j = $i % 2; - - print qq| - -|; - - - $column_data{dunning_level} = - qq||; - $column_data{dunning_description} = qq||; - my $active = ($ref->{active}) ? "checked" : ""; - $column_data{active} = - qq||; - my $email = ($ref->{email}) ? "checked" : ""; - $column_data{email} = - qq||; + $form->get_lists('charts' => { 'key' => 'ALL_CHARTS', + 'transdate' => 'current_date' }); - my $auto = ($ref->{auto}) ? "checked" : ""; - $column_data{auto} = - qq||; - $column_data{payment_terms} = qq||; - $column_data{terms} = qq||; - $column_data{fee} = qq||; - $column_data{interest_rate} = qq||; - $column_data{template} = qq||; + $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; + } - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; + 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; + } } - $i++; - my $j = $i % 2; - - print qq| - -|; - - - $column_data{dunning_level} = - qq||; - $column_data{dunning_description} = qq||; - $column_data{active} = - qq||; - my $email = ""; - $column_data{email} = - qq||; - my $auto = ""; - $column_data{auto} = - qq||; - $column_data{payment_terms} = qq||; - $column_data{terms} = qq||; - $column_data{fee} = qq||; - $column_data{interest_rate} = qq||; - $column_data{template} = qq||; + $form->{title} = $locale->text('Edit Dunning Process Config'); + $form->{callback} ||= build_std_url("action=edit_config"); - $form->{rowcount} = $i; - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - - - print qq| -
$form->{title}
$i%
$i%
- - - -
- - - -
-{script}> - - - - -{login}> -{password}> - - - -
- - - -|; + $form->header(); + print $form->parse_html_template("dunning/edit_config"); $lxdebug->leave_sub(); } sub add { $lxdebug->enter_sub(); + + $auth->assert('dunning_edit'); + # setup customer selection $form->all_vc(\%myconfig, "customer", "AR"); DN->get_config(\%myconfig, \%$form); - if (@{ $form->{all_customer} }) { - map { $customer .= "\n" - } (@{ $form->{DUNNING} }); - } - $dunning_level = qq| - - | . $locale->text('Next Dunning Level') . qq| - - - | if $form->{selectdunning_level}; - - # departments - if (@{ $form->{all_departments} }) { - $form->{selectdepartment} = ""; - } - } - - - $form->{nextsub} = "save_dunning"; - - $form->{jsscript} = 1; - $form->{javascript} .= qq||; - - $form->{callback} = - "$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 dunning_description_next active email customername invnumber invdate inv_duedate amount next_duedate fee interest ); - - $column_header{dunning_description} = - qq|| - . $locale->text('Current / Next Level') - . qq||; - $column_header{active} = - qq|| - . 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|| - . 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|| - . $locale->text('Customername') - . qq||; - $column_header{invnumber} = - qq|| - . $locale->text('Invno.') - . qq||; - $column_header{inv_duedate} = - qq|| - . $locale->text('Inv. Duedate') - . qq||; - $column_header{next_duedate} = - qq|| - . $locale->text('Dunning Duedate') - . qq||; - $column_header{invdate} = - qq|| - . $locale->text('Invdate') - . qq||; - $column_header{amount} = - qq|| - . $locale->text('Amount') - . qq||; - $column_header{fee} = - qq|| - . $locale->text('Total Fees') - . qq||; - $column_header{interest} = - qq|| - . $locale->text('Interest') - . qq||; - - $form->header; - - - print qq| - - - -
{script}> - - - - - - - - |; - map { print "$column_header{$_}\n" if $column_header{$_}; } @column_index; - - print qq| - -|; - my $i = 0; - foreach $ref (@{ $form->{DUNNINGS} }) { - - $i++; - my $j = $i % 2; - - print qq| - -|; + foreach my $row (@{ $form->{DUNNINGS} }) { + $row->{DUNNING_CONFIG} = [ map +{ %{ $_ } }, @{ $form->{DUNNING_CONFIG} } ]; - $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/; + if ($row->{next_dunning_config_id}) { + map { $_->{SELECTED} = $_->{id} == $row->{next_dunning_config_id} } @{ $row->{DUNNING_CONFIG } }; } - - $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{inv_duedate} = qq||; - $column_data{invdate} = qq||; - $column_data{invnumber} = qq||; - $column_data{customername} = qq||; - - map { $column_data{$_} = - qq|| - } qw(amount fee interest); - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; + map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, -2) } qw(amount fee interest); } - $form->{rowcount} = $i; - - print qq| -
$form->{title}
| - . qq|| - . qq|| - . ($ref->{dunning_level} ? $ref->{dunning_level} : " ") - . qq|| - . qq|| - . qq|$ref->{next_duedate}$ref->{duedate}$ref->{transdate}$ref->{invnumber}$ref->{customername}| - . H($form->format_amount(\%myconfig, $ref->{$_} * 1, -2)) - . qq|
- - - -
- -|; - print_options(); - print qq| -
-{script}> - - - - - + $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(customer invnumber ordnumber groupinvoices minamount dunning_level notes)); -{login}> -{password}> - - - -
- - - -|; + $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(); - } sub save { $lxdebug->enter_sub(); + $auth->assert('config'); + for my $i (1 .. $form->{rowcount}) { if ($form->{"dunning_description_$i"} ne "") { $form->isblank("dunning_level_$i", $locale->text('Dunning Level missing in row '). $i); @@ -551,7 +162,7 @@ sub save { $form->{addition} = "SAVED FOR DUNNING"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history $form->redirect($locale->text('Dunning Process Config saved!')); $lxdebug->leave_sub(); @@ -560,6 +171,8 @@ sub save { sub save_dunning { $lxdebug->enter_sub(); + $auth->assert('dunning_edit'); + my $active=1; my @rows = (); undef($form->{DUNNING_PDFS}); @@ -587,7 +200,7 @@ sub save_dunning { foreach my $level (values %{ $levels }) { next unless scalar @{ $level }; - DN->save_dunning(\%myconfig, \%$form, $level, $userspath, $spool, $sendmail); + DN->save_dunning(\%myconfig, $form, $level, $userspath, $spool); } } @@ -600,12 +213,12 @@ sub save_dunning { "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); + DN->save_dunning(\%myconfig, $form, $level, $userspath, $spool); } } if($form->{DUNNING_PDFS}) { - DN->melt_pdfs(\%myconfig, \%$form,$spool); + DN->melt_pdfs(\%myconfig, $form, $form->{copies}); } # saving the history @@ -616,7 +229,10 @@ sub save_dunning { } # /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(); } @@ -624,14 +240,8 @@ sub save_dunning { sub set_email { $lxdebug->enter_sub(); + $auth->assert('dunning_edit'); - 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))); - - if ($form->{email_attachment}) { - $form->{email_attachment} = "checked"; - } $form->{"title"} = $locale->text("Set eMail text"); $form->header(); print($form->parse_html_template("dunning/set_email")); @@ -641,178 +251,29 @@ sub set_email { sub search { $lxdebug->enter_sub(); - # setup customer selection - $form->all_vc(\%myconfig, "customer", "AR"); + + $auth->assert('dunning_edit'); + + $form->get_lists("customers" => "ALL_CUSTOMERS", + "departments" => "ALL_DEPARTMENTS"); DN->get_config(\%myconfig, \%$form); - if (@{ $form->{all_customer} }) { - map { $customer .= "\n" - } (@{ $form->{DUNNING} }); - } - $dunning_level = qq| - - | . $locale->text('Next Dunning Level') . qq| - - - | if $form->{selectdunning_level}; - - # departments - if (@{ $form->{all_departments} }) { - $form->{selectdepartment} = "