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

(-)a/C4/ILSDI/Services.pm (-2 / +6 lines)
Lines 779-786 sub HoldTitle { Link Here
779
    }
779
    }
780
780
781
    my $expdate;
781
    my $expdate;
782
    if ( C4::Context->preference('ReserveExpiration') and $cgi->param('expiry_date') ) {
782
    if ( C4::Context->preference('ReserveExpiration') ) {
783
        $expdate = $cgi->param('expiry_date');
783
        if ( $cgi->param('expiry_date') ) {
784
            $expdate = $cgi->param('expiry_date');
785
        }
786
    } else {
787
        return { code => 'expirationDateDisabled' };
784
    }
788
    }
785
789
786
    # Add the reserve
790
    # 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 $expdate        = C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef;
188
    my $expdate        = $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 = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
200
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
197
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
201
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
198
202
(-)a/Koha/Club/Hold.pm (-1 / +5 lines)
Lines 69-74 sub add { Link Here
69
    Koha::Exceptions::ClubHold::NoPatrons->throw()
69
    Koha::Exceptions::ClubHold::NoPatrons->throw()
70
        unless scalar @enrollments;
70
        unless scalar @enrollments;
71
71
72
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
73
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
74
    }
75
72
    my $biblio = Koha::Biblios->find($params->{biblio_id});
76
    my $biblio = Koha::Biblios->find($params->{biblio_id});
73
77
74
    my $club_params = {
78
    my $club_params = {
Lines 123-129 sub add { Link Here
123
                borrowernumber  => $patron_id,
127
                borrowernumber  => $patron_id,
124
                biblionumber    => $params->{biblio_id},
128
                biblionumber    => $params->{biblio_id},
125
                priority        => $priority,
129
                priority        => $priority,
126
                expiration_date => C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef,
130
                expiration_date => $params->{expiration_date},
127
                notes           => $params->{notes},
131
                notes           => $params->{notes},
128
                title           => $biblio->title,
132
                title           => $biblio->title,
129
                itemnumber      => $params->{item_id},
133
                itemnumber      => $params->{item_id},
(-)a/Koha/Exceptions/Hold.pm (-1 / +5 lines)
Lines 31-37 use Exception::Class ( Link Here
31
    'Koha::Exceptions::Hold::InvalidPickupLocation' => {
31
    'Koha::Exceptions::Hold::InvalidPickupLocation' => {
32
        isa         => 'Koha::Exceptions::Hold',
32
        isa         => 'Koha::Exceptions::Hold',
33
        description => 'The supplied pickup location is not valid'
33
        description => 'The supplied pickup location is not valid'
34
    }
34
    },
35
    'Koha::Exceptions::Hold::ExpirationDateDisabled' => [
36
        isa         => 'Koha::Exceptions::Hold',
37
        description => 'Expiration date not allowed'
38
    },
35
);
39
);
36
40
37
sub full_message {
41
sub full_message {
(-)a/Koha/REST/V1/Clubs/Holds.pm (-1 / +8 lines)
Lines 54-60 sub add { Link Here
54
        my $pickup_library_id = $body->{pickup_library_id};
54
        my $pickup_library_id = $body->{pickup_library_id};
55
        my $item_id           = $body->{item_id};
55
        my $item_id           = $body->{item_id};
56
        my $item_type         = $body->{item_type};
56
        my $item_type         = $body->{item_type};
57
        my $expiration_date   = C4::Context->preference('ReserveExpiration') ? $body->{expiration_date} : undef;
57
        my $expiration_date   = $body->{expiration_date};
58
        my $notes             = $body->{notes};
58
        my $notes             = $body->{notes};
59
        my $default_patron_home = $body->{default_patron_home};
59
        my $default_patron_home = $body->{default_patron_home};
60
60
Lines 103-108 sub add { Link Here
103
            );
103
            );
104
        }
104
        }
105
105
106
        if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) {
107
            return $c->render(
108
                status  => 400,
109
                openapi => { error => "Expiration date not allowed" }
110
            );
111
        }
112
106
        # AddReserve expects date to be in syspref format
113
        # AddReserve expects date to be in syspref format
107
        if ($expiration_date) {
114
        if ($expiration_date) {
108
            $expiration_date = output_pref( dt_from_string( $expiration_date, 'rfc3339' ) );
115
            $expiration_date = output_pref( dt_from_string( $expiration_date, 'rfc3339' ) );
(-)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