3 # Copyright 2009 Foundations Bible College.
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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
24 use HTML::Template::Pro;
27 use C4::Auth qw(get_template_and_user);
28 use C4::Output qw(output_html_with_http_headers);
29 use C4::Labels::Lib 1.000000 qw(get_all_templates get_all_layouts get_label_output_formats);
32 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34 template_name => "labels/label-print.tmpl",
38 flagsrequired => { catalogue => 1 },
43 my $op = $cgi->param('op') || 'none';
44 my @select_labels = $cgi->param('label_id') if $cgi->param('label_id'); # this will handle individual label printing
45 my @batch_ids = $cgi->param('batch_id') if $cgi->param('batch_id');
46 my $layout_id = $cgi->param('layout_id') || undef;
47 my $template_id = $cgi->param('template_id') || undef;
48 my $start_label = $cgi->param('start_label') || 1;
49 my $output_format = $cgi->param('output_format') || 'pdf';
51 my $templates = undef;
52 my $label_output_formats = undef;
54 my $multi_batch_count = scalar(@batch_ids);
56 if ($op eq 'export') {
57 foreach my $batch_id (@batch_ids) {
58 push (@batches, {create_script => ($output_format eq 'pdf' ? 'label-create-pdf.pl' : 'label-create-csv.pl'),
59 batch_id => $batch_id,
60 template_id => $template_id,
61 layout_id => $layout_id,
62 start_label => $start_label,
69 elsif ($op eq 'none') {
70 # setup select menus for selecting layout and template for this run...
71 @batch_ids = grep{$_ = {batch_id => $_}} @batch_ids;
72 $templates = get_all_templates(field_list => 'template_id, template_code');
73 $layouts = get_all_layouts(field_list => 'layout_id, layout_name');
74 $label_output_formats = get_label_output_formats();
76 batch_ids => \@batch_ids,
77 templates => $templates,
79 label_output_formats => $label_output_formats,
80 multi_batch_count => $multi_batch_count,
83 output_html_with_http_headers $cgi, $cookie, $template->output;