<div class="yui-b">
<div class="yui-g">
<h3>Discharge</h3>
+[% FOR message IN messages %]
+ <div class="dialog [% message.type %]">
+ [% IF message.code == "unable_to_generate_pdf" %]
+ An error occurs when generating the pdf file.
+ Please contact the administrator to resolve this problem.
+ [% END %]
+ </div>
+[% END %]
[% UNLESS can_be_discharged %]
<p>Cannot edit discharge: borrower has issues.</p>
[% ELSE %]
<div class="span10">
<div id="discharge" class="maincontainer">
<h1>Discharge</h1>
+ [% FOR message IN messages %]
+ <div class="dialog [% message.type %]">
+ [% IF message.code == "unable_to_generate_pdf" %]
+ An error occurs when generating the pdf file.
+ Please contact the staff to resolve this problem.
+ [% END %]
+ </div>
+ [% END %]
+
[% IF success %]
<p>Your discharge request has been sent. Your discharge will be available on this page within a few days.</p>
[% ELSIF available %]
<p>Your discharge will be available on this page within a few days.</p>
[% ELSIF has_issues %]
<p>You cannot be discharged, you have issues. Please return items before asking for a discharge.</p>
- [% ELSE %]
+ [% ELSIF not messages %]
<h2>What is a discharge?</h2>
<p>This document certifies that you have returned all borrowed items. It is sometimes asked during a file transfer from a school to another. The discharge is sent by us to your school. You will also find it available on your reader account.</p>
<p><strong>Warning</strong>: This request is only valid if you are in good standing with the library. Once the application is made, you can not borrow library materials.</p>
=cut
use Modern::Perl;
+use Carp;
use CGI qw( -utf8 );
use C4::Auth;
borrowernumber => $borrowernumber
});
}
- my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
- { borrowernumber => $borrowernumber, } );
-
- binmode(STDOUT);
- print $input->header(
- -type => 'application/pdf',
- -charset => 'utf-8',
- -attachment => "discharge_$borrowernumber.pdf",
- );
- open my $fh, '<', $pdf_path;
- my @lines = <$fh>;
- close $fh;
- print @lines;
- exit;
+ eval {
+ my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
+ { borrowernumber => $borrowernumber, } );
+
+ binmode(STDOUT);
+ print $input->header(
+ -type => 'application/pdf',
+ -charset => 'utf-8',
+ -attachment => "discharge_$borrowernumber.pdf",
+ );
+ open my $fh, '<', $pdf_path;
+ my @lines = <$fh>;
+ close $fh;
+ print @lines;
+ exit;
+ };
+ if ( $@ ) {
+ carp $@;
+ $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
+ }
}
$template->param(
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
+use Carp;
use C4::Auth qw(:DEFAULT get_session);
use CGI qw( -utf8 );
}
}
elsif ( $op eq 'get' ) {
- my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
- borrowernumber => $loggedinuser
- });
+ eval {
+ my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
+ borrowernumber => $loggedinuser
+ });
- binmode(STDOUT);
- print $input->header(
- -type => 'application/pdf',
- -charset => 'utf-8',
- -attachment => "discharge_$loggedinuser.pdf",
- );
- open my $fh, '<', $pdf_path;
- my @lines = <$fh>;
- close $fh;
- print @lines;
- exit;
+ binmode(STDOUT);
+ print $input->header(
+ -type => 'application/pdf',
+ -charset => 'utf-8',
+ -attachment => "discharge_$loggedinuser.pdf",
+ );
+ open my $fh, '<', $pdf_path;
+ my @lines = <$fh>;
+ close $fh;
+ print @lines;
+ exit;
+ };
+ if ( $@ ) {
+ carp $@;
+ $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
+ }
}
else {
my $pending = Koha::Borrower::Discharge::count({