@@ -, +, @@ --- .../bootstrap/en/modules/opac-memberentry.tt | 2 +- opac/svc/patron/show_checkouts_to_relatives | 49 ++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletions(-) create mode 100755 opac/svc/patron/show_checkouts_to_relatives --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -826,7 +826,7 @@ [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] $('#update_privacy_guarantor_checkouts').click( function() { - $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }) + $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json') .done(function( data ) { var message; if ( data.success ) { --- a/opac/svc/patron/show_checkouts_to_relatives +++ a/opac/svc/patron/show_checkouts_to_relatives @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +# Copyright 2015 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +use Modern::Perl; + +use CGI; +use JSON qw(to_json); + +use C4::Auth qw(check_cookie_auth); +use Koha::Database; + +my $cgi = new CGI; + +my $privacy_guarantor_checkouts = $cgi->param('privacy_guarantor_checkouts'); + +my ( $auth_status, $sessionID ) = + check_cookie_auth( $cgi->cookie('CGISESSID') ); +if ( $auth_status ne "ok" ) { + exit 0; +} + +my $borrowernumber = C4::Context->userenv->{'number'}; +my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber ); + +if ( $borrower ) { + $borrower = $borrower->update( { privacy_guarantor_checkouts => $privacy_guarantor_checkouts } ); +} + +binmode STDOUT, ':encoding(UTF-8)'; +print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); + +print to_json( { success => $borrower ? 1 : 0 } ); --