3 # Copyright 2013 BibLibre
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>.
23 use C4
::Auth
qw( check_cookie_auth );
24 use JSON
qw( to_json );
25 use Koha
::List
::Patron
;
29 my ( $auth_status, $sessionID ) = check_cookie_auth
(
30 $input->cookie('CGISESSID'),
31 { tools
=> 'manage_patron_lists' },
34 exit 0 if $auth_status ne "ok";
35 my $add_to_patron_list = $input->param('add_to_patron_list');
36 my $new_patron_list = $input->param('new_patron_list');
37 my @borrowernumbers = $input->param('borrowernumbers[]');
40 if ($add_to_patron_list) {
43 if ( $add_to_patron_list eq 'new' ) {
44 $patron_list = AddPatronList
( { name
=> $new_patron_list } );
48 [ GetPatronLists
( { patron_list_id
=> $add_to_patron_list } ) ]->[0];
51 my @patrons_added_to_list = AddPatronsToList
( { list
=> $patron_list, borrowernumbers
=> \
@borrowernumbers } );
53 $response->{patron_list
} = { patron_list_id
=> $patron_list->patron_list_id, name
=> $patron_list->name };
54 $response->{patrons_added_to_list
} = scalar( @patrons_added_to_list );
57 binmode STDOUT
, ":encoding(UTF-8)";
59 -type
=> 'application/json',
63 print to_json
( $response );