View | Details | Raw Unified | Return to bug 16077
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/card-print.tt (-165 lines)
Lines 1-165 Link Here
1
    [% INCLUDE 'doc-head-open.inc' %]
2
    <title>Koha &rsaquo; Tools &rsaquo; Patron Card Creator &rsaquo; Patron card printing/exporting</title>
3
    [% INCLUDE 'doc-head-close.inc' %]
4
    <script type="text/JavaScript" language="JavaScript">
5
        //<![CDATA[
6
            function Done() {
7
                window.location = "[% referer %]";
8
            };
9
        //]]>
10
    </script>
11
    <style type="text/css">#custom-doc {width:47.23em; *width:46.04em; min-width:610px; margin:auto; margin-top:0.4em;}</style>
12
    <style type="text/css">table {border-collapse: separate; border-spacing: 0; border: hidden none;} .header {cursor: auto; background-position: center center; background-repeat: repeat;}</style>
13
</head>
14
<body id="pcard_card-print" class="tools pcard">
15
    <div id="custom-doc" class="yui-t2">
16
        <div id="bd">
17
            [% IF ( batches ) %]
18
            <form>
19
                <div align="center">
20
                    <div class="message">
21
                        <b>Click on the following link(s) to download the exported batch(es).</b>
22
                    </div>
23
                </div>
24
                <fieldset class="rows">
25
                    <table class="borderless">
26
                        [% FOREACH batche IN batches %]
27
                        <tr>
28
                            [% IF ( batche.label_ids ) %]
29
                            <td class="borderless">
30
                                [% batche.label_count %] Single cards
31
                            </td>
32
                            <td class="borderless">
33
                                <h1 id="pdf">
34
                                    <a href="/cgi-bin/koha/labels/[% batche.create_script %]?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_label=[% batche.start_label %][% batche.label_ids %]">label_single_[% batche.label_count %].pdf</a>
35
                                </h1>
36
                            </td>
37
                            <td class="borderless">
38
                                <h1 id="csv">
39
                                    <a href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.label_ids %]">label_single_[% batche.label_count %].csv</a>
40
                                </h1>
41
                            </td>
42
                            <td class="borderless">
43
                                <h1 id="xml">
44
                                    <a href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.label_ids %]">label_single_[% batche.label_count %].xml</a>
45
                                </h1>
46
                            </td>
47
                            [% ELSIF ( batche.item_numbers ) %]
48
                            <td class="borderless">
49
                                [% batche.label_count %] Single Cards
50
                            </td>
51
                            <td class="borderless">
52
                                <h1 id="pdf">
53
                                    <a href="/cgi-bin/koha/labels/[% batche.create_script %]?template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_label=[% batche.start_label %][% batche.item_numbers %]">label_single_[% batche.label_count %].pdf</a>
54
                                </h1>
55
                            </td>
56
                            <td class="borderless">
57
                                <h1 id="csv">
58
                                    <a href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.item_numbers %]">label_single_[% batche.label_count %].csv</a>
59
                                </h1>
60
                            </td>
61
                            <td class="borderless">
62
                                <h1 id="xml">
63
                                    <a href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.item_numbers %]">label_single_[% batche.label_count %].xml</a>
64
                                </h1>
65
                            </td>
66
                            [% ELSE %]
67
                            <td class="borderless">
68
                                Card batch number [% batche.batch_id %]
69
                            </td>
70
                            <td class="borderless">
71
                                <h1 id="pdf">
72
                                    <a href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_label=[% batche.start_label %]">label_batch_[% batche.batch_id %].pdf</a>
73
                                </h1>
74
                            </td>
75
                            <td class="borderless">
76
                                <h1 id="csv">
77
                                    <a href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]">label_batch_[% batche.batch_id %].csv</a>
78
                                </h1>
79
                            </td>
80
                            <td class="borderless">
81
                                <h1 id="xml">
82
                                    <a href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]">label_batch_[% batche.batch_id %].xml</a>
83
                                </h1>
84
                            </td>
85
                            [% END %]
86
                        </tr>
87
                        [% END %]
88
                    </table>
89
                </fieldset>
90
                <fieldset class="action">
91
                    <div style="margin: 10px 10px 10px 0px;">
92
                        <span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="done" onclick="parent.parent.GB_hide();" value="Done"></span></span>
93
                    </div>
94
                </fieldset>
95
            </form>
96
            [% ELSE %]
97
            <div align="center">
98
                <div class="message">
99
                    [% IF ( label_ids ) %]
100
                    <b>Exporting [% label_count %] cards(s).</b>
101
                    [% ELSIF ( item_numbers ) %]
102
                    <b>Exporting [% item_count %] cards(s).</b>
103
                    [% ELSE %]
104
                    <b>[% multi_batch_count %] batch(es) to export.</b>
105
                    [% END %]
106
                </div>
107
            </div>
108
            <form name="exporting" method="post" action="/cgi-bin/koha/labels/label-print.pl">
109
                <input type="hidden" name="op" value="export" />
110
                <input type="hidden" name="referer" value="[% referer %]" />
111
                [% FOREACH batch_id IN batch_ids %]
112
                    <input type="hidden" name="batch_id" value="[% batch_id.batch_id %]" />
113
                [% END %]
114
                [% FOREACH label_id IN label_ids %]
115
                    <input type="hidden" name="label_id" value="[% label_id.label_id %]" />
116
                [% END %]
117
                [% FOREACH item_number IN item_numbers %]
118
                    <input type="hidden" name="item_number" value="[% item_number.item_number %]" />
119
                [% END %]
120
                <fieldset class="rows">
121
                    <table class="borderless">
122
                        <tr>
123
                            <td class="borderless">
124
                                <label for="template">Select a template to be applied: </label>
125
                            </td>
126
                            <td class="borderless">
127
                                <select name="template_id">
128
                                    [% FOREACH template IN templates %]
129
                                    <option value="[% template.template_id %]">[% template.template_code %]</option>
130
                                    [% END %]
131
                                </select>
132
                            </td>
133
                        </tr>
134
                        <tr>
135
                            <td class="borderless">
136
                                <label for="layout">Select a layout to be applied: </label>
137
                            </td>
138
                            <td class="borderless">
139
                                <select name="layout_id">
140
                                    [% FOREACH layout IN layouts %]
141
                                    <option value="[% layout.layout_id %]">[% layout.layout_name %]</option>
142
                                    [% END %]
143
                                </select>
144
                            </td>
145
                        </tr>
146
                        <tr>
147
                            <td class="borderless">
148
                                <label for="start_label">Enter starting card number: </label>
149
                            </td>
150
                            <td class="borderless">
151
                                <input type="text" size="5" id="start_label" name="start_label" class="focus" title="Starting card number" value="1"/>
152
                            </td>
153
                        </tr>
154
                    </table>
155
                </fieldset>
156
                <fieldset class="action">
157
                    <div style="margin: 10px 10px 10px 0px;">
158
                        <span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Export" /></span></span>
159
                        <span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="done" onclick="parent.parent.GB_hide();" value="Cancel"></span></span>
160
                    </div>
161
                </fieldset>
162
            </form>
163
            [% END %]
164
        </div>
165
    [% INCLUDE 'intranet-bottom.inc' %]
(-)a/patroncards/card-print.pl (-132 lines)
Lines 1-131 Link Here
1
#!/usr/bin/perl
2
#
3
# Copyright 2009 Foundations Bible College.
4
#
5
# This file is part of Koha.
6
#
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.
11
#
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.
16
#
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>.
19
20
use strict;
21
use warnings;
22
23
use CGI qw ( -utf8 );
24
use Data::Dumper;
25
26
use C4::Auth qw(get_template_and_user);
27
use C4::Output qw(output_html_with_http_headers);
28
use C4::Creators;
29
use C4::Labels;
30
31
my $cgi = new CGI;
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "patroncards/card-print.tt",
35
        query           => $cgi,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => { catalogue => 1 },
39
        debug           => 1,
40
    }
41
);
42
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;
52
53
my $layouts = undef;
54
my $templates = undef;
55
my $label_output_formats = undef;
56
my @batches = ();
57
my $multi_batch_count = scalar(@batch_ids);
58
my $label_count = scalar(@label_ids);
59
my $item_count = scalar(@item_numbers);
60
61
if ($op eq 'export') {
62
    if (@label_ids) {
63
        my $label_id_param = '&amp;label_id=';
64
        $label_id_param .= join ('&amp;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),
72
                        });
73
        $template->param(
74
                        batches     => \@batches,
75
                        referer     => $referer,
76
                        );
77
    }
78
    elsif (@item_numbers) {
79
        my $item_number_param = '&amp;item_number=';
80
        $item_number_param .= join ('&amp;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),
87
                        });
88
        $template->param(
89
                        batches     => \@batches,
90
                        referer     => $referer,
91
                        );
92
    }
93
    elsif (@batch_ids) {
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,
100
                            });
101
        }
102
        $template->param(
103
                        batches     => \@batches,
104
                        referer     => $referer,
105
                        );
106
    }
107
}
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();
118
    $template->param(
119
                    batch_ids                   => \@batch_ids,
120
                    label_ids                   => \@label_ids,
121
                    item_numbers                => \@item_numbers,
122
                    templates                   => $templates,
123
                    layouts                     => $layouts,
124
                    label_output_formats        => $label_output_formats,
125
                    multi_batch_count           => $multi_batch_count,
126
                    label_count                 => $label_count,
127
                    item_count                  => $item_count,
128
                    referer                     => $referer,
129
                    );
130
}
131
output_html_with_http_headers $cgi, $cookie, $template->output;
132
- 

Return to bug 16077