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

(-)a/C4/Circulation.pm (-32 / +50 lines)
Lines 1671-1713 Neither C<$branchcode> nor C<$itemtype> should be '*'. Link Here
1671
1671
1672
sub GetBranchItemRule {
1672
sub GetBranchItemRule {
1673
    my ( $branchcode, $itemtype ) = @_;
1673
    my ( $branchcode, $itemtype ) = @_;
1674
    my $dbh = C4::Context->dbh();
1674
1675
    my $result = {};
1675
    # Set search precedences
1676
1676
    my @params = (
1677
    my @attempts = (
1677
        {
1678
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1678
            branchcode   => $branchcode,
1679
            FROM branch_item_rules
1679
            categorycode => undef,
1680
            WHERE branchcode = ?
1680
            itemtype     => $itemtype,
1681
              AND itemtype = ?', $branchcode, $itemtype],
1681
        },
1682
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1682
        {
1683
            FROM default_branch_circ_rules
1683
            branchcode   => $branchcode,
1684
            WHERE branchcode = ?', $branchcode],
1684
            categorycode => undef,
1685
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1685
            itemtype     => undef,
1686
            FROM default_branch_item_rules
1686
        },
1687
            WHERE itemtype = ?', $itemtype],
1687
        {
1688
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1688
            branchcode   => undef,
1689
            FROM default_circ_rules'],
1689
            categorycode => undef,
1690
            itemtype     => $itemtype,
1691
        },
1692
        {
1693
            branchcode   => undef,
1694
            categorycode => undef,
1695
            itemtype     => undef,
1696
        },
1690
    );
1697
    );
1691
1698
1692
    foreach my $attempt (@attempts) {
1699
    # Initialize default values
1693
        my ($query, @bind_params) = @{$attempt};
1700
    my $rules = {
1694
        my $search_result = $dbh->selectrow_hashref ( $query , {}, @bind_params )
1701
        holdallowed             => undef,
1695
          or next;
1702
        hold_fulfillment_policy => undef,
1696
1703
        returnbranch            => undef,
1697
        # Since branch/category and branch/itemtype use the same per-branch
1704
    };
1698
        # defaults tables, we have to check that the key we want is set, not
1705
1699
        # just that a row was returned
1706
    # Search for rules!
1700
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1707
    foreach my $rule_name (qw( holdallowed hold_fulfillment_policy returnbranch )) {
1701
        $result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} );
1708
        foreach my $params (@params) {
1702
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1709
            my $rule = Koha::CirculationRules->search(
1710
                {
1711
                    rule_name => $rule_name,
1712
                    %$params,
1713
                }
1714
            )->next();
1715
1716
            if ( $rule ) {
1717
                $rules->{$rule_name} = $rule->rule_value;
1718
                last;
1719
            }
1720
        }
1703
    }
1721
    }
1704
    
1722
1705
    # built-in default circulation rule
1723
    # built-in default circulation rule
1706
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1724
    $rules->{holdallowed} = 2                 unless ( defined $rules->{holdallowed} );
1707
    $result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} );
1725
    $rules->{hold_fulfillment_policy} = 'any' unless ( defined $rules->{hold_fulfillment_policy} );
1708
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
1726
    $rules->{returnbranch} = 'homebranch'     unless ( defined $rules->{returnbranch} );
1709
1727
1710
    return $result;
1728
    return $rules;
1711
}
1729
}
1712
1730
1713
=head2 AddReturn
1731
=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 253-311 elsif ($op eq "set-branch-defaults") { Link Here
253
    $max_holds = '' if $max_holds !~ /^\d+/;
330
    $max_holds = '' if $max_holds !~ /^\d+/;
254
331
255
    if ($branch eq "*") {
332
    if ($branch eq "*") {
256
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
257
                                        FROM default_circ_rules");
258
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
259
                                        (holdallowed, hold_fulfillment_policy, returnbranch)
260
                                        VALUES (?, ?, ?)");
261
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
262
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
263
264
        $sth_search->execute();
265
        my $res = $sth_search->fetchrow_hashref();
266
        if ($res->{total}) {
267
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
268
        } else {
269
            $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
270
        }
271
272
        Koha::CirculationRules->set_rules(
333
        Koha::CirculationRules->set_rules(
273
            {
334
            {
274
                categorycode => undef,
335
                categorycode => undef,
275
                itemtype     => undef,
336
                itemtype     => undef,
276
                branchcode   => undef,
337
                branchcode   => undef,
277
                rules        => {
338
                rules        => {
278
                    patron_maxissueqty             => $patron_maxissueqty,
339
                    patron_maxissueqty       => $patron_maxissueqty,
279
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
340
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
341
                    holdallowed              => $holdallowed,
342
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
343
                    returnbranch             => $returnbranch,
280
                }
344
                }
281
            }
345
            }
282
        );
346
        );
283
    } else {
347
    } else {
284
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
285
                                        FROM default_branch_circ_rules
286
                                        WHERE branchcode = ?");
287
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
288
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
289
                                        VALUES (?, ?, ?, ?)");
290
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
291
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
292
                                        WHERE branchcode = ?");
293
        $sth_search->execute($branch);
294
        my $res = $sth_search->fetchrow_hashref();
295
        if ($res->{total}) {
296
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
297
        } else {
298
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
299
        }
300
301
        Koha::CirculationRules->set_rules(
348
        Koha::CirculationRules->set_rules(
302
            {
349
            {
303
                categorycode => undef,
350
                categorycode => undef,
304
                itemtype     => undef,
351
                itemtype     => undef,
305
                branchcode   => $branch,
352
                branchcode   => $branch,
306
                rules        => {
353
                rules        => {
307
                    patron_maxissueqty             => $patron_maxissueqty,
354
                    patron_maxissueqty       => $patron_maxissueqty,
308
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
355
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
356
                    holdallowed              => $holdallowed,
357
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
358
                    returnbranch             => $returnbranch,
309
                }
359
                }
310
            }
360
            }
311
        );
361
        );
Lines 399-474 elsif ($op eq "add-branch-item") { Link Here
399
449
400
    if ($branch eq "*") {
450
    if ($branch eq "*") {
401
        if ($itemtype eq "*") {
451
        if ($itemtype eq "*") {
402
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
452
            Koha::CirculationRules->set_rules(
403
                                            FROM default_circ_rules");
453
                {
404
            my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
454
                    categorycode => undef,
405
                                            (holdallowed, hold_fulfillment_policy, returnbranch)
455
                    itemtype     => undef,
406
                                            VALUES (?, ?, ?)");
456
                    branchcode   => undef,
407
            my $sth_update = $dbh->prepare("UPDATE default_circ_rules
457
                    rules        => {
408
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
458
                        holdallowed             => $holdallowed,
409
459
                        hold_fulfillment_policy => $hold_fulfillment_policy,
410
            $sth_search->execute();
460
                        returnbranch            => $returnbranch,
411
            my $res = $sth_search->fetchrow_hashref();
461
                    }
412
            if ($res->{total}) {
462
                }
413
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
463
            );
414
            } else {
415
                $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
416
            }
417
        } else {
464
        } else {
418
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
465
            Koha::CirculationRules->set_rules(
419
                                            FROM default_branch_item_rules
466
                {
420
                                            WHERE itemtype = ?");
467
                    categorycode => undef,
421
            my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules
468
                    itemtype     => $itemtype,
422
                                            (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
469
                    branchcode   => undef,
423
                                            VALUES (?, ?, ?, ?)");
470
                    rules        => {
424
            my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules
471
                        holdallowed             => $holdallowed,
425
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
472
                        hold_fulfillment_policy => $hold_fulfillment_policy,
426
                                            WHERE itemtype = ?");
473
                        returnbranch            => $returnbranch,
427
            $sth_search->execute($itemtype);
474
                    }
428
            my $res = $sth_search->fetchrow_hashref();
475
                }
429
            if ($res->{total}) {
476
            );
430
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype);
431
            } else {
432
                $sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
433
            }
434
        }
477
        }
435
    } elsif ($itemtype eq "*") {
478
    } elsif ($itemtype eq "*") {
436
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
479
            Koha::CirculationRules->set_rules(
437
                                        FROM default_branch_circ_rules
480
                {
438
                                        WHERE branchcode = ?");
481
                    categorycode => undef,
439
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
482
                    itemtype     => undef,
440
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
483
                    branchcode   => $branch,
441
                                        VALUES (?, ?, ?, ?)");
484
                    rules        => {
442
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
485
                        holdallowed             => $holdallowed,
443
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
486
                        hold_fulfillment_policy => $hold_fulfillment_policy,
444
                                        WHERE branchcode = ?");
487
                        returnbranch            => $returnbranch,
445
        $sth_search->execute($branch);
488
                    }
446
        my $res = $sth_search->fetchrow_hashref();
489
                }
447
        if ($res->{total}) {
490
            );
448
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
449
        } else {
450
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
451
        }
452
    } else {
491
    } else {
453
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
492
        Koha::CirculationRules->set_rules(
454
                                        FROM branch_item_rules
493
            {
455
                                        WHERE branchcode = ?
494
                categorycode => undef,
456
                                        AND   itemtype = ?");
495
                itemtype     => $itemtype,
457
        my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules
496
                branchcode   => $branch,
458
                                        (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
497
                rules        => {
459
                                        VALUES (?, ?, ?, ?, ?)");
498
                    holdallowed             => $holdallowed,
460
        my $sth_update = $dbh->prepare("UPDATE branch_item_rules
499
                    hold_fulfillment_policy => $hold_fulfillment_policy,
461
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
500
                    returnbranch            => $returnbranch,
462
                                        WHERE branchcode = ?
501
                }
463
                                        AND itemtype = ?");
502
            }
464
503
        );
465
        $sth_search->execute($branch, $itemtype);
466
        my $res = $sth_search->fetchrow_hashref();
467
        if ($res->{total}) {
468
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype);
469
        } else {
470
            $sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
471
        }
472
    }
504
    }
473
}
505
}
474
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
506
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
Lines 551-626 while (my $row = $sth2->fetchrow_hashref) { Link Here
551
583
552
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
584
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
553
585
554
my $sth_branch_item;
555
if ($branch eq "*") {
556
    $sth_branch_item = $dbh->prepare("
557
        SELECT default_branch_item_rules.*,
558
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
559
        FROM default_branch_item_rules
560
        JOIN itemtypes USING (itemtype)
561
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
562
            AND localization.entity = 'itemtypes'
563
            AND localization.lang = ?
564
    ");
565
    $sth_branch_item->execute($language);
566
} else {
567
    $sth_branch_item = $dbh->prepare("
568
        SELECT branch_item_rules.*,
569
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
570
        FROM branch_item_rules
571
        JOIN itemtypes USING (itemtype)
572
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
573
            AND localization.entity = 'itemtypes'
574
            AND localization.lang = ?
575
        WHERE branch_item_rules.branchcode = ?
576
    ");
577
    $sth_branch_item->execute($language, $branch);
578
}
579
580
my @branch_item_rules = ();
581
while (my $row = $sth_branch_item->fetchrow_hashref) {
582
    push @branch_item_rules, $row;
583
}
584
my @sorted_branch_item_rules = sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @branch_item_rules;
585
586
# note undef holdallowed so that template can deal with them
587
foreach my $entry (@sorted_branch_item_rules) {
588
    $entry->{holdallowed_any}  = 1 if ( $entry->{holdallowed} == 2 );
589
    $entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 );
590
}
591
592
$template->param(show_branch_cat_rule_form => 1);
586
$template->param(show_branch_cat_rule_form => 1);
593
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules);
594
595
my $sth_defaults;
596
if ($branch eq "*") {
597
    $sth_defaults = $dbh->prepare("
598
        SELECT *
599
        FROM default_circ_rules
600
    ");
601
    $sth_defaults->execute();
602
} else {
603
    $sth_defaults = $dbh->prepare("
604
        SELECT *
605
        FROM default_branch_circ_rules
606
        WHERE branchcode = ?
607
    ");
608
    $sth_defaults->execute($branch);
609
}
610
611
my $defaults = $sth_defaults->fetchrow_hashref;
612
613
if ($defaults) {
614
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
615
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
616
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
617
    $template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} );
618
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
619
    $template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} );
620
    $template->param( default_returnbranch      => $defaults->{returnbranch} );
621
}
622
623
$template->param(default_rules => ($defaults ? 1 : 0));
624
587
625
$template->param(
588
$template->param(
626
    patron_categories => $patron_categories,
589
    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 423-446 Link Here
423
                    </td>
423
                    </td>
424
                    <td>
424
                    <td>
425
                        <select name="holdallowed">
425
                        <select name="holdallowed">
426
                            [% IF ( default_holdallowed_any ) %]
426
                            [% SET holdallowed = CirculationRules.Get( branchcode, undef, undef, 'holdallowed' ) %]
427
                            <option value="2" selected="selected">
427
                            <option value="">
428
                                Not set
429
                            </option>
430
431
                            [% IF holdallowed == 2 %]
432
                                <option value="2" selected="selected">
428
                            [% ELSE %]
433
                            [% ELSE %]
429
                            <option value="2">
434
                                <option value="2">
430
                            [% END %]
435
                            [% END %]
431
                                From any library
436
                                From any library
432
                            </option>
437
                            </option>
433
                            [% IF ( default_holdallowed_same ) %]
438
434
                            <option value="1" selected="selected">
439
                            [% IF holdallowed == 1 %]
440
                                <option value="1" selected="selected">
435
                            [% ELSE %]
441
                            [% ELSE %]
436
                            <option value="1">
442
                                <option value="1">
437
                            [% END %]
443
                            [% END %]
438
                                From home library
444
                                From home library
439
                            </option>
445
                            </option>
440
                            [% IF ( default_holdallowed_none ) %]
446
441
                            <option value="0" selected="selected">
447
                            [% IF holdallowed == 0 %]
448
                                <option value="0" selected="selected">
442
                            [% ELSE %]
449
                            [% ELSE %]
443
                            <option value="0">
450
                                <option value="0">
444
                            [% END %]
451
                            [% END %]
445
                                No holds allowed
452
                                No holds allowed
446
                            </option>
453
                            </option>
Lines 448-454 Link Here
448
                    </td>
455
                    </td>
449
                    <td>
456
                    <td>
450
                        <select name="hold_fulfillment_policy">
457
                        <select name="hold_fulfillment_policy">
451
                            [% IF default_hold_fulfillment_policy == 'any' %]
458
                            [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, undef, 'hold_fulfillment_policy' ) %]
459
460
                            <option value="">
461
                                Not set
462
                            </option>
463
464
                            [% IF hold_fulfillment_policy == 'any' %]
452
                                <option value="any" selected="selected">
465
                                <option value="any" selected="selected">
453
                                    any library
466
                                    any library
454
                                </option>
467
                                </option>
Lines 458-464 Link Here
458
                                </option>
471
                                </option>
459
                            [% END %]
472
                            [% END %]
460
473
461
                            [% IF default_hold_fulfillment_policy == 'homebranch' %]
474
                            [% IF hold_fulfillment_policy == 'homebranch' %]
462
                                <option value="homebranch" selected="selected">
475
                                <option value="homebranch" selected="selected">
463
                                    item's home library
476
                                    item's home library
464
                                </option>
477
                                </option>
Lines 468-474 Link Here
468
                                </option>
481
                                </option>
469
                            [% END %]
482
                            [% END %]
470
483
471
                            [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
484
                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
472
                                <option value="holdingbranch" selected="selected">
485
                                <option value="holdingbranch" selected="selected">
473
                                    item's holding library
486
                                    item's holding library
474
                                </option>
487
                                </option>
Lines 481-501 Link Here
481
                    </td>
494
                    </td>
482
                    <td>
495
                    <td>
483
                        <select name="returnbranch">
496
                        <select name="returnbranch">
484
                            [% IF ( default_returnbranch == 'homebranch' ) %]
497
                            [% SET returnbranch = CirculationRules.Get( branchcode, undef, undef, 'returnbranch' ) %]
498
499
                            <option value="">
500
                                Not set
501
                            </option>
502
503
                            [% IF returnbranch == 'homebranch' %]
485
                            <option value="homebranch" selected="selected">
504
                            <option value="homebranch" selected="selected">
486
                            [% ELSE %]
505
                            [% ELSE %]
487
                            <option value="homebranch">
506
                            <option value="homebranch">
488
                            [% END %]
507
                            [% END %]
489
                                Item returns home
508
                                Item returns home
490
                            </option>
509
                            </option>
491
                            [% IF ( default_returnbranch == 'holdingbranch' ) %]
510
                            [% IF returnbranch == 'holdingbranch' %]
492
                            <option value="holdingbranch" selected="selected">
511
                            <option value="holdingbranch" selected="selected">
493
                            [% ELSE %]
512
                            [% ELSE %]
494
                            <option value="holdingbranch">
513
                            <option value="holdingbranch">
495
                            [% END %]
514
                            [% END %]
496
                                Item returns to issuing library
515
                                Item returns to issuing library
497
                            </option>
516
                            </option>
498
                            [% IF ( default_returnbranch == 'noreturn' ) %]
517
                            [% IF returnbranch == 'noreturn' %]
499
                            <option value="noreturn" selected="selected">
518
                            <option value="noreturn" selected="selected">
500
                            [% ELSE %]
519
                            [% ELSE %]
501
                            <option value="noreturn">
520
                            <option value="noreturn">
Lines 702-749 Link Here
702
                    <th>Return policy</th>
721
                    <th>Return policy</th>
703
                    <th>&nbsp;</th>
722
                    <th>&nbsp;</th>
704
                </tr>
723
                </tr>
705
                [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
724
                [% FOREACH i IN itemtypeloop %]
706
                    [% UNLESS ( loop.odd ) %]
725
                    [% SET holdallowed = CirculationRules.Get( branchcode, undef, i.itemtype, 'holdallowed' ) %]
707
                    <tr class="highlight">
726
                    [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
708
                    [% ELSE %]
727
                    [% SET returnbranch = CirculationRules.Get( branchcode, undef, i.itemtype, 'returnbranch' ) %]
709
                    <tr>
728
729
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
730
                        <tr>
731
                            <td>
732
                                [% i.translated_description %]
733
                            </td>
734
                            <td>
735
                                [% IF holdallowed == 2 %]
736
                                    <span>From any library</span>
737
                                [% ELSIF holdallowed == 1 %]
738
                                    <span>From home library</span>
739
                                [% ELSE %]
740
                                    <span>No holds allowed</span>
741
                                [% END %]
742
                            </td>
743
                            <td>
744
                                [% IF hold_fulfillment_policy == 'any' %]
745
                                    <span>any library</span>
746
                                [% ELSIF hold_fulfillment_policy == 'homebranch' %]
747
                                    <span>item's home library</span>
748
                                [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
749
                                    <span>item's holding library</span>
750
                                [% END %]
751
                            </td>
752
                            <td>
753
                                [% IF returnbranch == 'homebranch' %]
754
                                    <span>Item returns home</span>
755
                                [% ELSIF returnbranch == 'holdingbranch' %]
756
                                    <span>Item returns to issuing branch</span>
757
                                [% ELSIF returnbranch == 'noreturn' %]
758
                                    <span>Item floats</span>
759
                                [% END %]
760
                            </td>
761
                            <td class="actions">
762
                                <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>
763
                            </td>
764
                        </tr>
710
                    [% END %]
765
                    [% END %]
711
                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
712
                                <em>Default</em>
713
                            [% ELSE %]
714
                                [% branch_item_rule_loo.translated_description | html %]
715
                            [% END %]
716
                        </td>
717
                        <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
718
                                <span>From any library</span>
719
                            [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
720
                                <span>From home library</span>
721
                            [% ELSE %]
722
                                <span>No holds allowed</span>
723
                            [% END %]
724
                        </td>
725
                        <td>[% IF ( branch_item_rule_loo.hold_fulfillment_policy == 'any' ) %]
726
                                <span>any library</span>
727
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'homebranch' ) %]
728
                                <span>item's home library</span>
729
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'holdingbranch' ) %]
730
                                <span>item's holding library</span>
731
                            [% END %]
732
                        </td>
733
                        <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
734
                                <span>Item returns home</span>
735
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
736
                                <span>Item returns to issuing branch</span>
737
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
738
                                <span>Item floats</span>
739
                            [% ELSE %]
740
                                <span>Error - unknown option</span>
741
                            [% END %]
742
                        </td>
743
                        <td class="actions">
744
                            <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>
745
                        </td>
746
                    </tr>
747
                [% END %]
766
                [% END %]
748
                <tr>
767
                <tr>
749
                    <td>
768
                    <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 47-52 my $borrowers_count = 5; Link Here
47
47
48
$dbh->do('DELETE FROM itemtypes');
48
$dbh->do('DELETE FROM itemtypes');
49
$dbh->do('DELETE FROM reserves');
49
$dbh->do('DELETE FROM reserves');
50
$dbh->do('DELETE FROM circulation_rules');
50
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
51
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
51
$insert_sth->execute('CAN');
52
$insert_sth->execute('CAN');
52
$insert_sth->execute('CANNOT');
53
$insert_sth->execute('CANNOT');
Lines 351-374 ok( Link Here
351
# Test branch item rules
352
# Test branch item rules
352
353
353
$dbh->do('DELETE FROM issuingrules');
354
$dbh->do('DELETE FROM issuingrules');
355
$dbh->do('DELETE FROM circulation_rules');
354
$dbh->do(
356
$dbh->do(
355
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
357
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
356
      VALUES (?, ?, ?, ?)},
358
      VALUES (?, ?, ?, ?)},
357
    {},
359
    {},
358
    '*', '*', '*', 25
360
    '*', '*', '*', 25
359
);
361
);
360
$dbh->do('DELETE FROM branch_item_rules');
362
Koha::CirculationRules->set_rules(
361
$dbh->do('DELETE FROM default_branch_circ_rules');
363
    {
362
$dbh->do('DELETE FROM default_branch_item_rules');
364
        branchcode => $branch_1,
363
$dbh->do('DELETE FROM default_circ_rules');
365
        itemtype   => 'CANNOT',
364
$dbh->do(q{
366
        categorycode => undef,
365
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
367
        rules => {
366
    VALUES (?, ?, ?, ?)
368
            holdallowed => 0,
367
}, {}, $branch_1, 'CANNOT', 0, 'homebranch');
369
            returnbranch => 'homebranch',
368
$dbh->do(q{
370
        }
369
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
371
    }
370
    VALUES (?, ?, ?, ?)
372
);
371
}, {}, $branch_1, 'CAN', 1, 'homebranch');
373
Koha::CirculationRules->set_rules(
374
    {
375
        branchcode => $branch_1,
376
        itemtype   => 'CAN',
377
        categorycode => undef,
378
        rules => {
379
            holdallowed => 1,
380
            returnbranch => 'homebranch',
381
        }
382
    }
383
);
372
$biblio = $builder->build_sample_biblio({ itemtype => 'CANNOT' });
384
$biblio = $builder->build_sample_biblio({ itemtype => 'CANNOT' });
373
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
385
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
374
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $biblio->biblionumber);
386
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $biblio->biblionumber);
(-)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 187-196 $requesters{$branch_3} = Koha::Patron->new({ Link Here
187
# to fill holds from anywhere.
189
# to fill holds from anywhere.
188
190
189
$dbh->do('DELETE FROM issuingrules');
191
$dbh->do('DELETE FROM issuingrules');
190
$dbh->do('DELETE FROM branch_item_rules');
191
$dbh->do('DELETE FROM default_branch_item_rules');
192
$dbh->do('DELETE FROM default_branch_circ_rules');
193
$dbh->do('DELETE FROM default_circ_rules');
194
$dbh->do(
192
$dbh->do(
195
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
193
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
196
      VALUES (?, ?, ?, ?)},
194
      VALUES (?, ?, ?, ?)},
Lines 199-217 $dbh->do( Link Here
199
);
197
);
200
198
201
# CPL allows only its own patrons to request its items
199
# CPL allows only its own patrons to request its items
202
$dbh->do(
200
Koha::CirculationRules->set_rules(
203
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
201
    {
204
      VALUES (?, ?, ?)},
202
        branchcode   => $branch_1,
205
    {},
203
        categorycode => undef,
206
    $branch_1, 1, 'homebranch',
204
        itemtype     => undef,
205
        rules        => {
206
            holdallowed  => 1,
207
            returnbranch => 'homebranch',
208
        }
209
    }
207
);
210
);
208
211
209
# ... while FPL allows anybody to request its items
212
# ... while FPL allows anybody to request its items
210
$dbh->do(
213
Koha::CirculationRules->set_rules(
211
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
214
    {
212
      VALUES (?, ?, ?)},
215
        branchcode   => $branch_2,
213
    {},
216
        categorycode => undef,
214
    $branch_2, 2, 'homebranch',
217
        itemtype     => undef,
218
        rules        => {
219
            holdallowed  => 2,
220
            returnbranch => 'homebranch',
221
        }
222
    }
215
);
223
);
216
224
217
my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
225
my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
218
- 

Return to bug 18928