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

(-)a/C4/ILSDI/Services.pm (-2 / +6 lines)
Lines 787-794 sub HoldTitle { Link Here
787
787
788
    my $resdate = $cgi->param('start_date');
788
    my $resdate = $cgi->param('start_date');
789
    my $expdate;
789
    my $expdate;
790
    if ( C4::Context->preference('ReserveExpiration') and $cgi->param('expiry_date') ) {
790
    if ( C4::Context->preference('ReserveExpiration') ) {
791
        $expdate = $cgi->param('expiry_date');
791
        if ( $cgi->param('expiry_date') ) {
792
            $expdate = $cgi->param('expiry_date');
793
        }
794
    } else {
795
        return { code => 'expirationDateDisabled' };
792
    }
796
    }
793
797
794
    # Add the reserve
798
    # Add the reserve
(-)a/C4/Reserves.pm (-1 / +5 lines)
Lines 186-192 sub AddReserve { Link Here
186
    my $biblionumber   = $params->{biblionumber};
186
    my $biblionumber   = $params->{biblionumber};
187
    my $priority       = $params->{priority};
187
    my $priority       = $params->{priority};
188
    my $resdate        = $params->{reservation_date};
188
    my $resdate        = $params->{reservation_date};
189
    my $patron_expiration_date = C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef;
189
    my $patron_expiration_date = $params->{expiration_date};
190
    my $notes          = $params->{notes};
190
    my $notes          = $params->{notes};
191
    my $title          = $params->{title};
191
    my $title          = $params->{title};
192
    my $checkitem      = $params->{itemnumber};
192
    my $checkitem      = $params->{itemnumber};
Lines 195-200 sub AddReserve { Link Here
195
    my $non_priority   = $params->{non_priority};
195
    my $non_priority   = $params->{non_priority};
196
    my $item_group_id  = $params->{item_group_id};
196
    my $item_group_id  = $params->{item_group_id};
197
197
198
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
199
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
200
    }
201
198
    $resdate ||= dt_from_string;
202
    $resdate ||= dt_from_string;
199
203
200
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
204
    # 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 102-107 sub add { Link Here
102
            );
102
            );
103
        }
103
        }
104
104
105
        if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) {
106
            return $c->render(
107
                status  => 400,
108
                openapi => { error => "Expiration date not allowed" }
109
            );
110
        }
111
105
        my $club_hold = Koha::Club::Hold::add(
112
        my $club_hold = Koha::Club::Hold::add(
106
            {
113
            {
107
                club_id             => $club_id,
114
                club_id             => $club_id,
(-)a/Koha/REST/V1/Holds.pm (-2 / +8 lines)
Lines 74-80 sub add { Link Here
74
        my $item_id           = $body->{item_id};
74
        my $item_id           = $body->{item_id};
75
        my $patron_id         = $body->{patron_id};
75
        my $patron_id         = $body->{patron_id};
76
        my $item_type         = $body->{item_type};
76
        my $item_type         = $body->{item_type};
77
        my $expiration_date   = C4::Context->preference('ReserveExpiration') ? $body->{expiration_date} : undef;
77
        my $expiration_date   = $body->{expiration_date};
78
        my $notes             = $body->{notes};
78
        my $notes             = $body->{notes};
79
        my $hold_date         = $body->{hold_date};
79
        my $hold_date         = $body->{hold_date};
80
        my $non_priority      = $body->{non_priority};
80
        my $non_priority      = $body->{non_priority};
Lines 89-94 sub add { Link Here
89
            );
89
            );
90
        }
90
        }
91
91
92
        if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) {
93
            return $c->render(
94
                status  => 400,
95
                openapi => { error => "Expiration date not allowed" }
96
            );
97
        }
98
92
        if ( $item_id and $biblio_id ) {
99
        if ( $item_id and $biblio_id ) {
93
100
94
            $biblio = Koha::Biblios->find($biblio_id);
101
            $biblio = Koha::Biblios->find($biblio_id);
95
- 

Return to bug 24194