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>.
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
38 template_name
=> "opac-issue-note.tt",
45 my $patron = Koha
::Patrons
->find( $borrowernumber );
47 firstname
=> $patron->firstname,
48 surname
=> $patron->surname,
49 borrowernumber
=> $borrowernumber,
52 my $issue_id = $query->param('issue_id');
53 my $issue = Koha
::Checkouts
->find( $issue_id );
54 my $itemnumber = $issue->itemnumber;
55 my $biblio = $issue->item->biblio;
57 issue_id
=> $issue_id,
58 title
=> $biblio->title,
59 author
=> $biblio->author,
61 itemnumber
=> $issue->itemnumber,
64 my $action = $query->param('action') || "";
65 if ( $action eq 'issuenote' && C4
::Context
->preference('AllowCheckoutNotes') ) {
66 my $note = $query->param('note');
67 my $scrubber = C4
::Scrubber
->new();
68 my $clean_note = $scrubber->scrub($note);
69 if ( $issue->set({ notedate
=> dt_from_string
(), note
=> $clean_note, noteseen
=> 0 })->store ) {
70 if ($clean_note) { # only send email if note not empty
71 my $branch = Koha
::Libraries
->find( $issue->branchcode );
72 my $letter = C4
::Letters
::GetPreparedLetter
(
73 module
=> 'circulation',
74 letter_code
=> 'CHECKOUT_NOTE',
75 branchcode
=> $branch,
76 lang
=> $patron->lang,
78 'biblio' => $biblio->biblionumber,
79 'borrowers' => $borrowernumber,
83 my $to_address = $branch->inbound_email_address;
84 my $reply_address = $patron->email || $patron->emailpro || $patron->B_email;
86 C4
::Letters
::EnqueueLetter
({
88 message_transport_type
=> 'email',
89 borrowernumber
=> $patron->borrowernumber,
90 to_address
=> $to_address,
91 reply_address
=> $reply_address,
95 print $query->redirect("/cgi-bin/koha/opac-user.pl");
98 output_html_with_http_headers
$query, $cookie, $template->output, undef, { force_no_caching
=> 1 };