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

(-)a/C4/Reserves.pm (-8 / +20 lines)
Lines 2027-2040 sub RevertWaitingStatus { Link Here
2027
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2027
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2028
2028
2029
    ## Fix up the currently waiting reserve
2029
    ## Fix up the currently waiting reserve
2030
    $hold->set(
2030
    if ( C4::Context->preference('DisableReserveExpiration') ){
2031
        {
2031
        $hold->set(
2032
            priority    => 1,
2032
            {
2033
            found       => undef,
2033
                priority    => 1,
2034
            waitingdate => undef,
2034
                found       => undef,
2035
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2035
                waitingdate => undef,
2036
        }
2036
                expirationdate => undef,
2037
    )->store();
2037
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2038
            }
2039
        )->store();
2040
    } else {
2041
        $hold->set(
2042
            {
2043
                priority    => 1,
2044
                found       => undef,
2045
                waitingdate => undef,
2046
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2047
            }
2048
        )->store();
2049
    }
2038
2050
2039
    _FixPriority( { biblionumber => $hold->biblionumber } );
2051
    _FixPriority( { biblionumber => $hold->biblionumber } );
2040
2052
(-)a/Koha/Hold.pm (-24 / +27 lines)
Lines 173-208 sub set_waiting { Link Here
173
        waitingdate => $today->ymd,
173
        waitingdate => $today->ymd,
174
    };
174
    };
175
175
176
    my $requested_expiration;
176
    if ( C4::Context->preference('DisableReserveExpiration') ){
177
    if ($self->expirationdate) {
177
        $values->{expirationdate} = undef;
178
        $requested_expiration = dt_from_string($self->expirationdate);
178
    } else {
179
    }
179
        my $requested_expiration;
180
        if ($self->expirationdate) {
181
            $requested_expiration = dt_from_string($self->expirationdate);
182
        }
180
183
181
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
184
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
182
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
185
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
183
186
184
    my $expirationdate = $today->clone;
187
        my $expirationdate = $today->clone;
185
    $expirationdate->add(days => $max_pickup_delay);
188
        $expirationdate->add(days => $max_pickup_delay);
186
189
187
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
190
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
188
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
191
            my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
189
        my $daysmode = Koha::CirculationRules->get_effective_daysmode(
192
            my $daysmode = Koha::CirculationRules->get_effective_daysmode(
190
            {
193
                {
191
                categorycode => $self->borrower->categorycode,
194
                    categorycode => $self->borrower->categorycode,
192
                itemtype     => $itemtype,
195
                    itemtype     => $itemtype,
193
                branchcode   => $self->branchcode,
196
                    branchcode   => $self->branchcode,
194
            }
197
                }
195
        );
198
            );
196
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
199
            my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
200
            $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
201
        }
197
202
198
        $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
203
        # If patron's requested expiration date is prior to the
204
        # calculated one, we keep the patron's one.
205
        my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
206
        $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
199
    }
207
    }
200
208
201
    # If patron's requested expiration date is prior to the
202
    # calculated one, we keep the patron's one.
203
    my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
204
    $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
205
206
    $self->set($values)->store();
209
    $self->set($values)->store();
207
210
208
    return $self;
211
    return $self;
(-)a/installer/data/mysql/atomicupdate/bug24194-add-DisableReserveExpiration-syspref.perl (+7 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ( "DisableReserveExpiration", 0, NULL, "Disable the use of expiration date in reserves module.", "YesNo" ) });
4
5
    SetVersion( $DBversion );
6
    print "Upgrade to $DBversion done (Bug 24194 - DisableReserveExpiration system preference)\n";
7
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 163-168 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
163
('DefaultToLoggedInLibraryNoticesSlips',  '0', NULL ,  'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
163
('DefaultToLoggedInLibraryNoticesSlips',  '0', NULL ,  'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
164
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
164
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
165
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
165
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
166
('DisableReserveExpiration', 0, NULL, 'Disable the use of expiration date in reserves module.', 'YesNo'),
166
('Display856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding staff interface XSLT option must be on','Choice'),
167
('Display856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding staff interface XSLT option must be on','Choice'),
167
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
168
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
168
('displayFacetCount','0',NULL,NULL,'YesNo'),
169
('displayFacetCount','0',NULL,NULL,'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 168-173 Circulation: Link Here
168
                  yes: "Use"
168
                  yes: "Use"
169
                  no: "Don't use"
169
                  no: "Don't use"
170
            - circulation desks with circulation.
170
            - circulation desks with circulation.
171
        -
172
            - pref: DisableReserveExpiration
173
              choices:
174
                  yes: Disable
175
                  no: "Don't disable"
176
            - the use of expiration dates in reserves.
171
177
172
    Checkout policy:
178
    Checkout policy:
173
        -
179
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-6 / +8 lines)
Lines 445-456 Link Here
445
                                </li>
445
                                </li>
446
                            [% END %]
446
                            [% END %]
447
447
448
                            <li>
448
                            [% IF !Koha.Preference('DisableReserveExpiration') %]
449
                                <label for="to">Hold expires on date:</label>
449
                                <li>
450
                                <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
450
                                    <label for="to">Hold expires on date:</label>
451
                                <input type="hidden" class="datepickerto_hidden" />
451
                                    <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
452
                                <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
452
                                    <input type="hidden" class="datepickerto_hidden" />
453
                            </li>
453
                                    <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
454
                                </li>
455
                            [% END %]
454
456
455
                            [% UNLESS ( multi_hold ) %]
457
                            [% UNLESS ( multi_hold ) %]
456
                                <li>
458
                                <li>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-5 / +7 lines)
Lines 284-294 Link Here
284
                                                    </li>
284
                                                    </li>
285
                                                [% END %]
285
                                                [% END %]
286
286
287
                                                <li>
287
                                                [% IF !Koha.Preference('DisableReserveExpiration') %]
288
                                                    <label for="to[% bibitemloo.biblionumber | html %]">Hold not needed after:</label>
288
                                                    <li>
289
                                                    <input type="text" name="expiration_date_[% bibitemloo.biblionumber | html %]" id="to[% bibitemloo.biblionumber | html %]" size="10" class="holddateto" />
289
                                                        <label for="to[% bibitemloo.biblionumber | html %]">Hold not needed after:</label>
290
                                                    <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
290
                                                        <input type="text" name="expiration_date_[% bibitemloo.biblionumber | html %]" id="to[% bibitemloo.biblionumber | html %]" size="10" class="holddateto" />
291
                                                </li>
291
                                                        <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
292
                                                    </li>
293
                                                [% END %]
292
294
293
                                                [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
295
                                                [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
294
                                                    [% itemtypes = [] %]
296
                                                    [% itemtypes = [] %]
(-)a/t/db_dependent/Hold.t (-1 / +35 lines)
Lines 29-35 use Koha::Item; Link Here
29
use Koha::DateUtils;
29
use Koha::DateUtils;
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
31
32
use Test::More tests => 29;
32
use Test::More tests => 30;
33
use Test::Exception;
33
use Test::Exception;
34
use Test::Warn;
34
use Test::Warn;
35
35
Lines 270-272 subtest 'suspend() tests' => sub { Link Here
270
270
271
    $schema->storage->txn_rollback;
271
    $schema->storage->txn_rollback;
272
};
272
};
273
274
subtest 'DisableReserveExpiration syspref tests' => sub {
275
276
    plan tests => 2;
277
278
    $schema->storage->txn_begin;
279
280
    # Disable expiration date for reserves
281
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
282
283
    my $expirationdate = dt_from_string->add( days => 1 );
284
    my $hold = $builder->build_object(
285
        {   class => 'Koha::Holds',
286
            value => { expirationdate => $expirationdate }
287
        }
288
    );
289
    $hold->set_waiting;
290
291
    is( $hold->expirationdate, undef, "No expiration date should be set with reserve expiration disabled" );
292
293
    # Re-enable expiration date for reserves
294
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
295
296
    $hold = $builder->build_object(
297
        {   class => 'Koha::Holds',
298
            value => { expirationdate => $expirationdate }
299
        }
300
    );
301
    $hold->set_waiting();
302
303
    is( $hold->expirationdate, $expirationdate->ymd, "Expiration date is set as expected" );
304
305
    $schema->storage->txn_rollback;
306
};
(-)a/t/db_dependent/Reserves.t (-2 / +34 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 64;
20
use Test::More tests => 65;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1150-1156 subtest 'CheckReserves additional test' => sub { Link Here
1150
    is( $matched_reserve->{reserve_id},
1150
    is( $matched_reserve->{reserve_id},
1151
        $reserve1->reserve_id, "We got the Transit reserve" );
1151
        $reserve1->reserve_id, "We got the Transit reserve" );
1152
    is( scalar @$possible_reserves, 2, 'We do get both reserves' );
1152
    is( scalar @$possible_reserves, 2, 'We do get both reserves' );
1153
};
1154
1155
subtest 'DisableReserveExpiration syspref tests' => sub {
1156
1157
    plan tests => 2;
1158
1159
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1160
1161
    my $expirationdate = dt_from_string->add( days => 1 );
1162
    my $hold = $builder->build_object(
1163
        {   class => 'Koha::Holds',
1164
            value => { expirationdate => $expirationdate }
1165
        }
1166
    );
1167
1168
    # Disable expiration date for reserves
1169
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
1170
1171
    my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1172
1173
    is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" );
1174
1175
    # Re-enable expiration date for reserves
1176
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1177
1178
    $hold = $builder->build_object(
1179
        {   class => 'Koha::Holds',
1180
            value => { expirationdate => $expirationdate }
1181
        }
1182
    );
1183
1184
    $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1153
1185
1186
    is( $reverted->expirationdate, $expirationdate->ymd, "Expiration date remains as expected" );
1154
};
1187
};
1155
1188
1156
sub count_hold_print_messages {
1189
sub count_hold_print_messages {
1157
- 

Return to bug 24194