Discharge
+ [% FOR message IN messages %] + + [% END %] + [% IF success %]Your discharge request has been sent. Your discharge will be available on this page within a few days.
[% ELSIF available %] @@ -31,7 +40,7 @@Your discharge will be available on this page within a few days.
[% ELSIF has_issues %]You cannot be discharged, you have issues. Please return items before asking for a discharge.
- [% ELSE %] + [% ELSIF not messages %]What is a discharge?
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.
Warning: 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.
--- a/members/discharge.pl +++ a/members/discharge.pl @@ -28,6 +28,7 @@ Allows librarian to edit and/or manage borrowers' discharges =cut use Modern::Perl; +use Carp; use CGI qw( -utf8 ); use C4::Auth; @@ -75,20 +76,26 @@ if ( $input->param('borrowernumber') ) { 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( --- a/opac/opac-discharge.pl +++ a/opac/opac-discharge.pl @@ -18,6 +18,7 @@ # along with Koha; if not, see