Lines 23-28
use CGI;
Link Here
|
23 |
use JSON qw(to_json); |
23 |
use JSON qw(to_json); |
24 |
|
24 |
|
25 |
use C4::Context; |
25 |
use C4::Context; |
|
|
26 |
use C4::Output qw(output_with_http_headers); |
26 |
use C4::Auth qw(check_cookie_auth); |
27 |
use C4::Auth qw(check_cookie_auth); |
27 |
use Koha::DateUtils qw(dt_from_string); |
28 |
use Koha::DateUtils qw(dt_from_string); |
28 |
use Koha::Holds; |
29 |
use Koha::Holds; |
Lines 33-44
my ( $auth_status, $sessionID ) =
Link Here
|
33 |
check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } ); |
34 |
check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } ); |
34 |
|
35 |
|
35 |
if ( $auth_status ne "ok" ) { |
36 |
if ( $auth_status ne "ok" ) { |
|
|
37 |
print $input->header(-type => 'text/plain', -status => '403 Forbidden'); |
36 |
exit 0; |
38 |
exit 0; |
37 |
} |
39 |
} |
38 |
|
40 |
|
39 |
binmode STDOUT, ":encoding(UTF-8)"; |
|
|
40 |
print $input->header( -type => 'text/json', -charset => 'UTF-8' ); |
41 |
|
42 |
my $reserve_id = $input->param('reserve_id'); |
41 |
my $reserve_id = $input->param('reserve_id'); |
43 |
|
42 |
|
44 |
my $suspend_until = $input->param('suspend_until') || undef; |
43 |
my $suspend_until = $input->param('suspend_until') || undef; |
Lines 46-62
if ($suspend_until) {
Link Here
|
46 |
eval { $suspend_until = dt_from_string($suspend_until) }; |
45 |
eval { $suspend_until = dt_from_string($suspend_until) }; |
47 |
|
46 |
|
48 |
if ($@) { |
47 |
if ($@) { |
49 |
print to_json( { success => 0, error => 'INVALID_DATE' } ); |
48 |
my $json = to_json( { success => 0, error => 'INVALID_DATE' } ); |
|
|
49 |
output_with_http_headers( $input, undef, $json, "json" ); |
50 |
exit; |
50 |
exit; |
51 |
} |
51 |
} |
52 |
} |
52 |
} |
53 |
|
53 |
|
54 |
my $hold = Koha::Holds->find($reserve_id); |
54 |
my $hold = Koha::Holds->find($reserve_id); |
55 |
unless ($hold) { |
55 |
unless ($hold) { |
56 |
print to_json( { success => 0, error => 'HOLD_NOT_FOUND' } ); |
56 |
my $json = to_json( { success => 0, error => 'HOLD_NOT_FOUND' } ); |
|
|
57 |
output_with_http_headers( $input, undef, $json, "json" ); |
57 |
exit; |
58 |
exit; |
58 |
} |
59 |
} |
59 |
|
60 |
|
60 |
$hold->suspend_hold($suspend_until); |
61 |
$hold->suspend_hold($suspend_until); |
61 |
|
62 |
|
62 |
print to_json( { success => $hold->suspend() } ); |
63 |
my $json = to_json( { success => $hold->suspend() } ); |
|
|
64 |
output_with_http_headers( $input, undef, $json, "json" ); |