3 # This file is part of Koha.
5 # Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
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 JSON qw( to_json );
25 use C4::Auth qw ( check_cookie_auth );
26 use C4::Output qw( is_ajax output_with_http_headers );
31 svc/checkout_notes - Web service for managing patron notes set on issues
38 my $is_ajax = is_ajax();
40 my ( $auth_status ) = check_cookie_auth( $query->cookie('CGISESSID'), { circulate => 'manage_checkout_notes' } );
41 if ( $auth_status ne "ok" ) {
45 my $issue_id = $query->param('issue_id');
46 my $issue = Koha::Checkouts->find($issue_id);
47 my $action = $query->param('action');
48 my $status = 'success';
49 if ($action eq 'seen'){
50 $issue->set({ noteseen => 1 })->store;
51 if ( $issue->noteseen != 1 ) {
54 } elsif ($action eq 'notseen'){
55 $issue->set({ noteseen => 0 })->store;
56 if ( $issue->noteseen != 0 ) {
60 my $json = to_json ( { status => $status } );
61 output_with_http_headers $query, undef, $json, 'js';