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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/help/patroncards/manage.tt (-1 / +2 lines)
Lines 11-16 Link Here
11
<h1>Templates</h1>
11
<h1>Templates</h1>
12
12
13
<p>A template is the label/card stock you are using. This might be Avery 5160 for address labels, Gaylord 47-284 for spine labels or Avery 28371 for your patron cards, just to give a couple of examples. These labels will include all of the information you will need for setting up a Koha, this information may be on the packaging, and if not it can usually be found on the vendor's website.</p>
13
<p>A template is the label/card stock you are using. This might be Avery 5160 for address labels, Gaylord 47-284 for spine labels or Avery 28371 for your patron cards, just to give a couple of examples. These labels will include all of the information you will need for setting up a Koha, this information may be on the packaging, and if not it can usually be found on the vendor's website.</p>
14
<p>To print to a duplex card printer you need a '1 up template' (1 row / 1 column) and for both card sides a separate layout.</p>
14
15
15
<h2>Batches</h2>
16
<h2>Batches</h2>
16
17
Lines 18-21 Link Here
18
19
19
<p><strong>See the full documentation for the Patron Card Creator in the <a href="http://manual.koha-community.org/[% helpVersion %]/en/patroncardcreator.html">manual</a> (online).</strong></p>
20
<p><strong>See the full documentation for the Patron Card Creator in the <a href="http://manual.koha-community.org/[% helpVersion %]/en/patroncardcreator.html">manual</a> (online).</strong></p>
20
21
21
[% INCLUDE 'help-bottom.inc' %]
22
[% INCLUDE 'help-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt (-3 / +14 lines)
Lines 26-42 Link Here
26
                        [% IF ( batche.label_ids ) %]
26
                        [% IF ( batche.label_ids ) %]
27
                        <legend>[% batche.card_count %] Single patron cards</legend>
27
                        <legend>[% batche.card_count %] Single patron cards</legend>
28
                        <p>
28
                        <p>
29
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script %]?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_card=[% batche.start_card %][% batche.label_ids %]">label_single_[% batche.card_count %].pdf</a>
29
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script %]?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]]&amp;layout_back_id=[% batche.layout_back_id %]&amp;start_card=[% batche.start_card %][% batche.label_ids %]">label_single_[% batche.card_count %].pdf</a>
30
                        </p>
30
                        </p>
31
                        [% ELSIF ( batche.borrower_numbers ) %]
31
                        [% ELSIF ( batche.borrower_numbers ) %]
32
                        <legend>[% batche.card_count %] Single Patron Cards</legend>
32
                        <legend>[% batche.card_count %] Single Patron Cards</legend>
33
                        <p>
33
                        <p>
34
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script %]?template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_card=[% batche.start_card %][% batche.borrower_numbers %]">label_single_[% batche.card_count %].pdf</a>
34
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script %]?template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;layout_back_id=[% batche.layout_back_id %]&amp;start_card=[% batche.start_card %][% batche.borrower_numbers %]">label_single_[% batche.card_count %].pdf</a>
35
                        </p>
35
                        </p>
36
                        [% ELSE %]
36
                        [% ELSE %]
37
                        <legend>Card batch number [% batche.batch_id %]</legend>
37
                        <legend>Card batch number [% batche.batch_id %]</legend>
38
                        <p>
38
                        <p>
39
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_card=[% batche.start_card %]">label_batch_[% batche.batch_id %].pdf</a>
39
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;layout_back_id=[% batche.layout_back_id %]&amp;start_card=[% batche.start_card %]">label_batch_[% batche.batch_id %].pdf</a>
40
                        </p>
40
                        </p>
41
                        [% END %]
41
                        [% END %]
42
                    [% END %]
42
                    [% END %]
Lines 94-99 Link Here
94
                            </select>
94
                            </select>
95
                        </li>
95
                        </li>
96
                        <li>
96
                        <li>
97
                            <label style="width:9em" for="layout_back_id">Select a layout for back side: </label>
98
                            <select name="layout_back_id" id="layout_back_id">
99
                                <option value="0">Back side layout not used</option>
100
                                [% FOREACH layout IN layouts %]
101
                                <option value="[% layout.layout_id %]">[% layout.layout_name %]</option>
102
                                [% END %]
103
                            </select>
104
                            <span class="hint">Used for duplex printers (needs a '1 up template')</span>
105
                        </li>
106
107
                        <li>
97
                            <label style="width:9em" for="start_card">Enter starting card position: </label>
108
                            <label style="width:9em" for="start_card">Enter starting card position: </label>
98
                            <input type="text" size="5" id="start_card" name="start_card" class="focus" title="Starting card number" value="1" />
109
                            <input type="text" size="5" id="start_card" name="start_card" class="focus" title="Starting card number" value="1" />
99
                        </li>
110
                        </li>
(-)a/patroncards/create-pdf.pl (-5 / +20 lines)
Lines 26-31 use Graphics::Magick; Link Here
26
use XML::Simple;
26
use XML::Simple;
27
use POSIX qw(ceil);
27
use POSIX qw(ceil);
28
use autouse 'Data::Dumper' => qw(Dumper);
28
use autouse 'Data::Dumper' => qw(Dumper);
29
use Clone qw(clone);
29
30
30
use C4::Debug;
31
use C4::Debug;
31
use C4::Context;
32
use C4::Context;
Lines 48-53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
48
my $batch_id    = $cgi->param('batch_id') if $cgi->param('batch_id');
49
my $batch_id    = $cgi->param('batch_id') if $cgi->param('batch_id');
49
my $template_id = $cgi->param('template_id') || undef;
50
my $template_id = $cgi->param('template_id') || undef;
50
my $layout_id   = $cgi->param('layout_id') || undef;
51
my $layout_id   = $cgi->param('layout_id') || undef;
52
my $layout_back_id   = $cgi->param('layout_back_id') || undef;
51
my $start_card = $cgi->param('start_card') || 1;
53
my $start_card = $cgi->param('start_card') || 1;
52
my @label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
54
my @label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
53
my @borrower_numbers  = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number');
55
my @borrower_numbers  = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number');
Lines 70-75 $pdf = C4::Creators::PDF->new(InitVars => 0); Link Here
70
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
72
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
71
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
73
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
72
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
74
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
75
my $layout_back = C4::Patroncards::Layout->retrieve(layout_id => $layout_back_id) if ( $layout_back_id );
73
76
74
$| = 1;
77
$| = 1;
75
78
Lines 110-115 else { Link Here
110
}
113
}
111
114
112
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);
115
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);
116
my $layout_back_xml = XMLin($layout_back->get_attr('layout_xml'), ForceArray => 1) if ( defined $layout_back );
113
117
114
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page to swap columns
118
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page to swap columns
115
    my $even = 1;
119
    my $even = 1;
Lines 127-138 if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page t Link Here
127
CARD_ITEMS:
131
CARD_ITEMS:
128
foreach my $item (@{$items}) {
132
foreach my $item (@{$items}) {
129
    if ($item) {
133
    if ($item) {
134
135
#my $print_layout_xml = $layout_back_xml;
136
        my $print_layout_xml = (( ($cardscount % 2  == 1) && ( $layout_back_id ) ) ?
137
            clone($layout_back_xml) : clone($layout_xml) );
138
130
        $cardscount ++;
139
        $cardscount ++;
131
        my $borrower_number = $item->{'borrower_number'};
140
        my $borrower_number = $item->{'borrower_number'};
132
        my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
141
        my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
133
142
134
#       Set barcode data
143
#       Set barcode data
135
        $layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $layout_xml->{'barcode'};
144
        $print_layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $print_layout_xml->{'barcode'};
136
145
137
#       Create a new patroncard object
146
#       Create a new patroncard object
138
        my $patron_card = C4::Patroncards::Patroncard->new(
147
        my $patron_card = C4::Patroncards::Patroncard->new(
Lines 142-158 foreach my $item (@{$items}) { Link Here
142
                lly                     => $lly,
151
                lly                     => $lly,
143
                height                  => $pc_template->get_attr('label_height'), # of the card
152
                height                  => $pc_template->get_attr('label_height'), # of the card
144
                width                   => $pc_template->get_attr('label_width'),
153
                width                   => $pc_template->get_attr('label_width'),
145
                layout                  => $layout_xml,
154
                layout                  => $print_layout_xml,
146
                text_wrap_cols          => 30, #FIXME: hardcoded,
155
                text_wrap_cols          => 30, #FIXME: hardcoded,
147
        );
156
        );
148
157
149
        $patron_card->draw_guide_box($pdf) if $layout_xml->{'guide_box'};
158
        $patron_card->draw_guide_box($pdf) if $print_layout_xml->{'guide_box'};
150
        $patron_card->draw_barcode($pdf) if $layout_xml->{'barcode'};
159
        $patron_card->draw_barcode($pdf) if $print_layout_xml->{'barcode'};
151
160
152
#       Do image foo and place binary image data into layout hash
161
#       Do image foo and place binary image data into layout hash
153
        my $image_data = {};
162
        my $image_data = {};
154
        my $error = undef;
163
        my $error = undef;
155
        my $images = $layout_xml->{'images'};
164
        my $images = $print_layout_xml->{'images'};
156
        PROCESS_IMAGES:
165
        PROCESS_IMAGES:
157
        foreach (keys %{$images}) {
166
        foreach (keys %{$images}) {
158
            if (grep{m/source/} keys(%{$images->{$_}->{'data_source'}->[0]})) {
167
            if (grep{m/source/} keys(%{$images->{$_}->{'data_source'}->[0]})) {
Lines 232-237 foreach my $item (@{$items}) { Link Here
232
        $patron_card->draw_text($pdf);
241
        $patron_card->draw_text($pdf);
233
    }
242
    }
234
    ($llx, $lly, $new_page) = $pc_template->get_next_label_pos();
243
    ($llx, $lly, $new_page) = $pc_template->get_next_label_pos();
244
245
    if ( ($cardscount % 2  == 1) && ( $layout_back_id ) ) {
246
        $pdf->Page();
247
        redo; # Use same patron data again for backside in card printer
248
    }
249
235
    $pdf->Page() if $new_page;
250
    $pdf->Page() if $new_page;
236
}
251
}
237
# No errors occurred within eval, we can issue the pdf
252
# No errors occurred within eval, we can issue the pdf
(-)a/patroncards/print.pl (-1 / +5 lines)
Lines 45-50 my @label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id'); # th Link Here
45
my @batch_ids = $cgi->multi_param('batch_id') if $cgi->param('batch_id');
45
my @batch_ids = $cgi->multi_param('batch_id') if $cgi->param('batch_id');
46
my $patronlist_id = $cgi->param('patronlist_id') || undef;
46
my $patronlist_id = $cgi->param('patronlist_id') || undef;
47
my $layout_id = $cgi->param('layout_id') || undef;
47
my $layout_id = $cgi->param('layout_id') || undef;
48
my $layout_back_id = $cgi->param('layout_back_id') || undef;
48
my $template_id = $cgi->param('template_id') || undef;
49
my $template_id = $cgi->param('template_id') || undef;
49
my $start_card = $cgi->param('start_card') || 1;
50
my $start_card = $cgi->param('start_card') || 1;
50
my @borrower_numbers = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number');
51
my @borrower_numbers = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number');
Lines 67-72 if ($op eq 'export') { Link Here
67
                         batch_id        => $batch_ids[0],
68
                         batch_id        => $batch_ids[0],
68
                         template_id     => $template_id,
69
                         template_id     => $template_id,
69
                         layout_id       => $layout_id,
70
                         layout_id       => $layout_id,
71
                         layout_back_id  => $layout_back_id,
70
                         start_card      => $start_card,
72
                         start_card      => $start_card,
71
                         label_ids       => $label_id_param,
73
                         label_ids       => $label_id_param,
72
                         card_count      => scalar(@label_ids),
74
                         card_count      => scalar(@label_ids),
Lines 82-87 if ($op eq 'export') { Link Here
82
        push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),
84
        push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),
83
                         template_id     => $template_id,
85
                         template_id     => $template_id,
84
                         layout_id       => $layout_id,
86
                         layout_id       => $layout_id,
87
                         layout_back_id  => $layout_back_id,
85
                         start_card      => $start_card,
88
                         start_card      => $start_card,
86
                         borrower_numbers    => $borrower_number_param,
89
                         borrower_numbers    => $borrower_number_param,
87
                         card_count      => scalar(@borrower_numbers),
90
                         card_count      => scalar(@borrower_numbers),
Lines 97-102 if ($op eq 'export') { Link Here
97
                            batch_id        => $batch_id,
100
                            batch_id        => $batch_id,
98
                            template_id     => $template_id,
101
                            template_id     => $template_id,
99
                            layout_id       => $layout_id,
102
                            layout_id       => $layout_id,
103
                            layout_back_id  => $layout_back_id,
100
                            start_card      => $start_card,
104
                            start_card      => $start_card,
101
                            });
105
                            });
102
        }
106
        }
Lines 110-115 if ($op eq 'export') { Link Here
110
                         patronlist_id   => $patronlist_id,
114
                         patronlist_id   => $patronlist_id,
111
                         template_id     => $template_id,
115
                         template_id     => $template_id,
112
                         layout_id       => $layout_id,
116
                         layout_id       => $layout_id,
117
                         layout_back_id  => $layout_back_id,
113
                         start_card      => $start_card,
118
                         start_card      => $start_card,
114
                         referer         => $referer,
119
                         referer         => $referer,
115
                        );
120
                        );
116
- 

Return to bug 18465