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 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 194-199 sub AddReserve { Link Here
194
    my $non_priority   = $params->{non_priority};
194
    my $non_priority   = $params->{non_priority};
195
    my $item_group_id  = $params->{item_group_id};
195
    my $item_group_id  = $params->{item_group_id};
196
196
197
    if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) {
198
        Koha::Exceptions::Hold::ExpirationDateDisabled->throw;
199
    }
200
197
    $resdate ||= dt_from_string;
201
    $resdate ||= dt_from_string;
198
202
199
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
203
    # 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