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

(-)a/C4/Creators/Layout.pm (+1 lines)
Lines 108-113 sub retrieve { Link Here
108
        return -1;
108
        return -1;
109
    }
109
    }
110
    my $self = $sth->fetchrow_hashref;
110
    my $self = $sth->fetchrow_hashref;
111
    return -2 unless ( $self ); # Make it behave like C4::Patroncards::Batch->retrieve()
111
    bless ($self, $type);
112
    bless ($self, $type);
112
    return $self;
113
    return $self;
113
}
114
}
(-)a/C4/Creators/Template.pm (+1 lines)
Lines 127-132 sub retrieve { Link Here
127
        return -1;
127
        return -1;
128
    }
128
    }
129
    my $self = $sth->fetchrow_hashref;
129
    my $self = $sth->fetchrow_hashref;
130
    return -2 unless ( $self ); # Make it behave like C4::Patroncards::Batch->retrieve() 
130
    $self = _conv_points($self) if (($opts{convert} && $opts{convert} == 1) || $opts{profile_id});
131
    $self = _conv_points($self) if (($opts{convert} && $opts{convert} == 1) || $opts{profile_id});
131
    $self = _apply_profile($self, $opts{'creator'}) if $opts{profile_id} && $self->{'profile_id'};        # don't bother if there is no profile_id
132
    $self = _apply_profile($self, $opts{'creator'}) if $opts{profile_id} && $self->{'profile_id'};        # don't bother if there is no profile_id
132
    $self->{'template_stat'} = 1;
133
    $self->{'template_stat'} = 1;
(-)a/patroncards/create-pdf.pl (-6 / +65 lines)
Lines 45-57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
45
                                                                     });
45
                                                                     });
46
46
47
47
48
my $batch_id    = $cgi->param('batch_id') if $cgi->param('batch_id');
48
my $batch_id    = $cgi->param('batch_id') || undef;
49
my $template_id = $cgi->param('template_id') || undef;
49
my $template_id = $cgi->param('template_id') || undef;
50
my $layout_id   = $cgi->param('layout_id') || undef;
50
my $layout_id   = $cgi->param('layout_id') || undef;
51
my $start_card = $cgi->param('start_card') || 1;
51
my $start_card  = $cgi->param('start_card') || 1;
52
my @label_ids   = $cgi->param('label_id') if $cgi->param('label_id');
52
my @label_ids   = $cgi->param('label_id') if $cgi->param('label_id');
53
my @borrower_numbers  = $cgi->param('borrower_number') if $cgi->param('borrower_number');
53
my @borrower_numbers  = $cgi->param('borrower_number') if $cgi->param('borrower_number');
54
54
55
56
# Proof of concept pretesting see Bug 14138
57
# Prepare for pre-tests
58
59
my $batch_failed = '';
60
my $patron_failed = '';
61
my $template_failed = '';
62
my $layout_failed = '';
63
64
65
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id) if ($batch_id);
66
# returns -1 or -2 if error occured
67
$batch_failed = $batch_id if ( ( $batch && $batch < 0 ) || ! $batch );
68
69
# Later add code to handle lists (Bug 14131)
70
# Later prevent that more than one of patron / batch / list is given
71
72
if ( @borrower_numbers ) {
73
   my $test_number = GetMember(borrowernumber => @borrower_numbers);
74
   $patron_failed = @borrower_numbers unless ( $test_number );
75
}
76
77
my $pc_template;
78
my $template_failed = '';
79
if ( $template_id ) {
80
    $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
81
    # returns -1 or -2 if error occured
82
    $template_failed = $template_id if ( $pc_template && $pc_template < 0 );
83
} else {
84
    $template_failed = 'missing';
85
}
86
87
my $layout;
88
if ( $layout_id ) {
89
    $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
90
    # returns -1 or -2 if error occured
91
    $layout_failed = $layout_id if ( $layout && $layout < 0 );
92
} else {
93
    $layout_failed = 'missing';
94
}
95
96
97
# Display the errors and go back to previous page
98
# Later: Fit better into Koha look and feel (Template?) / Translation issues (is hard coded) 
99
if ( $batch_failed || $patron_failed || $template_failed || $layout_failed  ) {
100
    my $errmessage = '';
101
    $errmessage .= "ERROR ";
102
    $errmessage .= "Template $template_failed " if ( $template_failed );
103
    $errmessage .= "Layout $layout_failed " if ( $layout_failed );
104
    $errmessage .= "Batch $batch_failed " if ( $batch_failed );
105
    $errmessage .= "Patron $patron_failed" if ( $patron_failed );
106
107
    print $cgi->header( -type => 'text/html', -encoding => 'utf-8', );
108
    my $errtitle = 'Error preparing PDF document';
109
    my $errscript = "alert(\" $errmessage \"); window.history.back();";
110
    print $cgi-> start_html( -title => $errtitle, -onLoad => $errscript, );
111
    print $cgi->h1($errtitle);
112
    print $cgi->end_html();
113
    exit 1;
114
}
115
116
117
# Do the work
55
my $items = undef; # items = cards
118
my $items = undef; # items = cards
56
my $new_page = 0;
119
my $new_page = 0;
57
120
Lines 62-70 print $cgi->header( -type => 'application/pdf', Link Here
62
                  );
125
                  );
63
126
64
my $pdf = C4::Creators::PDF->new(InitVars => 0);
127
my $pdf = C4::Creators::PDF->new(InitVars => 0);
65
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
66
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
67
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
68
128
69
$| = 1;
129
$| = 1;
70
130
71
- 

Return to bug 14138