X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=e418fa28fff78e7f3c3281898f164eb9c443dabe;hb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44;hp=627f6963340f74c548de25cc519839ecc22383fd;hpb=8de8e5398d67e7afdcf42951f020b813128aea73;p=kivitendo-erp.git diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index 627f69633..e418fa28f 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -31,11 +31,14 @@ # #====================================================================== -use POSIX; +use POSIX qw(strftime); use SL::IS; use SL::PE; use SL::DN; +use SL::DB::Dunning; +use SL::Helper::Flash; +use SL::Locale::String qw(t8); use SL::ReportGenerator; require "bin/mozilla/common.pl"; @@ -105,8 +108,6 @@ sub add { $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"); @@ -144,7 +145,6 @@ sub show_invoices { $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)); $form->{PRINT_OPTIONS} = print_options('inline' => 1, @@ -154,8 +154,6 @@ sub show_invoices { 'no_opendocument' => 1,); $form->header(); - $form->{onload} = "document.getElementsByName('language_id')[0].disabled = - !document.getElementsByName('force_lang')[0].checked;"; print $form->parse_html_template("dunning/show_invoices"); $main::lxdebug->leave_sub(); @@ -256,7 +254,8 @@ sub save_dunning { $form->{language_id} = $saved_language_id; - if($form->{DUNNING_PDFS}) { + if (scalar @{ $form->{DUNNING_PDFS} }) { + $form->{dunning_id} = strftime("%Y%m%d", localtime time) if scalar @{ $form->{DUNNING_PDFS}} > 1; DN->melt_pdfs(\%myconfig, $form, $form->{copies}); } @@ -285,7 +284,7 @@ sub set_email { $main::auth->assert('dunning_edit'); $form->{"title"} = $locale->text("Set eMail text"); - $form->header(); + $form->header(no_layout => 1); print($form->parse_html_template("dunning/set_email")); $main::lxdebug->leave_sub(); @@ -302,7 +301,7 @@ sub search { $form->get_lists("customers" => "ALL_CUSTOMERS", "departments" => "ALL_DEPARTMENTS"); - $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); + $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]); DN->get_config(\%myconfig, \%$form); @@ -310,16 +309,10 @@ sub search { $form->{SHOW_DEPARTMENT_DDBOX} = scalar @{ $form->{ALL_CUSTOMERS} }; $form->{SHOW_DUNNING_LEVELS} = scalar @{ $form->{DUNNING} }; - $form->{jsscript} = 1; $form->{title} = $locale->text('Dunnings'); - $form->{fokus} = "search.customer"; $form->header(); - $form->{onload} = qq|focus()| - . qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')| - . qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; - print $form->parse_html_template("dunning/search"); $main::lxdebug->leave_sub(); @@ -460,8 +453,6 @@ sub show_dunning { $report->set_options_from_form(); - $form->{onload} = "document.getElementsByName('language_id')[0].disabled = - !document.getElementsByName('force_lang')[0].checked;"; $report->generate_with_headers(); $main::lxdebug->leave_sub(); @@ -485,6 +476,29 @@ sub print_dunning { $main::lxdebug->leave_sub(); } +sub delete { + $main::auth->assert('dunning_edit'); + + my @dunning_ids = map { $::form->{"dunning_id_$_"} } grep { $::form->{"selected_$_"} } (1..$::form->{rowcount}); + + if (!scalar @dunning_ids) { + $::form->error($::locale->text('No dunnings have been selected for printing.')); + } + + my $dunnings = SL::DB::Manager::Dunning->get_all(query => [ dunning_id => \@dunning_ids ]); + + SL::DB::Dunning->new->db->with_transaction(sub { + for my $dunning (@$dunnings) { + SL::DB::Manager::Invoice->find_by(id => $dunning->trans_id)->update_attributes(dunning_config_id => undef); + $dunning->delete; + } + }); + + flash('info', t8('#1 dunnings have been deleted', scalar @$dunnings)); + + search(); +} + sub print_multiple { $main::lxdebug->enter_sub(); @@ -511,6 +525,7 @@ sub print_multiple { if (!$form->{force_lang}) { $form->{language_id} = $language_ids[$i]; } + $form->{dunning_id} = $dunning_id; DN->print_invoice_for_fees(\%myconfig, $form, $dunning_id); DN->print_dunning(\%myconfig, $form, $dunning_id); $i++; @@ -518,7 +533,7 @@ sub print_multiple { $form->{language_id} = $saved_language_id; if (scalar @{ $form->{DUNNING_PDFS} }) { - $form->{dunning_id} = strftime("%Y%m%d", localtime time); + $form->{dunning_id} = strftime("%Y%m%d", localtime time) if scalar @{ $form->{DUNNING_PDFS}} > 1; DN->melt_pdfs(\%myconfig, $form, $form->{copies}); if ($form->{media} eq 'printer') { @@ -537,4 +552,14 @@ sub continue { call_sub($main::form->{nextsub}); } +sub dispatcher { + foreach my $action (qw(delete print_multiple)) { + if ($::form->{"action_${action}"}) { + call_sub($action); + return; + } + } + + $::form->error($::locale->text('No action defined.')); +} # end of main