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

(-)a/C4/ILSDI/Services.pm (-2 / +6 lines)
Lines 793-800 sub HoldTitle { Link Here
793
793
794
    my $resdate = $cgi->param('start_date');
794
    my $resdate = $cgi->param('start_date');
795
    my $expdate;
795
    my $expdate;
796
    if ( C4::Context->preference('ReserveExpiration') and $cgi->param('expiry_date') ) {
796
    if ( C4::Context->preference('ReserveExpiration') ) {
797
        $expdate = $cgi->param('expiry_date');
797
        if ( $cgi->param('expiry_date') ) {
798
            $expdate = $cgi->param('expiry_date');
799
        }
800
    } else {
801
        return { code => 'expirationDateDisabled' };
798
    }
802
    }
799
803
800
    # Add the reserve
804
    # Add the reserve
(-)a/C4/Reserves.pm (-1 / +5 lines)
Lines 190-196 sub AddReserve { Link Here
190
    my $biblionumber   = $params->{biblionumber};
190
    my $biblionumber   = $params->{biblionumber};
191
    my $priority       = $params->{priority};
191
    my $priority       = $params->{priority};
192
    my $resdate        = $params->{reservation_date};
192
    my $resdate        = $params->{reservation_date};
193
    my $patron_expiration_date = C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef;
193
    my $patron_expiration_date = $params->{expiration_date};
194
    my $notes          = $params->{notes};
194
    my $notes          = $params->{notes};
195
    my $title          = $params->{title};
195
    my $title          = $params->{title};
196
    my $checkitem      = $params->{itemnumber};
196
    my $checkitem      = $params->{itemnumber};
Lines 199-204 sub AddReserve { Link Here
199
    my $non_priority   = $params->{non_priority};
199
    my $non_priority   = $params->{non_priority};
200
    my $item_group_id  = $params->{item_group_id};
200
    my $item_group_id  = $params->{item_group_id};
201
201
202
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
203
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
204
    }
205
202
    $resdate ||= dt_from_string;
206
    $resdate ||= dt_from_string;
203
207
204
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
208
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
(-)a/Koha/Club/Hold.pm (-1 / +5 lines)
Lines 71-76 sub add { Link Here
71
    Koha::Exceptions::ClubHold::NoPatrons->throw()
71
    Koha::Exceptions::ClubHold::NoPatrons->throw()
72
        unless scalar @enrollments;
72
        unless scalar @enrollments;
73
73
74
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
75
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
76
    }
77
74
    my $biblio = Koha::Biblios->find($params->{biblio_id});
78
    my $biblio = Koha::Biblios->find($params->{biblio_id});
75
79
76
    my $club_params = {
80
    my $club_params = {
Lines 126-132 sub add { Link Here
126
                borrowernumber  => $patron_id,
130
                borrowernumber  => $patron_id,
127
                biblionumber    => $params->{biblio_id},
131
                biblionumber    => $params->{biblio_id},
128
                priority        => $priority,
132
                priority        => $priority,
129
                expiration_date => C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef,
133
                expiration_date => $params->{expiration_date},
130
                notes           => $params->{notes},
134
                notes           => $params->{notes},
131
                title           => $biblio->title,
135
                title           => $biblio->title,
132
                itemnumber      => $params->{item_id},
136
                itemnumber      => $params->{item_id},
(-)a/Koha/Exceptions/Hold.pm (+4 lines)
Lines 39-44 use Exception::Class ( Link Here
39
    'Koha::Exceptions::Hold::MissingPickupLocation' => {
39
    'Koha::Exceptions::Hold::MissingPickupLocation' => {
40
        isa         => 'Koha::Exceptions::Hold',
40
        isa         => 'Koha::Exceptions::Hold',
41
        description => 'You must supply a pickup location when placing a hold'
41
        description => 'You must supply a pickup location when placing a hold'
42
    },
43
    'Koha::Exceptions::Hold::ExpirationDateDisabled' => {
44
        isa         => 'Koha::Exceptions::Hold',
45
        description => 'Expiration date not allowed'
42
    }
46
    }
43
);
47
);
44
48
(-)a/Koha/REST/V1/Clubs/Holds.pm (-1 / +8 lines)
Lines 53-59 sub add { Link Here
53
        my $pickup_library_id = $body->{pickup_library_id};
53
        my $pickup_library_id = $body->{pickup_library_id};
54
        my $item_id           = $body->{item_id};
54
        my $item_id           = $body->{item_id};
55
        my $item_type         = $body->{item_type};
55
        my $item_type         = $body->{item_type};
56
        my $expiration_date   = C4::Context->preference('ReserveExpiration') ? $body->{expiration_date} : undef;
56
        my $expiration_date   = $body->{expiration_date};
57
        my $notes             = $body->{notes};
57
        my $notes             = $body->{notes};
58
        my $default_patron_home = $body->{default_patron_home};
58
        my $default_patron_home = $body->{default_patron_home};
59
59
Lines 95-100 sub add { Link Here
95
        return $c->render_resource_not_found("Bibliographic record")
95
        return $c->render_resource_not_found("Bibliographic record")
96
            unless $biblio;
96
            unless $biblio;
97
97
98
        if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) {
99
            return $c->render(
100
                status  => 400,
101
                openapi => { error => "Expiration date not allowed" }
102
            );
103
        }
104
98
        my $club_hold = Koha::Club::Hold::add(
105
        my $club_hold = Koha::Club::Hold::add(
99
            {
106
            {
100
                club_id             => $club_id,
107
                club_id             => $club_id,
(-)a/Koha/REST/V1/Holds.pm (-2 / +8 lines)
Lines 82-88 sub add { Link Here
82
        my $item_id           = $body->{item_id};
82
        my $item_id           = $body->{item_id};
83
        my $patron_id         = $body->{patron_id};
83
        my $patron_id         = $body->{patron_id};
84
        my $item_type         = $body->{item_type};
84
        my $item_type         = $body->{item_type};
85
        my $expiration_date   = C4::Context->preference('ReserveExpiration') ? $body->{expiration_date} : undef;
85
        my $expiration_date   = $body->{expiration_date};
86
        my $notes             = $body->{notes};
86
        my $notes             = $body->{notes};
87
        my $hold_date         = $body->{hold_date};
87
        my $hold_date         = $body->{hold_date};
88
        my $non_priority      = $body->{non_priority};
88
        my $non_priority      = $body->{non_priority};
Lines 97-102 sub add { Link Here
97
            );
97
            );
98
        }
98
        }
99
99
100
        if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) {
101
            return $c->render(
102
                status  => 400,
103
                openapi => { error => "Expiration date not allowed" }
104
            );
105
        }
106
100
        if ( $item_id and $biblio_id ) {
107
        if ( $item_id and $biblio_id ) {
101
108
102
            $biblio = Koha::Biblios->find($biblio_id);
109
            $biblio = Koha::Biblios->find($biblio_id);
103
- 

Return to bug 24194