3 # Copyright 2009 Jesse Weaver
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 # find Koha's Perl modules
26 # test carefully before changing this
28 eval { require "$FindBin::Bin/../kohalib.pl" };
31 use CGI; # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
42 Usage: $0 OUTPUT_DIRECTORY
43 Will print all waiting print notices to
44 OUTPUT_DIRECTORY/notices-CURRENT_DATE.html .
49 my ( $stylesheet, $help );
55 usage( 0 ) if ( $help );
57 my $output_directory = $ARGV[0];
59 if ( !$output_directory || !-d $output_directory ) {
60 print STDERR "Error: You must specify a valid directory to dump the print notices in.\n";
64 my $today = C4::Dates->new();
65 my @messages = @{ GetPrintMessages() };
66 exit unless( @messages );
68 open OUTPUT, '>', File::Spec->catdir( $output_directory, "holdnotices-" . $today->output( 'iso' ) . ".html" );
70 my $template = C4::Templates::gettemplate( 'batch/print-notices.tmpl', 'intranet', new CGI );
73 stylesheet => C4::Context->preference("NoticeCSS"),
74 today => $today->output(),
75 messages => \@messages,
78 print OUTPUT $template->output;
80 foreach my $message ( @messages ) {
81 C4::Letters::_set_message_status( { message_id => $message->{'message_id'}, status => 'sent' } );