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

(-)a/Koha/CirculationRules.pm (+3 lines)
Lines 169-174 our $RULE_KINDS = { Link Here
169
    decreaseloanholds => {
169
    decreaseloanholds => {
170
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
170
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
171
    },
171
    },
172
    holds_pickup_period => {
173
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
174
    },
172
    # Not included (deprecated?):
175
    # Not included (deprecated?):
173
    #   * accountsent
176
    #   * accountsent
174
    #   * reservecharge
177
    #   * reservecharge
(-)a/Koha/Hold.pm (+12 lines)
Lines 196-201 sub set_waiting { Link Here
196
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
196
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
197
197
198
    my $expirationdate = $today->clone;
198
    my $expirationdate = $today->clone;
199
200
    my $rule = Koha::CirculationRules->get_effective_rule({
201
        categorycode => $self->borrower->categorycode,
202
        itemtype => $self->item->effective_itemtype,
203
        branchcode => $self->branchcode,
204
        rule_name => 'holds_pickup_period',
205
    });
206
    if ( defined($rule) and $rule->rule_value ne '' ){
207
        # circulation rule overrides ReservesMaxPickUpDelay
208
        $max_pickup_delay = $rule->rule_value;
209
    }
210
199
    $expirationdate->add(days => $max_pickup_delay);
211
    $expirationdate->add(days => $max_pickup_delay);
200
212
201
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
213
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
(-)a/admin/smart-rules.pl (+2 lines)
Lines 290-295 elsif ($op eq 'add') { Link Here
290
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
290
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
291
    my $note = $input->param('note');
291
    my $note = $input->param('note');
292
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
292
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
293
    my $holds_pickup_period = strip_non_numeric($input->param('holds_pickup_period'));
293
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
294
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
294
295
295
    my $rules = {
296
    my $rules = {
Lines 325-330 elsif ($op eq 'add') { Link Here
325
        article_requests              => $article_requests,
326
        article_requests              => $article_requests,
326
        note                          => $note,
327
        note                          => $note,
327
        decreaseloanholds             => $decreaseloanholds,
328
        decreaseloanholds             => $decreaseloanholds,
329
        holds_pickup_period           => $holds_pickup_period,
328
    };
330
    };
329
331
330
    Koha::CirculationRules->set_rules(
332
    Koha::CirculationRules->set_rules(
(-)a/installer/data/mysql/atomicupdate/bug_8367-add_holds_pickup_period_circrule.perl (+6 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES (NULL, NULL, NULL, 'holds_pickup_period', NULL) });
4
5
    NewVersion( $DBversion, 8367, "Add holds_pickup_period circulation rule" );
6
}
(-)a/installer/onboarding.pl (+1 lines)
Lines 288-293 if ( $step == 5 ) { Link Here
288
                reservesallowed                  => $reservesallowed,
288
                reservesallowed                  => $reservesallowed,
289
                suspension_chargeperiod          => undef,
289
                suspension_chargeperiod          => undef,
290
                decreaseloanholds                => undef,
290
                decreaseloanholds                => undef,
291
                holds_pickup_period              => undef,
291
              }
292
              }
292
        };
293
        };
293
294
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +6 lines)
Lines 126-131 Link Here
126
                <th>Holds per record (count)</th>
126
                <th>Holds per record (count)</th>
127
                <th>On shelf holds allowed</th>
127
                <th>On shelf holds allowed</th>
128
                <th>OPAC item level holds</th>
128
                <th>OPAC item level holds</th>
129
                <th>Holds pickup period (day)</th>
129
                <th>Article requests</th>
130
                <th>Article requests</th>
130
                <th>Rental discount (%)</th>
131
                <th>Rental discount (%)</th>
131
                <th class="noExport">Actions</th>
132
                <th class="noExport">Actions</th>
Lines 169-176 Link Here
169
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
170
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
170
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
171
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
171
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
172
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
173
                        [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %]
172
174
173
                        [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds %]
175
                        [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || holds_pickup_period %]
174
                        [% IF show_rule %]
176
                        [% IF show_rule %]
175
                            [% SET row_count = row_count + 1 %]
177
                            [% SET row_count = row_count + 1 %]
176
                            <tr row_countd="row_[% row_count | html %]">
178
                            <tr row_countd="row_[% row_count | html %]">
Lines 318-323 Link Here
318
                                            <span>Don't allow</span>
320
                                            <span>Don't allow</span>
319
                                        [% END %]
321
                                        [% END %]
320
                                    </td>
322
                                    </td>
323
                                    <td>[% holds_pickup_period | html %]</td>
321
                                    <td>
324
                                    <td>
322
                                        [% IF article_requests == 'no' %]
325
                                        [% IF article_requests == 'no' %]
323
                                            <span>No</span>
326
                                            <span>No</span>
Lines 450-455 Link Here
450
                            <option value="F">Force</option>
453
                            <option value="F">Force</option>
451
                        </select>
454
                        </select>
452
                    </td>
455
                    </td>
456
                    <td><input type="text" name="holds_pickup_period" id="holds_pickup_period" size="2" /></td>
453
                    <td>
457
                    <td>
454
                        <select id="article_requests" name="article_requests">
458
                        <select id="article_requests" name="article_requests">
455
                            <option value="no">No</option>
459
                            <option value="no">No</option>
Lines 503-508 Link Here
503
                      <th>Holds per record (count)</th>
507
                      <th>Holds per record (count)</th>
504
                      <th>On shelf holds allowed</th>
508
                      <th>On shelf holds allowed</th>
505
                      <th>OPAC item level holds</th>
509
                      <th>OPAC item level holds</th>
510
                      <th>Holds pickup period (day)</th>
506
                      <th>Article requests</th>
511
                      <th>Article requests</th>
507
                      <th>Rental discount (%)</th>
512
                      <th>Rental discount (%)</th>
508
                      <th>&nbsp;</th>
513
                      <th>&nbsp;</th>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (+19 lines)
Lines 271-276 Link Here
271
                                            [% END # / UNLESS singleBranchMode %]
271
                                            [% END # / UNLESS singleBranchMode %]
272
                                        </ul>
272
                                        </ul>
273
273
274
                                        [% IF pickup_delays %]
275
                                            <p id="pickup_delay" style="display:none;">When your item is ready for pickup, you will have <span id="pickup_delay_days"></span> days to pick it up from this library.</p>
276
                                        [% END %]
277
274
                                        <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber | html %]" style="display:none;" href="#">Show more options</a>
278
                                        <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber | html %]" style="display:none;" href="#">Show more options</a>
275
279
276
                                        <div id="hold-options-[% bibitemloo.biblionumber | html %]" class="hold-options">
280
                                        <div id="hold-options-[% bibitemloo.biblionumber | html %]" class="hold-options">
Lines 482-488 Link Here
482
        $(radios).first().attr("checked", "checked");
486
        $(radios).first().attr("checked", "checked");
483
    }
487
    }
484
488
489
    function calculate_delay_days(){
490
        var selected_branch = $("#branch_1").val();
491
        [% FOREACH branchcode IN pickup_delays.keys %]
492
            var branchcode = "[% branchcode | html %]";
493
            if ( branchcode == selected_branch ) {
494
                $("#pickup_delay_days").text([% pickup_delays.$branchcode | html %]);
495
            }
496
        [% END %]
497
    }
498
485
    $(document).ready(function() {
499
    $(document).ready(function() {
500
        calculate_delay_days();
501
        $("#pickup_delay").show();
502
        $("#branch_1").change(function(){
503
            calculate_delay_days();
504
        });
486
        $("#hold-request-form").preventDoubleFormSubmit();
505
        $("#hold-request-form").preventDoubleFormSubmit();
487
        var copiesRowId = null;
506
        var copiesRowId = null;
488
        var wasSpecific = false;
507
        var wasSpecific = false;
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (+11 lines)
Lines 344-349 sub GetWaitingHolds { Link Here
344
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode );
344
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode );
345
345
346
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
346
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
347
        my $rule = Koha::CirculationRules->get_effective_rule({
348
            categorycode => $issue->{categorycode},
349
            itemtype => $item->effective_itemtype,
350
            branchcode => $issue->{branchcode},
351
            rule_name => 'holds_pickup_period',
352
        });
353
        if ( defined($rule) and $rule->rule_value ne '' ){
354
            # circulation rule overrides ReservesMaxPickUpDelay
355
            $pickupdelay = $rule->rule_value;
356
        }
357
347
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
358
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
348
        if ( $calendar->is_holiday($pickup_date) ) {
359
        if ( $calendar->is_holiday($pickup_date) ) {
349
            $pickup_date = $calendar->next_open_days( $pickup_date, 1 );
360
            $pickup_date = $calendar->next_open_days( $pickup_date, 1 );
(-)a/opac/opac-reserve.pl (+15 lines)
Lines 682-685 if ( Link Here
682
    );
682
    );
683
}
683
}
684
684
685
my @branches = Koha::Libraries->search();
686
my %hold_pickup_delay_by_branch = ();
687
688
foreach my $branch ( @branches ) {
689
    my $rule = Koha::CirculationRules->get_effective_rule({
690
        categorycode => $patron->categorycode,
691
        branchcode => $branch->branchcode,
692
        itemtype => undef,
693
        rule_name => 'holds_pickup_period',
694
    });
695
    $hold_pickup_delay_by_branch{$branch->branchcode} = $rule->rule_value if ( $rule and $rule->rule_value );
696
}
697
698
$template->param( pickup_delays => \%hold_pickup_delay_by_branch );
699
685
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
700
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/t/db_dependent/Holds/WaitingReserves.t (-2 / +67 lines)
Lines 8-14 use Koha::DateUtils; Link Here
8
use t::lib::Mocks;
8
use t::lib::Mocks;
9
use t::lib::TestBuilder;
9
use t::lib::TestBuilder;
10
10
11
use Test::More tests => 11;
11
use Test::More tests => 13;
12
12
13
use_ok('C4::Reserves');
13
use_ok('C4::Reserves');
14
14
Lines 63-73 my $biblio = $builder->build_sample_biblio; Link Here
63
my $biblio2 = $builder->build_sample_biblio;
63
my $biblio2 = $builder->build_sample_biblio;
64
my $biblio3 = $builder->build_sample_biblio;
64
my $biblio3 = $builder->build_sample_biblio;
65
my $biblio4 = $builder->build_sample_biblio;
65
my $biblio4 = $builder->build_sample_biblio;
66
my $biblio5 = $builder->build_sample_biblio;
67
my $biblio6 = $builder->build_sample_biblio;
66
68
67
my $item1 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
69
my $item1 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
68
my $item2 = $builder->build_sample_item({biblionumber => $biblio2->biblionumber});
70
my $item2 = $builder->build_sample_item({biblionumber => $biblio2->biblionumber});
69
my $item3 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber});
71
my $item3 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber});
70
my $item4 = $builder->build_sample_item({biblionumber => $biblio4->biblionumber});
72
my $item4 = $builder->build_sample_item({biblionumber => $biblio4->biblionumber});
73
my $item5 = $builder->build_sample_item({biblionumber => $biblio5->biblionumber});
74
my $item6 = $builder->build_sample_item({biblionumber => $biblio6->biblionumber});
75
76
Koha::CirculationRules->set_rules({
77
    categorycode => undef,
78
    itemtype => undef,
79
    branchcode => undef,
80
    rules => {
81
        holds_pickup_period => undef,
82
    }
83
});
71
84
72
my $today = dt_from_string();
85
my $today = dt_from_string();
73
86
Lines 199-202 ModReserveAffect( $item4->itemnumber, $patron2->{borrowernumber}, 0, $reserve4-> Link Here
199
my $r4 = Koha::Holds->find($reserve4->{reserve_id});
212
my $r4 = Koha::Holds->find($reserve4->{reserve_id});
200
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' );
213
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' );
201
214
215
Koha::CirculationRules->set_rules({
216
    categorycode => $patron1->{categorycode},
217
    itemtype => undef,
218
    branchcode => undef,
219
    rules => {
220
        holds_pickup_period => '3',
221
    }
222
});
223
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 7);
224
225
my $reserve5_reservedate = $today->clone;
226
my $reserve5_expirationdate = $reserve5_reservedate->add(days => 3);
227
228
my $reserve5 = $builder->build({
229
    source => 'Reserve',
230
    value => {
231
        borrowernumber => $patron1->{borrowernumber},
232
        reservedate => $reserve5_reservedate->ymd,
233
        expirationdate => undef,
234
        biblionumber => $biblio5->biblionumber,
235
        branchcode => 'LIB2',
236
        priority => 1,
237
        found => '',
238
    },
239
});
240
241
ModReserveAffect( $item5->itemnumber, $patron1->{borrowernumber});
242
my $r5 = Koha::Holds->find($reserve5->{reserve_id});
243
244
is($r5->expirationdate, $reserve5_expirationdate->ymd, 'Expiration date should be set to today + 3 based on circulation rules' );
245
246
my $reserve6_reservedate = $today->clone;
247
# add 3 days of pickup + 1 day of holiday
248
my $reserve6_expirationdate = $reserve6_reservedate->add(days => 5);
249
250
my $reserve6 = $builder->build({
251
    source => 'Reserve',
252
    value => {
253
        borrowernumber => $patron1->{borrowernumber},
254
        reservedate => $reserve6_reservedate->ymd,
255
        expirationdate => undef,
256
        biblionumber => $biblio6->biblionumber,
257
        branchcode => 'LIB1',
258
        priority => 1,
259
        found => '',
260
    },
261
});
262
263
ModReserveAffect( $item6->itemnumber, $patron1->{borrowernumber});
264
my $r6 = Koha::Holds->find($reserve6->{reserve_id});
265
266
is($r6->expirationdate, $reserve6_expirationdate->ymd, 'Expiration date should be set to today + 4 based on circulation rules and including a holiday' );
267
202
$schema->storage->txn_rollback;
268
$schema->storage->txn_rollback;
203
- 

Return to bug 8367