var SUSPEND = _("Suspend");
var SUSPEND_HOLD_ON = _("Suspend hold on");
var CLEAR_DATE_TO_SUSPEND_INDEFINITELY = _("Clear date to suspend indefinitely");
+ var SUSPEND_HOLD_ERROR_DATE = _("Unable to suspend hold, invalid date");
+ var SUSPEND_HOLD_ERROR_NOT_FOUND = _("Unable to suspend hold, hold not found");
+ var RESUME_HOLD_ERROR_NOT_FOUND = _("Unable to resume, hold not found");
//]]>
</script>
var id = $(this).attr("id").replace("resume", "");
var hold = holds[id];
$.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){
- holdsTable.api().ajax.reload();
+ if ( data.success ) {
+ holdsTable.api().ajax.reload();
+ } else {
+ if ( data.error == "HOLD_NOT_FOUND" ) {
+ alert ( RESUME_HOLD_ERROR_NOT_FOUND );
+ holdsTable.api().ajax.reload();
+ }
+ }
});
});
});
e.preventDefault();
$.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
$('#suspend-modal').modal('hide');
- holdsTable.api().ajax.reload();
+ if ( data.success ) {
+ holdsTable.api().ajax.reload();
+ } else {
+ if ( data.error == "INVALID_DATE" ) {
+ alert( SUSPEND_HOLD_ERROR_DATE );
+ }
+ else if ( data.error == "HOLD_NOT_FOUND" ) {
+ alert ( SUSPEND_HOLD_ERROR_NOT_FOUND );
+ holdsTable.api().ajax.reload();
+ }
+ }
});
});
}
binmode STDOUT, ":encoding(UTF-8)";
-print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
+print $input->header( -type => 'text/json', -charset => 'UTF-8' );
my $reserve_id = $input->param('reserve_id');
my $hold = Koha::Holds->find( $reserve_id );
+
+unless ( $hold ) {
+ print to_json( { success => 0, error => "HOLD_NOT_FOUND" } );
+ exit;
+}
+
$hold->resume();
print to_json( { success => !$hold->suspend() } );
my $input = new CGI;
my ( $auth_status, $sessionID ) =
- check_cookie_auth( $input->cookie('CGISESSID'),
- { circulate => 'circulate_remaining_permissions' } );
+ check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } );
if ( $auth_status ne "ok" ) {
exit 0;
}
binmode STDOUT, ":encoding(UTF-8)";
-print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
+print $input->header( -type => 'text/json', -charset => 'UTF-8' );
my $reserve_id = $input->param('reserve_id');
my $suspend_until = $input->param('suspend_until') || undef;
-$suspend_until = dt_from_string( $suspend_until ) if $suspend_until;
+if ($suspend_until) {
+ eval { $suspend_until = dt_from_string($suspend_until) };
-my $hold = Koha::Holds->find( $reserve_id );
-$hold->suspend_hold( $suspend_until );
+ if ($@) {
+ print to_json( { success => 0, error => 'INVALID_DATE' } );
+ exit;
+ }
+}
+
+my $hold = Koha::Holds->find($reserve_id);
+unless ($hold) {
+ print to_json( { success => 0, error => 'HOLD_NOT_FOUND' } );
+ exit;
+}
+
+$hold->suspend_hold($suspend_until);
print to_json( { success => $hold->suspend() } );