Lines 30-51
use Koha::Holds;
Link Here
|
30 |
my $input = new CGI; |
30 |
my $input = new CGI; |
31 |
|
31 |
|
32 |
my ( $auth_status, $sessionID ) = |
32 |
my ( $auth_status, $sessionID ) = |
33 |
check_cookie_auth( $input->cookie('CGISESSID'), |
33 |
check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } ); |
34 |
{ circulate => 'circulate_remaining_permissions' } ); |
|
|
35 |
|
34 |
|
36 |
if ( $auth_status ne "ok" ) { |
35 |
if ( $auth_status ne "ok" ) { |
37 |
exit 0; |
36 |
exit 0; |
38 |
} |
37 |
} |
39 |
|
38 |
|
40 |
binmode STDOUT, ":encoding(UTF-8)"; |
39 |
binmode STDOUT, ":encoding(UTF-8)"; |
41 |
print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); |
40 |
print $input->header( -type => 'text/json', -charset => 'UTF-8' ); |
42 |
|
41 |
|
43 |
my $reserve_id = $input->param('reserve_id'); |
42 |
my $reserve_id = $input->param('reserve_id'); |
44 |
|
43 |
|
45 |
my $suspend_until = $input->param('suspend_until') || undef; |
44 |
my $suspend_until = $input->param('suspend_until') || undef; |
46 |
$suspend_until = dt_from_string( $suspend_until ) if $suspend_until; |
45 |
if ($suspend_until) { |
|
|
46 |
eval { $suspend_until = dt_from_string($suspend_until) }; |
47 |
|
47 |
|
48 |
my $hold = Koha::Holds->find( $reserve_id ); |
48 |
if ($@) { |
49 |
$hold->suspend_hold( $suspend_until ); |
49 |
print to_json( { success => 0, error => 'INVALID_DATE' } ); |
|
|
50 |
exit; |
51 |
} |
52 |
} |
53 |
|
54 |
my $hold = Koha::Holds->find($reserve_id); |
55 |
unless ($hold) { |
56 |
print to_json( { success => 0, error => 'HOLD_NOT_FOUND' } ); |
57 |
exit; |
58 |
} |
59 |
|
60 |
$hold->suspend_hold($suspend_until); |
50 |
|
61 |
|
51 |
print to_json( { success => $hold->suspend() } ); |
62 |
print to_json( { success => $hold->suspend() } ); |
52 |
- |
|
|