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

(-)a/svc/hold/resume (-7 / +7 lines)
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 30-54 use Koha::Holds; Link Here
30
my $input = new CGI;
31
my $input = new CGI;
31
32
32
my ( $auth_status, $sessionID ) =
33
my ( $auth_status, $sessionID ) =
33
  check_cookie_auth( $input->cookie('CGISESSID'),
34
  check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } );
34
    { circulate => 'circulate_remaining_permissions' } );
35
35
36
if ( $auth_status ne "ok" ) {
36
if ( $auth_status ne "ok" ) {
37
    print $input->header(-type => 'text/plain', -status => '403 Forbidden');
37
    exit 0;
38
    exit 0;
38
}
39
}
39
40
40
binmode STDOUT, ":encoding(UTF-8)";
41
print $input->header( -type => 'text/json', -charset => 'UTF-8' );
42
43
my $reserve_id = $input->param('reserve_id');
41
my $reserve_id = $input->param('reserve_id');
44
42
45
my $hold = Koha::Holds->find( $reserve_id );
43
my $hold = Koha::Holds->find( $reserve_id );
46
44
47
unless ( $hold ) {
45
unless ( $hold ) {
48
    print to_json( { success => 0, error => "HOLD_NOT_FOUND" } );
46
    my $json = to_json( { success => 0, error => "HOLD_NOT_FOUND" } );
47
    output_with_http_headers( $input, undef, $json, "json" );
49
    exit;
48
    exit;
50
}
49
}
51
50
52
$hold->resume();
51
$hold->resume();
53
52
54
print to_json( { success => !$hold->suspend() } );
53
my $json = to_json( { success => !$hold->suspend() } );
54
output_with_http_headers( $input, undef, $json, "json" );
(-)a/svc/hold/suspend (-7 / +8 lines)
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" );
63
- 

Return to bug 14310