View | Details | Raw Unified | Return to bug 14310
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc (+3 lines)
Lines 35-39 Link Here
35
    var SUSPEND = _("Suspend");
35
    var SUSPEND = _("Suspend");
36
    var SUSPEND_HOLD_ON = _("Suspend hold on");
36
    var SUSPEND_HOLD_ON = _("Suspend hold on");
37
    var CLEAR_DATE_TO_SUSPEND_INDEFINITELY = _("Clear date to suspend indefinitely");
37
    var CLEAR_DATE_TO_SUSPEND_INDEFINITELY = _("Clear date to suspend indefinitely");
38
    var SUSPEND_HOLD_ERROR_DATE = _("Unable to suspend hold, invalid date");
39
    var SUSPEND_HOLD_ERROR_NOT_FOUND = _("Unable to suspend hold, hold not found");
40
    var RESUME_HOLD_ERROR_NOT_FOUND = _("Unable to resume, hold not found");
38
//]]>
41
//]]>
39
</script>
42
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js (-2 / +19 lines)
Lines 162-168 $(document).ready(function() { Link Here
162
                    var id = $(this).attr("id").replace("resume", "");
162
                    var id = $(this).attr("id").replace("resume", "");
163
                    var hold = holds[id];
163
                    var hold = holds[id];
164
                    $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){
164
                    $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){
165
                      holdsTable.api().ajax.reload();
165
                      if ( data.success ) {
166
                          holdsTable.api().ajax.reload();
167
                      } else {
168
                        if ( data.error == "HOLD_NOT_FOUND" ) {
169
                            alert ( RESUME_HOLD_ERROR_NOT_FOUND );
170
                            holdsTable.api().ajax.reload();
171
                        }
172
                      }
166
                    });
173
                    });
167
                });
174
                });
168
            });
175
            });
Lines 209-215 $(document).ready(function() { Link Here
209
        e.preventDefault();
216
        e.preventDefault();
210
        $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
217
        $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){
211
          $('#suspend-modal').modal('hide');
218
          $('#suspend-modal').modal('hide');
212
          holdsTable.api().ajax.reload();
219
          if ( data.success ) {
220
              holdsTable.api().ajax.reload();
221
          } else {
222
            if ( data.error == "INVALID_DATE" ) { 
223
                alert( SUSPEND_HOLD_ERROR_DATE );
224
            }
225
            else if ( data.error == "HOLD_NOT_FOUND" ) {
226
                alert ( SUSPEND_HOLD_ERROR_NOT_FOUND );
227
                holdsTable.api().ajax.reload();
228
            }
229
          }
213
        });
230
        });
214
    });
231
    });
215
232
(-)a/svc/hold/resume (-1 / +7 lines)
Lines 38-48 if ( $auth_status ne "ok" ) { Link Here
38
}
38
}
39
39
40
binmode STDOUT, ":encoding(UTF-8)";
40
binmode STDOUT, ":encoding(UTF-8)";
41
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
41
print $input->header( -type => 'text/json', -charset => 'UTF-8' );
42
42
43
my $reserve_id = $input->param('reserve_id');
43
my $reserve_id = $input->param('reserve_id');
44
44
45
my $hold = Koha::Holds->find( $reserve_id );
45
my $hold = Koha::Holds->find( $reserve_id );
46
47
unless ( $hold ) {
48
    print to_json( { success => 0, error => "HOLD_NOT_FOUND" } );
49
    exit;
50
}
51
46
$hold->resume();
52
$hold->resume();
47
53
48
print to_json( { success => !$hold->suspend() } );
54
print to_json( { success => !$hold->suspend() } );
(-)a/svc/hold/suspend (-7 / +17 lines)
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
- 

Return to bug 14310