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

(-)a/Koha/CirculationRules.pm (+3 lines)
Lines 177-182 our $RULE_KINDS = { Link Here
177
    decreaseloanholds => {
177
    decreaseloanholds => {
178
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
178
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
179
    },
179
    },
180
    holds_pickup_period => {
181
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
182
    },
180
    # Not included (deprecated?):
183
    # Not included (deprecated?):
181
    #   * accountsent
184
    #   * accountsent
182
    #   * reservecharge
185
    #   * reservecharge
(-)a/Koha/Hold.pm (+11 lines)
Lines 191-196 sub set_waiting { Link Here
191
191
192
    my $new_expiration_date = $today->clone->add(days => $max_pickup_delay);
192
    my $new_expiration_date = $today->clone->add(days => $max_pickup_delay);
193
193
194
    my $rule = Koha::CirculationRules->get_effective_rule({
195
        categorycode => $self->borrower->categorycode,
196
        itemtype => $self->item->effective_itemtype,
197
        branchcode => $self->branchcode,
198
        rule_name => 'holds_pickup_period',
199
    });
200
    if ( defined($rule) and $rule->rule_value ne '' ){
201
        # circulation rule overrides ReservesMaxPickUpDelay
202
        $max_pickup_delay = $rule->rule_value;
203
    }
204
194
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
205
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
195
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
206
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
196
        my $daysmode = Koha::CirculationRules->get_effective_daysmode(
207
        my $daysmode = Koha::CirculationRules->get_effective_daysmode(
(-)a/admin/smart-rules.pl (+2 lines)
Lines 287-292 elsif ($op eq 'add') { Link Here
287
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
287
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
288
    my $note = $input->param('note');
288
    my $note = $input->param('note');
289
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
289
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
290
    my $holds_pickup_period = strip_non_numeric($input->param('holds_pickup_period'));
290
291
291
    my $rules = {
292
    my $rules = {
292
        maxissueqty                   => $maxissueqty,
293
        maxissueqty                   => $maxissueqty,
Lines 321-326 elsif ($op eq 'add') { Link Here
321
        article_requests              => $article_requests,
322
        article_requests              => $article_requests,
322
        note                          => $note,
323
        note                          => $note,
323
        decreaseloanholds             => $decreaseloanholds,
324
        decreaseloanholds             => $decreaseloanholds,
325
        holds_pickup_period           => $holds_pickup_period,
324
    };
326
    };
325
327
326
    Koha::CirculationRules->set_rules(
328
    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 140-145 Link Here
140
                <th>Holds per record (count)</th>
140
                <th>Holds per record (count)</th>
141
                <th>On shelf holds allowed</th>
141
                <th>On shelf holds allowed</th>
142
                <th>OPAC item level holds</th>
142
                <th>OPAC item level holds</th>
143
                <th>Holds pickup period (day)</th>
143
                <th>Article requests</th>
144
                <th>Article requests</th>
144
                <th>Rental discount (%)</th>
145
                <th>Rental discount (%)</th>
145
                <th class="noExport">Actions</th>
146
                <th class="noExport">Actions</th>
Lines 183-190 Link Here
183
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
184
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
184
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
185
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
185
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
186
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
187
                        [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %]
186
188
187
                        [% 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 %]
189
                        [% 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 %]
188
                        [% IF show_rule %]
190
                        [% IF show_rule %]
189
                            [% SET row_count = row_count + 1 %]
191
                            [% SET row_count = row_count + 1 %]
190
                            <tr row_countd="row_[% row_count | html %]">
192
                            <tr row_countd="row_[% row_count | html %]">
Lines 332-337 Link Here
332
                                            <span>Don't allow</span>
334
                                            <span>Don't allow</span>
333
                                        [% END %]
335
                                        [% END %]
334
                                    </td>
336
                                    </td>
337
                                    <td>[% holds_pickup_period | html %]</td>
335
                                    <td>
338
                                    <td>
336
                                        [% IF article_requests == 'no' %]
339
                                        [% IF article_requests == 'no' %]
337
                                            <span>No</span>
340
                                            <span>No</span>
Lines 464-469 Link Here
464
                            <option value="F">Force</option>
467
                            <option value="F">Force</option>
465
                        </select>
468
                        </select>
466
                    </td>
469
                    </td>
470
                    <td><input type="text" name="holds_pickup_period" id="holds_pickup_period" size="2" /></td>
467
                    <td>
471
                    <td>
468
                        <select id="article_requests" name="article_requests">
472
                        <select id="article_requests" name="article_requests">
469
                            <option value="no">No</option>
473
                            <option value="no">No</option>
Lines 517-522 Link Here
517
                      <th>Holds per record (count)</th>
521
                      <th>Holds per record (count)</th>
518
                      <th>On shelf holds allowed</th>
522
                      <th>On shelf holds allowed</th>
519
                      <th>OPAC item level holds</th>
523
                      <th>OPAC item level holds</th>
524
                      <th>Holds pickup period (day)</th>
520
                      <th>Article requests</th>
525
                      <th>Article requests</th>
521
                      <th>Rental discount (%)</th>
526
                      <th>Rental discount (%)</th>
522
                      <th>&nbsp;</th>
527
                      <th>&nbsp;</th>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (+20 lines)
Lines 273-278 Link Here
273
                                            [% END # / UNLESS singleBranchMode %]
273
                                            [% END # / UNLESS singleBranchMode %]
274
                                        </ul>
274
                                        </ul>
275
275
276
                                        [% IF pickup_delays %]
277
                                            <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>
278
                                        [% END %]
279
276
                                        <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber | html %]" style="display:none;" href="#">Show more options</a>
280
                                        <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber | html %]" style="display:none;" href="#">Show more options</a>
277
281
278
                                        <div id="hold-options-[% bibitemloo.biblionumber | html %]" class="hold-options">
282
                                        <div id="hold-options-[% bibitemloo.biblionumber | html %]" class="hold-options">
Lines 508-513 Link Here
508
        $(radios).first().attr("checked", "checked");
512
        $(radios).first().attr("checked", "checked");
509
    }
513
    }
510
514
515
    function calculate_delay_days(){
516
        var selected_branch = $("#branch_1").val();
517
        [% FOREACH branchcode IN pickup_delays.keys %]
518
            var branchcode = "[% branchcode | html %]";
519
            if ( branchcode == selected_branch ) {
520
                $("#pickup_delay_days").text([% pickup_delays.$branchcode | html %]);
521
            }
522
        [% END %]
523
    }
524
511
    $(document).ready(function() {
525
    $(document).ready(function() {
512
526
513
        $(".toggle_unholdable").click(function(e){
527
        $(".toggle_unholdable").click(function(e){
Lines 515-520 Link Here
515
            $(this).parent('div').find(".unholdable").toggle();
529
            $(this).parent('div').find(".unholdable").toggle();
516
        });
530
        });
517
531
532
        calculate_delay_days();
533
        $("#pickup_delay").show();
534
        $("#branch_1").change(function(){
535
            calculate_delay_days();
536
        });
537
518
        $("#hold-request-form").preventDoubleFormSubmit();
538
        $("#hold-request-form").preventDoubleFormSubmit();
519
        var copiesRowId = null;
539
        var copiesRowId = null;
520
        var wasSpecific = false;
540
        var wasSpecific = false;
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (+11 lines)
Lines 338-343 sub GetWaitingHolds { Link Here
338
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode );
338
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode );
339
339
340
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
340
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
341
        my $rule = Koha::CirculationRules->get_effective_rule({
342
            categorycode => $issue->{categorycode},
343
            itemtype => $item->effective_itemtype,
344
            branchcode => $issue->{branchcode},
345
            rule_name => 'holds_pickup_period',
346
        });
347
        if ( defined($rule) and $rule->rule_value ne '' ){
348
            # circulation rule overrides ReservesMaxPickUpDelay
349
            $pickupdelay = $rule->rule_value;
350
        }
351
341
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
352
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
342
        if ( $calendar->is_holiday($pickup_date) ) {
353
        if ( $calendar->is_holiday($pickup_date) ) {
343
            $pickup_date = $calendar->next_open_days( $pickup_date, 1 );
354
            $pickup_date = $calendar->next_open_days( $pickup_date, 1 );
(-)a/opac/opac-reserve.pl (+15 lines)
Lines 689-692 if ( Link Here
689
    );
689
    );
690
}
690
}
691
691
692
my @branches = Koha::Libraries->search();
693
my %hold_pickup_delay_by_branch = ();
694
695
foreach my $branch ( @branches ) {
696
    my $rule = Koha::CirculationRules->get_effective_rule({
697
        categorycode => $patron->categorycode,
698
        branchcode => $branch->branchcode,
699
        itemtype => undef,
700
        rule_name => 'holds_pickup_period',
701
    });
702
    $hold_pickup_delay_by_branch{$branch->branchcode} = $rule->rule_value if ( $rule and $rule->rule_value );
703
}
704
705
$template->param( pickup_delays => \%hold_pickup_delay_by_branch );
706
692
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
707
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 qw( dt_from_string ); 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', qw( ModReserve ModReserveAffect ));
13
use_ok('C4::Reserves', qw( ModReserve ModReserveAffect ));
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