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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc (-1 / +11 lines)
Lines 1-7 Link Here
1
[% IF ( error ) %]
1
[% IF ( error || CGI.param('pdferr') )  %]
2
<div class="dialog alert">
2
<div class="dialog alert">
3
  <p>
3
  <p>
4
    <strong>WARNING:</strong>
4
    <strong>WARNING:</strong>
5
        [% IF CGI.param('pdferr') %]
6
        Error while creating the PDF file.
7
        [% IF CGI.param('errnocards') %]No cards created (empty batch or list?)[% END %]
8
        [% IF CGI.param('errba') %]Batch: [% CGI.param('errba') %][% END %]
9
        [% IF CGI.param('errpl') %]Patron list: [%  CGI.param('errpl') %][% END %]
10
        [% IF CGI.param('errlo') %]Layout: [%  CGI.param('errlo') %][% END %]
11
        [% IF CGI.param('errtpl') %]Template: [%  CGI.param('errtpl') %][% END %]
12
13
        Please have your system administrator check the error log for details.
14
        [% END %]
5
        [% IF ( error == 101 ) %]
15
        [% IF ( error == 101 ) %]
6
        The database returned an error while [% IF ( card_element ) %]saving [% card_element %] [% element_id %][% ELSE %]attempting a save operation[% END %]. Please have your system administrator check the error log for details.
16
        The database returned an error while [% IF ( card_element ) %]saving [% card_element %] [% element_id %][% ELSE %]attempting a save operation[% END %]. Please have your system administrator check the error log for details.
7
        [% ELSIF ( error == 102 ) %]
17
        [% ELSIF ( error == 102 ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt (+1 lines)
Lines 1-3 Link Here
1
[% USE CGI %]
1
[% BLOCK translate_card_element %]
2
[% BLOCK translate_card_element %]
2
[%-  SWITCH element -%]
3
[%-  SWITCH element -%]
3
[%-  CASE 'layout'    -%]layout
4
[%-  CASE 'layout'    -%]layout
(-)a/patroncards/create-pdf.pl (-12 / +33 lines)
Lines 45-52 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
45
                                                                     flagsrequired   => { tools => 'label_creator' },
45
                                                                     flagsrequired   => { tools => 'label_creator' },
46
                                                                     debug           => 1,
46
                                                                     debug           => 1,
47
                                                                     });
47
                                                                     });
48
49
50
my $batch_id    = $cgi->param('batch_id') if $cgi->param('batch_id');
48
my $batch_id    = $cgi->param('batch_id') if $cgi->param('batch_id');
51
my $template_id = $cgi->param('template_id') || undef;
49
my $template_id = $cgi->param('template_id') || undef;
52
my $layout_id   = $cgi->param('layout_id') || undef;
50
my $layout_id   = $cgi->param('layout_id') || undef;
Lines 58-70 my $patronlist_id = $cgi->param('patronlist_id'); Link Here
58
my $items = undef; # items = cards
56
my $items = undef; # items = cards
59
my $new_page = 0;
57
my $new_page = 0;
60
58
61
my $pdf_file = (@label_ids || @borrower_numbers ? "card_single_" . scalar(@label_ids || @borrower_numbers) : "card_batch_$batch_id");
59
# Wrap pdf creation part into an eval, some vars need scope outside eval
62
print $cgi->header( -type       => 'application/pdf',
60
my $pdf_ok;
63
                    -encoding   => 'utf-8',
61
my $pdf;
64
                    -attachment => "$pdf_file.pdf",
62
my $pdf_file;
65
                  );
63
my $cardscount = 0;
64
65
#Note fo bug 14138: Indenting follows in separate patch to ease review
66
eval {
67
$pdf_file = (@label_ids || @borrower_numbers ? "card_single_" . scalar(@label_ids || @borrower_numbers) : "card_batch_$batch_id");
66
68
67
my $pdf = C4::Creators::PDF->new(InitVars => 0);
69
$pdf = C4::Creators::PDF->new(InitVars => 0);
68
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
70
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
69
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
71
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
70
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
72
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
Lines 125-130 if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page t Link Here
125
CARD_ITEMS:
127
CARD_ITEMS:
126
foreach my $item (@{$items}) {
128
foreach my $item (@{$items}) {
127
    if ($item) {
129
    if ($item) {
130
        $cardscount ++;
128
        my $borrower_number = $item->{'borrower_number'};
131
        my $borrower_number = $item->{'borrower_number'};
129
        my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
132
        my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
130
133
Lines 231-239 foreach my $item (@{$items}) { Link Here
231
    ($llx, $lly, $new_page) = $pc_template->get_next_label_pos();
234
    ($llx, $lly, $new_page) = $pc_template->get_next_label_pos();
232
    $pdf->Page() if $new_page;
235
    $pdf->Page() if $new_page;
233
}
236
}
237
# No errors occured within eval, we can issue the pdf
238
$pdf_ok = 1 if ($cardscount > 0);
239
}; # end of eval block
234
240
235
$pdf->End();
241
if ($pdf_ok) {
236
242
    #issue the pdf
237
# FIXME: Possibly do a redirect here if there were error encountered during PDF creation.
243
    print $cgi->header( -type       => 'application/pdf',
244
                    -encoding   => 'utf-8',
245
                    -attachment => "$pdf_file.pdf",
246
                  );
247
    $pdf->End();
248
}
249
else {
250
    # warn user that pdf is not created
251
    my $errparams = '&pdferr=1';
252
    $errparams .= "&errba=$batch_id" if $batch_id;
253
    $errparams .= "&errpl=$patronlist_id" if $patronlist_id;
254
    $errparams .= "&errlo=$layout_id" if $layout_id;
255
    $errparams .= "&errtpl=$template_id" if $template_id;
256
    $errparams .= "&errnocards=1" if !$cardscount;
257
258
    print $cgi->redirect("/cgi-bin/koha/patroncards/manage.pl?card_element=batch$errparams");
259
}
238
260
239
1;
261
1;
240
- 

Return to bug 14138