3 # This file is part of Koha.
5 # Copyright 2013 BibLibre
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use C4::Auth qw(:DEFAULT get_session);
30 use Koha::Borrower::Discharge;
35 my $op = $input->param("op");
37 # Getting the template and auth
38 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
39 template_name => "opac-discharge.tt",
45 if ( $op eq 'request' ) {
46 my $success = Koha::Borrower::Discharge::request({
47 borrowernumber => $loggedinuser,
51 $template->param( success => 1 );
54 $template->param( has_issues => 1 );
57 elsif ( $op eq 'get' ) {
58 my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
59 borrowernumber => $loggedinuser
64 -type => 'application/pdf',
66 -attachment => "discharge_$loggedinuser.pdf",
68 open my $fh, '<', $pdf_path;
75 my $pending = Koha::Borrower::Discharge::count({
76 borrowernumber => $loggedinuser,
79 my $available = Koha::Borrower::Discharge::count({
80 borrowernumber => $loggedinuser,
84 available => $available,
89 $template->param( dischargeview => 1 );
91 output_html_with_http_headers $input, $cookie, $template->output;