Translation updates for Koha 17.05
[koha.git] / opac / opac-issue-note.pl
blobbecd7083f740de7b61a6faaf16d5e4b27ae7397f
1 #!/usr/bin/perl
3 # Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
5 # This file is part of Koha.
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>.
20 use Modern::Perl;
22 use CGI qw ( -utf8 );
23 use C4::Koha;
24 use C4::Context;
25 use C4::Scrubber;
26 use C4::Members;
27 use C4::Output;
28 use C4::Auth;
29 use C4::Biblio;
30 use C4::Letters;
31 use Koha::Checkouts;
32 use Koha::DateUtils;
34 my $query = new CGI;
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
38 template_name => "opac-issue-note.tt",
39 query => $query,
40 type => "opac",
41 authnotrequired => 0,
42 debug => 1,
46 my $member = C4::Members::GetMember( borrowernumber => $borrowernumber );
47 $template->param(
48 firstname => $member->{'firstname'},
49 surname => $member->{'surname'},
50 borrowernumber => $borrowernumber,
53 my $issue_id = $query->param('issue_id');
54 my $issue = Koha::Checkouts->find( $issue_id );
55 my $itemnumber = $issue->itemnumber;
56 my $biblio = GetBiblioFromItemNumber($itemnumber);
57 $template->param(
58 issue_id => $issue_id,
59 title => $biblio->{'title'},
60 author => $biblio->{'author'},
61 note => $issue->note,
62 itemnumber => $issue->itemnumber,
65 my $action = $query->param('action') || "";
66 if ( $action eq 'issuenote' && C4::Context->preference('AllowCheckoutNotes') ) {
67 my $note = $query->param('note');
68 my $scrubber = C4::Scrubber->new();
69 my $clean_note = $scrubber->scrub($note);
70 if ( $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
71 if ($clean_note) { # only send email if note not empty
72 my $branch = Koha::Libraries->find( $issue->branchcode );
73 my $letter = C4::Letters::GetPreparedLetter (
74 module => 'circulation',
75 letter_code => 'PATRON_NOTE',
76 branchcode => $branch,
77 tables => {
78 'biblio' => $biblio->{biblionumber},
79 'borrowers' => $member->{borrowernumber},
82 C4::Message->enqueue($letter, $member, 'email');
85 print $query->redirect("/cgi-bin/koha/opac-user.pl");
88 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };