X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=419b4f4bd5dad11509bfc56c38a25e9983c4c7c7;hb=549f187d3a2b1d15f96c4556714666ed954447bb;hp=bc6798c6f13dc2f432995c19d71081d49b2fc25e;hpb=aab626748ac82bb9c9c04e7d23c717ce2468fea3;p=kivitendo-erp.git
diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl
index bc6798c6f..419b4f4bd 100644
--- a/bin/mozilla/dn.pl
+++ b/bin/mozilla/dn.pl
@@ -34,6 +34,7 @@
use POSIX qw(strftime);
+use List::Util qw(notall);
use List::MoreUtils qw(none);
use SL::IS;
@@ -43,7 +44,9 @@ use SL::DB::Dunning;
use SL::File;
use SL::Helper::Flash qw(flash);
use SL::Locale::String qw(t8);
+use SL::Presenter::EmailJournal;
use SL::Presenter::FileObject;
+use SL::Presenter::WebdavObject;
use SL::ReportGenerator;
require "bin/mozilla/common.pl";
@@ -209,6 +212,7 @@ sub save_dunning {
my $active=1;
my @rows = ();
+ my @status;
undef($form->{DUNNING_PDFS});
my $saved_language_id = $form->{language_id};
@@ -241,7 +245,10 @@ sub save_dunning {
if (!$form->{force_lang}) {
$form->{language_id} = @{$level}[0]->{language_id};
}
- DN->save_dunning(\%myconfig, $form, $level);
+ my $rc = DN->save_dunning(\%myconfig, $form, $level);
+ $rc->{error} =~ s{\n}{
}g if $rc->{error};
+ push @status, { invnumbers => [map { $form->{'invnumber_' . $_->{row}} } @$level],
+ map { ( $_ => $rc->{$_} ) } qw(error dunning_id print_original_invoice send_email), };
}
}
@@ -259,15 +266,27 @@ sub save_dunning {
if (!$form->{force_lang}) {
$form->{language_id} = @{$level}[0]->{language_id};
}
- DN->save_dunning(\%myconfig, $form, $level);
+ my $rc = DN->save_dunning(\%myconfig, $form, $level);
+ $rc->{error} =~ s{\n}{
}g if $rc->{error};
+ push @status, { invnumbers => [map { $form->{'invnumber_' . $_->{row}} } @$level],
+ map { ( $_ => $rc->{$_} ) } qw(error dunning_id print_original_invoice send_email), };
}
}
$form->{language_id} = $saved_language_id;
- if (scalar @{ $form->{DUNNING_PDFS} }) {
+ my $pdf_filename;
+ my $pdf_content;
+ if ($form->{DUNNING_PDFS} && 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});
+ ($pdf_filename, $pdf_content) = DN->melt_pdfs(\%myconfig, $form, $form->{copies}, return_content => $form->{media} ne 'printer');
+
+ flash('info', t8('Dunning Process started for selected invoices!'));
+ if ($form->{media} eq 'printer') {
+ flash('info', t8('The PDF has been printed'));
+ } else {
+ flash('info', t8('The PDF has been created'));
+ }
}
# saving the history
@@ -278,10 +297,13 @@ sub save_dunning {
}
# /saving the history
- if ($form->{media} eq 'printer') {
- delete $form->{callback};
- $form->redirect($locale->text('Dunning Process started for selected invoices!'));
- }
+ setup_dn_status_action_bar();
+ $form->{"title"} = $locale->text("Dunning status");
+ $form->header();
+ print $form->parse_html_template('dunning/status', {
+ pdf_filename => $pdf_filename,
+ pdf_content => $pdf_content,
+ status => \@status, });
$main::lxdebug->leave_sub();
}
@@ -295,7 +317,10 @@ sub set_email {
$main::auth->assert('dunning_edit');
$form->{"title"} = $locale->text("Set eMail text");
- $form->header(no_layout => 1);
+ $form->header(
+ no_layout => 1,
+ use_javascripts => [ qw(ckeditor/ckeditor ckeditor/adapters/jquery) ],
+ );
print($form->parse_html_template("dunning/set_email"));
$main::lxdebug->leave_sub();
@@ -340,7 +365,8 @@ sub show_dunning {
$main::auth->assert('dunning_edit');
my @filter_field_list = qw(customer_id customer dunning_id dunning_level department_id invnumber ordnumber
- transdatefrom transdateto dunningfrom dunningto notes showold l_salesman salesman_id);
+ transdatefrom transdateto dunningfrom dunningto notes showold l_salesman salesman_id
+ l_mails l_webdav l_documents);
report_generator_set_default_sort('customername', 1);
@@ -383,12 +409,14 @@ sub show_dunning {
'fee' => { 'text' => $locale->text('Total Fees') },
'interest' => { 'text' => $locale->text('Interest') },
'salesman' => { 'text' => $locale->text('Salesperson'), 'visible' => $form->{l_salesman} ? 1 : 0 },
- 'documents' => { 'text' => $locale->text('Documents') , 'visible' => $::instance_conf->get_doc_storage ? 1 : 0 },
+ 'documents' => { 'text' => $locale->text('Documents'), 'visible' => $form->{l_documents}? 1 : 0 },
+ 'webdav' => { 'text' => $locale->text('WebDAV'), 'visible' => $form->{l_webdav} ? 1 : 0 },
+ 'mails' => { 'text' => $locale->text('Mails'), 'visible' => $form->{l_mails} ? 1 : 0 },
);
$report->set_columns(%column_defs);
$report->set_column_order(qw(checkbox dunning_description dunning_id customername language invnumber transdate
- duedate amount dunning_date dunning_duedate fee interest salesman));
+ duedate amount dunning_date dunning_duedate fee interest salesman departmentname mails webdav documents));
$report->set_sort_indicator($form->{sort}, $form->{sortdir});
my $edit_url = sub { build_std_url('script=' . ($_[0]->{invoice} ? 'is' : 'ar') . '.pl', 'action=edit', 'callback') . '&id=' . $::form->escape($_[0]->{id}) };
@@ -451,7 +479,7 @@ sub show_dunning {
$row->{language} = { };
}
- if ($::instance_conf->get_doc_storage && $first_row_for_dunning) {
+ if ($form->{l_documents} && $first_row_for_dunning) {
my @files = SL::File->get_all_versions(object_id => $ref->{dunning_id},
object_type => 'dunning',
file_type => 'document',);
@@ -463,6 +491,32 @@ sub show_dunning {
$row->{documents} = { };
}
}
+ if ($form->{l_webdav} && $first_row_for_dunning) {
+ my $webdav = SL::Webdav->new(
+ type => 'dunning',
+ number => $ref->{dunning_id},
+ );
+ my @all_objects = $webdav->get_all_objects;
+ if (scalar @all_objects) {
+ my $html = join '
', map { SL::Presenter::WebdavObject::webdav_object($_) } @all_objects;
+ my $text = join "\n", map { $_->filename } @all_objects;
+ $row->{webdav} = { 'raw_data' => $html, data => $text };
+ } else {
+ $row->{webdav} = { };
+ }
+ }
+
+ if ($form->{l_mails}) {
+ my @mail_links = RecordLinks->get_links(from_table => 'dunning', to_table => 'email_journal', from_id => $ref->{dunning_table_id});
+ if (scalar @mail_links) {
+ my $email_journals = SL::DB::Manager::EmailJournal->get_all(where => [id => [ map { $_->{to_id} } @mail_links ]]);
+ my $html = join '
', map { SL::Presenter::EmailJournal::email_journal($_) } @$email_journals;
+ my $text = join "\n", map { $_->subject } @$email_journals;
+ $row->{mails} = { 'raw_data' => $html, data => $text };
+ } else {
+ $row->{mails} = { };
+ }
+ }
push @{ $current_dunning_rows }, $row;
@@ -676,4 +730,17 @@ sub setup_dn_edit_config_action_bar {
}
}
+sub setup_dn_status_action_bar {
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Back'),
+ link => $::form->{callback},
+ accesskey => 'enter',
+ ],
+ );
+ }
+
+}
+
# end of main