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

(-)a/C4/Reserves.pm (-8 / +20 lines)
Lines 2048-2061 sub RevertWaitingStatus { Link Here
2048
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2048
                           ->update({ priority => \'priority + 1' }, { no_triggers => 1 });
2049
2049
2050
    ## Fix up the currently waiting reserve
2050
    ## Fix up the currently waiting reserve
2051
    $hold->set(
2051
    if ( C4::Context->preference('DisableReserveExpiration') ){
2052
        {
2052
        $hold->set(
2053
            priority    => 1,
2053
            {
2054
            found       => undef,
2054
                priority    => 1,
2055
            waitingdate => undef,
2055
                found       => undef,
2056
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2056
                waitingdate => undef,
2057
        }
2057
                expirationdate => undef,
2058
    )->store();
2058
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2059
            }
2060
        )->store();
2061
    } else {
2062
        $hold->set(
2063
            {
2064
                priority    => 1,
2065
                found       => undef,
2066
                waitingdate => undef,
2067
                itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2068
            }
2069
        )->store();
2070
    }
2059
2071
2060
    _FixPriority( { biblionumber => $hold->biblionumber } );
2072
    _FixPriority( { biblionumber => $hold->biblionumber } );
2061
2073
(-)a/Koha/Hold.pm (-24 / +27 lines)
Lines 185-220 sub set_waiting { Link Here
185
        waitingdate => $today->ymd,
185
        waitingdate => $today->ymd,
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 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 => 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 => 65;
20
use Test::More tests => 66;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1190-1195 subtest 'AllowHoldOnPatronPossession test' => sub { Link Here
1190
       'Patron can place hold on an item loaned to itself');
1190
       'Patron can place hold on an item loaned to itself');
1191
};
1191
};
1192
1192
1193
subtest 'DisableReserveExpiration syspref tests' => sub {
1194
1195
    plan tests => 2;
1196
1197
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1198
1199
    my $expirationdate = dt_from_string->add( days => 1 );
1200
    my $hold = $builder->build_object(
1201
        {   class => 'Koha::Holds',
1202
            value => { expirationdate => $expirationdate }
1203
        }
1204
    );
1205
1206
    # Disable expiration date for reserves
1207
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 1 );
1208
1209
    my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1210
1211
    is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" );
1212
1213
    # Re-enable expiration date for reserves
1214
    t::lib::Mocks::mock_preference( 'DisableReserveExpiration', 0 );
1215
1216
    $hold = $builder->build_object(
1217
        {   class => 'Koha::Holds',
1218
            value => { expirationdate => $expirationdate }
1219
        }
1220
    );
1221
1222
    $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber });
1223
1224
    is( $reverted->expirationdate, $expirationdate->ymd, "Expiration date remains as expected" );
1225
};
1226
1193
sub count_hold_print_messages {
1227
sub count_hold_print_messages {
1194
    my $message_count = $dbh->selectall_arrayref(q{
1228
    my $message_count = $dbh->selectall_arrayref(q{
1195
        SELECT COUNT(*)
1229
        SELECT COUNT(*)
1196
- 

Return to bug 24194