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

(-)a/C4/Circulation.pm (-32 / +50 lines)
Lines 1721-1763 Neither C<$branchcode> nor C<$itemtype> should be '*'. Link Here
1721
1721
1722
sub GetBranchItemRule {
1722
sub GetBranchItemRule {
1723
    my ( $branchcode, $itemtype ) = @_;
1723
    my ( $branchcode, $itemtype ) = @_;
1724
    my $dbh = C4::Context->dbh();
1724
1725
    my $result = {};
1725
    # Set search precedences
1726
1726
    my @params = (
1727
    my @attempts = (
1727
        {
1728
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1728
            branchcode   => $branchcode,
1729
            FROM branch_item_rules
1729
            categorycode => undef,
1730
            WHERE branchcode = ?
1730
            itemtype     => $itemtype,
1731
              AND itemtype = ?', $branchcode, $itemtype],
1731
        },
1732
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1732
        {
1733
            FROM default_branch_circ_rules
1733
            branchcode   => $branchcode,
1734
            WHERE branchcode = ?', $branchcode],
1734
            categorycode => undef,
1735
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1735
            itemtype     => undef,
1736
            FROM default_branch_item_rules
1736
        },
1737
            WHERE itemtype = ?', $itemtype],
1737
        {
1738
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1738
            branchcode   => undef,
1739
            FROM default_circ_rules'],
1739
            categorycode => undef,
1740
            itemtype     => $itemtype,
1741
        },
1742
        {
1743
            branchcode   => undef,
1744
            categorycode => undef,
1745
            itemtype     => undef,
1746
        },
1740
    );
1747
    );
1741
1748
1742
    foreach my $attempt (@attempts) {
1749
    # Initialize default values
1743
        my ($query, @bind_params) = @{$attempt};
1750
    my $rules = {
1744
        my $search_result = $dbh->selectrow_hashref ( $query , {}, @bind_params )
1751
        holdallowed             => undef,
1745
          or next;
1752
        hold_fulfillment_policy => undef,
1746
1753
        returnbranch            => undef,
1747
        # Since branch/category and branch/itemtype use the same per-branch
1754
    };
1748
        # defaults tables, we have to check that the key we want is set, not
1755
1749
        # just that a row was returned
1756
    # Search for rules!
1750
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1757
    foreach my $rule_name (qw( holdallowed hold_fulfillment_policy returnbranch )) {
1751
        $result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} );
1758
        foreach my $params (@params) {
1752
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1759
            my $rule = Koha::CirculationRules->search(
1760
                {
1761
                    rule_name => $rule_name,
1762
                    %$params,
1763
                }
1764
            )->next();
1765
1766
            if ( $rule ) {
1767
                $rules->{$rule_name} = $rule->rule_value;
1768
                last;
1769
            }
1770
        }
1753
    }
1771
    }
1754
    
1772
1755
    # built-in default circulation rule
1773
    # built-in default circulation rule
1756
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1774
    $rules->{holdallowed} = 2                 unless ( defined $rules->{holdallowed} );
1757
    $result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} );
1775
    $rules->{hold_fulfillment_policy} = 'any' unless ( defined $rules->{hold_fulfillment_policy} );
1758
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
1776
    $rules->{returnbranch} = 'homebranch'     unless ( defined $rules->{returnbranch} );
1759
1777
1760
    return $result;
1778
    return $rules;
1761
}
1779
}
1762
1780
1763
=head2 AddReturn
1781
=head2 AddReturn
(-)a/admin/smart-rules.pl (-201 / +164 lines)
Lines 93-139 elsif ($op eq 'delete-branch-cat') { Link Here
93
    my $categorycode  = $input->param('categorycode');
93
    my $categorycode  = $input->param('categorycode');
94
    if ($branch eq "*") {
94
    if ($branch eq "*") {
95
        if ($categorycode eq "*") {
95
        if ($categorycode eq "*") {
96
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
96
             Koha::CirculationRules->set_rules(
97
            $sth_delete->execute();
97
                 {
98
                     categorycode => undef,
99
                     branchcode   => undef,
100
                     itemtype     => undef,
101
                     rules        => {
102
                         patron_maxissueqty             => undef,
103
                         patron_maxonsiteissueqty       => undef,
104
                         holdallowed             => undef,
105
                         hold_fulfillment_policy => undef,
106
                         returnbranch            => undef,
107
                     }
108
                 }
109
             );
110
         } else {
111
             Koha::CirculationRules->set_rules(
112
                 {
113
                     categorycode => $categorycode,
114
                     branchcode   => undef,
115
                     itemtype     => undef,
116
                     rules        => {
117
                         max_holds         => undef,
118
                         patron_maxissueqty       => undef,
119
                         patron_maxonsiteissueqty => undef,
120
                     }
121
                 }
122
             );
98
        }
123
        }
99
    } elsif ($categorycode eq "*") {
124
    } elsif ($categorycode eq "*") {
100
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
125
        Koha::CirculationRules->set_rules(
101
                                        WHERE branchcode = ?");
126
            {
102
        $sth_delete->execute($branch);
127
                categorycode => undef,
103
    }
128
                branchcode   => $branch,
104
    Koha::CirculationRules->set_rules(
129
                itemtype     => undef,
105
        {
130
                rules        => {
106
            categorycode => $categorycode eq '*' ? undef : $categorycode,
131
                    patron_maxissueqty             => undef,
107
            branchcode   => $branch eq '*'       ? undef : $branch,
132
                    patron_maxonsiteissueqty       => undef,
108
            itemtype     => undef,
133
                    holdallowed             => undef,
109
            rules        => {
134
                    hold_fulfillment_policy => undef,
110
                max_holds         => undef,
135
                    returnbranch            => undef,
111
                patron_maxissueqty             => undef,
136
                }
112
                patron_maxonsiteissueqty       => undef,
113
            }
137
            }
114
        }
138
        );
115
    );
139
    } else {
140
        Koha::CirculationRules->set_rules(
141
            {
142
                categorycode => $categorycode,
143
                branchcode   => $branch,
144
                itemtype     => undef,
145
                rules        => {
146
                    max_holds         => undef,
147
                    patron_maxissueqty       => undef,
148
                    patron_maxonsiteissueqty => undef,
149
                }
150
            }
151
        );
152
    }
116
}
153
}
117
elsif ($op eq 'delete-branch-item') {
154
elsif ($op eq 'delete-branch-item') {
118
    my $itemtype  = $input->param('itemtype');
155
    my $itemtype  = $input->param('itemtype');
119
    if ($branch eq "*") {
156
    if ($branch eq "*") {
120
        if ($itemtype eq "*") {
157
        if ($itemtype eq "*") {
121
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
158
            Koha::CirculationRules->set_rules(
122
            $sth_delete->execute();
159
                {
160
                    categorycode => undef,
161
                    branchcode   => undef,
162
                    itemtype     => undef,
163
                    rules        => {
164
                        patron_maxissueqty             => undef,
165
                        patron_maxonsiteissueqty       => undef,
166
                        holdallowed             => undef,
167
                        hold_fulfillment_policy => undef,
168
                        returnbranch            => undef,
169
                    }
170
                }
171
            );
123
        } else {
172
        } else {
124
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
173
            Koha::CirculationRules->set_rules(
125
                                            WHERE itemtype = ?");
174
                {
126
            $sth_delete->execute($itemtype);
175
                    categorycode => undef,
176
                    branchcode   => undef,
177
                    itemtype     => $itemtype,
178
                    rules        => {
179
                        holdallowed             => undef,
180
                        hold_fulfillment_policy => undef,
181
                        returnbranch            => undef,
182
                    }
183
                }
184
            );
127
        }
185
        }
128
    } elsif ($itemtype eq "*") {
186
    } elsif ($itemtype eq "*") {
129
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
187
        Koha::CirculationRules->set_rules(
130
                                        WHERE branchcode = ?");
188
            {
131
        $sth_delete->execute($branch);
189
                categorycode => undef,
190
                branchcode   => $branch,
191
                itemtype     => undef,
192
                rules        => {
193
                    maxissueqty             => undef,
194
                    maxonsiteissueqty       => undef,
195
                    holdallowed             => undef,
196
                    hold_fulfillment_policy => undef,
197
                    returnbranch            => undef,
198
                }
199
            }
200
        );
132
    } else {
201
    } else {
133
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
202
        Koha::CirculationRules->set_rules(
134
                                        WHERE branchcode = ?
203
            {
135
                                        AND itemtype = ?");
204
                categorycode => undef,
136
        $sth_delete->execute($branch, $itemtype);
205
                branchcode   => $branch,
206
                itemtype     => $itemtype,
207
                rules        => {
208
                    holdallowed             => undef,
209
                    hold_fulfillment_policy => undef,
210
                    returnbranch            => undef,
211
                }
212
            }
213
        );
137
    }
214
    }
138
}
215
}
139
# save the values entered
216
# save the values entered
Lines 256-314 elsif ($op eq "set-branch-defaults") { Link Here
256
    $max_holds = '' if $max_holds !~ /^\d+/;
333
    $max_holds = '' if $max_holds !~ /^\d+/;
257
334
258
    if ($branch eq "*") {
335
    if ($branch eq "*") {
259
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
260
                                        FROM default_circ_rules");
261
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
262
                                        (holdallowed, hold_fulfillment_policy, returnbranch)
263
                                        VALUES (?, ?, ?)");
264
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
265
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
266
267
        $sth_search->execute();
268
        my $res = $sth_search->fetchrow_hashref();
269
        if ($res->{total}) {
270
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
271
        } else {
272
            $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
273
        }
274
275
        Koha::CirculationRules->set_rules(
336
        Koha::CirculationRules->set_rules(
276
            {
337
            {
277
                categorycode => undef,
338
                categorycode => undef,
278
                itemtype     => undef,
339
                itemtype     => undef,
279
                branchcode   => undef,
340
                branchcode   => undef,
280
                rules        => {
341
                rules        => {
281
                    patron_maxissueqty             => $patron_maxissueqty,
342
                    patron_maxissueqty       => $patron_maxissueqty,
282
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
343
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
344
                    holdallowed              => $holdallowed,
345
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
346
                    returnbranch             => $returnbranch,
283
                }
347
                }
284
            }
348
            }
285
        );
349
        );
286
    } else {
350
    } else {
287
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
288
                                        FROM default_branch_circ_rules
289
                                        WHERE branchcode = ?");
290
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
291
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
292
                                        VALUES (?, ?, ?, ?)");
293
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
294
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
295
                                        WHERE branchcode = ?");
296
        $sth_search->execute($branch);
297
        my $res = $sth_search->fetchrow_hashref();
298
        if ($res->{total}) {
299
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
300
        } else {
301
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
302
        }
303
304
        Koha::CirculationRules->set_rules(
351
        Koha::CirculationRules->set_rules(
305
            {
352
            {
306
                categorycode => undef,
353
                categorycode => undef,
307
                itemtype     => undef,
354
                itemtype     => undef,
308
                branchcode   => $branch,
355
                branchcode   => $branch,
309
                rules        => {
356
                rules        => {
310
                    patron_maxissueqty             => $patron_maxissueqty,
357
                    patron_maxissueqty       => $patron_maxissueqty,
311
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
358
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
359
                    holdallowed              => $holdallowed,
360
                    hold_fulfillment_policy  => $hold_fulfillment_policy,
361
                    returnbranch             => $returnbranch,
312
                }
362
                }
313
            }
363
            }
314
        );
364
        );
Lines 402-477 elsif ($op eq "add-branch-item") { Link Here
402
452
403
    if ($branch eq "*") {
453
    if ($branch eq "*") {
404
        if ($itemtype eq "*") {
454
        if ($itemtype eq "*") {
405
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
455
            Koha::CirculationRules->set_rules(
406
                                            FROM default_circ_rules");
456
                {
407
            my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
457
                    categorycode => undef,
408
                                            (holdallowed, hold_fulfillment_policy, returnbranch)
458
                    itemtype     => undef,
409
                                            VALUES (?, ?, ?)");
459
                    branchcode   => undef,
410
            my $sth_update = $dbh->prepare("UPDATE default_circ_rules
460
                    rules        => {
411
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
461
                        holdallowed             => $holdallowed,
412
462
                        hold_fulfillment_policy => $hold_fulfillment_policy,
413
            $sth_search->execute();
463
                        returnbranch            => $returnbranch,
414
            my $res = $sth_search->fetchrow_hashref();
464
                    }
415
            if ($res->{total}) {
465
                }
416
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
466
            );
417
            } else {
418
                $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
419
            }
420
        } else {
467
        } else {
421
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
468
            Koha::CirculationRules->set_rules(
422
                                            FROM default_branch_item_rules
469
                {
423
                                            WHERE itemtype = ?");
470
                    categorycode => undef,
424
            my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules
471
                    itemtype     => $itemtype,
425
                                            (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
472
                    branchcode   => undef,
426
                                            VALUES (?, ?, ?, ?)");
473
                    rules        => {
427
            my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules
474
                        holdallowed             => $holdallowed,
428
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
475
                        hold_fulfillment_policy => $hold_fulfillment_policy,
429
                                            WHERE itemtype = ?");
476
                        returnbranch            => $returnbranch,
430
            $sth_search->execute($itemtype);
477
                    }
431
            my $res = $sth_search->fetchrow_hashref();
478
                }
432
            if ($res->{total}) {
479
            );
433
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype);
434
            } else {
435
                $sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
436
            }
437
        }
480
        }
438
    } elsif ($itemtype eq "*") {
481
    } elsif ($itemtype eq "*") {
439
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
482
            Koha::CirculationRules->set_rules(
440
                                        FROM default_branch_circ_rules
483
                {
441
                                        WHERE branchcode = ?");
484
                    categorycode => undef,
442
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
485
                    itemtype     => undef,
443
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
486
                    branchcode   => $branch,
444
                                        VALUES (?, ?, ?, ?)");
487
                    rules        => {
445
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
488
                        holdallowed             => $holdallowed,
446
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
489
                        hold_fulfillment_policy => $hold_fulfillment_policy,
447
                                        WHERE branchcode = ?");
490
                        returnbranch            => $returnbranch,
448
        $sth_search->execute($branch);
491
                    }
449
        my $res = $sth_search->fetchrow_hashref();
492
                }
450
        if ($res->{total}) {
493
            );
451
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
452
        } else {
453
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
454
        }
455
    } else {
494
    } else {
456
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
495
        Koha::CirculationRules->set_rules(
457
                                        FROM branch_item_rules
496
            {
458
                                        WHERE branchcode = ?
497
                categorycode => undef,
459
                                        AND   itemtype = ?");
498
                itemtype     => $itemtype,
460
        my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules
499
                branchcode   => $branch,
461
                                        (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
500
                rules        => {
462
                                        VALUES (?, ?, ?, ?, ?)");
501
                    holdallowed             => $holdallowed,
463
        my $sth_update = $dbh->prepare("UPDATE branch_item_rules
502
                    hold_fulfillment_policy => $hold_fulfillment_policy,
464
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
503
                    returnbranch            => $returnbranch,
465
                                        WHERE branchcode = ?
504
                }
466
                                        AND itemtype = ?");
505
            }
467
506
        );
468
        $sth_search->execute($branch, $itemtype);
469
        my $res = $sth_search->fetchrow_hashref();
470
        if ($res->{total}) {
471
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype);
472
        } else {
473
            $sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
474
        }
475
    }
507
    }
476
}
508
}
477
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
509
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
Lines 554-629 while (my $row = $sth2->fetchrow_hashref) { Link Here
554
586
555
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
587
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
556
588
557
my $sth_branch_item;
558
if ($branch eq "*") {
559
    $sth_branch_item = $dbh->prepare("
560
        SELECT default_branch_item_rules.*,
561
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
562
        FROM default_branch_item_rules
563
        JOIN itemtypes USING (itemtype)
564
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
565
            AND localization.entity = 'itemtypes'
566
            AND localization.lang = ?
567
    ");
568
    $sth_branch_item->execute($language);
569
} else {
570
    $sth_branch_item = $dbh->prepare("
571
        SELECT branch_item_rules.*,
572
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
573
        FROM branch_item_rules
574
        JOIN itemtypes USING (itemtype)
575
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
576
            AND localization.entity = 'itemtypes'
577
            AND localization.lang = ?
578
        WHERE branch_item_rules.branchcode = ?
579
    ");
580
    $sth_branch_item->execute($language, $branch);
581
}
582
583
my @branch_item_rules = ();
584
while (my $row = $sth_branch_item->fetchrow_hashref) {
585
    push @branch_item_rules, $row;
586
}
587
my @sorted_branch_item_rules = sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @branch_item_rules;
588
589
# note undef holdallowed so that template can deal with them
590
foreach my $entry (@sorted_branch_item_rules) {
591
    $entry->{holdallowed_any}  = 1 if ( $entry->{holdallowed} == 2 );
592
    $entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 );
593
}
594
595
$template->param(show_branch_cat_rule_form => 1);
589
$template->param(show_branch_cat_rule_form => 1);
596
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules);
597
598
my $sth_defaults;
599
if ($branch eq "*") {
600
    $sth_defaults = $dbh->prepare("
601
        SELECT *
602
        FROM default_circ_rules
603
    ");
604
    $sth_defaults->execute();
605
} else {
606
    $sth_defaults = $dbh->prepare("
607
        SELECT *
608
        FROM default_branch_circ_rules
609
        WHERE branchcode = ?
610
    ");
611
    $sth_defaults->execute($branch);
612
}
613
614
my $defaults = $sth_defaults->fetchrow_hashref;
615
616
if ($defaults) {
617
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
618
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
619
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
620
    $template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} );
621
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
622
    $template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} );
623
    $template->param( default_returnbranch      => $defaults->{returnbranch} );
624
}
625
626
$template->param(default_rules => ($defaults ? 1 : 0));
627
590
628
$template->param(
591
$template->param(
629
    patron_categories => $patron_categories,
592
    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 424-447 Link Here
424
                    </td>
424
                    </td>
425
                    <td>
425
                    <td>
426
                        <select name="holdallowed">
426
                        <select name="holdallowed">
427
                            [% IF ( default_holdallowed_any ) %]
427
                            [% SET holdallowed = CirculationRules.Get( branchcode, undef, undef, 'holdallowed' ) %]
428
                            <option value="2" selected="selected">
428
                            <option value="">
429
                                Not set
430
                            </option>
431
432
                            [% IF holdallowed == 2 %]
433
                                <option value="2" selected="selected">
429
                            [% ELSE %]
434
                            [% ELSE %]
430
                            <option value="2">
435
                                <option value="2">
431
                            [% END %]
436
                            [% END %]
432
                                From any library
437
                                From any library
433
                            </option>
438
                            </option>
434
                            [% IF ( default_holdallowed_same ) %]
439
435
                            <option value="1" selected="selected">
440
                            [% IF holdallowed == 1 %]
441
                                <option value="1" selected="selected">
436
                            [% ELSE %]
442
                            [% ELSE %]
437
                            <option value="1">
443
                                <option value="1">
438
                            [% END %]
444
                            [% END %]
439
                                From home library
445
                                From home library
440
                            </option>
446
                            </option>
441
                            [% IF ( default_holdallowed_none ) %]
447
442
                            <option value="0" selected="selected">
448
                            [% IF holdallowed == 0 %]
449
                                <option value="0" selected="selected">
443
                            [% ELSE %]
450
                            [% ELSE %]
444
                            <option value="0">
451
                                <option value="0">
445
                            [% END %]
452
                            [% END %]
446
                                No holds allowed
453
                                No holds allowed
447
                            </option>
454
                            </option>
Lines 449-455 Link Here
449
                    </td>
456
                    </td>
450
                    <td>
457
                    <td>
451
                        <select name="hold_fulfillment_policy">
458
                        <select name="hold_fulfillment_policy">
452
                            [% IF default_hold_fulfillment_policy == 'any' %]
459
                            [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, undef, 'hold_fulfillment_policy' ) %]
460
461
                            <option value="">
462
                                Not set
463
                            </option>
464
465
                            [% IF hold_fulfillment_policy == 'any' %]
453
                                <option value="any" selected="selected">
466
                                <option value="any" selected="selected">
454
                                    any library
467
                                    any library
455
                                </option>
468
                                </option>
Lines 459-465 Link Here
459
                                </option>
472
                                </option>
460
                            [% END %]
473
                            [% END %]
461
474
462
                            [% IF default_hold_fulfillment_policy == 'homebranch' %]
475
                            [% IF hold_fulfillment_policy == 'homebranch' %]
463
                                <option value="homebranch" selected="selected">
476
                                <option value="homebranch" selected="selected">
464
                                    item's home library
477
                                    item's home library
465
                                </option>
478
                                </option>
Lines 469-475 Link Here
469
                                </option>
482
                                </option>
470
                            [% END %]
483
                            [% END %]
471
484
472
                            [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
485
                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
473
                                <option value="holdingbranch" selected="selected">
486
                                <option value="holdingbranch" selected="selected">
474
                                    item's holding library
487
                                    item's holding library
475
                                </option>
488
                                </option>
Lines 482-502 Link Here
482
                    </td>
495
                    </td>
483
                    <td>
496
                    <td>
484
                        <select name="returnbranch">
497
                        <select name="returnbranch">
485
                            [% IF ( default_returnbranch == 'homebranch' ) %]
498
                            [% SET returnbranch = CirculationRules.Get( branchcode, undef, undef, 'returnbranch' ) %]
499
500
                            <option value="">
501
                                Not set
502
                            </option>
503
504
                            [% IF returnbranch == 'homebranch' %]
486
                            <option value="homebranch" selected="selected">
505
                            <option value="homebranch" selected="selected">
487
                            [% ELSE %]
506
                            [% ELSE %]
488
                            <option value="homebranch">
507
                            <option value="homebranch">
489
                            [% END %]
508
                            [% END %]
490
                                Item returns home
509
                                Item returns home
491
                            </option>
510
                            </option>
492
                            [% IF ( default_returnbranch == 'holdingbranch' ) %]
511
                            [% IF returnbranch == 'holdingbranch' %]
493
                            <option value="holdingbranch" selected="selected">
512
                            <option value="holdingbranch" selected="selected">
494
                            [% ELSE %]
513
                            [% ELSE %]
495
                            <option value="holdingbranch">
514
                            <option value="holdingbranch">
496
                            [% END %]
515
                            [% END %]
497
                                Item returns to issuing library
516
                                Item returns to issuing library
498
                            </option>
517
                            </option>
499
                            [% IF ( default_returnbranch == 'noreturn' ) %]
518
                            [% IF returnbranch == 'noreturn' %]
500
                            <option value="noreturn" selected="selected">
519
                            <option value="noreturn" selected="selected">
501
                            [% ELSE %]
520
                            [% ELSE %]
502
                            <option value="noreturn">
521
                            <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 => 11;
8
use Test::More tests => 11;
8
9
Lines 48-57 my $library_C = $library3->{branchcode}; Link Here
48
$dbh->do("DELETE FROM transport_cost");
49
$dbh->do("DELETE FROM transport_cost");
49
$dbh->do("DELETE FROM tmp_holdsqueue");
50
$dbh->do("DELETE FROM tmp_holdsqueue");
50
$dbh->do("DELETE FROM hold_fill_targets");
51
$dbh->do("DELETE FROM hold_fill_targets");
51
$dbh->do("DELETE FROM default_branch_circ_rules");
52
$dbh->do("DELETE FROM circulation_rules");
52
$dbh->do("DELETE FROM default_branch_item_rules");
53
$dbh->do("DELETE FROM default_circ_rules");
54
$dbh->do("DELETE FROM branch_item_rules");
55
53
56
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
54
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
57
55
Lines 74-81 my $itemnumber = Link Here
74
  or BAIL_OUT("Cannot find newly created item");
72
  or BAIL_OUT("Cannot find newly created item");
75
73
76
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
74
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
77
$dbh->do("DELETE FROM default_circ_rules");
75
$dbh->do("DELETE FROM circulation_rules");
78
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
76
Koha::CirculationRules->set_rules(
77
    {
78
        categorycode => undef,
79
        branchcode   => undef,
80
        itemtype     => undef,
81
        rules        => {
82
            holdallowed             => 2,
83
            hold_fulfillment_policy => 'homebranch',
84
        }
85
    }
86
);
79
87
80
# Home branch matches pickup branch
88
# Home branch matches pickup branch
81
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
89
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 96-103 is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); Link Here
96
Koha::Holds->find( $reserve_id )->cancel;
104
Koha::Holds->find( $reserve_id )->cancel;
97
105
98
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
106
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
99
$dbh->do("DELETE FROM default_circ_rules");
107
$dbh->do("DELETE FROM circulation_rules");
100
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
108
Koha::CirculationRules->set_rules(
109
    {
110
        categorycode => undef,
111
        branchcode   => undef,
112
        itemtype     => undef,
113
        rules        => {
114
            holdallowed             => 2,
115
            hold_fulfillment_policy => 'holdingbranch',
116
        }
117
    }
118
);
101
119
102
# Home branch matches pickup branch
120
# Home branch matches pickup branch
103
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
121
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 118-125 is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); Link Here
118
Koha::Holds->find( $reserve_id )->cancel;
136
Koha::Holds->find( $reserve_id )->cancel;
119
137
120
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
138
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
121
$dbh->do("DELETE FROM default_circ_rules");
139
$dbh->do("DELETE FROM circulation_rules");
122
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
140
Koha::CirculationRules->set_rules(
141
    {
142
        categorycode => undef,
143
        branchcode   => undef,
144
        itemtype     => undef,
145
        rules        => {
146
            holdallowed             => 2,
147
            hold_fulfillment_policy => 'any',
148
        }
149
    }
150
);
123
151
124
# Home branch matches pickup branch
152
# Home branch matches pickup branch
125
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
153
$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 175-183 $schema->txn_begin; Link Here
175
### Test holds queue builder does not violate holds policy ###
177
### Test holds queue builder does not violate holds policy ###
176
178
177
# Clear out existing rules relating to holdallowed
179
# Clear out existing rules relating to holdallowed
178
$dbh->do("DELETE FROM default_branch_circ_rules");
180
$dbh->do("DELETE FROM circulation_rules");
179
$dbh->do("DELETE FROM default_branch_item_rules");
180
$dbh->do("DELETE FROM default_circ_rules");
181
181
182
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
182
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
183
183
Lines 290-297 $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ) Link Here
290
290
291
my $holds_queue;
291
my $holds_queue;
292
292
293
$dbh->do("DELETE FROM default_circ_rules");
293
$dbh->do("DELETE FROM circulation_rules");
294
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 1 )");
294
Koha::CirculationRules->set_rule(
295
    {
296
        rule_name    => 'holdallowed',
297
        rule_value   => 1,
298
        branchcode   => undef,
299
        categorycode => undef,
300
        itemtype     => undef,
301
    }
302
);
295
C4::HoldsQueue::CreateQueue();
303
C4::HoldsQueue::CreateQueue();
296
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
304
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
297
is( @$holds_queue, 2, "Holds queue filling correct number for default holds policy 'from home library'" );
305
is( @$holds_queue, 2, "Holds queue filling correct number for default holds policy 'from home library'" );
Lines 320-327 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
320
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
328
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
321
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
329
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
322
330
323
$dbh->do("DELETE FROM default_circ_rules");
331
$dbh->do("DELETE FROM circulation_rules");
324
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
332
Koha::CirculationRules->set_rule(
333
    {
334
        rule_name    => 'holdallowed',
335
        rule_value   => 2,
336
        branchcode   => undef,
337
        categorycode => undef,
338
        itemtype     => undef,
339
    }
340
);
325
C4::HoldsQueue::CreateQueue();
341
C4::HoldsQueue::CreateQueue();
326
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
342
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
327
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
343
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
Lines 340-347 t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 0 ); Link Here
340
## Test LocalHoldsPriority
356
## Test LocalHoldsPriority
341
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
357
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
342
358
343
$dbh->do("DELETE FROM default_circ_rules");
359
$dbh->do("DELETE FROM circulation_rules");
344
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
360
Koha::CirculationRules->set_rule(
361
    {
362
        rule_name    => 'holdallowed',
363
        rule_value   => 2,
364
        branchcode   => undef,
365
        categorycode => undef,
366
        itemtype     => undef,
367
    }
368
);
345
$dbh->do("DELETE FROM issues");
369
$dbh->do("DELETE FROM issues");
346
370
347
# Test homebranch = patron branch
371
# Test homebranch = patron branch
Lines 473-482 $dbh->do("DELETE FROM biblioitems"); Link Here
473
$dbh->do("DELETE FROM transport_cost");
497
$dbh->do("DELETE FROM transport_cost");
474
$dbh->do("DELETE FROM tmp_holdsqueue");
498
$dbh->do("DELETE FROM tmp_holdsqueue");
475
$dbh->do("DELETE FROM hold_fill_targets");
499
$dbh->do("DELETE FROM hold_fill_targets");
476
$dbh->do("DELETE FROM default_branch_circ_rules");
477
$dbh->do("DELETE FROM default_branch_item_rules");
478
$dbh->do("DELETE FROM default_circ_rules");
479
$dbh->do("DELETE FROM branch_item_rules");
480
500
481
$dbh->do("
501
$dbh->do("
482
    INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')
502
    INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')
Lines 501-510 $dbh->do(" Link Here
501
    VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype')
521
    VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype')
502
");
522
");
503
523
504
$dbh->do("
524
Koha::CirculationRules->set_rules(
505
    INSERT INTO branch_item_rules ( branchcode, itemtype, holdallowed, returnbranch ) VALUES
525
    {
506
    ( '$library_A', '$itemtype', 2, 'homebranch' ), ( '$library_B', '$itemtype', 1, 'homebranch' );
526
        branchcode   => $library_A,
507
");
527
        itemtype     => $itemtype,
528
        categorycode => undef,
529
        rules        => {
530
            holdallowed  => 2,
531
            returnbranch => 'homebranch',
532
        }
533
    }
534
);
508
535
509
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
536
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
510
    undef, join( ',', $library_B, $library_A, $library_C ) );
537
    undef, join( ',', $library_B, $library_A, $library_C ) );
Lines 529-538 $dbh->do("DELETE FROM biblioitems"); Link Here
529
$dbh->do("DELETE FROM transport_cost");
556
$dbh->do("DELETE FROM transport_cost");
530
$dbh->do("DELETE FROM tmp_holdsqueue");
557
$dbh->do("DELETE FROM tmp_holdsqueue");
531
$dbh->do("DELETE FROM hold_fill_targets");
558
$dbh->do("DELETE FROM hold_fill_targets");
532
$dbh->do("DELETE FROM default_branch_circ_rules");
533
$dbh->do("DELETE FROM default_branch_item_rules");
534
$dbh->do("DELETE FROM default_circ_rules");
535
$dbh->do("DELETE FROM branch_item_rules");
536
559
537
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
560
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
538
561
Lines 578-587 $dbh->do("DELETE FROM biblioitems"); Link Here
578
$dbh->do("DELETE FROM transport_cost");
601
$dbh->do("DELETE FROM transport_cost");
579
$dbh->do("DELETE FROM tmp_holdsqueue");
602
$dbh->do("DELETE FROM tmp_holdsqueue");
580
$dbh->do("DELETE FROM hold_fill_targets");
603
$dbh->do("DELETE FROM hold_fill_targets");
581
$dbh->do("DELETE FROM default_branch_circ_rules");
582
$dbh->do("DELETE FROM default_branch_item_rules");
583
$dbh->do("DELETE FROM default_circ_rules");
584
$dbh->do("DELETE FROM branch_item_rules");
585
604
586
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
605
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
587
606
Lines 600-607 $dbh->do(" Link Here
600
");
619
");
601
620
602
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
621
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
603
$dbh->do("DELETE FROM default_circ_rules");
622
$dbh->do("DELETE FROM circulation_rules");
604
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
623
Koha::CirculationRules->set_rules(
624
    {
625
        branchcode   => undef,
626
        itemtype     => undef,
627
        categorycode => undef,
628
        rules        => {
629
            holdallowed             => 2,
630
            hold_fulfillment_policy => 'homebranch',
631
        }
632
    }
633
);
605
634
606
# Home branch matches pickup branch
635
# Home branch matches pickup branch
607
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
636
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 625-632 is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted Link Here
625
Koha::Holds->find( $reserve_id )->cancel;
654
Koha::Holds->find( $reserve_id )->cancel;
626
655
627
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
656
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
628
$dbh->do("DELETE FROM default_circ_rules");
657
$dbh->do("DELETE FROM circulation_rules");
629
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
658
Koha::CirculationRules->set_rules(
659
    {
660
        branchcode   => undef,
661
        itemtype     => undef,
662
        categorycode => undef,
663
        rules        => {
664
            holdallowed             => 2,
665
            hold_fulfillment_policy => 'holdingbranch',
666
        }
667
    }
668
);
630
669
631
# Home branch matches pickup branch
670
# Home branch matches pickup branch
632
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
671
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 650-657 is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted Link Here
650
Koha::Holds->find( $reserve_id )->cancel;
689
Koha::Holds->find( $reserve_id )->cancel;
651
690
652
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
691
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
653
$dbh->do("DELETE FROM default_circ_rules");
692
$dbh->do("DELETE FROM circulation_rules");
654
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
693
Koha::CirculationRules->set_rules(
694
    {
695
        branchcode   => undef,
696
        itemtype     => undef,
697
        categorycode => undef,
698
        rules        => {
699
            holdallowed             => 2,
700
            hold_fulfillment_policy => 'any',
701
        }
702
    }
703
);
655
704
656
# Home branch matches pickup branch
705
# Home branch matches pickup branch
657
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
706
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 690-699 $dbh->do("DELETE FROM biblioitems"); Link Here
690
$dbh->do("DELETE FROM transport_cost");
739
$dbh->do("DELETE FROM transport_cost");
691
$dbh->do("DELETE FROM tmp_holdsqueue");
740
$dbh->do("DELETE FROM tmp_holdsqueue");
692
$dbh->do("DELETE FROM hold_fill_targets");
741
$dbh->do("DELETE FROM hold_fill_targets");
693
$dbh->do("DELETE FROM default_branch_circ_rules");
694
$dbh->do("DELETE FROM default_branch_item_rules");
695
$dbh->do("DELETE FROM default_circ_rules");
696
$dbh->do("DELETE FROM branch_item_rules");
697
742
698
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
743
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
699
744
Lines 712-719 $dbh->do(" Link Here
712
");
757
");
713
758
714
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
759
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
715
$dbh->do("DELETE FROM default_circ_rules");
760
$dbh->do("DELETE FROM circulation_rules");
716
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
761
Koha::CirculationRules->set_rules(
762
    {
763
        branchcode   => undef,
764
        itemtype     => undef,
765
        categorycode => undef,
766
        rules        => {
767
            holdallowed             => 2,
768
            hold_fulfillment_policy => 'any',
769
        }
770
    }
771
);
717
772
718
# Home branch matches pickup branch
773
# Home branch matches pickup branch
719
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
774
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
Lines 747-756 t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); Link Here
747
$dbh->do("DELETE FROM tmp_holdsqueue");
802
$dbh->do("DELETE FROM tmp_holdsqueue");
748
$dbh->do("DELETE FROM hold_fill_targets");
803
$dbh->do("DELETE FROM hold_fill_targets");
749
$dbh->do("DELETE FROM reserves");
804
$dbh->do("DELETE FROM reserves");
750
$dbh->do("DELETE FROM default_branch_circ_rules");
751
$dbh->do("DELETE FROM default_branch_item_rules");
752
$dbh->do("DELETE FROM default_circ_rules");
753
$dbh->do("DELETE FROM branch_item_rules");
754
805
755
$item = Koha::Items->find( { biblionumber => $biblionumber } );
806
$item = Koha::Items->find( { biblionumber => $biblionumber } );
756
$item->holdingbranch( $item->homebranch );
807
$item->holdingbranch( $item->homebranch );
(-)a/t/db_dependent/Reserves.t (-15 / +22 lines)
Lines 40-45 use Koha::Libraries; Link Here
40
use Koha::Notice::Templates;
40
use Koha::Notice::Templates;
41
use Koha::Patrons;
41
use Koha::Patrons;
42
use Koha::Patron::Categories;
42
use Koha::Patron::Categories;
43
use Koha::CirculationRules;
43
44
44
BEGIN {
45
BEGIN {
45
    require_ok('C4::Reserves');
46
    require_ok('C4::Reserves');
Lines 50-55 my $database = Koha::Database->new(); Link Here
50
my $schema = $database->schema();
51
my $schema = $database->schema();
51
$schema->storage->txn_begin();
52
$schema->storage->txn_begin();
52
my $dbh = C4::Context->dbh;
53
my $dbh = C4::Context->dbh;
54
$dbh->do('DELETE FROM circulation_rules');
53
55
54
my $builder = t::lib::TestBuilder->new;
56
my $builder = t::lib::TestBuilder->new;
55
57
Lines 188-197 $requesters{$branch_3} = Koha::Patron->new({ Link Here
188
# to fill holds from anywhere.
190
# to fill holds from anywhere.
189
191
190
$dbh->do('DELETE FROM issuingrules');
192
$dbh->do('DELETE FROM issuingrules');
191
$dbh->do('DELETE FROM branch_item_rules');
192
$dbh->do('DELETE FROM default_branch_item_rules');
193
$dbh->do('DELETE FROM default_branch_circ_rules');
194
$dbh->do('DELETE FROM default_circ_rules');
195
$dbh->do(
193
$dbh->do(
196
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
194
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
197
      VALUES (?, ?, ?, ?)},
195
      VALUES (?, ?, ?, ?)},
Lines 200-218 $dbh->do( Link Here
200
);
198
);
201
199
202
# CPL allows only its own patrons to request its items
200
# CPL allows only its own patrons to request its items
203
$dbh->do(
201
Koha::CirculationRules->set_rules(
204
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
202
    {
205
      VALUES (?, ?, ?)},
203
        branchcode   => $branch_1,
206
    {},
204
        categorycode => undef,
207
    $branch_1, 1, 'homebranch',
205
        itemtype     => undef,
206
        rules        => {
207
            holdallowed  => 1,
208
            returnbranch => 'homebranch',
209
        }
210
    }
208
);
211
);
209
212
210
# ... while FPL allows anybody to request its items
213
# ... while FPL allows anybody to request its items
211
$dbh->do(
214
Koha::CirculationRules->set_rules(
212
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
215
    {
213
      VALUES (?, ?, ?)},
216
        branchcode   => $branch_2,
214
    {},
217
        categorycode => undef,
215
    $branch_2, 2, 'homebranch',
218
        itemtype     => undef,
219
        rules        => {
220
            holdallowed  => 2,
221
            returnbranch => 'homebranch',
222
        }
223
    }
216
);
224
);
217
225
218
my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
226
my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
219
- 

Return to bug 18928