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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
26 use C4
::Auth
qw(get_template_and_user);
27 use C4
::Output
qw(output_html_with_http_headers);
32 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
34 template_name
=> "patroncards/card-print.tt",
38 flagsrequired
=> { catalogue
=> 1 },
43 my $op = $cgi->param('op') || 'none';
44 my @label_ids = $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 @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
50 my $output_format = $cgi->param('output_format') || 'pdf';
51 my $referer = $cgi->param('referer') || undef;
54 my $templates = undef;
55 my $label_output_formats = undef;
57 my $multi_batch_count = scalar(@batch_ids);
58 my $label_count = scalar(@label_ids);
59 my $item_count = scalar(@item_numbers);
61 if ($op eq 'export') {
63 my $label_id_param = '&label_id=';
64 $label_id_param .= join ('&label_id=',@label_ids);
65 push (@batches, {create_script
=> ($output_format eq 'pdf' ?
'label-create-pdf.pl' : 'label-create-csv.pl'),
66 batch_id
=> $batch_ids[0],
67 template_id
=> $template_id,
68 layout_id
=> $layout_id,
69 start_label
=> $start_label,
70 label_ids
=> $label_id_param,
71 label_count
=> scalar(@label_ids),
78 elsif (@item_numbers) {
79 my $item_number_param = '&item_number=';
80 $item_number_param .= join ('&item_number=',@item_numbers);
81 push (@batches, {create_script
=> ($output_format eq 'pdf' ?
'label-create-pdf.pl' : 'label-create-csv.pl'),
82 template_id
=> $template_id,
83 layout_id
=> $layout_id,
84 start_label
=> $start_label,
85 item_numbers
=> $item_number_param,
86 label_count
=> scalar(@item_numbers),
94 foreach my $batch_id (@batch_ids) {
95 push (@batches, {create_script
=> ($output_format eq 'pdf' ?
'label-create-pdf.pl' : 'label-create-csv.pl'),
96 batch_id
=> $batch_id,
97 template_id
=> $template_id,
98 layout_id
=> $layout_id,
99 start_label
=> $start_label,
103 batches
=> \
@batches,
108 elsif ($op eq 'none') {
109 # setup select menus for selecting layout and template for this run...
110 $referer = $ENV{'HTTP_REFERER'};
111 $referer =~ s/^.*?:\/\/.*?
(\
/.*)$/$1/m
;
112 @batch_ids = grep{$_ = {batch_id
=> $_}} @batch_ids;
113 @label_ids = grep{$_ = {label_id
=> $_}} @label_ids;
114 @item_numbers = grep{$_ = {item_number
=> $_}} @item_numbers;
115 $templates = get_all_templates
(field_list
=> 'template_id, template_code');
116 $layouts = get_all_layouts
(field_list
=> 'layout_id, layout_name');
117 $label_output_formats = get_label_output_formats
();
119 batch_ids
=> \
@batch_ids,
120 label_ids
=> \
@label_ids,
121 item_numbers
=> \
@item_numbers,
122 templates
=> $templates,
124 label_output_formats
=> $label_output_formats,
125 multi_batch_count
=> $multi_batch_count,
126 label_count
=> $label_count,
127 item_count
=> $item_count,
131 output_html_with_http_headers
$cgi, $cookie, $template->output;