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

(-)a/C4/ILSDI/Services.pm (-2 / +6 lines)
Lines 778-785 sub HoldTitle { Link Here
778
778
779
    my $resdate = $cgi->param('start_date');
779
    my $resdate = $cgi->param('start_date');
780
    my $expdate;
780
    my $expdate;
781
    if ( C4::Context->preference('ReserveExpiration') and $cgi->param('expiry_date') ) {
781
    if ( C4::Context->preference('ReserveExpiration') ) {
782
        $expdate = $cgi->param('expiry_date');
782
        if ( $cgi->param('expiry_date') ) {
783
            $expdate = $cgi->param('expiry_date');
784
        }
785
    } else {
786
        return { code => 'expirationDateDisabled' };
783
    }
787
    }
784
788
785
    # Add the reserve
789
    # Add the reserve
(-)a/C4/Reserves.pm (-1 / +5 lines)
Lines 185-191 sub AddReserve { Link Here
185
    my $biblionumber   = $params->{biblionumber};
185
    my $biblionumber   = $params->{biblionumber};
186
    my $priority       = $params->{priority};
186
    my $priority       = $params->{priority};
187
    my $resdate        = $params->{reservation_date};
187
    my $resdate        = $params->{reservation_date};
188
    my $patron_expiration_date = C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef;
188
    my $patron_expiration_date = $params->{expiration_date};
189
    my $notes          = $params->{notes};
189
    my $notes          = $params->{notes};
190
    my $title          = $params->{title};
190
    my $title          = $params->{title};
191
    my $checkitem      = $params->{itemnumber};
191
    my $checkitem      = $params->{itemnumber};
Lines 193-198 sub AddReserve { Link Here
193
    my $itemtype       = $params->{itemtype};
193
    my $itemtype       = $params->{itemtype};
194
    my $non_priority   = $params->{non_priority};
194
    my $non_priority   = $params->{non_priority};
195
195
196
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
197
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
198
    }
199
196
    $resdate ||= dt_from_string;
200
    $resdate ||= dt_from_string;
197
201
198
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
202
    # 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 70-75 sub add { Link Here
70
    Koha::Exceptions::ClubHold::NoPatrons->throw()
70
    Koha::Exceptions::ClubHold::NoPatrons->throw()
71
        unless scalar @enrollments;
71
        unless scalar @enrollments;
72
72
73
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
74
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
75
    }
76
73
    my $biblio = Koha::Biblios->find($params->{biblio_id});
77
    my $biblio = Koha::Biblios->find($params->{biblio_id});
74
78
75
    my $club_params = {
79
    my $club_params = {
Lines 125-131 sub add { Link Here
125
                borrowernumber  => $patron_id,
129
                borrowernumber  => $patron_id,
126
                biblionumber    => $params->{biblio_id},
130
                biblionumber    => $params->{biblio_id},
127
                priority        => $priority,
131
                priority        => $priority,
128
                expiration_date => C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef,
132
                expiration_date => $params->{expiration_date},
129
                notes           => $params->{notes},
133
                notes           => $params->{notes},
130
                title           => $biblio->title,
134
                title           => $biblio->title,
131
                itemnumber      => $params->{item_id},
135
                itemnumber      => $params->{item_id},
(-)a/Koha/Exceptions/Hold.pm (+4 lines)
Lines 35-40 use Exception::Class ( Link Here
35
    'Koha::Exceptions::Hold::MissingPickupLocation' => {
35
    'Koha::Exceptions::Hold::MissingPickupLocation' => {
36
        isa         => 'Koha::Exceptions::Hold',
36
        isa         => 'Koha::Exceptions::Hold',
37
        description => 'You must supply a pickup location when placing a hold'
37
        description => 'You must supply a pickup location when placing a hold'
38
    },
39
    'Koha::Exceptions::Hold::ExpirationDateDisabled' => {
40
        isa         => 'Koha::Exceptions::Hold',
41
        description => 'Expiration date not allowed'
38
    }
42
    }
39
);
43
);
40
44
(-)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
            # check they are consistent
101
            # check they are consistent
95
- 

Return to bug 24194