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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt (+8 lines)
Lines 18-23 Link Here
18
    <div class="yui-b">
18
    <div class="yui-b">
19
<div class="yui-g">
19
<div class="yui-g">
20
<h3>Discharge</h3>
20
<h3>Discharge</h3>
21
[% FOR message IN messages %]
22
    <div class="dialog [% message.type %]">
23
    [% IF message.code == "unable_to_generate_pdf" %]
24
        An error occurs when generating the pdf file.
25
        Please contact the administrator to resolve this problem.
26
    [% END %]
27
    </div>
28
[% END %]
21
[% UNLESS can_be_discharged %]
29
[% UNLESS can_be_discharged %]
22
    <p>Cannot edit discharge: borrower has issues.</p>
30
    <p>Cannot edit discharge: borrower has issues.</p>
23
[% ELSE %]
31
[% ELSE %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt (-1 / +10 lines)
Lines 23-28 Link Here
23
            <div class="span10">
23
            <div class="span10">
24
                <div id="discharge" class="maincontainer">
24
                <div id="discharge" class="maincontainer">
25
                    <h1>Discharge</h1>
25
                    <h1>Discharge</h1>
26
                    [% FOR message IN messages %]
27
                        <div class="dialog [% message.type %]">
28
                        [% IF message.code == "unable_to_generate_pdf" %]
29
                            An error occurs when generating the pdf file.
30
                            Please contact the staff to resolve this problem.
31
                        [% END %]
32
                        </div>
33
                    [% END %]
34
26
                    [% IF success %]
35
                    [% IF success %]
27
                        <p>Your discharge request has been sent. Your discharge will be available on this page within a few days.</p>
36
                        <p>Your discharge request has been sent. Your discharge will be available on this page within a few days.</p>
28
                    [% ELSIF available %]
37
                    [% ELSIF available %]
Lines 31-37 Link Here
31
                        <p>Your discharge will be available on this page within a few days.</p>
40
                        <p>Your discharge will be available on this page within a few days.</p>
32
                    [% ELSIF has_issues %]
41
                    [% ELSIF has_issues %]
33
                        <p>You cannot be discharged, you have issues. Please return items before asking for a discharge.</p>
42
                        <p>You cannot be discharged, you have issues. Please return items before asking for a discharge.</p>
34
                    [% ELSE %]
43
                    [% ELSIF not messages %]
35
                        <h2>What is a discharge?</h2>
44
                        <h2>What is a discharge?</h2>
36
                        <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>
45
                        <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>
37
                        <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>
46
                        <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>
(-)a/members/discharge.pl (-14 / +21 lines)
Lines 28-33 Allows librarian to edit and/or manage borrowers' discharges Link Here
28
=cut
28
=cut
29
29
30
use Modern::Perl;
30
use Modern::Perl;
31
use Carp;
31
32
32
use CGI qw( -utf8 );
33
use CGI qw( -utf8 );
33
use C4::Auth;
34
use C4::Auth;
Lines 75-94 if ( $input->param('borrowernumber') ) { Link Here
75
                borrowernumber => $borrowernumber
76
                borrowernumber => $borrowernumber
76
            });
77
            });
77
        }
78
        }
78
        my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
79
        eval {
79
            { borrowernumber => $borrowernumber, } );
80
            my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
80
81
                { borrowernumber => $borrowernumber, } );
81
        binmode(STDOUT);
82
82
        print $input->header(
83
            binmode(STDOUT);
83
            -type       => 'application/pdf',
84
            print $input->header(
84
            -charset    => 'utf-8',
85
                -type       => 'application/pdf',
85
            -attachment => "discharge_$borrowernumber.pdf",
86
                -charset    => 'utf-8',
86
        );
87
                -attachment => "discharge_$borrowernumber.pdf",
87
        open my $fh, '<', $pdf_path;
88
            );
88
        my @lines = <$fh>;
89
            open my $fh, '<', $pdf_path;
89
        close $fh;
90
            my @lines = <$fh>;
90
        print @lines;
91
            close $fh;
91
        exit;
92
            print @lines;
93
            exit;
94
        };
95
        if ( $@ ) {
96
            carp $@;
97
            $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
98
        }
92
    }
99
    }
93
100
94
    $template->param(
101
    $template->param(
(-)a/opac/opac-discharge.pl (-15 / +21 lines)
Lines 18-23 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Carp;
21
22
22
use C4::Auth qw(:DEFAULT get_session);
23
use C4::Auth qw(:DEFAULT get_session);
23
use CGI qw( -utf8 );
24
use CGI qw( -utf8 );
Lines 55-75 if ( $op eq 'request' ) { Link Here
55
    }
56
    }
56
}
57
}
57
elsif ( $op eq 'get' ) {
58
elsif ( $op eq 'get' ) {
58
    my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
59
    eval {
59
        borrowernumber => $loggedinuser
60
        my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
60
    });
61
            borrowernumber => $loggedinuser
62
        });
61
63
62
    binmode(STDOUT);
64
        binmode(STDOUT);
63
    print $input->header(
65
        print $input->header(
64
        -type       => 'application/pdf',
66
            -type       => 'application/pdf',
65
        -charset    => 'utf-8',
67
            -charset    => 'utf-8',
66
        -attachment => "discharge_$loggedinuser.pdf",
68
            -attachment => "discharge_$loggedinuser.pdf",
67
    );
69
        );
68
    open my $fh, '<', $pdf_path;
70
        open my $fh, '<', $pdf_path;
69
    my @lines = <$fh>;
71
        my @lines = <$fh>;
70
    close $fh;
72
        close $fh;
71
    print @lines;
73
        print @lines;
72
    exit;
74
        exit;
75
    };
76
    if ( $@ ) {
77
        carp $@;
78
        $template->param( messages => [ {type => 'error', code => 'unable_to_generate_pdf'} ] );
79
    }
73
}
80
}
74
else {
81
else {
75
    my $pending = Koha::Borrower::Discharge::count({
82
    my $pending = Koha::Borrower::Discharge::count({
76
- 

Return to bug 8007