Revision e80effa2
Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt
SL/Controller/Letter.pm | ||
---|---|---|
18 | 18 |
use SL::Locale::String qw(t8); |
19 | 19 |
use SL::IS; |
20 | 20 |
use SL::ReportGenerator; |
21 |
use SL::Webdav; |
|
22 |
use SL::Webdav::File; |
|
21 | 23 |
|
22 | 24 |
use Rose::Object::MakeMethods::Generic ( |
23 | 25 |
'scalar --get_set_init' => [ qw(letter all_employees models) ], |
... | ... | |
248 | 250 |
return !$err; |
249 | 251 |
} |
250 | 252 |
|
251 |
my $webdav_copy_args = Form->new(''); |
|
252 |
%{ $webdav_copy_args } = ( |
|
253 |
%{ $::form }, |
|
254 |
tmpdir => dirname($pdf_file_name), |
|
255 |
tmpfile => basename($pdf_file_name), |
|
256 |
cwd => POSIX::getcwd(), |
|
253 |
$::form->{letternumber} = $self->letter->letternumber; |
|
254 |
my $attachment_name = $::form->generate_attachment_filename; |
|
255 |
my $webdav_file = SL::Webdav::File->new( |
|
256 |
filename => $attachment_name, |
|
257 |
webdav => SL::Webdav->new( |
|
258 |
type => 'letter', |
|
259 |
number => $self->letter->letternumber, |
|
260 |
), |
|
257 | 261 |
); |
258 | 262 |
|
259 | 263 |
if (!$::form->{printer_id} || $::form->{media} eq 'screen') { |
260 |
|
|
261 |
my $file = IO::File->new($pdf_file_name, 'r') || croak("Cannot open file '$pdf_file_name'"); |
|
262 |
my $size = -s $pdf_file_name; |
|
263 |
my $content_type = 'application/pdf'; |
|
264 |
$::form->{letternumber} = $self->letter->letternumber; |
|
265 |
my $attachment_name = $::form->generate_attachment_filename; |
|
266 |
$attachment_name =~ s:.*//::g; |
|
267 |
|
|
268 |
print $::form->create_http_response(content_type => $content_type, |
|
269 |
content_disposition => 'attachment; filename="' . $attachment_name . '"', |
|
270 |
content_length => $size); |
|
271 |
|
|
272 |
$::locale->with_raw_io(\*STDOUT, sub { print while <$file> }); |
|
273 |
$file->close; |
|
274 |
|
|
275 |
Common::copy_file_to_webdav_folder($webdav_copy_args) if $::instance_conf->get_webdav_documents; |
|
264 |
$self->send_file($pdf_file_name, name => $attachment_name); |
|
265 |
$webdav_file->store(file => $pdf_file_name) if $::instance_conf->get_webdav_documents; |
|
276 | 266 |
unlink $pdf_file_name; |
267 |
|
|
277 | 268 |
return 1; |
278 | 269 |
} |
279 | 270 |
|
... | ... | |
283 | 274 |
file_name => $pdf_file_name, |
284 | 275 |
); |
285 | 276 |
|
286 |
Common::copy_file_to_webdav_folder($webdav_copy_args) if $::instance_conf->get_webdav_documents; |
|
287 |
|
|
277 |
$webdav_file->store(file => $pdf_file_name) if $::instance_conf->get_webdav_documents; |
|
288 | 278 |
unlink $pdf_file_name; |
289 | 279 |
|
290 | 280 |
flash_later('info', t8('The documents have been sent to the printer \'#1\'.', $printer->printer_description)); |
Auch abrufbar als: Unified diff
Brieffunktion: Nutzung von SL::Webdav zur Speicherung im Webdav
Common::copy_file_to_webdav_folder ist alter Code, der bei neuem Code
nicht mehr benutzt werden sollte.