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

(-)a/C4/Circulation.pm (-32 / +50 lines)
Lines 1659-1701 Neither C<$branchcode> nor C<$itemtype> should be '*'. Link Here
1659
1659
1660
sub GetBranchItemRule {
1660
sub GetBranchItemRule {
1661
    my ( $branchcode, $itemtype ) = @_;
1661
    my ( $branchcode, $itemtype ) = @_;
1662
    my $dbh = C4::Context->dbh();
1662
1663
    my $result = {};
1663
    # Set search precedences
1664
1664
    my @params = (
1665
    my @attempts = (
1665
        {
1666
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1666
            branchcode   => $branchcode,
1667
            FROM branch_item_rules
1667
            categorycode => undef,
1668
            WHERE branchcode = ?
1668
            itemtype     => $itemtype,
1669
              AND itemtype = ?', $branchcode, $itemtype],
1669
        },
1670
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1670
        {
1671
            FROM default_branch_circ_rules
1671
            branchcode   => $branchcode,
1672
            WHERE branchcode = ?', $branchcode],
1672
            categorycode => undef,
1673
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1673
            itemtype     => undef,
1674
            FROM default_branch_item_rules
1674
        },
1675
            WHERE itemtype = ?', $itemtype],
1675
        {
1676
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1676
            branchcode   => undef,
1677
            FROM default_circ_rules'],
1677
            categorycode => undef,
1678
            itemtype     => $itemtype,
1679
        },
1680
        {
1681
            branchcode   => undef,
1682
            categorycode => undef,
1683
            itemtype     => undef,
1684
        },
1678
    );
1685
    );
1679
1686
1680
    foreach my $attempt (@attempts) {
1687
    # Initialize default values
1681
        my ($query, @bind_params) = @{$attempt};
1688
    my $rules = {
1682
        my $search_result = $dbh->selectrow_hashref ( $query , {}, @bind_params )
1689
        holdallowed             => undef,
1683
          or next;
1690
        hold_fulfillment_policy => undef,
1684
1691
        returnbranch            => undef,
1685
        # Since branch/category and branch/itemtype use the same per-branch
1692
    };
1686
        # defaults tables, we have to check that the key we want is set, not
1693
1687
        # just that a row was returned
1694
    # Search for rules!
1688
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1695
    foreach my $rule_name (qw( holdallowed hold_fulfillment_policy returnbranch )) {
1689
        $result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} );
1696
        foreach my $params (@params) {
1690
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1697
            my $rule = Koha::CirculationRules->search(
1698
                {
1699
                    rule_name => $rule_name,
1700
                    %$params,
1701
                }
1702
            )->next();
1703
1704
            if ( $rule ) {
1705
                $rules->{$rule_name} = $rule->rule_value;
1706
                last;
1707
            }
1708
        }
1691
    }
1709
    }
1692
    
1710
1693
    # built-in default circulation rule
1711
    # built-in default circulation rule
1694
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1712
    $rules->{holdallowed} = 2                 unless ( defined $rules->{holdallowed} );
1695
    $result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} );
1713
    $rules->{hold_fulfillment_policy} = 'any' unless ( defined $rules->{hold_fulfillment_policy} );
1696
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
1714
    $rules->{returnbranch} = 'homebranch'     unless ( defined $rules->{returnbranch} );
1697
1715
1698
    return $result;
1716
    return $rules;
1699
}
1717
}
1700
1718
1701
=head2 AddReturn
1719
=head2 AddReturn
(-)a/admin/smart-rules.pl (-201 / +164 lines)
Lines 89-135 elsif ($op eq 'delete-branch-cat') { Link Here
89
    my $categorycode  = $input->param('categorycode');
89
    my $categorycode  = $input->param('categorycode');
90
    if ($branch eq "*") {
90
    if ($branch eq "*") {
91
        if ($categorycode eq "*") {
91
        if ($categorycode eq "*") {
92
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
92
             Koha::CirculationRules->set_rules(
93
            $sth_delete->execute();
93
                 {
94
                     categorycode => undef,
95
                     branchcode   => undef,
96
                     itemtype     => undef,
97
                     rules        => {
98
                         patron_maxissueqty             => undef,
99
                         patron_maxonsiteissueqty       => undef,
100
                         holdallowed             => undef,
101
                         hold_fulfillment_policy => undef,
102
                         returnbranch            => undef,
103
                     }
104
                 }
105
             );
106
         } else {
107
             Koha::CirculationRules->set_rules(
108
                 {
109
                     categorycode => $categorycode,
110
                     branchcode   => undef,
111
                     itemtype     => undef,
112
                     rules        => {
113
                         max_holds         => undef,
114
                         patron_maxissueqty       => undef,
115
                         patron_maxonsiteissueqty => undef,
116
                     }
117
                 }
118
             );
94
        }
119
        }
95
    } elsif ($categorycode eq "*") {
120
    } elsif ($categorycode eq "*") {
96
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
121
        Koha::CirculationRules->set_rules(
97
                                        WHERE branchcode = ?");
122
            {
98
        $sth_delete->execute($branch);
123
                categorycode => undef,
99
    }
124
                branchcode   => $branch,
100
    Koha::CirculationRules->set_rules(
125
                itemtype     => undef,
101
        {
126
                rules        => {
102
            categorycode => $categorycode eq '*' ? undef : $categorycode,
127
                    patron_maxissueqty             => undef,
103
            branchcode   => $branch eq '*'       ? undef : $branch,
128
                    patron_maxonsiteissueqty       => undef,
104
            itemtype     => undef,
129
                    holdallowed             => undef,
105
            rules        => {
130
                    hold_fulfillment_policy => undef,
106
                max_holds         => undef,
131
                    returnbranch            => undef,
107
                patron_maxissueqty             => undef,
132
                }
108
                patron_maxonsiteissueqty       => undef,
109
            }
133
            }
110
        }
134
        );
111
    );
135
    } else {
136
        Koha::CirculationRules->set_rules(
137
            {
138
                categorycode => $categorycode,
139
                branchcode   => $branch,
140
                itemtype     => undef,
141
                rules        => {
142
                    max_holds         => undef,
143
                    patron_maxissueqty       => undef,
144
                    patron_maxonsiteissueqty => undef,
145
                }
146
            }
147
        );
148
    }
112
}
149
}
113
elsif ($op eq 'delete-branch-item') {
150
elsif ($op eq 'delete-branch-item') {
114
    my $itemtype  = $input->param('itemtype');
151
    my $itemtype  = $input->param('itemtype');
115
    if ($branch eq "*") {
152
    if ($branch eq "*") {
116
        if ($itemtype eq "*") {
153
        if ($itemtype eq "*") {
117
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
154
            Koha::CirculationRules->set_rules(
118
            $sth_delete->execute();
155
                {
156
                    categorycode => undef,
157
                    branchcode   => undef,
158
                    itemtype     => undef,
159
                    rules        => {
160
                        patron_maxissueqty             => undef,
161
                        patron_maxonsiteissueqty       => undef,
162
                        holdallowed             => undef,
163
                        hold_fulfillment_policy => undef,
164
                        returnbranch            => undef,
165
                    }
166
                }
167
            );
119
        } else {
168
        } else {
120
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
169
            Koha::CirculationRules->set_rules(
121
                                            WHERE itemtype = ?");
170
                {
122
            $sth_delete->execute($itemtype);
171
                    categorycode => undef,
172
                    branchcode   => undef,
173
                    itemtype     => $itemtype,
174
                    rules        => {
175
                        holdallowed             => undef,
176
                        hold_fulfillment_policy => undef,
177
                        returnbranch            => undef,
178
                    }
179
                }
180
            );
123
        }
181
        }
124
    } elsif ($itemtype eq "*") {
182
    } elsif ($itemtype eq "*") {
125
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
183
        Koha::CirculationRules->set_rules(
126
                                        WHERE branchcode = ?");
184
            {
127
        $sth_delete->execute($branch);
185
                categorycode => undef,
186
                branchcode   => $branch,
187
                itemtype     => undef,
188
                rules        => {
189
                    maxissueqty             => undef,
190
                    maxonsiteissueqty       => undef,
191
                    holdallowed             => undef,
192
                    hold_fulfillment_policy => undef,
193
                    returnbranch            => undef,
194
                }
195
            }
196
        );
128
    } else {
197
    } else {
129
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
198
        Koha::CirculationRules->set_rules(
130
                                        WHERE branchcode = ?
199
            {
131
                                        AND itemtype = ?");
200
                categorycode => undef,
132
        $sth_delete->execute($branch, $itemtype);
201
                branchcode   => $branch,
202
                itemtype     => $itemtype,
203
                rules        => {
204
                    holdallowed             => undef,
205
                    hold_fulfillment_policy => undef,
206
                    returnbranch            => undef,
207
                }
208
            }
209
        );
133
    }
210
    }
134
}
211
}
135
# save the values entered
212
# save the values entered
Lines 251-309 elsif ($op eq "set-branch-defaults") { Link Here
251
    $max_holds = '' if $max_holds !~ /^\d+/;
328
    $max_holds = '' if $max_holds !~ /^\d+/;
252
329
253
    if ($branch eq "*") {
330
    if ($branch eq "*") {
254
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
255
                                        FROM default_circ_rules");
256
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
257
                                        (holdallowed, hold_fulfillment_policy, returnbranch)
258
                                        VALUES (?, ?, ?)");
259
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
260
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
261
262
        $sth_search->execute();
263
        my $res = $sth_search->fetchrow_hashref();
264
        if ($res->{total}) {
265
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
266
        } else {
267
            $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
268
        }
269
270
        Koha::CirculationRules->set_rules(
331
        Koha::CirculationRules->set_rules(
271
            {
332
            {
272
                categorycode => undef,
333
                categorycode => undef,
273
                itemtype     => undef,
334
                itemtype     => undef,
274
                branchcode   => undef,
335
                branchcode   => undef,
275
                rules        => {
336
                rules        => {
276
                    patron_maxissueqty             => $patron_maxissueqty,
337
                    patron_maxissueqty       => $patron_maxissueqty,
277
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
338
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
339
                    holdallowed              => $holdallowed,
340
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
341
                    returnbranch             => $returnbranch,
278
                }
342
                }
279
            }
343
            }
280
        );
344
        );
281
    } else {
345
    } else {
282
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
283
                                        FROM default_branch_circ_rules
284
                                        WHERE branchcode = ?");
285
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
286
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
287
                                        VALUES (?, ?, ?, ?)");
288
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
289
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
290
                                        WHERE branchcode = ?");
291
        $sth_search->execute($branch);
292
        my $res = $sth_search->fetchrow_hashref();
293
        if ($res->{total}) {
294
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
295
        } else {
296
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
297
        }
298
299
        Koha::CirculationRules->set_rules(
346
        Koha::CirculationRules->set_rules(
300
            {
347
            {
301
                categorycode => undef,
348
                categorycode => undef,
302
                itemtype     => undef,
349
                itemtype     => undef,
303
                branchcode   => $branch,
350
                branchcode   => $branch,
304
                rules        => {
351
                rules        => {
305
                    patron_maxissueqty             => $patron_maxissueqty,
352
                    patron_maxissueqty       => $patron_maxissueqty,
306
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
353
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
354
                    holdallowed              => $holdallowed,
355
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
356
                    returnbranch             => $returnbranch,
307
                }
357
                }
308
            }
358
            }
309
        );
359
        );
Lines 397-472 elsif ($op eq "add-branch-item") { Link Here
397
447
398
    if ($branch eq "*") {
448
    if ($branch eq "*") {
399
        if ($itemtype eq "*") {
449
        if ($itemtype eq "*") {
400
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
450
            Koha::CirculationRules->set_rules(
401
                                            FROM default_circ_rules");
451
                {
402
            my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
452
                    categorycode => undef,
403
                                            (holdallowed, hold_fulfillment_policy, returnbranch)
453
                    itemtype     => undef,
404
                                            VALUES (?, ?, ?)");
454
                    branchcode   => undef,
405
            my $sth_update = $dbh->prepare("UPDATE default_circ_rules
455
                    rules        => {
406
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
456
                        holdallowed             => $holdallowed,
407
457
                        hold_fulfillment_policy => $hold_fulfillment_policy,
408
            $sth_search->execute();
458
                        returnbranch            => $returnbranch,
409
            my $res = $sth_search->fetchrow_hashref();
459
                    }
410
            if ($res->{total}) {
460
                }
411
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
461
            );
412
            } else {
413
                $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
414
            }
415
        } else {
462
        } else {
416
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
463
            Koha::CirculationRules->set_rules(
417
                                            FROM default_branch_item_rules
464
                {
418
                                            WHERE itemtype = ?");
465
                    categorycode => undef,
419
            my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules
466
                    itemtype     => $itemtype,
420
                                            (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
467
                    branchcode   => undef,
421
                                            VALUES (?, ?, ?, ?)");
468
                    rules        => {
422
            my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules
469
                        holdallowed             => $holdallowed,
423
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
470
                        hold_fulfillment_policy => $hold_fulfillment_policy,
424
                                            WHERE itemtype = ?");
471
                        returnbranch            => $returnbranch,
425
            $sth_search->execute($itemtype);
472
                    }
426
            my $res = $sth_search->fetchrow_hashref();
473
                }
427
            if ($res->{total}) {
474
            );
428
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype);
429
            } else {
430
                $sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
431
            }
432
        }
475
        }
433
    } elsif ($itemtype eq "*") {
476
    } elsif ($itemtype eq "*") {
434
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
477
            Koha::CirculationRules->set_rules(
435
                                        FROM default_branch_circ_rules
478
                {
436
                                        WHERE branchcode = ?");
479
                    categorycode => undef,
437
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
480
                    itemtype     => undef,
438
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
481
                    branchcode   => $branch,
439
                                        VALUES (?, ?, ?, ?)");
482
                    rules        => {
440
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
483
                        holdallowed             => $holdallowed,
441
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
484
                        hold_fulfillment_policy => $hold_fulfillment_policy,
442
                                        WHERE branchcode = ?");
485
                        returnbranch            => $returnbranch,
443
        $sth_search->execute($branch);
486
                    }
444
        my $res = $sth_search->fetchrow_hashref();
487
                }
445
        if ($res->{total}) {
488
            );
446
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
447
        } else {
448
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
449
        }
450
    } else {
489
    } else {
451
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
490
        Koha::CirculationRules->set_rules(
452
                                        FROM branch_item_rules
491
            {
453
                                        WHERE branchcode = ?
492
                categorycode => undef,
454
                                        AND   itemtype = ?");
493
                itemtype     => $itemtype,
455
        my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules
494
                branchcode   => $branch,
456
                                        (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
495
                rules        => {
457
                                        VALUES (?, ?, ?, ?, ?)");
496
                    holdallowed             => $holdallowed,
458
        my $sth_update = $dbh->prepare("UPDATE branch_item_rules
497
                    hold_fulfillment_policy => $hold_fulfillment_policy,
459
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
498
                    returnbranch            => $returnbranch,
460
                                        WHERE branchcode = ?
499
                }
461
                                        AND itemtype = ?");
500
            }
462
501
        );
463
        $sth_search->execute($branch, $itemtype);
464
        my $res = $sth_search->fetchrow_hashref();
465
        if ($res->{total}) {
466
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype);
467
        } else {
468
            $sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
469
        }
470
    }
502
    }
471
}
503
}
472
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
504
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
Lines 549-624 while (my $row = $sth2->fetchrow_hashref) { Link Here
549
581
550
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
582
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
551
583
552
my $sth_branch_item;
553
if ($branch eq "*") {
554
    $sth_branch_item = $dbh->prepare("
555
        SELECT default_branch_item_rules.*,
556
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
557
        FROM default_branch_item_rules
558
        JOIN itemtypes USING (itemtype)
559
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
560
            AND localization.entity = 'itemtypes'
561
            AND localization.lang = ?
562
    ");
563
    $sth_branch_item->execute($language);
564
} else {
565
    $sth_branch_item = $dbh->prepare("
566
        SELECT branch_item_rules.*,
567
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
568
        FROM branch_item_rules
569
        JOIN itemtypes USING (itemtype)
570
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
571
            AND localization.entity = 'itemtypes'
572
            AND localization.lang = ?
573
        WHERE branch_item_rules.branchcode = ?
574
    ");
575
    $sth_branch_item->execute($language, $branch);
576
}
577
578
my @branch_item_rules = ();
579
while (my $row = $sth_branch_item->fetchrow_hashref) {
580
    push @branch_item_rules, $row;
581
}
582
my @sorted_branch_item_rules = sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @branch_item_rules;
583
584
# note undef holdallowed so that template can deal with them
585
foreach my $entry (@sorted_branch_item_rules) {
586
    $entry->{holdallowed_any}  = 1 if ( $entry->{holdallowed} == 2 );
587
    $entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 );
588
}
589
590
$template->param(show_branch_cat_rule_form => 1);
584
$template->param(show_branch_cat_rule_form => 1);
591
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules);
592
593
my $sth_defaults;
594
if ($branch eq "*") {
595
    $sth_defaults = $dbh->prepare("
596
        SELECT *
597
        FROM default_circ_rules
598
    ");
599
    $sth_defaults->execute();
600
} else {
601
    $sth_defaults = $dbh->prepare("
602
        SELECT *
603
        FROM default_branch_circ_rules
604
        WHERE branchcode = ?
605
    ");
606
    $sth_defaults->execute($branch);
607
}
608
609
my $defaults = $sth_defaults->fetchrow_hashref;
610
611
if ($defaults) {
612
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
613
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
614
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
615
    $template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} );
616
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
617
    $template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} );
618
    $template->param( default_returnbranch      => $defaults->{returnbranch} );
619
}
620
621
$template->param(default_rules => ($defaults ? 1 : 0));
622
585
623
$template->param(
586
$template->param(
624
    patron_categories => $patron_categories,
587
    patron_categories => $patron_categories,
(-)a/installer/data/mysql/atomicupdate/bug_18928.perl (+81 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    if ( column_exists( 'default_circ_rules', 'holdallowed' ) ) {
4
        $dbh->do("
5
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
6
            SELECT NULL, NULL, NULL, 'holdallowed', holdallowed
7
            FROM default_circ_rules
8
        ");
9
        $dbh->do("
10
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
11
            SELECT NULL, NULL, NULL, 'hold_fulfillment_policy', hold_fulfillment_policy
12
            FROM default_circ_rules
13
        ");
14
        $dbh->do("
15
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
16
            SELECT NULL, NULL, NULL, 'returnbranch', returnbranch
17
            FROM default_circ_rules
18
        ");
19
        $dbh->do("DROP TABLE default_circ_rules");
20
    }
21
22
    if ( column_exists( 'default_branch_circ_rules', 'holdallowed' ) ) {
23
        $dbh->do("
24
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
25
            SELECT NULL, branchcode, NULL, 'holdallowed', holdallowed
26
            FROM default_branch_circ_rules
27
        ");
28
        $dbh->do("
29
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
30
            SELECT NULL, branchcode, NULL, 'hold_fulfillment_policy', hold_fulfillment_policy
31
            FROM default_branch_circ_rules
32
        ");
33
        $dbh->do("
34
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
35
            SELECT NULL, branchcode, NULL, 'returnbranch', returnbranch
36
            FROM default_branch_circ_rules
37
        ");
38
        $dbh->do("DROP TABLE default_branch_circ_rules");
39
    }
40
41
    if ( column_exists( 'branch_item_rules', 'holdallowed' ) ) {
42
        $dbh->do("
43
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
44
            SELECT NULL, branchcode, itemtype, 'holdallowed', holdallowed
45
            FROM branch_item_rules
46
        ");
47
        $dbh->do("
48
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
49
            SELECT NULL, branchcode, itemtype, 'hold_fulfillment_policy', hold_fulfillment_policy
50
            FROM branch_item_rules
51
        ");
52
        $dbh->do("
53
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
54
            SELECT NULL, branchcode, itemtype, 'returnbranch', returnbranch
55
            FROM branch_item_rules
56
        ");
57
        $dbh->do("DROP TABLE branch_item_rules");
58
    }
59
60
    if ( column_exists( 'default_branch_item_rules', 'holdallowed' ) ) {
61
        $dbh->do("
62
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
63
            SELECT NULL, NULL, itemtype, 'holdallowed', holdallowed
64
            FROM default_branch_item_rules
65
        ");
66
        $dbh->do("
67
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
68
            SELECT NULL, NULL, itemtype, 'hold_fulfillment_policy', hold_fulfillment_policy
69
            FROM default_branch_item_rules
70
        ");
71
        $dbh->do("
72
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
73
            SELECT NULL, NULL, itemtype, 'returnbranch', returnbranch
74
            FROM default_branch_item_rules
75
        ");
76
        $dbh->do("DROP TABLE default_branch_item_rules");
77
    }
78
79
    SetVersion( $DBversion );
80
    print "Upgrade to $DBversion done (Bug 18928 - Move holdallowed, hold_fulfillment_policy, returnbranch to circulation_rules)\n";
81
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-56 / +75 lines)
Lines 415-438 Link Here
415
                    </td>
415
                    </td>
416
                    <td>
416
                    <td>
417
                        <select name="holdallowed">
417
                        <select name="holdallowed">
418
                            [% IF ( default_holdallowed_any ) %]
418
                            [% SET holdallowed = CirculationRules.Get( branchcode, undef, undef, 'holdallowed' ) %]
419
                            <option value="2" selected="selected">
419
                            <option value="">
420
                                Not set
421
                            </option>
422
423
                            [% IF holdallowed == 2 %]
424
                                <option value="2" selected="selected">
420
                            [% ELSE %]
425
                            [% ELSE %]
421
                            <option value="2">
426
                                <option value="2">
422
                            [% END %]
427
                            [% END %]
423
                                From any library
428
                                From any library
424
                            </option>
429
                            </option>
425
                            [% IF ( default_holdallowed_same ) %]
430
426
                            <option value="1" selected="selected">
431
                            [% IF holdallowed == 1 %]
432
                                <option value="1" selected="selected">
427
                            [% ELSE %]
433
                            [% ELSE %]
428
                            <option value="1">
434
                                <option value="1">
429
                            [% END %]
435
                            [% END %]
430
                                From home library
436
                                From home library
431
                            </option>
437
                            </option>
432
                            [% IF ( default_holdallowed_none ) %]
438
433
                            <option value="0" selected="selected">
439
                            [% IF holdallowed == 0 %]
440
                                <option value="0" selected="selected">
434
                            [% ELSE %]
441
                            [% ELSE %]
435
                            <option value="0">
442
                                <option value="0">
436
                            [% END %]
443
                            [% END %]
437
                                No holds allowed
444
                                No holds allowed
438
                            </option>
445
                            </option>
Lines 440-446 Link Here
440
                    </td>
447
                    </td>
441
                    <td>
448
                    <td>
442
                        <select name="hold_fulfillment_policy">
449
                        <select name="hold_fulfillment_policy">
443
                            [% IF default_hold_fulfillment_policy == 'any' %]
450
                            [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, undef, 'hold_fulfillment_policy' ) %]
451
452
                            <option value="">
453
                                Not set
454
                            </option>
455
456
                            [% IF hold_fulfillment_policy == 'any' %]
444
                                <option value="any" selected="selected">
457
                                <option value="any" selected="selected">
445
                                    any library
458
                                    any library
446
                                </option>
459
                                </option>
Lines 450-456 Link Here
450
                                </option>
463
                                </option>
451
                            [% END %]
464
                            [% END %]
452
465
453
                            [% IF default_hold_fulfillment_policy == 'homebranch' %]
466
                            [% IF hold_fulfillment_policy == 'homebranch' %]
454
                                <option value="homebranch" selected="selected">
467
                                <option value="homebranch" selected="selected">
455
                                    item's home library
468
                                    item's home library
456
                                </option>
469
                                </option>
Lines 460-466 Link Here
460
                                </option>
473
                                </option>
461
                            [% END %]
474
                            [% END %]
462
475
463
                            [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
476
                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
464
                                <option value="holdingbranch" selected="selected">
477
                                <option value="holdingbranch" selected="selected">
465
                                    item's holding library
478
                                    item's holding library
466
                                </option>
479
                                </option>
Lines 473-493 Link Here
473
                    </td>
486
                    </td>
474
                    <td>
487
                    <td>
475
                        <select name="returnbranch">
488
                        <select name="returnbranch">
476
                            [% IF ( default_returnbranch == 'homebranch' ) %]
489
                            [% SET returnbranch = CirculationRules.Get( branchcode, undef, undef, 'returnbranch' ) %]
490
491
                            <option value="">
492
                                Not set
493
                            </option>
494
495
                            [% IF returnbranch == 'homebranch' %]
477
                            <option value="homebranch" selected="selected">
496
                            <option value="homebranch" selected="selected">
478
                            [% ELSE %]
497
                            [% ELSE %]
479
                            <option value="homebranch">
498
                            <option value="homebranch">
480
                            [% END %]
499
                            [% END %]
481
                                Item returns home
500
                                Item returns home
482
                            </option>
501
                            </option>
483
                            [% IF ( default_returnbranch == 'holdingbranch' ) %]
502
                            [% IF returnbranch == 'holdingbranch' %]
484
                            <option value="holdingbranch" selected="selected">
503
                            <option value="holdingbranch" selected="selected">
485
                            [% ELSE %]
504
                            [% ELSE %]
486
                            <option value="holdingbranch">
505
                            <option value="holdingbranch">
487
                            [% END %]
506
                            [% END %]
488
                                Item returns to issuing library
507
                                Item returns to issuing library
489
                            </option>
508
                            </option>
490
                            [% IF ( default_returnbranch == 'noreturn' ) %]
509
                            [% IF returnbranch == 'noreturn' %]
491
                            <option value="noreturn" selected="selected">
510
                            <option value="noreturn" selected="selected">
492
                            [% ELSE %]
511
                            [% ELSE %]
493
                            <option value="noreturn">
512
                            <option value="noreturn">
Lines 694-741 Link Here
694
                    <th>Return policy</th>
713
                    <th>Return policy</th>
695
                    <th>&nbsp;</th>
714
                    <th>&nbsp;</th>
696
                </tr>
715
                </tr>
697
                [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
716
                [% FOREACH i IN itemtypeloop %]
698
                    [% UNLESS ( loop.odd ) %]
717
                    [% SET holdallowed = CirculationRules.Get( branchcode, undef, i.itemtype, 'holdallowed' ) %]
699
                    <tr class="highlight">
718
                    [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
700
                    [% ELSE %]
719
                    [% SET returnbranch = CirculationRules.Get( branchcode, undef, i.itemtype, 'returnbranch' ) %]
701
                    <tr>
720
721
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
722
                        <tr>
723
                            <td>
724
                                [% i.translated_description %]
725
                            </td>
726
                            <td>
727
                                [% IF holdallowed == 2 %]
728
                                    <span>From any library</span>
729
                                [% ELSIF holdallowed == 1 %]
730
                                    <span>From home library</span>
731
                                [% ELSE %]
732
                                    <span>No holds allowed</span>
733
                                [% END %]
734
                            </td>
735
                            <td>
736
                                [% IF hold_fulfillment_policy == 'any' %]
737
                                    <span>any library</span>
738
                                [% ELSIF hold_fulfillment_policy == 'homebranch' %]
739
                                    <span>item's home library</span>
740
                                [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
741
                                    <span>item's holding library</span>
742
                                [% END %]
743
                            </td>
744
                            <td>
745
                                [% IF returnbranch == 'homebranch' %]
746
                                    <span>Item returns home</span>
747
                                [% ELSIF returnbranch == 'holdingbranch' %]
748
                                    <span>Item returns to issuing branch</span>
749
                                [% ELSIF returnbranch == 'noreturn' %]
750
                                    <span>Item floats</span>
751
                                [% END %]
752
                            </td>
753
                            <td class="actions">
754
                                <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% i.itemtype %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
755
                            </td>
756
                        </tr>
702
                    [% END %]
757
                    [% END %]
703
                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
704
                                <em>Default</em>
705
                            [% ELSE %]
706
                                [% branch_item_rule_loo.translated_description | html %]
707
                            [% END %]
708
                        </td>
709
                        <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
710
                                <span>From any library</span>
711
                            [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
712
                                <span>From home library</span>
713
                            [% ELSE %]
714
                                <span>No holds allowed</span>
715
                            [% END %]
716
                        </td>
717
                        <td>[% IF ( branch_item_rule_loo.hold_fulfillment_policy == 'any' ) %]
718
                                <span>any library</span>
719
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'homebranch' ) %]
720
                                <span>item's home library</span>
721
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'holdingbranch' ) %]
722
                                <span>item's holding library</span>
723
                            [% END %]
724
                        </td>
725
                        <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
726
                                <span>Item returns home</span>
727
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
728
                                <span>Item returns to issuing branch</span>
729
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
730
                                <span>Item floats</span>
731
                            [% ELSE %]
732
                                <span>Error - unknown option</span>
733
                            [% END %]
734
                        </td>
735
                        <td class="actions">
736
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
737
                        </td>
738
                    </tr>
739
                [% END %]
758
                [% END %]
740
                <tr>
759
                <tr>
741
                    <td>
760
                    <td>
(-)a/t/db_dependent/Circulation/Branch.t (-25 / +36 lines)
Lines 44-49 can_ok( 'C4::Circulation', qw( Link Here
44
my $schema = Koha::Database->schema;
44
my $schema = Koha::Database->schema;
45
$schema->storage->txn_begin;
45
$schema->storage->txn_begin;
46
my $dbh = C4::Context->dbh;
46
my $dbh = C4::Context->dbh;
47
my $query;
47
48
48
$dbh->do(q|DELETE FROM issues|);
49
$dbh->do(q|DELETE FROM issues|);
49
$dbh->do(q|DELETE FROM items|);
50
$dbh->do(q|DELETE FROM items|);
Lines 53-62 $dbh->do(q|DELETE FROM branches|); Link Here
53
$dbh->do(q|DELETE FROM categories|);
54
$dbh->do(q|DELETE FROM categories|);
54
$dbh->do(q|DELETE FROM accountlines|);
55
$dbh->do(q|DELETE FROM accountlines|);
55
$dbh->do(q|DELETE FROM itemtypes|);
56
$dbh->do(q|DELETE FROM itemtypes|);
56
$dbh->do(q|DELETE FROM branch_item_rules|);
57
$dbh->do(q|DELETE FROM circulation_rules|);
57
$dbh->do(q|DELETE FROM default_branch_circ_rules|);
58
$dbh->do(q|DELETE FROM default_circ_rules|);
59
$dbh->do(q|DELETE FROM default_branch_item_rules|);
60
58
61
my $builder = t::lib::TestBuilder->new();
59
my $builder = t::lib::TestBuilder->new();
62
60
Lines 164-175 Koha::CirculationRules->set_rules( Link Here
164
    }
162
    }
165
);
163
);
166
164
167
my $query = q|
168
    INSERT INTO default_branch_circ_rules
169
    (branchcode, holdallowed, returnbranch)
170
    VALUES( ?, ?, ? )
171
|;
172
$dbh->do( $query, {}, $samplebranch2->{branchcode}, 1, 'holdingbranch' );
173
Koha::CirculationRules->set_rules(
165
Koha::CirculationRules->set_rules(
174
    {
166
    {
175
        branchcode   => $samplebranch2->{branchcode},
167
        branchcode   => $samplebranch2->{branchcode},
Lines 178-183 Koha::CirculationRules->set_rules( Link Here
178
        rules        => {
170
        rules        => {
179
            patron_maxissueqty       => 3,
171
            patron_maxissueqty       => 3,
180
            patron_maxonsiteissueqty => 2,
172
            patron_maxonsiteissueqty => 2,
173
            holdallowed              => 1,
174
            returnbranch             => 'holdingbranch',
181
        }
175
        }
182
    }
176
    }
183
);
177
);
Lines 196-222 Koha::CirculationRules->set_rules( Link Here
196
        rules        => {
190
        rules        => {
197
            patron_maxissueqty       => 4,
191
            patron_maxissueqty       => 4,
198
            patron_maxonsiteissueqty => 5,
192
            patron_maxonsiteissueqty => 5,
193
            holdallowed              => 3,
194
            returnbranch             => 'homebranch',
199
        }
195
        }
200
    }
196
    }
201
);
197
);
202
198
203
$query =
199
Koha::CirculationRules->set_rules(
204
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)";
200
    {
205
my $sth = $dbh->prepare($query);
201
        branchcode   => $samplebranch1->{branchcode},
206
$sth->execute(
202
        categorycode => undef,
207
    $samplebranch1->{branchcode},
203
        itemtype     => $sampleitemtype1->{itemtype},
208
    $sampleitemtype1->{itemtype},
204
        rules        => {
209
    5, 'homebranch'
205
            holdallowed       => 5,
206
            returnbranch      => 'homebranch',
207
        }
208
    }
210
);
209
);
211
$sth->execute(
210
Koha::CirculationRules->set_rules(
212
    $samplebranch2->{branchcode},
211
    {
213
    $sampleitemtype1->{itemtype},
212
        branchcode   => $samplebranch2->{branchcode},
214
    5, 'holdingbranch'
213
        categorycode => undef,
214
        itemtype     => $sampleitemtype1->{itemtype},
215
        rules        => {
216
            holdallowed       => 5,
217
            returnbranch      => 'holdingbranch',
218
        }
219
    }
215
);
220
);
216
$sth->execute(
221
Koha::CirculationRules->set_rules(
217
    $samplebranch2->{branchcode},
222
    {
218
    $sampleitemtype2->{itemtype},
223
        branchcode   => $samplebranch2->{branchcode},
219
    5, 'noreturn'
224
        categorycode => undef,
225
        itemtype     => $sampleitemtype2->{itemtype},
226
        rules        => {
227
            holdallowed       => 5,
228
            returnbranch      => 'noreturn',
229
        }
230
    }
220
);
231
);
221
232
222
#Test GetBranchBorrowerCircRule
233
#Test GetBranchBorrowerCircRule
(-)a/t/db_dependent/Holds.t (-12 / +24 lines)
Lines 45-50 my $borrowers_count = 5; Link Here
45
45
46
$dbh->do('DELETE FROM itemtypes');
46
$dbh->do('DELETE FROM itemtypes');
47
$dbh->do('DELETE FROM reserves');
47
$dbh->do('DELETE FROM reserves');
48
$dbh->do('DELETE FROM circulation_rules');
48
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
49
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
49
$insert_sth->execute('CAN');
50
$insert_sth->execute('CAN');
50
$insert_sth->execute('CANNOT');
51
$insert_sth->execute('CANNOT');
Lines 353-376 ok( Link Here
353
# Test branch item rules
354
# Test branch item rules
354
355
355
$dbh->do('DELETE FROM issuingrules');
356
$dbh->do('DELETE FROM issuingrules');
357
$dbh->do('DELETE FROM circulation_rules');
356
$dbh->do(
358
$dbh->do(
357
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
359
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
358
      VALUES (?, ?, ?, ?)},
360
      VALUES (?, ?, ?, ?)},
359
    {},
361
    {},
360
    '*', '*', '*', 25
362
    '*', '*', '*', 25
361
);
363
);
362
$dbh->do('DELETE FROM branch_item_rules');
364
Koha::CirculationRules->set_rules(
363
$dbh->do('DELETE FROM default_branch_circ_rules');
365
    {
364
$dbh->do('DELETE FROM default_branch_item_rules');
366
        branchcode => $branch_1,
365
$dbh->do('DELETE FROM default_circ_rules');
367
        itemtype   => 'CANNOT',
366
$dbh->do(q{
368
        categorycode => undef,
367
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
369
        rules => {
368
    VALUES (?, ?, ?, ?)
370
            holdallowed => 0,
369
}, {}, $branch_1, 'CANNOT', 0, 'homebranch');
371
            returnbranch => 'homebranch',
370
$dbh->do(q{
372
        }
371
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
373
    }
372
    VALUES (?, ?, ?, ?)
374
);
373
}, {}, $branch_1, 'CAN', 1, 'homebranch');
375
Koha::CirculationRules->set_rules(
376
    {
377
        branchcode => $branch_1,
378
        itemtype   => 'CAN',
379
        categorycode => undef,
380
        rules => {
381
            holdallowed => 1,
382
            returnbranch => 'homebranch',
383
        }
384
    }
385
);
374
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
386
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
375
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
387
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
376
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
388
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
(-)a/t/db_dependent/Holds/HoldFulfillmentPolicy.t (-10 / +38 lines)
Lines 3-8 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use C4::Context;
5
use C4::Context;
6
use Koha::CirculationRules;
6
7
7
use Test::More tests => 10;
8
use Test::More tests => 10;
8
9
Lines 47-56 my $library_C = $library3->{branchcode}; Link Here
47
$dbh->do("DELETE FROM transport_cost");
48
$dbh->do("DELETE FROM transport_cost");
48
$dbh->do("DELETE FROM tmp_holdsqueue");
49
$dbh->do("DELETE FROM tmp_holdsqueue");
49
$dbh->do("DELETE FROM hold_fill_targets");
50
$dbh->do("DELETE FROM hold_fill_targets");
50
$dbh->do("DELETE FROM default_branch_circ_rules");
51
$dbh->do("DELETE FROM circulation_rules");
51
$dbh->do("DELETE FROM default_branch_item_rules");
52
$dbh->do("DELETE FROM default_circ_rules");
53
$dbh->do("DELETE FROM branch_item_rules");
54
52
55
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
53
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
56
54
Lines 73-80 my $itemnumber = Link Here
73
  or BAIL_OUT("Cannot find newly created item");
71
  or BAIL_OUT("Cannot find newly created item");
74
72
75
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
73
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
76
$dbh->do("DELETE FROM default_circ_rules");
74
$dbh->do("DELETE FROM circulation_rules");
77
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
75
Koha::CirculationRules->set_rules(
76
    {
77
        categorycode => undef,
78
        branchcode   => undef,
79
        itemtype     => undef,
80
        rules        => {
81
            holdallowed             => 2,
82
            hold_fulfillment_policy => 'homebranch',
83
        }
84
    }
85
);
78
86
79
# Home branch matches pickup branch
87
# Home branch matches pickup branch
80
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
88
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 95-102 is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); Link Here
95
Koha::Holds->find( $reserve_id )->cancel;
103
Koha::Holds->find( $reserve_id )->cancel;
96
104
97
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
105
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
98
$dbh->do("DELETE FROM default_circ_rules");
106
$dbh->do("DELETE FROM circulation_rules");
99
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
107
Koha::CirculationRules->set_rules(
108
    {
109
        categorycode => undef,
110
        branchcode   => undef,
111
        itemtype     => undef,
112
        rules        => {
113
            holdallowed             => 2,
114
            hold_fulfillment_policy => 'holdingbranch',
115
        }
116
    }
117
);
100
118
101
# Home branch matches pickup branch
119
# Home branch matches pickup branch
102
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
120
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 117-124 is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); Link Here
117
Koha::Holds->find( $reserve_id )->cancel;
135
Koha::Holds->find( $reserve_id )->cancel;
118
136
119
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
137
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
120
$dbh->do("DELETE FROM default_circ_rules");
138
$dbh->do("DELETE FROM circulation_rules");
121
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
139
Koha::CirculationRules->set_rules(
140
    {
141
        categorycode => undef,
142
        branchcode   => undef,
143
        itemtype     => undef,
144
        rules        => {
145
            holdallowed             => 2,
146
            hold_fulfillment_policy => 'any',
147
        }
148
    }
149
);
122
150
123
# Home branch matches pickup branch
151
# Home branch matches pickup branch
124
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
152
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
(-)a/t/db_dependent/Holds/HoldItemtypeLimit.t (-6 / +13 lines)
Lines 3-8 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use C4::Context;
5
use C4::Context;
6
use Koha::CirculationRules;
6
7
7
use Test::More tests => 4;
8
use Test::More tests => 4;
8
9
Lines 64-73 $dbh->do("DELETE FROM biblioitems"); Link Here
64
$dbh->do("DELETE FROM transport_cost");
65
$dbh->do("DELETE FROM transport_cost");
65
$dbh->do("DELETE FROM tmp_holdsqueue");
66
$dbh->do("DELETE FROM tmp_holdsqueue");
66
$dbh->do("DELETE FROM hold_fill_targets");
67
$dbh->do("DELETE FROM hold_fill_targets");
67
$dbh->do("DELETE FROM default_branch_circ_rules");
68
$dbh->do("DELETE FROM default_branch_item_rules");
69
$dbh->do("DELETE FROM default_circ_rules");
70
$dbh->do("DELETE FROM branch_item_rules");
71
68
72
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
69
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
73
70
Lines 89-96 my $itemnumber = Link Here
89
  $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber")
86
  $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber")
90
  or BAIL_OUT("Cannot find newly created item");
87
  or BAIL_OUT("Cannot find newly created item");
91
88
92
$dbh->do("DELETE FROM default_circ_rules");
89
$dbh->do("DELETE FROM circulation_rules");
93
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
90
Koha::CirculationRules->set_rules(
91
    {
92
        itemtype     => undef,
93
        categorycode => undef,
94
        branchcode   => undef,
95
        rules        => {
96
            holdallowed             => 2,
97
            hold_fulfillment_policy => 'any',
98
        }
99
    }
100
);
94
101
95
# Itemtypes match
102
# Itemtypes match
96
my $reserve_id = AddReserve( $branchcode, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype );
103
my $reserve_id = AddReserve( $branchcode, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype );
(-)a/t/db_dependent/HoldsQueue.t (-41 / +92 lines)
Lines 18-23 use Koha::Database; Link Here
18
use Koha::DateUtils;
18
use Koha::DateUtils;
19
use Koha::Items;
19
use Koha::Items;
20
use Koha::Holds;
20
use Koha::Holds;
21
use Koha::CirculationRules;
21
22
22
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
23
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 32-37 BEGIN { Link Here
32
my $schema = Koha::Database->schema;
33
my $schema = Koha::Database->schema;
33
$schema->storage->txn_begin;
34
$schema->storage->txn_begin;
34
my $dbh = C4::Context->dbh;
35
my $dbh = C4::Context->dbh;
36
$dbh->do("DELETE FROM circulation_rules");
35
37
36
my $builder = t::lib::TestBuilder->new;
38
my $builder = t::lib::TestBuilder->new;
37
39
Lines 172-180 $schema->txn_begin; Link Here
172
### Test holds queue builder does not violate holds policy ###
174
### Test holds queue builder does not violate holds policy ###
173
175
174
# Clear out existing rules relating to holdallowed
176
# Clear out existing rules relating to holdallowed
175
$dbh->do("DELETE FROM default_branch_circ_rules");
177
$dbh->do("DELETE FROM circulation_rules");
176
$dbh->do("DELETE FROM default_branch_item_rules");
177
$dbh->do("DELETE FROM default_circ_rules");
178
178
179
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
179
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
180
180
Lines 287-294 $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ) Link Here
287
287
288
my $holds_queue;
288
my $holds_queue;
289
289
290
$dbh->do("DELETE FROM default_circ_rules");
290
$dbh->do("DELETE FROM circulation_rules");
291
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 1 )");
291
Koha::CirculationRules->set_rule(
292
    {
293
        rule_name    => 'holdallowed',
294
        rule_value   => 1,
295
        branchcode   => undef,
296
        categorycode => undef,
297
        itemtype     => undef,
298
    }
299
);
292
C4::HoldsQueue::CreateQueue();
300
C4::HoldsQueue::CreateQueue();
293
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
301
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
294
is( @$holds_queue, 2, "Holds queue filling correct number for default holds policy 'from home library'" );
302
is( @$holds_queue, 2, "Holds queue filling correct number for default holds policy 'from home library'" );
Lines 317-324 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
317
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
325
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
318
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
326
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
319
327
320
$dbh->do("DELETE FROM default_circ_rules");
328
$dbh->do("DELETE FROM circulation_rules");
321
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
329
Koha::CirculationRules->set_rule(
330
    {
331
        rule_name    => 'holdallowed',
332
        rule_value   => 2,
333
        branchcode   => undef,
334
        categorycode => undef,
335
        itemtype     => undef,
336
    }
337
);
322
C4::HoldsQueue::CreateQueue();
338
C4::HoldsQueue::CreateQueue();
323
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
339
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
324
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
340
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
Lines 337-344 t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 0 ); Link Here
337
## Test LocalHoldsPriority
353
## Test LocalHoldsPriority
338
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
354
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
339
355
340
$dbh->do("DELETE FROM default_circ_rules");
356
$dbh->do("DELETE FROM circulation_rules");
341
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
357
Koha::CirculationRules->set_rule(
358
    {
359
        rule_name    => 'holdallowed',
360
        rule_value   => 2,
361
        branchcode   => undef,
362
        categorycode => undef,
363
        itemtype     => undef,
364
    }
365
);
342
$dbh->do("DELETE FROM issues");
366
$dbh->do("DELETE FROM issues");
343
367
344
# Test homebranch = patron branch
368
# Test homebranch = patron branch
Lines 427-436 $dbh->do("DELETE FROM biblioitems"); Link Here
427
$dbh->do("DELETE FROM transport_cost");
451
$dbh->do("DELETE FROM transport_cost");
428
$dbh->do("DELETE FROM tmp_holdsqueue");
452
$dbh->do("DELETE FROM tmp_holdsqueue");
429
$dbh->do("DELETE FROM hold_fill_targets");
453
$dbh->do("DELETE FROM hold_fill_targets");
430
$dbh->do("DELETE FROM default_branch_circ_rules");
431
$dbh->do("DELETE FROM default_branch_item_rules");
432
$dbh->do("DELETE FROM default_circ_rules");
433
$dbh->do("DELETE FROM branch_item_rules");
434
454
435
$dbh->do("
455
$dbh->do("
436
    INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')
456
    INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')
Lines 455-464 $dbh->do(" Link Here
455
    VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype')
475
    VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype')
456
");
476
");
457
477
458
$dbh->do("
478
Koha::CirculationRules->set_rules(
459
    INSERT INTO branch_item_rules ( branchcode, itemtype, holdallowed, returnbranch ) VALUES
479
    {
460
    ( '$library_A', '$itemtype', 2, 'homebranch' ), ( '$library_B', '$itemtype', 1, 'homebranch' );
480
        branchcode   => $library_A,
461
");
481
        itemtype     => $itemtype,
482
        categorycode => undef,
483
        rules        => {
484
            holdallowed  => 2,
485
            returnbranch => 'homebranch',
486
        }
487
    }
488
);
462
489
463
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
490
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
464
    undef, join( ',', $library_B, $library_A, $library_C ) );
491
    undef, join( ',', $library_B, $library_A, $library_C ) );
Lines 483-492 $dbh->do("DELETE FROM biblioitems"); Link Here
483
$dbh->do("DELETE FROM transport_cost");
510
$dbh->do("DELETE FROM transport_cost");
484
$dbh->do("DELETE FROM tmp_holdsqueue");
511
$dbh->do("DELETE FROM tmp_holdsqueue");
485
$dbh->do("DELETE FROM hold_fill_targets");
512
$dbh->do("DELETE FROM hold_fill_targets");
486
$dbh->do("DELETE FROM default_branch_circ_rules");
487
$dbh->do("DELETE FROM default_branch_item_rules");
488
$dbh->do("DELETE FROM default_circ_rules");
489
$dbh->do("DELETE FROM branch_item_rules");
490
513
491
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
514
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
492
515
Lines 532-541 $dbh->do("DELETE FROM biblioitems"); Link Here
532
$dbh->do("DELETE FROM transport_cost");
555
$dbh->do("DELETE FROM transport_cost");
533
$dbh->do("DELETE FROM tmp_holdsqueue");
556
$dbh->do("DELETE FROM tmp_holdsqueue");
534
$dbh->do("DELETE FROM hold_fill_targets");
557
$dbh->do("DELETE FROM hold_fill_targets");
535
$dbh->do("DELETE FROM default_branch_circ_rules");
536
$dbh->do("DELETE FROM default_branch_item_rules");
537
$dbh->do("DELETE FROM default_circ_rules");
538
$dbh->do("DELETE FROM branch_item_rules");
539
558
540
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
559
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
541
560
Lines 554-561 $dbh->do(" Link Here
554
");
573
");
555
574
556
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
575
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
557
$dbh->do("DELETE FROM default_circ_rules");
576
$dbh->do("DELETE FROM circulation_rules");
558
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
577
Koha::CirculationRules->set_rules(
578
    {
579
        branchcode   => undef,
580
        itemtype     => undef,
581
        categorycode => undef,
582
        rules        => {
583
            holdallowed             => 2,
584
            hold_fulfillment_policy => 'homebranch',
585
        }
586
    }
587
);
559
588
560
# Home branch matches pickup branch
589
# Home branch matches pickup branch
561
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
590
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 579-586 is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted Link Here
579
Koha::Holds->find( $reserve_id )->cancel;
608
Koha::Holds->find( $reserve_id )->cancel;
580
609
581
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
610
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
582
$dbh->do("DELETE FROM default_circ_rules");
611
$dbh->do("DELETE FROM circulation_rules");
583
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
612
Koha::CirculationRules->set_rules(
613
    {
614
        branchcode   => undef,
615
        itemtype     => undef,
616
        categorycode => undef,
617
        rules        => {
618
            holdallowed             => 2,
619
            hold_fulfillment_policy => 'holdingbranch',
620
        }
621
    }
622
);
584
623
585
# Home branch matches pickup branch
624
# Home branch matches pickup branch
586
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
625
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 604-611 is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted Link Here
604
Koha::Holds->find( $reserve_id )->cancel;
643
Koha::Holds->find( $reserve_id )->cancel;
605
644
606
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
645
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
607
$dbh->do("DELETE FROM default_circ_rules");
646
$dbh->do("DELETE FROM circulation_rules");
608
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
647
Koha::CirculationRules->set_rules(
648
    {
649
        branchcode   => undef,
650
        itemtype     => undef,
651
        categorycode => undef,
652
        rules        => {
653
            holdallowed             => 2,
654
            hold_fulfillment_policy => 'any',
655
        }
656
    }
657
);
609
658
610
# Home branch matches pickup branch
659
# Home branch matches pickup branch
611
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
660
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 644-653 $dbh->do("DELETE FROM biblioitems"); Link Here
644
$dbh->do("DELETE FROM transport_cost");
693
$dbh->do("DELETE FROM transport_cost");
645
$dbh->do("DELETE FROM tmp_holdsqueue");
694
$dbh->do("DELETE FROM tmp_holdsqueue");
646
$dbh->do("DELETE FROM hold_fill_targets");
695
$dbh->do("DELETE FROM hold_fill_targets");
647
$dbh->do("DELETE FROM default_branch_circ_rules");
648
$dbh->do("DELETE FROM default_branch_item_rules");
649
$dbh->do("DELETE FROM default_circ_rules");
650
$dbh->do("DELETE FROM branch_item_rules");
651
696
652
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
697
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
653
698
Lines 666-673 $dbh->do(" Link Here
666
");
711
");
667
712
668
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
713
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
669
$dbh->do("DELETE FROM default_circ_rules");
714
$dbh->do("DELETE FROM circulation_rules");
670
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
715
Koha::CirculationRules->set_rules(
716
    {
717
        branchcode   => undef,
718
        itemtype     => undef,
719
        categorycode => undef,
720
        rules        => {
721
            holdallowed             => 2,
722
            hold_fulfillment_policy => 'any',
723
        }
724
    }
725
);
671
726
672
# Home branch matches pickup branch
727
# Home branch matches pickup branch
673
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
728
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
Lines 701-710 t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); Link Here
701
$dbh->do("DELETE FROM tmp_holdsqueue");
756
$dbh->do("DELETE FROM tmp_holdsqueue");
702
$dbh->do("DELETE FROM hold_fill_targets");
757
$dbh->do("DELETE FROM hold_fill_targets");
703
$dbh->do("DELETE FROM reserves");
758
$dbh->do("DELETE FROM reserves");
704
$dbh->do("DELETE FROM default_branch_circ_rules");
705
$dbh->do("DELETE FROM default_branch_item_rules");
706
$dbh->do("DELETE FROM default_circ_rules");
707
$dbh->do("DELETE FROM branch_item_rules");
708
759
709
my $item = Koha::Items->find( { biblionumber => $biblionumber } );
760
my $item = Koha::Items->find( { biblionumber => $biblionumber } );
710
$item->holdingbranch( $item->homebranch );
761
$item->holdingbranch( $item->homebranch );
(-)a/t/db_dependent/Reserves.t (-15 / +22 lines)
Lines 39-44 use Koha::Libraries; Link Here
39
use Koha::Notice::Templates;
39
use Koha::Notice::Templates;
40
use Koha::Patrons;
40
use Koha::Patrons;
41
use Koha::Patron::Categories;
41
use Koha::Patron::Categories;
42
use Koha::CirculationRules;
42
43
43
BEGIN {
44
BEGIN {
44
    require_ok('C4::Reserves');
45
    require_ok('C4::Reserves');
Lines 49-54 my $database = Koha::Database->new(); Link Here
49
my $schema = $database->schema();
50
my $schema = $database->schema();
50
$schema->storage->txn_begin();
51
$schema->storage->txn_begin();
51
my $dbh = C4::Context->dbh;
52
my $dbh = C4::Context->dbh;
53
$dbh->do('DELETE FROM circulation_rules');
52
54
53
my $builder = t::lib::TestBuilder->new;
55
my $builder = t::lib::TestBuilder->new;
54
56
Lines 200-209 $requesters{$branch_3} = Koha::Patron->new({ Link Here
200
# to fill holds from anywhere.
202
# to fill holds from anywhere.
201
203
202
$dbh->do('DELETE FROM issuingrules');
204
$dbh->do('DELETE FROM issuingrules');
203
$dbh->do('DELETE FROM branch_item_rules');
204
$dbh->do('DELETE FROM default_branch_item_rules');
205
$dbh->do('DELETE FROM default_branch_circ_rules');
206
$dbh->do('DELETE FROM default_circ_rules');
207
$dbh->do(
205
$dbh->do(
208
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
206
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
209
      VALUES (?, ?, ?, ?)},
207
      VALUES (?, ?, ?, ?)},
Lines 212-230 $dbh->do( Link Here
212
);
210
);
213
211
214
# CPL allows only its own patrons to request its items
212
# CPL allows only its own patrons to request its items
215
$dbh->do(
213
Koha::CirculationRules->set_rules(
216
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
214
    {
217
      VALUES (?, ?, ?)},
215
        branchcode   => $branch_1,
218
    {},
216
        categorycode => undef,
219
    $branch_1, 1, 'homebranch',
217
        itemtype     => undef,
218
        rules        => {
219
            holdallowed  => 1,
220
            returnbranch => 'homebranch',
221
        }
222
    }
220
);
223
);
221
224
222
# ... while FPL allows anybody to request its items
225
# ... while FPL allows anybody to request its items
223
$dbh->do(
226
Koha::CirculationRules->set_rules(
224
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
227
    {
225
      VALUES (?, ?, ?)},
228
        branchcode   => $branch_2,
226
    {},
229
        categorycode => undef,
227
    $branch_2, 2, 'homebranch',
230
        itemtype     => undef,
231
        rules        => {
232
            holdallowed  => 2,
233
            returnbranch => 'homebranch',
234
        }
235
    }
228
);
236
);
229
237
230
# helper biblio for the bug 10272 regression test
238
# helper biblio for the bug 10272 regression test
231
- 

Return to bug 18928