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

(-)a/C4/Reserves.pm (-8 / +20 lines)
Lines 2094-2107 sub RevertWaitingStatus { Link Here
2094
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2094
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2095
2095
2096
    ## Fix up the currently waiting reserve
2096
    ## Fix up the currently waiting reserve
2097
    $hold->set(
2097
    if ( C4::Context->preference('DisableReserveExpiration') ){
2098
        {
2098
        $hold->set(
2099
            priority    => 1,
2099
            {
2100
            found       => undef,
2100
                priority    => 1,
2101
            waitingdate => undef,
2101
                found       => undef,
2102
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2102
                waitingdate => undef,
2103
        }
2103
                expirationdate => undef,
2104
    )->store();
2104
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2105
            }
2106
        )->store();
2107
    } else {
2108
        $hold->set(
2109
            {
2110
                priority    => 1,
2111
                found       => undef,
2112
                waitingdate => undef,
2113
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2114
            }
2115
        )->store();
2116
    }
2105
2117
2106
    _FixPriority( { biblionumber => $hold->biblionumber } );
2118
    _FixPriority( { biblionumber => $hold->biblionumber } );
2107
2119
(-)a/Koha/Hold.pm (-24 / +27 lines)
Lines 185-220 sub set_waiting { Link Here
185
        desk_id => $desk_id,
185
        desk_id => $desk_id,
186
    };
186
    };
187
187
188
    my $requested_expiration;
188
    if ( C4::Context->preference('DisableReserveExpiration') ){
189
    if ($self->expirationdate) {
189
        $values->{expirationdate} = undef;
190
        $requested_expiration = dt_from_string($self->expirationdate);
190
    } else {
191
    }
191
        my $requested_expiration;
192
        if ($self->expirationdate) {
193
            $requested_expiration = dt_from_string($self->expirationdate);
194
        }
192
195
193
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
196
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
194
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
197
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
195
198
196
    my $expirationdate = $today->clone;
199
        my $expirationdate = $today->clone;
197
    $expirationdate->add(days => $max_pickup_delay);
200
        $expirationdate->add(days => $max_pickup_delay);
198
201
199
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
202
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
200
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
203
            my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
201
        my $daysmode = Koha::CirculationRules->get_effective_daysmode(
204
            my $daysmode = Koha::CirculationRules->get_effective_daysmode(
202
            {
205
                {
203
                categorycode => $self->borrower->categorycode,
206
                    categorycode => $self->borrower->categorycode,
204
                itemtype     => $itemtype,
207
                    itemtype     => $itemtype,
205
                branchcode   => $self->branchcode,
208
                    branchcode   => $self->branchcode,
206
            }
209
                }
207
        );
210
            );
208
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
211
            my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
212
            $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
213
        }
209
214
210
        $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
215
        # If patron's requested expiration date is prior to the
216
        # calculated one, we keep the patron's one.
217
        my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
218
        $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
211
    }
219
    }
212
220
213
    # If patron's requested expiration date is prior to the
214
    # calculated one, we keep the patron's one.
215
    my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
216
    $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
217
218
    $self->set($values)->store();
221
    $self->set($values)->store();
219
222
220
    return $self;
223
    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/mandatory/sysprefs.sql (+1 lines)
Lines 175-180 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
175
('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'),
175
('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'),
176
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
176
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
177
('CSVDelimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
177
('CSVDelimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
178
('DisableReserveExpiration', 0, NULL, 'Disable the use of expiration date in reserves module.', 'YesNo'),
178
('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'),
179
('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'),
179
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
180
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
180
('displayFacetCount','0',NULL,NULL,'YesNo'),
181
('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
                  1: "Use"
168
                  1: "Use"
169
                  0: "Don't use"
169
                  0: "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 (-4 / +6 lines)
Lines 522-531 Link Here
522
                                </li>
522
                                </li>
523
                            [% END %]
523
                            [% END %]
524
524
525
                            <li>
525
                            [% IF !Koha.Preference('DisableReserveExpiration') %]
526
                                <label for="to">Hold expires on date:</label>
526
                                <li>
527
                                <input id="expiration_date" name="expiration_date" id="to" size="10" type="text" class="flatpickr" data-flatpickr-futuredate="true" />
527
                                    <label for="to">Hold expires on date:</label>
528
                            </li>
528
                                    <input id="expiration_date" name="expiration_date" id="to" size="10" type="text" class="flatpickr" data-flatpickr-futuredate="true" />
529
                                </li>
530
                            [% END %]
529
531
530
                            [% UNLESS ( multi_hold ) %]
532
                            [% UNLESS ( multi_hold ) %]
531
                                <li>
533
                                <li>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-5 / +7 lines)
Lines 286-296 Link Here
286
                                                    </li>
286
                                                    </li>
287
                                                [% END %]
287
                                                [% END %]
288
288
289
                                                <li>
289
                                                [% IF !Koha.Preference('DisableReserveExpiration') %]
290
                                                    <label for="to[% bibitemloo.biblionumber | html %]">Hold not needed after:</label>
290
                                                    <li>
291
                                                    <input type="text" name="expiration_date_[% bibitemloo.biblionumber | html %]" id="to[% bibitemloo.biblionumber | html %]" size="10" class="holddateto" />
291
                                                        <label for="to[% bibitemloo.biblionumber | html %]">Hold not needed after:</label>
292
                                                    <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
292
                                                        <input type="text" name="expiration_date_[% bibitemloo.biblionumber | html %]" id="to[% bibitemloo.biblionumber | html %]" size="10" class="holddateto" />
293
                                                </li>
293
                                                        <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
294
                                                    </li>
295
                                                [% END %]
294
296
295
                                                [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
297
                                                [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
296
                                                    [% itemtypes = [] %]
298
                                                    [% itemtypes = [] %]
(-)a/t/db_dependent/Hold.t (+34 lines)
Lines 367-369 subtest 'suspend() tests' => sub { Link Here
367
367
368
    $schema->storage->txn_rollback;
368
    $schema->storage->txn_rollback;
369
};
369
};
370
371
subtest 'DisableReserveExpiration syspref tests' => sub {
372
373
    plan tests => 2;
374
375
    $schema->storage->txn_begin;
376
377
    # Disable expiration date for reserves
378
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
379
380
    my $expirationdate = dt_from_string->add( days => 1 );
381
    my $hold = $builder->build_object(
382
        {   class => 'Koha::Holds',
383
            value => { expirationdate => $expirationdate }
384
        }
385
    );
386
    $hold->set_waiting;
387
388
    is( $hold->expirationdate, undef, "No expiration date should be set with reserve expiration disabled" );
389
390
    # Re-enable expiration date for reserves
391
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
392
393
    $hold = $builder->build_object(
394
        {   class => 'Koha::Holds',
395
            value => { expirationdate => $expirationdate }
396
        }
397
    );
398
    $hold->set_waiting();
399
400
    is( $hold->expirationdate, $expirationdate->ymd, "Expiration date is set as expected" );
401
402
    $schema->storage->txn_rollback;
403
};
(-)a/t/db_dependent/Reserves.t (-2 / +35 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 68;
20
use Test::More tests => 69;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1332-1337 subtest 'ModReserveAffect logging' => sub { Link Here
1332
    like( $log->info, qr{$expected}, 'Timestamp logged is the current one' );
1332
    like( $log->info, qr{$expected}, 'Timestamp logged is the current one' );
1333
};
1333
};
1334
1334
1335
subtest 'DisableReserveExpiration syspref tests' => sub {
1336
1337
    plan tests => 2;
1338
1339
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1340
1341
    my $expirationdate = dt_from_string->add( days => 1 );
1342
    my $hold = $builder->build_object(
1343
        {   class => 'Koha::Holds',
1344
            value => { expirationdate => $expirationdate }
1345
        }
1346
    );
1347
1348
    # Disable expiration date for reserves
1349
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
1350
1351
    my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1352
1353
    is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" );
1354
1355
    # Re-enable expiration date for reserves
1356
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1357
1358
    $hold = $builder->build_object(
1359
        {   class => 'Koha::Holds',
1360
            value => { expirationdate => $expirationdate }
1361
        }
1362
    );
1363
1364
    $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1365
1366
    is( $reverted->expirationdate, $expirationdate->ymd, "Expiration date remains as expected" );
1367
};
1368
1335
sub count_hold_print_messages {
1369
sub count_hold_print_messages {
1336
    my $message_count = $dbh->selectall_arrayref(q{
1370
    my $message_count = $dbh->selectall_arrayref(q{
1337
        SELECT COUNT(*)
1371
        SELECT COUNT(*)
1338
- 

Return to bug 24194