X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=misc%2Fcronjobs%2Fgather_print_notices.pl;h=248716e339bd372e515bab7465b68147f2b89d82;hb=a52a0a8811f6ad03c422c62280bc184a9e16996d;hp=286b035372a931ef3dca4a602464d0f76ad1fb2a;hpb=37328c709ecb1e8868c4dd8ce344e844647d8715;p=koha_fer diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl index 286b035372..248716e339 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -59,9 +59,9 @@ usage(0) if ($help); my $output_directory = $ARGV[0]; -if ( !$output_directory || !-d $output_directory ) { +if ( !$output_directory || !-d $output_directory || !-w $output_directory ) { print STDERR -"Error: You must specify a valid directory to dump the print notices in.\n"; +"Error: You must specify a valid and writeable directory to dump the print notices in.\n"; usage(1); } @@ -69,6 +69,14 @@ my $today = C4::Dates->new(); my @all_messages = @{ GetPrintMessages() }; exit unless (@all_messages); +## carriage return replaced by
as output is html +foreach my $message (@all_messages) { + local $_ = $message->{'content'}; + s/\n/
/g; + s/\r//g; + $message->{'content'} = $_; +} + my $OUTPUT; if ($split) { @@ -79,9 +87,10 @@ if ($split) { foreach my $branchcode ( keys %messages_by_branch ) { my @messages = @{ $messages_by_branch{$branchcode} }; - open $OUTPUT, '>', - File::Spec->catdir( $output_directory, + my $output_file = File::Spec->catdir( $output_directory, "holdnotices-" . $today->output('iso') . "-$branchcode.html" ); + open $OUTPUT, '>', $output_file + or die "Could not open $output_file: $!"; my $template = C4::Templates::gettemplate( 'batch/print-notices.tmpl', 'intranet', @@ -104,9 +113,11 @@ if ($split) { } } else { - open $OUTPUT, '>', - File::Spec->catdir( $output_directory, + my $output_file = File::Spec->catdir( $output_directory, "holdnotices-" . $today->output('iso') . ".html" ); + open $OUTPUT, '>', $output_file + or die "Could not open $output_file: $!"; + my $template = C4::Templates::gettemplate( 'batch/print-notices.tmpl', 'intranet',