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

(-)a/C4/Reserves.pm (-8 / +20 lines)
Lines 2063-2076 sub RevertWaitingStatus { Link Here
2063
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2063
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2064
2064
2065
    ## Fix up the currently waiting reserve
2065
    ## Fix up the currently waiting reserve
2066
    $hold->set(
2066
    if ( C4::Context->preference('DisableReserveExpiration') ){
2067
        {
2067
        $hold->set(
2068
            priority    => 1,
2068
            {
2069
            found       => undef,
2069
                priority    => 1,
2070
            waitingdate => undef,
2070
                found       => undef,
2071
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2071
                waitingdate => undef,
2072
        }
2072
                expirationdate => undef,
2073
    )->store();
2073
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2074
            }
2075
        )->store();
2076
    } else {
2077
        $hold->set(
2078
            {
2079
                priority    => 1,
2080
                found       => undef,
2081
                waitingdate => undef,
2082
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2083
            }
2084
        )->store();
2085
    }
2074
2086
2075
    _FixPriority( { biblionumber => $hold->biblionumber } );
2087
    _FixPriority( { biblionumber => $hold->biblionumber } );
2076
2088
(-)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 164-169 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
164
('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
('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
('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
('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
('CSVDelimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
166
('CSVDelimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
167
('DisableReserveExpiration', 0, NULL, 'Disable the use of expiration date in reserves module.', 'YesNo'),
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'),
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'),
168
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
169
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
169
('displayFacetCount','0',NULL,NULL,'YesNo'),
170
('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 449-460 Link Here
449
                                </li>
449
                                </li>
450
                            [% END %]
450
                            [% END %]
451
451
452
                            <li>
452
                            [% IF !Koha.Preference('DisableReserveExpiration') %]
453
                                <label for="to">Hold expires on date:</label>
453
                                <li>
454
                                <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
454
                                    <label for="to">Hold expires on date:</label>
455
                                <input type="hidden" class="datepickerto_hidden" />
455
                                    <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
456
                                <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
456
                                    <input type="hidden" class="datepickerto_hidden" />
457
                            </li>
457
                                    <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
458
                                </li>
459
                            [% END %]
458
460
459
                            [% UNLESS ( multi_hold ) %]
461
                            [% UNLESS ( multi_hold ) %]
460
                                <li>
462
                                <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 1217-1222 subtest 'MergeHolds' => sub { Link Here
1217
    is( $biblio_2->holds->count, 1, 'Hold has been transferred' );
1217
    is( $biblio_2->holds->count, 1, 'Hold has been transferred' );
1218
};
1218
};
1219
1219
1220
subtest 'DisableReserveExpiration syspref tests' => sub {
1221
1222
    plan tests => 2;
1223
1224
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1225
1226
    my $expirationdate = dt_from_string->add( days => 1 );
1227
    my $hold = $builder->build_object(
1228
        {   class => 'Koha::Holds',
1229
            value => { expirationdate => $expirationdate }
1230
        }
1231
    );
1232
1233
    # Disable expiration date for reserves
1234
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
1235
1236
    my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1237
1238
    is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" );
1239
1240
    # Re-enable expiration date for reserves
1241
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1242
1243
    $hold = $builder->build_object(
1244
        {   class => 'Koha::Holds',
1245
            value => { expirationdate => $expirationdate }
1246
        }
1247
    );
1248
1249
    $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1250
1251
    is( $reverted->expirationdate, $expirationdate->ymd, "Expiration date remains as expected" );
1252
};
1253
1220
sub count_hold_print_messages {
1254
sub count_hold_print_messages {
1221
    my $message_count = $dbh->selectall_arrayref(q{
1255
    my $message_count = $dbh->selectall_arrayref(q{
1222
        SELECT COUNT(*)
1256
        SELECT COUNT(*)
1223
- 

Return to bug 24194