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( encode_json );
26 use C4::Auth qw( check_cookie_auth );
27 use C4::Output qw( is_ajax output_with_http_headers );
28 use C4::Patroncards::Batch;
29 use C4::Labels::Batch;
33 svc/creator_batches - Web service for managing AJAX functionality for patroncards and label batches
40 my $is_ajax = is_ajax();
42 my ( $auth_status ) = check_cookie_auth( $cgi->cookie('CGISESSID'), { catalogue => 1 } );
43 if ( $auth_status ne "ok" ) {
47 my $op = $cgi->param('op') || q{};
48 if ($is_ajax && $op eq 'cud-set_permission') {
49 my $batch_id = $cgi->param('batch_id');
50 my $description = $cgi->param('newdescription');
51 my $dbh = C4::Context->dbh;
52 my $status = 'success';
54 my $query = "UPDATE creator_batches SET description = ? WHERE batch_id = ?";
55 my $sth = $dbh->prepare($query);
56 $sth->execute($description, $batch_id);
63 my $json = encode_json ( { status => $status, newdesc => $description } );
64 output_with_http_headers $cgi, undef, $json, 'js';