Mahnbericht: Nach Mahnungsnummer filtern können und diese Anzeigen
[kivitendo-erp.git] / bin / mozilla / dn.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2006
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 # MA 02110-1335, USA.
29 #======================================================================
30 #
31 # Dunning process module
32 #
33 #======================================================================
34
35 use POSIX qw(strftime);
36
37 use List::MoreUtils qw(none);
38
39 use SL::IS;
40 use SL::DN;
41 use SL::DB::Department;
42 use SL::DB::Dunning;
43 use SL::File;
44 use SL::Helper::Flash qw(flash);
45 use SL::Locale::String qw(t8);
46 use SL::Presenter::FileObject;
47 use SL::ReportGenerator;
48
49 require "bin/mozilla/common.pl";
50 require "bin/mozilla/reportgenerator.pl";
51 require "bin/mozilla/io.pl";
52
53 use strict;
54
55 1;
56
57 sub edit_config {
58   $main::lxdebug->enter_sub();
59
60   my $form     = $main::form;
61   my %myconfig = %main::myconfig;
62   my $locale   = $main::locale;
63
64   $main::auth->assert('config');
65
66   DN->get_config(\%myconfig, \%$form);
67   $form->get_lists('charts' => { 'key'       => 'ALL_CHARTS',
68                                  'transdate' => 'current_date' });
69
70   $form->{SELECT_AR_AMOUNT} = [];
71   $form->{SELECT_AR}        = [];
72
73   foreach my $chart (@{ $form->{ALL_CHARTS} }) {
74     $chart->{LINKS} = { map { $_, 1 } split m/:/, $chart->{link} };
75
76     if ($chart->{LINKS}->{AR}) {
77       $chart->{AR_selected} = "selected" if $chart->{id} == $form->{AR};
78       push @{ $form->{SELECT_AR} }, $chart;
79     }
80
81     if ($chart->{LINKS}->{AR_amount}) {
82       $chart->{AR_amount_fee_selected}      = "selected" if $chart->{id} == $form->{AR_amount_fee};
83       $chart->{AR_amount_interest_selected} = "selected" if $chart->{id} == $form->{AR_amount_interest};
84       push @{ $form->{SELECT_AR_AMOUNT} }, $chart;
85     }
86   }
87
88   $form->{title}      = $locale->text('Edit Dunning Process Config');
89   $form->{callback} ||= build_std_url("action=edit_config");
90
91   setup_dn_edit_config_action_bar();
92
93   $form->header();
94   print $form->parse_html_template("dunning/edit_config");
95
96   $main::lxdebug->leave_sub();
97 }
98
99 sub add {
100   $main::lxdebug->enter_sub();
101
102   my $form     = $main::form;
103   my %myconfig = %main::myconfig;
104   my $locale   = $main::locale;
105
106   $main::auth->assert('dunning_edit');
107
108   DN->get_config(\%myconfig, \%$form);
109
110   $form->get_lists("departments" => "ALL_DEPARTMENTS");
111
112   $form->{SHOW_DUNNING_LEVEL_SELECTION} = $form->{DUNNING}         && scalar @{ $form->{DUNNING} };
113   $form->{SHOW_DEPARTMENT_SELECTION}    = $form->{ALL_DEPARTMENTS} && scalar @{ $form->{ALL_DEPARTMENTS} || [] };
114
115   $form->{title}    = $locale->text('Start Dunning Process');
116
117   setup_dn_add_action_bar();
118   $form->header();
119
120   print $form->parse_html_template("dunning/add");
121
122   $main::lxdebug->leave_sub();
123 }
124
125 sub show_invoices {
126   $main::lxdebug->enter_sub();
127
128   my $form     = $main::form;
129   my %myconfig = %main::myconfig;
130   my $locale   = $main::locale;
131
132   $main::auth->assert('dunning_edit');
133
134   DN->get_invoices(\%myconfig, \%$form);
135   $form->{title} = $locale->text('Start Dunning Process');
136
137   foreach my $row (@{ $form->{DUNNINGS} }) {
138     $row->{DUNNING_CONFIG} = [ map +{ %{ $_ } }, @{ $form->{DUNNING_CONFIG} } ];
139
140     if ($row->{next_dunning_config_id}) {
141       map { $_->{SELECTED} = $_->{id} == $row->{next_dunning_config_id} } @{ $row->{DUNNING_CONFIG } };
142     }
143     map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, 2) } qw(amount open_amount fee interest);
144
145     if ($row->{'language_id'}) {
146       $row->{language} = SL::DB::Manager::Language->find_by_or_create('id' => $row->{'language_id'})->{'description'};
147     }
148   }
149
150   $form->get_lists('printers'  => 'printers',
151                    'languages' => 'languages');
152
153   $form->{type}           = 'dunning';
154   $form->{rowcount}       = scalar @{ $form->{DUNNINGS} };
155   $form->{callback}     ||= build_std_url("action=show_invoices", qw(customer invnumber ordnumber groupinvoices minamount dunning_level notes));
156
157   $form->{PRINT_OPTIONS}  = print_options('inline'          => 1,
158                                           'no_queue'        => 1,
159                                           'no_postscript'   => 1,
160                                           'no_html'         => 1,
161                                           'no_opendocument' => 1,);
162
163   setup_dn_show_invoices_action_bar();
164   $form->header();
165   print $form->parse_html_template("dunning/show_invoices");
166
167   $main::lxdebug->leave_sub();
168 }
169
170 sub save {
171   $main::lxdebug->enter_sub();
172
173   my $form     = $main::form;
174   my %myconfig = %main::myconfig;
175   my $locale   = $main::locale;
176
177   $main::auth->assert('config');
178
179   for my $i (1 .. $form->{rowcount}) {
180     if ($form->{"dunning_description_$i"} ne "") {
181       $form->isblank("dunning_level_$i", $locale->text('Dunning Level missing in row '). $i);
182       $form->isblank("dunning_description_$i", $locale->text('Dunning Description missing in row '). $i);
183       $form->isblank("terms_$i", $locale->text('Terms missing in row '). $i);
184       $form->isblank("payment_terms_$i", $locale->text('Payment Terms missing in row '). $i);
185     }
186   }
187
188   DN->save_config(\%myconfig, \%$form);
189   # saving the history
190   if(!exists $form->{addition} && $form->{id} ne "") {
191     $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
192     $form->{addition} = "SAVED FOR DUNNING";
193     $form->save_history;
194   }
195   # /saving the history
196   $form->redirect($locale->text('Dunning Process Config saved!'));
197
198   $main::lxdebug->leave_sub();
199 }
200
201 sub save_dunning {
202   $main::lxdebug->enter_sub();
203
204   my $form     = $main::form;
205   my %myconfig = %main::myconfig;
206   my $locale   = $main::locale;
207
208   $main::auth->assert('dunning_edit');
209
210   my $active=1;
211   my @rows = ();
212   undef($form->{DUNNING_PDFS});
213
214   my $saved_language_id = $form->{language_id};
215
216   if ($form->{groupinvoices} || $form->{l_include_credit_notes}) {
217     my %dunnings_for;
218
219     for my $i (1 .. $form->{rowcount}) {
220       next unless ($form->{"active_$i"});
221
222       $dunnings_for{$form->{"customer_id_$i"}} ||= {};
223       my $dunning_levels = $dunnings_for{$form->{"customer_id_$i"}};
224
225       $dunning_levels->{$form->{"next_dunning_config_id_$i"}} ||= [];
226       my $level = $dunning_levels->{$form->{"next_dunning_config_id_$i"}};
227
228       push @{ $level }, { "row"                    => $i,
229                           "invoice_id"             => $form->{"inv_id_$i"},
230                           "credit_note"            => $form->{"credit_note_$i"},
231                           "customer_id"            => $form->{"customer_id_$i"},
232                           "language_id"            => $form->{"language_id_$i"},
233                           "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
234                           "print_invoice"          => $form->{"include_invoice_$i"},
235                           "email"                  => $form->{"email_$i"}, };
236     }
237
238     foreach my $levels (values %dunnings_for) {
239       foreach my $level (values %{ $levels }) {
240         next unless scalar @{ $level };
241         if (!$form->{force_lang}) {
242           $form->{language_id} = @{$level}[0]->{language_id};
243         }
244         DN->save_dunning(\%myconfig, $form, $level);
245       }
246     }
247
248   } else {
249     for my $i (1 .. $form->{rowcount}) {
250       next unless $form->{"active_$i"};
251
252       my $level = [ { "row"                    => $i,
253                       "invoice_id"             => $form->{"inv_id_$i"},
254                       "customer_id"            => $form->{"customer_id_$i"},
255                       "language_id"            => $form->{"language_id_$i"},
256                       "next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
257                       "print_invoice"          => $form->{"include_invoice_$i"},
258                       "email"                  => $form->{"email_$i"}, } ];
259       if (!$form->{force_lang}) {
260         $form->{language_id} = @{$level}[0]->{language_id};
261       }
262       DN->save_dunning(\%myconfig, $form, $level);
263     }
264   }
265
266   $form->{language_id} = $saved_language_id;
267
268   if (scalar @{ $form->{DUNNING_PDFS} }) {
269     $form->{dunning_id} = strftime("%Y%m%d", localtime time) if scalar @{ $form->{DUNNING_PDFS}} > 1;
270     DN->melt_pdfs(\%myconfig, $form, $form->{copies});
271   }
272
273   # saving the history
274   if(!exists $form->{addition} && $form->{id} ne "") {
275     $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"};
276     $form->{addition} = "DUNNING STARTED";
277     $form->save_history;
278   }
279   # /saving the history
280
281   if ($form->{media} eq 'printer') {
282     delete $form->{callback};
283     $form->redirect($locale->text('Dunning Process started for selected invoices!'));
284   }
285
286   $main::lxdebug->leave_sub();
287 }
288
289 sub set_email {
290   $main::lxdebug->enter_sub();
291
292   my $form     = $main::form;
293   my $locale   = $main::locale;
294
295   $main::auth->assert('dunning_edit');
296
297   $form->{"title"} = $locale->text("Set eMail text");
298   $form->header(no_layout => 1);
299   print($form->parse_html_template("dunning/set_email"));
300
301   $main::lxdebug->leave_sub();
302 }
303
304 sub search {
305   $main::lxdebug->enter_sub();
306
307   my $form     = $main::form;
308   my %myconfig = %main::myconfig;
309   my $locale   = $main::locale;
310
311   $main::auth->assert('dunning_edit');
312
313   $form->get_lists("customers"   => "ALL_CUSTOMERS",
314                    "departments" => "ALL_DEPARTMENTS");
315   $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
316
317   DN->get_config(\%myconfig, \%$form);
318
319   $form->{SHOW_DUNNING_LEVELS}   = scalar @{ $form->{DUNNING} };
320
321   $form->{title}    = $locale->text('Dunnings');
322
323   setup_dn_search_action_bar();
324   $form->header();
325
326   print $form->parse_html_template("dunning/search");
327
328   $main::lxdebug->leave_sub();
329
330 }
331
332 sub show_dunning {
333   $main::lxdebug->enter_sub();
334
335   my $form     = $main::form;
336   my %myconfig = %main::myconfig;
337   my $locale   = $main::locale;
338   my $cgi      = $::request->{cgi};
339
340   $main::auth->assert('dunning_edit');
341
342   my @filter_field_list = qw(customer_id customer dunning_id dunning_level department_id invnumber ordnumber
343                              transdatefrom transdateto dunningfrom dunningto notes showold l_salesman salesman_id);
344
345   report_generator_set_default_sort('customername', 1);
346
347   DN->get_dunning(\%myconfig, \%$form);
348
349   if (!$form->{callback}) {
350     $form->{callback} = build_std_url("action=show_dunning", @filter_field_list);
351   }
352
353   $form->get_lists('printers'  => 'printers',
354                    'languages' => 'languages');
355
356   $form->{type}          = 'dunning';
357   $form->{PRINT_OPTIONS} = print_options('inline'          => 1,
358                                          'no_queue'        => 1,
359                                          'no_postscript'   => 1,
360                                          'no_html'         => 1,
361                                          'no_opendocument' => 1,);
362   $form->{title}         = $locale->text('Dunning overview');
363
364   my $report = SL::ReportGenerator->new(\%myconfig, $form);
365
366   $report->set_options('std_column_visibility' => 1,
367                        'title'                 => $form->{title});
368   $report->set_export_options('show_dunning', @filter_field_list, qw(sort sortdir));
369
370   my %column_defs         =  (
371     'checkbox'            => { 'text' => '', 'visible' => 'HTML' },
372     'dunning_description' => { 'text' => $locale->text('Dunning Level') },
373     'customername'        => { 'text' => $locale->text('Customername') },
374     'departmentname'      => { 'text' => $locale->text('Department') },
375     'language'            => { 'text' => $locale->text('Language') },
376     'invnumber'           => { 'text' => $locale->text('Invnumber') },
377     'transdate'           => { 'text' => $locale->text('Invdate') },
378     'duedate'             => { 'text' => $locale->text('Invoice Duedate') },
379     'amount'              => { 'text' => $locale->text('Amount') },
380     'dunning_id'          => { 'text' => $locale->text('Dunning number') },
381     'dunning_date'        => { 'text' => $locale->text('Dunning Date') },
382     'dunning_duedate'     => { 'text' => $locale->text('Dunning Duedate') },
383     'fee'                 => { 'text' => $locale->text('Total Fees') },
384     'interest'            => { 'text' => $locale->text('Interest') },
385     'salesman'            => { 'text' => $locale->text('Salesperson'), 'visible' => $form->{l_salesman} ? 1 : 0 },
386     'documents'           => { 'text' => $locale->text('Documents')  , 'visible' => $::instance_conf->get_doc_storage ? 1 : 0 },
387   );
388
389   $report->set_columns(%column_defs);
390   $report->set_column_order(qw(checkbox dunning_description dunning_id customername language invnumber transdate
391                                duedate amount dunning_date dunning_duedate fee interest salesman));
392   $report->set_sort_indicator($form->{sort}, $form->{sortdir});
393
394   my $edit_url  = sub { build_std_url('script=' . ($_[0]->{invoice} ? 'is' : 'ar') . '.pl', 'action=edit', 'callback') . '&id=' . $::form->escape($_[0]->{id}) };
395   my $print_url = sub { build_std_url('action=print_dunning', 'format=pdf', 'media=screen', 'dunning_id='.$_[0]->{dunning_id}, 'language_id=' . $_[0]->{language_id}) };
396   my $sort_url  = build_std_url('action=show_dunning', grep { $form->{$_} } @filter_field_list);
397
398   foreach my $name (qw(dunning_description customername invnumber transdate duedate dunning_date dunning_duedate salesman dunning_id)) {
399     my $sortdir                 = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
400     $column_defs{$name}->{link} = $sort_url . "&sort=$name&sortdir=$sortdir";
401   }
402
403   my %alignment = map { $_ => 'right' } qw(transdate duedate amount dunning_date dunning_duedate fee interest salesman dunning_id);
404
405   my ($current_dunning_rows, $previous_dunning_id, $first_row_for_dunning);
406
407   $current_dunning_rows  = [];
408   $first_row_for_dunning = 1;
409   $form->{rowcount}      = scalar @{ $form->{DUNNINGS} };
410
411   my $i = 0;
412
413   foreach my $ref (@{ $form->{DUNNINGS} }) {
414     $i++;
415
416     if ($previous_dunning_id != $ref->{dunning_id}) {
417       $report->add_data($current_dunning_rows) if (scalar @{ $current_dunning_rows });
418       $current_dunning_rows  = [];
419       $first_row_for_dunning = 1;
420     }
421
422     if ($ref->{'language_id'}) {
423       $ref->{language} = SL::DB::Manager::Language->find_by('id' => $ref->{'language_id'})->{'description'};
424     }
425
426     my $row = { };
427     foreach my $column (keys %{ $ref }) {
428       $row->{$column} = {
429         'data'  => $first_row_for_dunning || (none { $_ eq $column } qw(dunning_description customername dunning_id)) ? $ref->{$column} : '',
430
431         'align' => $alignment{$column},
432
433         'link'  => (  $column eq 'invnumber'           ? $edit_url->($ref)
434                     : $column eq 'dunning_description' ? $print_url->($ref)
435                     : $column eq 'dunning_id'          ? $print_url->($ref)
436                     :                                    ''),
437       };
438     }
439
440     $row->{checkbox} = !$first_row_for_dunning ? { } : {
441       'raw_data' =>   $cgi->hidden('-name' => "dunning_id_$i", '-value' => $ref->{dunning_id})
442                     . $cgi->checkbox('-name' => "selected_$i", '-value' => 1, '-label' => ''),
443       'valign'   => 'center',
444       'align'    => 'center',
445     };
446
447     if ($first_row_for_dunning) {
448       $row->{language} = {'raw_data' => $cgi->hidden('-name' => "language_id_$i", '-value' => $ref->{language_id})
449                                         . " $ref->{language}" };
450     } else {
451       $row->{language} = { };
452     }
453
454     if ($::instance_conf->get_doc_storage && $first_row_for_dunning) {
455       my @files  = SL::File->get_all_versions(object_id   => $ref->{dunning_id},
456                                               object_type => 'dunning',
457                                               file_type   => 'document',);
458       if (scalar @files) {
459         my $html          = join '<br>', map { SL::Presenter::FileObject::file_object($_) } @files;
460         my $text          = join "\n",   map { $_->file_name                              } @files;
461         $row->{documents} = { 'raw_data' => $html, data => $text };
462       } else {
463         $row->{documents} = { };
464       }
465     }
466
467     push @{ $current_dunning_rows }, $row;
468
469     $previous_dunning_id   = $ref->{dunning_id};
470     $first_row_for_dunning = 0;
471   }
472
473   $report->add_data($current_dunning_rows) if (scalar @{ $current_dunning_rows });
474
475   $report->set_options('raw_top_info_text'    => $form->parse_html_template('dunning/show_dunning_top'),
476                        'raw_bottom_info_text' => $form->parse_html_template('dunning/show_dunning_bottom'),
477                        'output_format'        => 'HTML',
478                        'attachment_basename'  => $locale->text('dunning_list') . strftime('_%Y%m%d', localtime time),
479     );
480
481   $report->set_options_from_form();
482
483   setup_dn_show_dunning_action_bar();
484   $report->generate_with_headers();
485
486   $main::lxdebug->leave_sub();
487
488 }
489
490 sub print_dunning {
491   $main::lxdebug->enter_sub();
492
493   my $form     = $main::form;
494
495   $main::auth->assert('dunning_edit');
496
497   $form->{rowcount}     = 1;
498   $form->{selected_1}   = 1;
499   $form->{dunning_id_1} = $form->{dunning_id};
500   $form->{language_id_1} = $form->{language_id};
501
502   print_multiple();
503
504   $main::lxdebug->leave_sub();
505 }
506
507 sub delete {
508   $main::auth->assert('dunning_edit');
509
510   my @dunning_ids = map { $::form->{"dunning_id_$_"} } grep { $::form->{"selected_$_"} } (1..$::form->{rowcount});
511
512   if (!scalar @dunning_ids) {
513     $::form->error($::locale->text('No dunnings have been selected for printing.'));
514   }
515
516   my $dunnings = SL::DB::Manager::Dunning->get_all(query => [ dunning_id => \@dunning_ids ]);
517
518   SL::DB::Dunning->new->db->with_transaction(sub {
519     for my $dunning (@$dunnings) {
520       SL::DB::Manager::Invoice->find_by(id => $dunning->trans_id)->update_attributes(dunning_config_id => undef);
521       $dunning->delete;
522     }
523   });
524
525   flash('info', t8('#1 dunnings have been deleted', scalar @$dunnings));
526
527   search();
528 }
529
530 sub print_multiple {
531   $main::lxdebug->enter_sub();
532
533   my $form     = $main::form;
534   my %myconfig = %main::myconfig;
535   my $locale   = $main::locale;
536
537   $main::auth->assert('dunning_edit');
538
539   $form->{title} = $locale->text('Print dunnings');
540
541   my @dunning_ids = map { $form->{"dunning_id_$_"} } grep { $form->{"selected_$_"} } (1..$form->{rowcount});
542   my @language_ids = map { $form->{"language_id_$_"} } grep { $form->{"selected_$_"} } (1..$form->{rowcount});
543
544   if (!scalar @dunning_ids) {
545     $form->error($locale->text('No dunnings have been selected for printing.'));
546   }
547
548   $form->{DUNNING_PDFS} = [];
549
550   my $saved_language_id = $form->{language_id};
551   my $i = 0;
552   foreach my $dunning_id (@dunning_ids) {
553     if (!$form->{force_lang}) {
554       $form->{language_id} = $language_ids[$i];
555     }
556     $form->{dunning_id} = $dunning_id;
557     DN->print_invoice_for_fees(\%myconfig, $form, $dunning_id);
558     DN->print_dunning(\%myconfig, $form, $dunning_id);
559
560     # print original dunned invoices, if they where printed on dunning run
561     my $dunnings = SL::DB::Manager::Dunning->get_all(where => [dunning_id => $dunning_id, original_invoice_printed => 1]);
562     DN->print_original_invoice(\%myconfig, $form, $dunning_id, $_->trans_id) for @$dunnings;
563
564     $i++;
565   }
566   $form->{language_id} = $saved_language_id;
567
568   if (scalar @{ $form->{DUNNING_PDFS} }) {
569     $form->{dunning_id} = strftime("%Y%m%d", localtime time) if scalar @{ $form->{DUNNING_PDFS}} > 1;
570     DN->melt_pdfs(\%myconfig, $form, $form->{copies});
571
572     if ($form->{media} eq 'printer') {
573       $form->header();
574       $form->info($locale->text('The dunnings have been printed.'));
575     }
576
577   } else {
578     $form->redirect($locale->text('Could not print dunning.'));
579   }
580
581   $main::lxdebug->leave_sub();
582 }
583
584 sub continue {
585   call_sub($main::form->{nextsub});
586 }
587
588 sub dispatcher {
589   foreach my $action (qw(delete print_multiple)) {
590     if ($::form->{"action_${action}"}) {
591       call_sub($action);
592       return;
593     }
594   }
595
596   $::form->error($::locale->text('No action defined.'));
597 }
598
599 sub setup_dn_add_action_bar {
600   my %params = @_;
601
602   for my $bar ($::request->layout->get('actionbar')) {
603     $bar->add(
604       action => [
605         t8('Search'),
606         submit    => [ '#form', { action => "show_invoices" } ],
607         accesskey => 'enter',
608       ],
609     );
610   }
611 }
612
613 sub setup_dn_show_invoices_action_bar {
614   my %params = @_;
615
616   for my $bar ($::request->layout->get('actionbar')) {
617     $bar->add(
618       action => [
619         t8('Create'),
620         submit    => [ '#form', { action => "save_dunning" } ],
621         checks    => [ [ 'kivi.check_if_entries_selected', '[name^=active_]' ] ],
622         accesskey => 'enter',
623         only_once => 1,
624       ],
625     );
626   }
627 }
628
629 sub setup_dn_search_action_bar {
630   my %params = @_;
631
632   for my $bar ($::request->layout->get('actionbar')) {
633     $bar->add(
634       action => [
635         t8('Search'),
636         submit    => [ '#form', { action => "show_dunning" } ],
637         accesskey => 'enter',
638       ],
639     );
640   }
641 }
642
643 sub setup_dn_show_dunning_action_bar {
644   my %params = @_;
645
646   for my $bar ($::request->layout->get('actionbar')) {
647     $bar->add(
648       action => [
649         t8('Print'),
650         submit    => [ '#form', { action => "print_multiple" } ],
651         checks    => [ [ 'kivi.check_if_entries_selected', '[name^=selected_]' ] ],
652         accesskey => 'enter',
653       ],
654
655       action => [
656         t8('Delete'),
657         submit  => [ '#form', { action => "delete" } ],
658         checks  => [ [ 'kivi.check_if_entries_selected', '[name^=selected_]' ] ],
659         confirm => $::locale->text('This resets the dunning process for the selected invoices. Posted dunning invoices will not be changed!'),
660       ],
661     );
662   }
663 }
664
665 sub setup_dn_edit_config_action_bar {
666   my %params = @_;
667
668   for my $bar ($::request->layout->get('actionbar')) {
669     $bar->add(
670       action => [
671         t8('Save'),
672         submit    => [ '#form', { action => "save" } ],
673         accesskey => 'enter',
674       ],
675     );
676   }
677 }
678
679 # end of main