projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'bankerweiterung_und_skonto'
[kivitendo-erp.git]
/
bin
/
mozilla
/
letter.pl
diff --git
a/bin/mozilla/letter.pl
b/bin/mozilla/letter.pl
index
18564d3
..
d9a0742
100755
(executable)
--- a/
bin/mozilla/letter.pl
+++ b/
bin/mozilla/letter.pl
@@
-21,6
+21,8
@@
use SL::DB::Contact;
use SL::DB::Default;
use SL::Helper::CreatePDF;
use SL::Helper::Flash;
use SL::DB::Default;
use SL::Helper::CreatePDF;
use SL::Helper::Flash;
+use SL::Common;
+use Cwd;
require "bin/mozilla/reportgenerator.pl";
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
require "bin/mozilla/reportgenerator.pl";
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
@@
-371,8
+373,17
@@
sub print_letter {
);
my $pdf_file_name;
eval {
);
my $pdf_file_name;
eval {
+ # catch LaTeX template not found error
+ my $tex_templates = $::instance_conf->get_templates . '/letter.tex';
+ die( t8('Please create/copy a template named letter.tex in your client template dir') ) unless (-e $tex_templates);
+
$pdf_file_name = SL::Helper::CreatePDF->create_pdf(%create_params);
$pdf_file_name = SL::Helper::CreatePDF->create_pdf(%create_params);
+ # set some form defaults for printing webdav copy variables
+ $form->{tmpfile} = $pdf_file_name;
+ $form->{tmpdir} = 'users';
+ $form->{type} = 'letter';
+ $form->{cwd} = getcwd();
if ( $::form->{media} eq 'email') {
my $mail = Mailer->new;
my $signature = $::myconfig{signature};
if ( $::form->{media} eq 'email') {
my $mail = Mailer->new;
my $signature = $::myconfig{signature};
@@
-384,18
+395,20
@@
sub print_letter {
$mail->{message} .= "\n-- \n$signature";
$mail->{message} =~ s/\r//g;
$mail->{message} .= "\n-- \n$signature";
$mail->{message} =~ s/\r//g;
+ # copy_file_to_webdav was already done via io.pl -> edit_e_mail
my $err = $mail->send;
my $err = $mail->send;
-# TODO
-# $self
-# ->js
-# ->flash($err?'error':'info',
-# $err?t8('A mail error occurred: #1', $err):
-# t8('The document have been sent to \'#1\'.', $mail->{to}))
-# ->render($self);
+
# TODO
+
# $self
+
# ->js
+
# ->flash($err?'error':'info',
+
# $err?t8('A mail error occurred: #1', $err):
+
# t8('The document have been sent to \'#1\'.', $mail->{to}))
+
# ->render($self);
return $err?0:1;
}
return $err?0:1;
}
- if (!$::form->{printer_id}) {
+ if (!$::form->{printer_id} || $::form->{media} eq 'screen') {
+
my $file = IO::File->new($pdf_file_name, 'r') || croak("Cannot open file '$pdf_file_name'");
my $size = -s $pdf_file_name;
my $content_type = 'application/pdf';
my $file = IO::File->new($pdf_file_name, 'r') || croak("Cannot open file '$pdf_file_name'");
my $size = -s $pdf_file_name;
my $content_type = 'application/pdf';
@@
-408,6
+421,7
@@
sub print_letter {
$::locale->with_raw_io(\*STDOUT, sub { print while <$file> });
$file->close;
$::locale->with_raw_io(\*STDOUT, sub { print while <$file> });
$file->close;
+ Common::copy_file_to_webdav_folder($form) if $::instance_conf->get_webdav_documents;
unlink $pdf_file_name;
return 1;
}
unlink $pdf_file_name;
return 1;
}
@@
-419,6
+433,7
@@
sub print_letter {
binmode $out;
print $out scalar(read_file($pdf_file_name));
close $out;
binmode $out;
print $out scalar(read_file($pdf_file_name));
close $out;
+ Common::copy_file_to_webdav_folder($form) if $::instance_conf->get_webdav_documents;
flash_later('info', t8('The documents have been sent to the printer \'#1\'.', $printer->printer_description));
my $callback = build_std_url('letter.pl', 'action=edit', 'id=' . $letter->{id}, 'printer_id');
flash_later('info', t8('The documents have been sent to the printer \'#1\'.', $printer->printer_description));
my $callback = build_std_url('letter.pl', 'action=edit', 'id=' . $letter->{id}, 'printer_id');
@@
-491,6
+506,7
@@
sub e_mail {
$letter->check_number;
$letter->save;
$letter->check_number;
$letter->save;
+ $form->{formname} = "letter";
$letter->export_to($::form);
$::form->{id} = $letter->{id};
$letter->export_to($::form);
$::form->{id} = $letter->{id};