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

(-)a/C4/Reserves.pm (-8 / +20 lines)
Lines 2071-2084 sub RevertWaitingStatus { Link Here
2071
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2071
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2072
2072
2073
    ## Fix up the currently waiting reserve
2073
    ## Fix up the currently waiting reserve
2074
    $hold->set(
2074
    if ( C4::Context->preference('DisableReserveExpiration') ){
2075
        {
2075
        $hold->set(
2076
            priority    => 1,
2076
            {
2077
            found       => undef,
2077
                priority    => 1,
2078
            waitingdate => undef,
2078
                found       => undef,
2079
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2079
                waitingdate => undef,
2080
        }
2080
                expirationdate => undef,
2081
    )->store();
2081
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2082
            }
2083
        )->store();
2084
    } else {
2085
        $hold->set(
2086
            {
2087
                priority    => 1,
2088
                found       => undef,
2089
                waitingdate => undef,
2090
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2091
            }
2092
        )->store();
2093
    }
2082
2094
2083
    _FixPriority( { biblionumber => $hold->biblionumber } );
2095
    _FixPriority( { biblionumber => $hold->biblionumber } );
2084
2096
(-)a/Koha/Hold.pm (-24 / +27 lines)
Lines 187-222 sub set_waiting { Link Here
187
        desk_id => $desk_id,
187
        desk_id => $desk_id,
188
    };
188
    };
189
189
190
    my $requested_expiration;
190
    if ( C4::Context->preference('DisableReserveExpiration') ){
191
    if ($self->expirationdate) {
191
        $values->{expirationdate} = undef;
192
        $requested_expiration = dt_from_string($self->expirationdate);
192
    } else {
193
    }
193
        my $requested_expiration;
194
        if ($self->expirationdate) {
195
            $requested_expiration = dt_from_string($self->expirationdate);
196
        }
194
197
195
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
198
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
196
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
199
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
197
200
198
    my $expirationdate = $today->clone;
201
        my $expirationdate = $today->clone;
199
    $expirationdate->add(days => $max_pickup_delay);
202
        $expirationdate->add(days => $max_pickup_delay);
200
203
201
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
204
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
202
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
205
            my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
203
        my $daysmode = Koha::CirculationRules->get_effective_daysmode(
206
            my $daysmode = Koha::CirculationRules->get_effective_daysmode(
204
            {
207
                {
205
                categorycode => $self->borrower->categorycode,
208
                    categorycode => $self->borrower->categorycode,
206
                itemtype     => $itemtype,
209
                    itemtype     => $itemtype,
207
                branchcode   => $self->branchcode,
210
                    branchcode   => $self->branchcode,
208
            }
211
                }
209
        );
212
            );
210
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
213
            my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
214
            $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
215
        }
211
216
212
        $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
217
        # If patron's requested expiration date is prior to the
218
        # calculated one, we keep the patron's one.
219
        my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
220
        $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
213
    }
221
    }
214
222
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;
219
220
    $self->set($values)->store();
223
    $self->set($values)->store();
221
224
222
    return $self;
225
    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 165-170 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
165
('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'),
165
('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'),
166
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
166
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
167
('CSVDelimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
167
('CSVDelimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
168
('DisableReserveExpiration', 0, NULL, 'Disable the use of expiration date in reserves module.', 'YesNo'),
168
('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'),
169
('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'),
169
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
170
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
170
('displayFacetCount','0',NULL,NULL,'YesNo'),
171
('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 (-6 / +8 lines)
Lines 447-458 Link Here
447
                                </li>
447
                                </li>
448
                            [% END %]
448
                            [% END %]
449
449
450
                            <li>
450
                            [% IF !Koha.Preference('DisableReserveExpiration') %]
451
                                <label for="to">Hold expires on date:</label>
451
                                <li>
452
                                <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
452
                                    <label for="to">Hold expires on date:</label>
453
                                <input type="hidden" class="datepickerto_hidden" />
453
                                    <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
454
                                <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
454
                                    <input type="hidden" class="datepickerto_hidden" />
455
                            </li>
455
                                    <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
456
                                </li>
457
                            [% END %]
456
458
457
                            [% UNLESS ( multi_hold ) %]
459
                            [% UNLESS ( multi_hold ) %]
458
                                <li>
460
                                <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 => 33;
32
use Test::More tests => 34;
33
use Test::Exception;
33
use Test::Exception;
34
use Test::Warn;
34
use Test::Warn;
35
35
Lines 286-288 subtest 'suspend() tests' => sub { Link Here
286
286
287
    $schema->storage->txn_rollback;
287
    $schema->storage->txn_rollback;
288
};
288
};
289
290
subtest 'DisableReserveExpiration syspref tests' => sub {
291
292
    plan tests => 2;
293
294
    $schema->storage->txn_begin;
295
296
    # Disable expiration date for reserves
297
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
298
299
    my $expirationdate = dt_from_string->add( days => 1 );
300
    my $hold = $builder->build_object(
301
        {   class => 'Koha::Holds',
302
            value => { expirationdate => $expirationdate }
303
        }
304
    );
305
    $hold->set_waiting;
306
307
    is( $hold->expirationdate, undef, "No expiration date should be set with reserve expiration disabled" );
308
309
    # Re-enable expiration date for reserves
310
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
311
312
    $hold = $builder->build_object(
313
        {   class => 'Koha::Holds',
314
            value => { expirationdate => $expirationdate }
315
        }
316
    );
317
    $hold->set_waiting();
318
319
    is( $hold->expirationdate, $expirationdate->ymd, "Expiration date is set as expected" );
320
321
    $schema->storage->txn_rollback;
322
};
(-)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 => 66;
20
use Test::More tests => 67;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1218-1223 subtest 'MergeHolds' => sub { Link Here
1218
    is( $biblio_2->holds->count, 1, 'Hold has been transferred' );
1218
    is( $biblio_2->holds->count, 1, 'Hold has been transferred' );
1219
};
1219
};
1220
1220
1221
subtest 'DisableReserveExpiration syspref tests' => sub {
1222
1223
    plan tests => 2;
1224
1225
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1226
1227
    my $expirationdate = dt_from_string->add( days => 1 );
1228
    my $hold = $builder->build_object(
1229
        {   class => 'Koha::Holds',
1230
            value => { expirationdate => $expirationdate }
1231
        }
1232
    );
1233
1234
    # Disable expiration date for reserves
1235
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
1236
1237
    my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1238
1239
    is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" );
1240
1241
    # Re-enable expiration date for reserves
1242
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1243
1244
    $hold = $builder->build_object(
1245
        {   class => 'Koha::Holds',
1246
            value => { expirationdate => $expirationdate }
1247
        }
1248
    );
1249
1250
    $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1251
1252
    is( $reverted->expirationdate, $expirationdate->ymd, "Expiration date remains as expected" );
1253
};
1254
1221
sub count_hold_print_messages {
1255
sub count_hold_print_messages {
1222
    my $message_count = $dbh->selectall_arrayref(q{
1256
    my $message_count = $dbh->selectall_arrayref(q{
1223
        SELECT COUNT(*)
1257
        SELECT COUNT(*)
1224
- 

Return to bug 24194