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

(-)a/C4/Reserves.pm (-2 / +19 lines)
Lines 2225-2233 sub MoveReserve { Link Here
2225
        )->next();
2225
        )->next();
2226
2226
2227
        if ($hold) {
2227
        if ($hold) {
2228
            if ( $hold->itemnumber ) {
2228
2229
2229
            # The item is reserved by the current patron
2230
                # The item is reserved by the current patron
2230
            $hold->fill( { item_id => $item->id } );
2231
                $hold->fill( { item_id => $item->id } );
2232
            } else {
2233
                my $controlbranch = $patron->branchcode;
2234
                if ( C4::Context->preference('ReservesControlBranch') eq 'ItemHomeLibrary' ) {
2235
                    $controlbranch = $item->homebranch;
2236
                }
2237
2238
                my $fill_other_biblio_holds_policy = Koha::CirculationRules->get_effective_rule_value(
2239
                    {
2240
                        categorycode => undef,
2241
                        itemtype     => $item->itype,
2242
                        branchcode   => $controlbranch,
2243
                        rule_name    => 'fill_other_biblio_holds_policy',
2244
                    }
2245
                );
2246
                $hold->fill( { item_id => $item->id } ) if $fill_other_biblio_holds_policy;
2247
            }
2231
        }
2248
        }
2232
2249
2233
        $hold = Koha::Holds->find( $res->{reserve_id} );
2250
        $hold = Koha::Holds->find( $res->{reserve_id} );
(-)a/Koha/CirculationRules.pm (+4 lines)
Lines 74-79 our $RULE_KINDS = { Link Here
74
        scope        => [ 'branchcode', 'itemtype' ],
74
        scope        => [ 'branchcode', 'itemtype' ],
75
        can_be_blank => 0,
75
        can_be_blank => 0,
76
    },
76
    },
77
    fill_other_biblio_holds_policy => {
78
        scope        => [ 'branchcode', 'itemtype' ],
79
        can_be_blank => 0,
80
    },
77
    returnbranch => {
81
    returnbranch => {
78
        scope        => [ 'branchcode', 'itemtype' ],
82
        scope        => [ 'branchcode', 'itemtype' ],
79
        can_be_blank => 0,
83
        can_be_blank => 0,
(-)a/admin/smart-rules.pl (-46 / +55 lines)
Lines 212-222 if ( $op eq 'cud-delete' ) { Link Here
212
                    branchcode => undef,
212
                    branchcode => undef,
213
                    itemtype   => undef,
213
                    itemtype   => undef,
214
                    rules      => {
214
                    rules      => {
215
                        holdallowed             => undef,
215
                        holdallowed                    => undef,
216
                        hold_fulfillment_policy => undef,
216
                        hold_fulfillment_policy        => undef,
217
                        bookings_lead_period    => undef,
217
                        fill_other_biblio_holds_policy => undef,
218
                        bookings_trail_period   => undef,
218
                        bookings_lead_period           => undef,
219
                        returnbranch            => undef,
219
                        bookings_trail_period          => undef,
220
                        returnbranch                   => undef,
220
                    }
221
                    }
221
                }
222
                }
222
            );
223
            );
Lines 226-236 if ( $op eq 'cud-delete' ) { Link Here
226
                    branchcode => undef,
227
                    branchcode => undef,
227
                    itemtype   => $itemtype,
228
                    itemtype   => $itemtype,
228
                    rules      => {
229
                    rules      => {
229
                        holdallowed             => undef,
230
                        holdallowed                    => undef,
230
                        hold_fulfillment_policy => undef,
231
                        hold_fulfillment_policy        => undef,
231
                        bookings_lead_period    => undef,
232
                        fill_other_biblio_holds_policy => undef,
232
                        bookings_trail_period   => undef,
233
                        bookings_lead_period           => undef,
233
                        returnbranch            => undef,
234
                        bookings_trail_period          => undef,
235
                        returnbranch                   => undef,
234
                    }
236
                    }
235
                }
237
                }
236
            );
238
            );
Lines 241-251 if ( $op eq 'cud-delete' ) { Link Here
241
                branchcode => $branch,
243
                branchcode => $branch,
242
                itemtype   => undef,
244
                itemtype   => undef,
243
                rules      => {
245
                rules      => {
244
                    holdallowed             => undef,
246
                    holdallowed                    => undef,
245
                    hold_fulfillment_policy => undef,
247
                    hold_fulfillment_policy        => undef,
246
                    bookings_lead_period    => undef,
248
                    fill_other_biblio_holds_policy => undef,
247
                    bookings_trail_period   => undef,
249
                    bookings_lead_period           => undef,
248
                    returnbranch            => undef,
250
                    bookings_trail_period          => undef,
251
                    returnbranch                   => undef,
249
                }
252
                }
250
            }
253
            }
251
        );
254
        );
Lines 255-265 if ( $op eq 'cud-delete' ) { Link Here
255
                branchcode => $branch,
258
                branchcode => $branch,
256
                itemtype   => $itemtype,
259
                itemtype   => $itemtype,
257
                rules      => {
260
                rules      => {
258
                    holdallowed             => undef,
261
                    holdallowed                    => undef,
259
                    hold_fulfillment_policy => undef,
262
                    hold_fulfillment_policy        => undef,
260
                    bookings_lead_period    => undef,
263
                    fill_other_biblio_holds_policy => undef,
261
                    bookings_trail_period   => undef,
264
                    bookings_lead_period           => undef,
262
                    returnbranch            => undef,
265
                    bookings_trail_period          => undef,
266
                    returnbranch                   => undef,
263
                }
267
                }
264
            }
268
            }
265
        );
269
        );
Lines 609-620 elsif ( $op eq 'cud-add' ) { Link Here
609
        }
613
        }
610
    );
614
    );
611
} elsif ( $op eq "cud-add-branch-item" ) {
615
} elsif ( $op eq "cud-add-branch-item" ) {
612
    my $itemtype                = $input->param('itemtype');
616
    my $itemtype                       = $input->param('itemtype');
613
    my $holdallowed             = $input->param('holdallowed');
617
    my $holdallowed                    = $input->param('holdallowed');
614
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
618
    my $hold_fulfillment_policy        = $input->param('hold_fulfillment_policy');
615
    my $bookings_lead_period    = $input->param('bookings_lead_period');
619
    my $fill_other_biblio_holds_policy = $input->param('fill_other_biblio_holds_policy');
616
    my $bookings_trail_period   = $input->param('bookings_trail_period');
620
    my $bookings_lead_period           = $input->param('bookings_lead_period');
617
    my $returnbranch            = $input->param('returnbranch');
621
    my $bookings_trail_period          = $input->param('bookings_trail_period');
622
    my $returnbranch                   = $input->param('returnbranch');
618
623
619
    if ( $branch eq "*" ) {
624
    if ( $branch eq "*" ) {
620
        if ( $itemtype eq "*" ) {
625
        if ( $itemtype eq "*" ) {
Lines 623-633 elsif ( $op eq 'cud-add' ) { Link Here
623
                    itemtype   => undef,
628
                    itemtype   => undef,
624
                    branchcode => undef,
629
                    branchcode => undef,
625
                    rules      => {
630
                    rules      => {
626
                        holdallowed             => $holdallowed,
631
                        holdallowed                    => $holdallowed,
627
                        hold_fulfillment_policy => $hold_fulfillment_policy,
632
                        hold_fulfillment_policy        => $hold_fulfillment_policy,
628
                        bookings_lead_period    => $bookings_lead_period,
633
                        fill_other_biblio_holds_policy => $fill_other_biblio_holds_policy,
629
                        bookings_trail_period   => $bookings_trail_period,
634
                        bookings_lead_period           => $bookings_lead_period,
630
                        returnbranch            => $returnbranch,
635
                        bookings_trail_period          => $bookings_trail_period,
636
                        returnbranch                   => $returnbranch,
631
                    }
637
                    }
632
                }
638
                }
633
            );
639
            );
Lines 637-647 elsif ( $op eq 'cud-add' ) { Link Here
637
                    itemtype   => $itemtype,
643
                    itemtype   => $itemtype,
638
                    branchcode => undef,
644
                    branchcode => undef,
639
                    rules      => {
645
                    rules      => {
640
                        holdallowed             => $holdallowed,
646
                        holdallowed                    => $holdallowed,
641
                        hold_fulfillment_policy => $hold_fulfillment_policy,
647
                        hold_fulfillment_policy        => $hold_fulfillment_policy,
642
                        bookings_lead_period    => $bookings_lead_period,
648
                        fill_other_biblio_holds_policy => $fill_other_biblio_holds_policy,
643
                        bookings_trail_period   => $bookings_trail_period,
649
                        bookings_lead_period           => $bookings_lead_period,
644
                        returnbranch            => $returnbranch,
650
                        bookings_trail_period          => $bookings_trail_period,
651
                        returnbranch                   => $returnbranch,
645
                    }
652
                    }
646
                }
653
                }
647
            );
654
            );
Lines 652-662 elsif ( $op eq 'cud-add' ) { Link Here
652
                itemtype   => undef,
659
                itemtype   => undef,
653
                branchcode => $branch,
660
                branchcode => $branch,
654
                rules      => {
661
                rules      => {
655
                    holdallowed             => $holdallowed,
662
                    holdallowed                    => $holdallowed,
656
                    hold_fulfillment_policy => $hold_fulfillment_policy,
663
                    hold_fulfillment_policy        => $hold_fulfillment_policy,
657
                    bookings_lead_period    => $bookings_lead_period,
664
                    fill_other_biblio_holds_policy => $fill_other_biblio_holds_policy,
658
                    bookings_trail_period   => $bookings_trail_period,
665
                    bookings_lead_period           => $bookings_lead_period,
659
                    returnbranch            => $returnbranch,
666
                    bookings_trail_period          => $bookings_trail_period,
667
                    returnbranch                   => $returnbranch,
660
                }
668
                }
661
            }
669
            }
662
        );
670
        );
Lines 666-676 elsif ( $op eq 'cud-add' ) { Link Here
666
                itemtype   => $itemtype,
674
                itemtype   => $itemtype,
667
                branchcode => $branch,
675
                branchcode => $branch,
668
                rules      => {
676
                rules      => {
669
                    holdallowed             => $holdallowed,
677
                    holdallowed                    => $holdallowed,
670
                    hold_fulfillment_policy => $hold_fulfillment_policy,
678
                    fill_other_biblio_holds_policy => $fill_other_biblio_holds_policy,
671
                    bookings_lead_period    => $bookings_lead_period,
679
                    hold_fulfillment_policy        => $hold_fulfillment_policy,
672
                    bookings_trail_period   => $bookings_trail_period,
680
                    bookings_lead_period           => $bookings_lead_period,
673
                    returnbranch            => $returnbranch,
681
                    bookings_trail_period          => $bookings_trail_period,
682
                    returnbranch                   => $returnbranch,
674
                }
683
                }
675
            }
684
            }
676
        );
685
        );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +16 lines)
Lines 1310-1315 Link Here
1310
                <tr>
1310
                <tr>
1311
                    <th>Item type</th>
1311
                    <th>Item type</th>
1312
                    <th>Hold policy</th>
1312
                    <th>Hold policy</th>
1313
                    <th>Fill other holds on record</th>
1313
                    <th>Hold and booking pickup library match</th>
1314
                    <th>Hold and booking pickup library match</th>
1314
                    <th>Booking pre-processing (days)</th>
1315
                    <th>Booking pre-processing (days)</th>
1315
                    <th>Booking post-processing (days)</th>
1316
                    <th>Booking post-processing (days)</th>
Lines 1320-1331 Link Here
1320
                    [% SET it = i.itemtype %]
1321
                    [% SET it = i.itemtype %]
1321
                    [% SET c = undef %]
1322
                    [% SET c = undef %]
1322
                    [% SET holdallowed = all_rules.$c.$it.holdallowed %]
1323
                    [% SET holdallowed = all_rules.$c.$it.holdallowed %]
1324
                    [% SET fill_other_biblio_holds_policy = all_rules.$c.$it.fill_other_biblio_holds_policy %]
1323
                    [% SET hold_fulfillment_policy = all_rules.$c.$it.hold_fulfillment_policy %]
1325
                    [% SET hold_fulfillment_policy = all_rules.$c.$it.hold_fulfillment_policy %]
1324
                    [% SET bookings_lead_period = all_rules.$c.$it.bookings_lead_period %]
1326
                    [% SET bookings_lead_period = all_rules.$c.$it.bookings_lead_period %]
1325
                    [% SET bookings_trail_period = all_rules.$c.$it.bookings_trail_period %]
1327
                    [% SET bookings_trail_period = all_rules.$c.$it.bookings_trail_period %]
1326
                    [% SET returnbranch = all_rules.$c.$it.returnbranch %]
1328
                    [% SET returnbranch = all_rules.$c.$it.returnbranch %]
1327
1329
1328
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch || bookings_lead_period || bookings_trail_period %]
1330
                    [% IF holdallowed || hold_fulfillment_policy || fill_other_biblio_holds_policy || returnbranch || bookings_lead_period || bookings_trail_period %]
1329
                        <tr>
1331
                        <tr>
1330
                            <td> [% i.translated_description | html %] </td>
1332
                            <td> [% i.translated_description | html %] </td>
1331
                            <td>
1333
                            <td>
Lines 1339-1344 Link Here
1339
                                    <span>No holds allowed</span>
1341
                                    <span>No holds allowed</span>
1340
                                [% END %]
1342
                                [% END %]
1341
                            </td>
1343
                            </td>
1344
                            <td>
1345
                                [% IF fill_other_biblio_holds_policy %]
1346
                                    <span> Yes </span>
1347
                                [% ELSE %]
1348
                                    <span> No </span>
1349
                                [% END %]
1350
                            </td>
1342
                            <td>
1351
                            <td>
1343
                                [% IF hold_fulfillment_policy == 'any' %]
1352
                                [% IF hold_fulfillment_policy == 'any' %]
1344
                                    <span>any library</span>
1353
                                    <span>any library</span>
Lines 1391-1396 Link Here
1391
                            <option value="not_allowed">No holds allowed</option>
1400
                            <option value="not_allowed">No holds allowed</option>
1392
                        </select>
1401
                        </select>
1393
                    </td>
1402
                    </td>
1403
                    <td>
1404
                        <select name="fill_other_biblio_holds_policy">
1405
                            <option value="1" selected="selected"> Yes </option>
1406
                            <option value="0"> No </option>
1407
                        </select>
1408
                    </td>
1394
                    <td>
1409
                    <td>
1395
                        <select name="hold_fulfillment_policy">
1410
                        <select name="hold_fulfillment_policy">
1396
                            <option value="any"> any library </option>
1411
                            <option value="any"> any library </option>
(-)a/t/db_dependent/Reserves.t (-2 / +33 lines)
Lines 1027-1033 subtest 'ChargeReserveFee tests' => sub { Link Here
1027
1027
1028
subtest 'MoveReserve additional test' => sub {
1028
subtest 'MoveReserve additional test' => sub {
1029
1029
1030
    plan tests => 8;
1030
    plan tests => 10;
1031
1031
1032
    # Create the items and patrons we need
1032
    # Create the items and patrons we need
1033
    my $biblio = $builder->build_sample_biblio();
1033
    my $biblio = $builder->build_sample_biblio();
Lines 1098-1103 subtest 'MoveReserve additional test' => sub { Link Here
1098
    is( $patron_2->holds->count,       0, "The 2nd patron no longer has a hold" );
1098
    is( $patron_2->holds->count,       0, "The 2nd patron no longer has a hold" );
1099
    is( $patron_2->old_holds->count(), 2, "The 2nd patron's hold was filled and moved to old holds" );
1099
    is( $patron_2->old_holds->count(), 2, "The 2nd patron's hold was filled and moved to old holds" );
1100
1100
1101
    my $reserve_4 = AddReserve(
1102
        {
1103
            branchcode     => $item_2->homebranch,
1104
            borrowernumber => $patron_2->borrowernumber,
1105
            biblionumber   => $biblio->biblionumber,
1106
            priority       => 1,
1107
            itemnumber     => undef,
1108
        }
1109
    );
1110
    Koha::CirculationRules->set_rule(
1111
        {
1112
            branchcode => $item_1->homebranch,
1113
            itemtype   => $item_1->itype,
1114
            rule_name  => 'fill_other_biblio_holds_policy',
1115
            rule_value => 0
1116
        }
1117
    );
1118
    Koha::CirculationRules->set_rule(
1119
        {
1120
            branchcode => $patron_2->branchcode,
1121
            itemtype   => $item_1->itype,
1122
            rule_name  => 'fill_other_biblio_holds_policy',
1123
            rule_value => 1
1124
        }
1125
    );
1126
    t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
1127
    MoveReserve( $item_1, $patron_2 );
1128
    is( $patron_2->holds->count, 1, "The hold is not filled because of circ rules" );
1129
    t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
1130
    MoveReserve( $item_1, $patron_2 );
1131
    is( $patron_2->holds->count, 0, "The hold is filled because of circ rules and affected by ReservesControlBranch" );
1132
1101
};
1133
};
1102
1134
1103
# FIXME: Should be in Circulation.t
1135
# FIXME: Should be in Circulation.t
1104
- 

Return to bug 41267