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

(-)a/C4/Circulation.pm (-33 / +51 lines)
Lines 1620-1626 wildcards. Link Here
1620
sub GetBranchBorrowerCircRule {
1620
sub GetBranchBorrowerCircRule {
1621
    my ( $branchcode, $categorycode ) = @_;
1621
    my ( $branchcode, $categorycode ) = @_;
1622
1622
1623
    # Set search prededences
1623
    # Set search precedences
1624
    my @params = (
1624
    my @params = (
1625
        {
1625
        {
1626
            branchcode   => $branchcode,
1626
            branchcode   => $branchcode,
Lines 1702-1744 Neither C<$branchcode> nor C<$itemtype> should be '*'. Link Here
1702
1702
1703
sub GetBranchItemRule {
1703
sub GetBranchItemRule {
1704
    my ( $branchcode, $itemtype ) = @_;
1704
    my ( $branchcode, $itemtype ) = @_;
1705
    my $dbh = C4::Context->dbh();
1705
1706
    my $result = {};
1706
    # Set search precedences
1707
1707
    my @params = (
1708
    my @attempts = (
1708
        {
1709
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1709
            branchcode   => $branchcode,
1710
            FROM branch_item_rules
1710
            categorycode => undef,
1711
            WHERE branchcode = ?
1711
            itemtype     => $itemtype,
1712
              AND itemtype = ?', $branchcode, $itemtype],
1712
        },
1713
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1713
        {
1714
            FROM default_branch_circ_rules
1714
            branchcode   => $branchcode,
1715
            WHERE branchcode = ?', $branchcode],
1715
            categorycode => undef,
1716
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1716
            itemtype     => undef,
1717
            FROM default_branch_item_rules
1717
        },
1718
            WHERE itemtype = ?', $itemtype],
1718
        {
1719
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1719
            branchcode   => undef,
1720
            FROM default_circ_rules'],
1720
            categorycode => undef,
1721
            itemtype     => $itemtype,
1722
        },
1723
        {
1724
            branchcode   => undef,
1725
            categorycode => undef,
1726
            itemtype     => undef,
1727
        },
1721
    );
1728
    );
1722
1729
1723
    foreach my $attempt (@attempts) {
1730
    # Initialize default values
1724
        my ($query, @bind_params) = @{$attempt};
1731
    my $rules = {
1725
        my $search_result = $dbh->selectrow_hashref ( $query , {}, @bind_params )
1732
        holdallowed             => undef,
1726
          or next;
1733
        hold_fulfillment_policy => undef,
1727
1734
        returnbranch            => undef,
1728
        # Since branch/category and branch/itemtype use the same per-branch
1735
    };
1729
        # defaults tables, we have to check that the key we want is set, not
1736
1730
        # just that a row was returned
1737
    # Search for rules!
1731
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1738
    foreach my $rule_name (qw( holdallowed hold_fulfillment_policy returnbranch )) {
1732
        $result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} );
1739
        foreach my $params (@params) {
1733
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1740
            my $rule = Koha::CirculationRules->search(
1741
                {
1742
                    rule_name => $rule_name,
1743
                    %$params,
1744
                }
1745
            )->next();
1746
1747
            if ( $rule ) {
1748
                $rules->{$rule_name} = $rule->rule_value;
1749
                last;
1750
            }
1751
        }
1734
    }
1752
    }
1735
    
1753
1736
    # built-in default circulation rule
1754
    # built-in default circulation rule
1737
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1755
    $rules->{holdallowed} = 2                 unless ( defined $rules->{holdallowed} );
1738
    $result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} );
1756
    $rules->{hold_fulfillment_policy} = 'any' unless ( defined $rules->{hold_fulfillment_policy} );
1739
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
1757
    $rules->{returnbranch} = 'homebranch'     unless ( defined $rules->{returnbranch} );
1740
1758
1741
    return $result;
1759
    return $rules;
1742
}
1760
}
1743
1761
1744
=head2 AddReturn
1762
=head2 AddReturn
(-)a/admin/smart-rules.pl (-201 / +164 lines)
Lines 85-131 elsif ($op eq 'delete-branch-cat') { Link Here
85
    my $categorycode  = $input->param('categorycode');
85
    my $categorycode  = $input->param('categorycode');
86
    if ($branch eq "*") {
86
    if ($branch eq "*") {
87
        if ($categorycode eq "*") {
87
        if ($categorycode eq "*") {
88
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
88
             Koha::CirculationRules->set_rules(
89
            $sth_delete->execute();
89
                 {
90
                     categorycode => undef,
91
                     branchcode   => undef,
92
                     itemtype     => undef,
93
                     rules        => {
94
                         patron_maxissueqty             => undef,
95
                         patron_maxonsiteissueqty       => undef,
96
                         holdallowed             => undef,
97
                         hold_fulfillment_policy => undef,
98
                         returnbranch            => undef,
99
                     }
100
                 }
101
             );
102
         } else {
103
             Koha::CirculationRules->set_rules(
104
                 {
105
                     categorycode => $categorycode,
106
                     branchcode   => undef,
107
                     itemtype     => undef,
108
                     rules        => {
109
                         max_holds         => undef,
110
                         patron_maxissueqty       => undef,
111
                         patron_maxonsiteissueqty => undef,
112
                     }
113
                 }
114
             );
90
        }
115
        }
91
    } elsif ($categorycode eq "*") {
116
    } elsif ($categorycode eq "*") {
92
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
117
        Koha::CirculationRules->set_rules(
93
                                        WHERE branchcode = ?");
118
            {
94
        $sth_delete->execute($branch);
119
                categorycode => undef,
95
    }
120
                branchcode   => $branch,
96
    Koha::CirculationRules->set_rules(
121
                itemtype     => undef,
97
        {
122
                rules        => {
98
            categorycode => $categorycode eq '*' ? undef : $categorycode,
123
                    patron_maxissueqty             => undef,
99
            branchcode   => $branch eq '*'       ? undef : $branch,
124
                    patron_maxonsiteissueqty       => undef,
100
            itemtype     => undef,
125
                    holdallowed             => undef,
101
            rules        => {
126
                    hold_fulfillment_policy => undef,
102
                max_holds         => undef,
127
                    returnbranch            => undef,
103
                patron_maxissueqty             => undef,
128
                }
104
                patron_maxonsiteissueqty       => undef,
105
            }
129
            }
106
        }
130
        );
107
    );
131
    } else {
132
        Koha::CirculationRules->set_rules(
133
            {
134
                categorycode => $categorycode,
135
                branchcode   => $branch,
136
                itemtype     => undef,
137
                rules        => {
138
                    max_holds         => undef,
139
                    patron_maxissueqty       => undef,
140
                    patron_maxonsiteissueqty => undef,
141
                }
142
            }
143
        );
144
    }
108
}
145
}
109
elsif ($op eq 'delete-branch-item') {
146
elsif ($op eq 'delete-branch-item') {
110
    my $itemtype  = $input->param('itemtype');
147
    my $itemtype  = $input->param('itemtype');
111
    if ($branch eq "*") {
148
    if ($branch eq "*") {
112
        if ($itemtype eq "*") {
149
        if ($itemtype eq "*") {
113
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
150
            Koha::CirculationRules->set_rules(
114
            $sth_delete->execute();
151
                {
152
                    categorycode => undef,
153
                    branchcode   => undef,
154
                    itemtype     => undef,
155
                    rules        => {
156
                        patron_maxissueqty             => undef,
157
                        patron_maxonsiteissueqty       => undef,
158
                        holdallowed             => undef,
159
                        hold_fulfillment_policy => undef,
160
                        returnbranch            => undef,
161
                    }
162
                }
163
            );
115
        } else {
164
        } else {
116
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
165
            Koha::CirculationRules->set_rules(
117
                                            WHERE itemtype = ?");
166
                {
118
            $sth_delete->execute($itemtype);
167
                    categorycode => undef,
168
                    branchcode   => undef,
169
                    itemtype     => $itemtype,
170
                    rules        => {
171
                        holdallowed             => undef,
172
                        hold_fulfillment_policy => undef,
173
                        returnbranch            => undef,
174
                    }
175
                }
176
            );
119
        }
177
        }
120
    } elsif ($itemtype eq "*") {
178
    } elsif ($itemtype eq "*") {
121
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
179
        Koha::CirculationRules->set_rules(
122
                                        WHERE branchcode = ?");
180
            {
123
        $sth_delete->execute($branch);
181
                categorycode => undef,
182
                branchcode   => $branch,
183
                itemtype     => undef,
184
                rules        => {
185
                    maxissueqty             => undef,
186
                    maxonsiteissueqty       => undef,
187
                    holdallowed             => undef,
188
                    hold_fulfillment_policy => undef,
189
                    returnbranch            => undef,
190
                }
191
            }
192
        );
124
    } else {
193
    } else {
125
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
194
        Koha::CirculationRules->set_rules(
126
                                        WHERE branchcode = ?
195
            {
127
                                        AND itemtype = ?");
196
                categorycode => undef,
128
        $sth_delete->execute($branch, $itemtype);
197
                branchcode   => $branch,
198
                itemtype     => $itemtype,
199
                rules        => {
200
                    holdallowed             => undef,
201
                    hold_fulfillment_policy => undef,
202
                    returnbranch            => undef,
203
                }
204
            }
205
        );
129
    }
206
    }
130
}
207
}
131
# save the values entered
208
# save the values entered
Lines 241-299 elsif ($op eq "set-branch-defaults") { Link Here
241
    $max_holds = undef if $max_holds !~ /^\d+/;
318
    $max_holds = undef if $max_holds !~ /^\d+/;
242
319
243
    if ($branch eq "*") {
320
    if ($branch eq "*") {
244
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
245
                                        FROM default_circ_rules");
246
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
247
                                        (holdallowed, hold_fulfillment_policy, returnbranch)
248
                                        VALUES (?, ?, ?)");
249
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
250
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
251
252
        $sth_search->execute();
253
        my $res = $sth_search->fetchrow_hashref();
254
        if ($res->{total}) {
255
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
256
        } else {
257
            $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
258
        }
259
260
        Koha::CirculationRules->set_rules(
321
        Koha::CirculationRules->set_rules(
261
            {
322
            {
262
                categorycode => undef,
323
                categorycode => undef,
263
                itemtype     => undef,
324
                itemtype     => undef,
264
                branchcode   => undef,
325
                branchcode   => undef,
265
                rules        => {
326
                rules        => {
266
                    patron_maxissueqty             => $patron_maxissueqty,
327
                    patron_maxissueqty       => $patron_maxissueqty,
267
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
328
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
329
                    holdallowed              => $holdallowed,
330
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
331
                    returnbranch             => $returnbranch,
268
                }
332
                }
269
            }
333
            }
270
        );
334
        );
271
    } else {
335
    } else {
272
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
273
                                        FROM default_branch_circ_rules
274
                                        WHERE branchcode = ?");
275
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
276
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
277
                                        VALUES (?, ?, ?, ?)");
278
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
279
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
280
                                        WHERE branchcode = ?");
281
        $sth_search->execute($branch);
282
        my $res = $sth_search->fetchrow_hashref();
283
        if ($res->{total}) {
284
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
285
        } else {
286
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
287
        }
288
289
        Koha::CirculationRules->set_rules(
336
        Koha::CirculationRules->set_rules(
290
            {
337
            {
291
                categorycode => undef,
338
                categorycode => undef,
292
                itemtype     => undef,
339
                itemtype     => undef,
293
                branchcode   => $branch,
340
                branchcode   => $branch,
294
                rules        => {
341
                rules        => {
295
                    patron_maxissueqty             => $patron_maxissueqty,
342
                    patron_maxissueqty       => $patron_maxissueqty,
296
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
343
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
344
                    holdallowed              => $holdallowed,
345
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
346
                    returnbranch             => $returnbranch,
297
                }
347
                }
298
            }
348
            }
299
        );
349
        );
Lines 387-462 elsif ($op eq "add-branch-item") { Link Here
387
437
388
    if ($branch eq "*") {
438
    if ($branch eq "*") {
389
        if ($itemtype eq "*") {
439
        if ($itemtype eq "*") {
390
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
440
            Koha::CirculationRules->set_rules(
391
                                            FROM default_circ_rules");
441
                {
392
            my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
442
                    categorycode => undef,
393
                                            (holdallowed, hold_fulfillment_policy, returnbranch)
443
                    itemtype     => undef,
394
                                            VALUES (?, ?, ?)");
444
                    branchcode   => undef,
395
            my $sth_update = $dbh->prepare("UPDATE default_circ_rules
445
                    rules        => {
396
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
446
                        holdallowed             => $holdallowed,
397
447
                        hold_fulfillment_policy => $hold_fulfillment_policy,
398
            $sth_search->execute();
448
                        returnbranch            => $returnbranch,
399
            my $res = $sth_search->fetchrow_hashref();
449
                    }
400
            if ($res->{total}) {
450
                }
401
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
451
            );
402
            } else {
403
                $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
404
            }
405
        } else {
452
        } else {
406
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
453
            Koha::CirculationRules->set_rules(
407
                                            FROM default_branch_item_rules
454
                {
408
                                            WHERE itemtype = ?");
455
                    categorycode => undef,
409
            my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules
456
                    itemtype     => $itemtype,
410
                                            (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
457
                    branchcode   => undef,
411
                                            VALUES (?, ?, ?, ?)");
458
                    rules        => {
412
            my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules
459
                        holdallowed             => $holdallowed,
413
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
460
                        hold_fulfillment_policy => $hold_fulfillment_policy,
414
                                            WHERE itemtype = ?");
461
                        returnbranch            => $returnbranch,
415
            $sth_search->execute($itemtype);
462
                    }
416
            my $res = $sth_search->fetchrow_hashref();
463
                }
417
            if ($res->{total}) {
464
            );
418
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype);
419
            } else {
420
                $sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
421
            }
422
        }
465
        }
423
    } elsif ($itemtype eq "*") {
466
    } elsif ($itemtype eq "*") {
424
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
467
            Koha::CirculationRules->set_rules(
425
                                        FROM default_branch_circ_rules
468
                {
426
                                        WHERE branchcode = ?");
469
                    categorycode => undef,
427
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
470
                    itemtype     => undef,
428
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
471
                    branchcode   => $branch,
429
                                        VALUES (?, ?, ?, ?)");
472
                    rules        => {
430
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
473
                        holdallowed             => $holdallowed,
431
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
474
                        hold_fulfillment_policy => $hold_fulfillment_policy,
432
                                        WHERE branchcode = ?");
475
                        returnbranch            => $returnbranch,
433
        $sth_search->execute($branch);
476
                    }
434
        my $res = $sth_search->fetchrow_hashref();
477
                }
435
        if ($res->{total}) {
478
            );
436
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
437
        } else {
438
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
439
        }
440
    } else {
479
    } else {
441
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
480
        Koha::CirculationRules->set_rules(
442
                                        FROM branch_item_rules
481
            {
443
                                        WHERE branchcode = ?
482
                categorycode => undef,
444
                                        AND   itemtype = ?");
483
                itemtype     => $itemtype,
445
        my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules
484
                branchcode   => $branch,
446
                                        (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
485
                rules        => {
447
                                        VALUES (?, ?, ?, ?, ?)");
486
                    holdallowed             => $holdallowed,
448
        my $sth_update = $dbh->prepare("UPDATE branch_item_rules
487
                    hold_fulfillment_policy => $hold_fulfillment_policy,
449
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
488
                    returnbranch            => $returnbranch,
450
                                        WHERE branchcode = ?
489
                }
451
                                        AND itemtype = ?");
490
            }
452
491
        );
453
        $sth_search->execute($branch, $itemtype);
454
        my $res = $sth_search->fetchrow_hashref();
455
        if ($res->{total}) {
456
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype);
457
        } else {
458
            $sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
459
        }
460
    }
492
    }
461
}
493
}
462
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
494
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
Lines 539-614 while (my $row = $sth2->fetchrow_hashref) { Link Here
539
571
540
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
572
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
541
573
542
my $sth_branch_item;
543
if ($branch eq "*") {
544
    $sth_branch_item = $dbh->prepare("
545
        SELECT default_branch_item_rules.*,
546
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
547
        FROM default_branch_item_rules
548
        JOIN itemtypes USING (itemtype)
549
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
550
            AND localization.entity = 'itemtypes'
551
            AND localization.lang = ?
552
    ");
553
    $sth_branch_item->execute($language);
554
} else {
555
    $sth_branch_item = $dbh->prepare("
556
        SELECT branch_item_rules.*,
557
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
558
        FROM branch_item_rules
559
        JOIN itemtypes USING (itemtype)
560
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
561
            AND localization.entity = 'itemtypes'
562
            AND localization.lang = ?
563
        WHERE branch_item_rules.branchcode = ?
564
    ");
565
    $sth_branch_item->execute($language, $branch);
566
}
567
568
my @branch_item_rules = ();
569
while (my $row = $sth_branch_item->fetchrow_hashref) {
570
    push @branch_item_rules, $row;
571
}
572
my @sorted_branch_item_rules = sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @branch_item_rules;
573
574
# note undef holdallowed so that template can deal with them
575
foreach my $entry (@sorted_branch_item_rules) {
576
    $entry->{holdallowed_any}  = 1 if ( $entry->{holdallowed} == 2 );
577
    $entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 );
578
}
579
580
$template->param(show_branch_cat_rule_form => 1);
574
$template->param(show_branch_cat_rule_form => 1);
581
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules);
582
583
my $sth_defaults;
584
if ($branch eq "*") {
585
    $sth_defaults = $dbh->prepare("
586
        SELECT *
587
        FROM default_circ_rules
588
    ");
589
    $sth_defaults->execute();
590
} else {
591
    $sth_defaults = $dbh->prepare("
592
        SELECT *
593
        FROM default_branch_circ_rules
594
        WHERE branchcode = ?
595
    ");
596
    $sth_defaults->execute($branch);
597
}
598
599
my $defaults = $sth_defaults->fetchrow_hashref;
600
601
if ($defaults) {
602
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
603
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
604
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
605
    $template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} );
606
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
607
    $template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} );
608
    $template->param( default_returnbranch      => $defaults->{returnbranch} );
609
}
610
611
$template->param(default_rules => ($defaults ? 1 : 0));
612
575
613
$template->param(
576
$template->param(
614
    patron_categories => $patron_categories,
577
    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 385-408 Link Here
385
                    </td>
385
                    </td>
386
                    <td>
386
                    <td>
387
                        <select name="holdallowed">
387
                        <select name="holdallowed">
388
                            [% IF ( default_holdallowed_any ) %]
388
                            [% SET holdallowed = CirculationRules.Get( branchcode, undef, undef, 'holdallowed' ) %]
389
                            <option value="2" selected="selected">
389
                            <option value="">
390
                                Not set
391
                            </option>
392
393
                            [% IF holdallowed == 2 %]
394
                                <option value="2" selected="selected">
390
                            [% ELSE %]
395
                            [% ELSE %]
391
                            <option value="2">
396
                                <option value="2">
392
                            [% END %]
397
                            [% END %]
393
                                From any library
398
                                From any library
394
                            </option>
399
                            </option>
395
                            [% IF ( default_holdallowed_same ) %]
400
396
                            <option value="1" selected="selected">
401
                            [% IF holdallowed == 1 %]
402
                                <option value="1" selected="selected">
397
                            [% ELSE %]
403
                            [% ELSE %]
398
                            <option value="1">
404
                                <option value="1">
399
                            [% END %]
405
                            [% END %]
400
                                From home library
406
                                From home library
401
                            </option>
407
                            </option>
402
                            [% IF ( default_holdallowed_none ) %]
408
403
                            <option value="0" selected="selected">
409
                            [% IF holdallowed == 0 %]
410
                                <option value="0" selected="selected">
404
                            [% ELSE %]
411
                            [% ELSE %]
405
                            <option value="0">
412
                                <option value="0">
406
                            [% END %]
413
                            [% END %]
407
                                No holds allowed
414
                                No holds allowed
408
                            </option>
415
                            </option>
Lines 410-416 Link Here
410
                    </td>
417
                    </td>
411
                    <td>
418
                    <td>
412
                        <select name="hold_fulfillment_policy">
419
                        <select name="hold_fulfillment_policy">
413
                            [% IF default_hold_fulfillment_policy == 'any' %]
420
                            [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, undef, 'hold_fulfillment_policy' ) %]
421
422
                            <option value="">
423
                                Not set
424
                            </option>
425
426
                            [% IF hold_fulfillment_policy == 'any' %]
414
                                <option value="any" selected="selected">
427
                                <option value="any" selected="selected">
415
                                    any library
428
                                    any library
416
                                </option>
429
                                </option>
Lines 420-426 Link Here
420
                                </option>
433
                                </option>
421
                            [% END %]
434
                            [% END %]
422
435
423
                            [% IF default_hold_fulfillment_policy == 'homebranch' %]
436
                            [% IF hold_fulfillment_policy == 'homebranch' %]
424
                                <option value="homebranch" selected="selected">
437
                                <option value="homebranch" selected="selected">
425
                                    item's home library
438
                                    item's home library
426
                                </option>
439
                                </option>
Lines 430-436 Link Here
430
                                </option>
443
                                </option>
431
                            [% END %]
444
                            [% END %]
432
445
433
                            [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
446
                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
434
                                <option value="holdingbranch" selected="selected">
447
                                <option value="holdingbranch" selected="selected">
435
                                    item's holding library
448
                                    item's holding library
436
                                </option>
449
                                </option>
Lines 443-463 Link Here
443
                    </td>
456
                    </td>
444
                    <td>
457
                    <td>
445
                        <select name="returnbranch">
458
                        <select name="returnbranch">
446
                            [% IF ( default_returnbranch == 'homebranch' ) %]
459
                            [% SET returnbranch = CirculationRules.Get( branchcode, undef, undef, 'returnbranch' ) %]
460
461
                            <option value="">
462
                                Not set
463
                            </option>
464
465
                            [% IF returnbranch == 'homebranch' %]
447
                            <option value="homebranch" selected="selected">
466
                            <option value="homebranch" selected="selected">
448
                            [% ELSE %]
467
                            [% ELSE %]
449
                            <option value="homebranch">
468
                            <option value="homebranch">
450
                            [% END %]
469
                            [% END %]
451
                                Item returns home
470
                                Item returns home
452
                            </option>
471
                            </option>
453
                            [% IF ( default_returnbranch == 'holdingbranch' ) %]
472
                            [% IF returnbranch == 'holdingbranch' %]
454
                            <option value="holdingbranch" selected="selected">
473
                            <option value="holdingbranch" selected="selected">
455
                            [% ELSE %]
474
                            [% ELSE %]
456
                            <option value="holdingbranch">
475
                            <option value="holdingbranch">
457
                            [% END %]
476
                            [% END %]
458
                                Item returns to issuing library
477
                                Item returns to issuing library
459
                            </option>
478
                            </option>
460
                            [% IF ( default_returnbranch == 'noreturn' ) %]
479
                            [% IF returnbranch == 'noreturn' %]
461
                            <option value="noreturn" selected="selected">
480
                            <option value="noreturn" selected="selected">
462
                            [% ELSE %]
481
                            [% ELSE %]
463
                            <option value="noreturn">
482
                            <option value="noreturn">
Lines 663-710 Link Here
663
                    <th>Return policy</th>
682
                    <th>Return policy</th>
664
                    <th>&nbsp;</th>
683
                    <th>&nbsp;</th>
665
                </tr>
684
                </tr>
666
                [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
685
                [% FOREACH i IN itemtypeloop %]
667
                    [% UNLESS ( loop.odd ) %]
686
                    [% SET holdallowed = CirculationRules.Get( branchcode, undef, i.itemtype, 'holdallowed' ) %]
668
                    <tr class="highlight">
687
                    [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
669
                    [% ELSE %]
688
                    [% SET returnbranch = CirculationRules.Get( branchcode, undef, i.itemtype, 'returnbranch' ) %]
670
                    <tr>
689
690
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
691
                        <tr>
692
                            <td>
693
                                [% i.translated_description %]
694
                            </td>
695
                            <td>
696
                                [% IF holdallowed == 2 %]
697
                                    From any library
698
                                [% ELSIF holdallowed == 1 %]
699
                                    From home library
700
                                [% ELSE %]
701
                                    No holds allowed
702
                                [% END %]
703
                            </td>
704
                            <td>
705
                                [% IF hold_fulfillment_policy == 'any' %]
706
                                    any library
707
                                [% ELSIF hold_fulfillment_policy == 'homebranch' %]
708
                                    item's home library
709
                                [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
710
                                    item's holding library
711
                                [% END %]
712
                            </td>
713
                            <td>
714
                                [% IF returnbranch == 'homebranch' %]
715
                                    Item returns home
716
                                [% ELSIF returnbranch == 'holdingbranch' %]
717
                                    Item returns to issuing branch
718
                                [% ELSIF returnbranch == 'noreturn' %]
719
                                    Item floats
720
                                [% END %]
721
                            </td>
722
                            <td class="actions">
723
                                <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>
724
                            </td>
725
                        </tr>
671
                    [% END %]
726
                    [% END %]
672
                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
673
                                <em>Default</em>
674
                            [% ELSE %]
675
                                [% branch_item_rule_loo.translated_description %]
676
                            [% END %]
677
                        </td>
678
                        <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
679
                                From any library
680
                            [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
681
                                From home library
682
                            [% ELSE %]
683
                                No holds allowed
684
                            [% END %]
685
                        </td>
686
                        <td>[% IF ( branch_item_rule_loo.hold_fulfillment_policy == 'any' ) %]
687
                                any library
688
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'homebranch' ) %]
689
                                item's home library
690
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'holdingbranch' ) %]
691
                                item's holding library
692
                            [% END %]
693
                        </td>
694
                        <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
695
                                Item returns home
696
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
697
                                Item returns to issuing branch
698
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
699
                                Item floats
700
                            [% ELSE %]
701
                                Error - unknown option
702
                            [% END %]
703
                        </td>
704
                        <td class="actions">
705
                            <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 %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
706
                        </td>
707
                    </tr>
708
                [% END %]
727
                [% END %]
709
                <tr>
728
                <tr>
710
                    <td>
729
                    <td>
(-)a/t/db_dependent/Circulation/Branch.t (-25 / +36 lines)
Lines 43-48 can_ok( 'C4::Circulation', qw( Link Here
43
my $schema = Koha::Database->schema;
43
my $schema = Koha::Database->schema;
44
$schema->storage->txn_begin;
44
$schema->storage->txn_begin;
45
my $dbh = C4::Context->dbh;
45
my $dbh = C4::Context->dbh;
46
my $query;
46
47
47
$dbh->do(q|DELETE FROM issues|);
48
$dbh->do(q|DELETE FROM issues|);
48
$dbh->do(q|DELETE FROM items|);
49
$dbh->do(q|DELETE FROM items|);
Lines 52-61 $dbh->do(q|DELETE FROM branches|); Link Here
52
$dbh->do(q|DELETE FROM categories|);
53
$dbh->do(q|DELETE FROM categories|);
53
$dbh->do(q|DELETE FROM accountlines|);
54
$dbh->do(q|DELETE FROM accountlines|);
54
$dbh->do(q|DELETE FROM itemtypes|);
55
$dbh->do(q|DELETE FROM itemtypes|);
55
$dbh->do(q|DELETE FROM branch_item_rules|);
56
$dbh->do(q|DELETE FROM circulation_rules|);
56
$dbh->do(q|DELETE FROM default_branch_circ_rules|);
57
$dbh->do(q|DELETE FROM default_circ_rules|);
58
$dbh->do(q|DELETE FROM default_branch_item_rules|);
59
57
60
my $builder = t::lib::TestBuilder->new();
58
my $builder = t::lib::TestBuilder->new();
61
59
Lines 163-174 Koha::CirculationRules->set_rules( Link Here
163
    }
161
    }
164
);
162
);
165
163
166
my $query = q|
167
    INSERT INTO default_branch_circ_rules
168
    (branchcode, holdallowed, returnbranch)
169
    VALUES( ?, ?, ? )
170
|;
171
$dbh->do( $query, {}, $samplebranch2->{branchcode}, 1, 'holdingbranch' );
172
Koha::CirculationRules->set_rules(
164
Koha::CirculationRules->set_rules(
173
    {
165
    {
174
        branchcode   => $samplebranch2->{branchcode},
166
        branchcode   => $samplebranch2->{branchcode},
Lines 177-182 Koha::CirculationRules->set_rules( Link Here
177
        rules        => {
169
        rules        => {
178
            patron_maxissueqty       => 3,
170
            patron_maxissueqty       => 3,
179
            patron_maxonsiteissueqty => 2,
171
            patron_maxonsiteissueqty => 2,
172
            holdallowed              => 1,
173
            returnbranch             => 'holdingbranch',
180
        }
174
        }
181
    }
175
    }
182
);
176
);
Lines 195-221 Koha::CirculationRules->set_rules( Link Here
195
        rules        => {
189
        rules        => {
196
            patron_maxissueqty       => 4,
190
            patron_maxissueqty       => 4,
197
            patron_maxonsiteissueqty => 5,
191
            patron_maxonsiteissueqty => 5,
192
            holdallowed              => 3,
193
            returnbranch             => 'homebranch',
198
        }
194
        }
199
    }
195
    }
200
);
196
);
201
197
202
$query =
198
Koha::CirculationRules->set_rules(
203
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)";
199
    {
204
my $sth = $dbh->prepare($query);
200
        branchcode   => $samplebranch1->{branchcode},
205
$sth->execute(
201
        categorycode => undef,
206
    $samplebranch1->{branchcode},
202
        itemtype     => $sampleitemtype1->{itemtype},
207
    $sampleitemtype1->{itemtype},
203
        rules        => {
208
    5, 'homebranch'
204
            holdallowed       => 5,
205
            returnbranch      => 'homebranch',
206
        }
207
    }
209
);
208
);
210
$sth->execute(
209
Koha::CirculationRules->set_rules(
211
    $samplebranch2->{branchcode},
210
    {
212
    $sampleitemtype1->{itemtype},
211
        branchcode   => $samplebranch2->{branchcode},
213
    5, 'holdingbranch'
212
        categorycode => undef,
213
        itemtype     => $sampleitemtype1->{itemtype},
214
        rules        => {
215
            holdallowed       => 5,
216
            returnbranch      => 'holdingbranch',
217
        }
218
    }
214
);
219
);
215
$sth->execute(
220
Koha::CirculationRules->set_rules(
216
    $samplebranch2->{branchcode},
221
    {
217
    $sampleitemtype2->{itemtype},
222
        branchcode   => $samplebranch2->{branchcode},
218
    5, 'noreturn'
223
        categorycode => undef,
224
        itemtype     => $sampleitemtype2->{itemtype},
225
        rules        => {
226
            holdallowed       => 5,
227
            returnbranch      => 'noreturn',
228
        }
229
    }
219
);
230
);
220
231
221
#Test GetBranchBorrowerCircRule
232
#Test GetBranchBorrowerCircRule
(-)a/t/db_dependent/Holds.t (-12 / +24 lines)
Lines 42-47 my $borrowers_count = 5; Link Here
42
42
43
$dbh->do('DELETE FROM itemtypes');
43
$dbh->do('DELETE FROM itemtypes');
44
$dbh->do('DELETE FROM reserves');
44
$dbh->do('DELETE FROM reserves');
45
$dbh->do('DELETE FROM circulation_rules');
45
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
46
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
46
$insert_sth->execute('CAN');
47
$insert_sth->execute('CAN');
47
$insert_sth->execute('CANNOT');
48
$insert_sth->execute('CANNOT');
Lines 350-373 ok( Link Here
350
# Test branch item rules
351
# Test branch item rules
351
352
352
$dbh->do('DELETE FROM issuingrules');
353
$dbh->do('DELETE FROM issuingrules');
354
$dbh->do('DELETE FROM circulation_rules');
353
$dbh->do(
355
$dbh->do(
354
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
356
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
355
      VALUES (?, ?, ?, ?)},
357
      VALUES (?, ?, ?, ?)},
356
    {},
358
    {},
357
    '*', '*', '*', 25
359
    '*', '*', '*', 25
358
);
360
);
359
$dbh->do('DELETE FROM branch_item_rules');
361
Koha::CirculationRules->set_rules(
360
$dbh->do('DELETE FROM default_branch_circ_rules');
362
    {
361
$dbh->do('DELETE FROM default_branch_item_rules');
363
        branchcode => $branch_1,
362
$dbh->do('DELETE FROM default_circ_rules');
364
        itemtype   => 'CANNOT',
363
$dbh->do(q{
365
        categorycode => undef,
364
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
366
        rules => {
365
    VALUES (?, ?, ?, ?)
367
            holdallowed => 0,
366
}, {}, $branch_1, 'CANNOT', 0, 'homebranch');
368
            returnbranch => 'homebranch',
367
$dbh->do(q{
369
        }
368
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
370
    }
369
    VALUES (?, ?, ?, ?)
371
);
370
}, {}, $branch_1, 'CAN', 1, 'homebranch');
372
Koha::CirculationRules->set_rules(
373
    {
374
        branchcode => $branch_1,
375
        itemtype   => 'CAN',
376
        categorycode => undef,
377
        rules => {
378
            holdallowed => 1,
379
            returnbranch => 'homebranch',
380
        }
381
    }
382
);
371
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
383
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
372
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
384
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
373
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
385
    { 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 197-206 $requesters{$branch_3} = AddMember( Link Here
197
# to fill holds from anywhere.
199
# to fill holds from anywhere.
198
200
199
$dbh->do('DELETE FROM issuingrules');
201
$dbh->do('DELETE FROM issuingrules');
200
$dbh->do('DELETE FROM branch_item_rules');
201
$dbh->do('DELETE FROM default_branch_item_rules');
202
$dbh->do('DELETE FROM default_branch_circ_rules');
203
$dbh->do('DELETE FROM default_circ_rules');
204
$dbh->do(
202
$dbh->do(
205
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
203
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
206
      VALUES (?, ?, ?, ?)},
204
      VALUES (?, ?, ?, ?)},
Lines 209-227 $dbh->do( Link Here
209
);
207
);
210
208
211
# CPL allows only its own patrons to request its items
209
# CPL allows only its own patrons to request its items
212
$dbh->do(
210
Koha::CirculationRules->set_rules(
213
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
211
    {
214
      VALUES (?, ?, ?)},
212
        branchcode   => $branch_1,
215
    {},
213
        categorycode => undef,
216
    $branch_1, 1, 'homebranch',
214
        itemtype     => undef,
215
        rules        => {
216
            holdallowed  => 1,
217
            returnbranch => 'homebranch',
218
        }
219
    }
217
);
220
);
218
221
219
# ... while FPL allows anybody to request its items
222
# ... while FPL allows anybody to request its items
220
$dbh->do(
223
Koha::CirculationRules->set_rules(
221
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
224
    {
222
      VALUES (?, ?, ?)},
225
        branchcode   => $branch_2,
223
    {},
226
        categorycode => undef,
224
    $branch_2, 2, 'homebranch',
227
        itemtype     => undef,
228
        rules        => {
229
            holdallowed  => 2,
230
            returnbranch => 'homebranch',
231
        }
232
    }
225
);
233
);
226
234
227
# helper biblio for the bug 10272 regression test
235
# helper biblio for the bug 10272 regression test
228
- 

Return to bug 18928