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

(-)a/C4/Circulation.pm (-33 / +51 lines)
Lines 1610-1616 wildcards. Link Here
1610
sub GetBranchBorrowerCircRule {
1610
sub GetBranchBorrowerCircRule {
1611
    my ( $branchcode, $categorycode ) = @_;
1611
    my ( $branchcode, $categorycode ) = @_;
1612
1612
1613
    # Set search prededences
1613
    # Set search precedences
1614
    my @params = (
1614
    my @params = (
1615
        {
1615
        {
1616
            branchcode   => $branchcode,
1616
            branchcode   => $branchcode,
Lines 1692-1734 Neither C<$branchcode> nor C<$itemtype> should be '*'. Link Here
1692
1692
1693
sub GetBranchItemRule {
1693
sub GetBranchItemRule {
1694
    my ( $branchcode, $itemtype ) = @_;
1694
    my ( $branchcode, $itemtype ) = @_;
1695
    my $dbh = C4::Context->dbh();
1695
1696
    my $result = {};
1696
    # Set search precedences
1697
1697
    my @params = (
1698
    my @attempts = (
1698
        {
1699
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1699
            branchcode   => $branchcode,
1700
            FROM branch_item_rules
1700
            categorycode => undef,
1701
            WHERE branchcode = ?
1701
            itemtype     => $itemtype,
1702
              AND itemtype = ?', $branchcode, $itemtype],
1702
        },
1703
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1703
        {
1704
            FROM default_branch_circ_rules
1704
            branchcode   => $branchcode,
1705
            WHERE branchcode = ?', $branchcode],
1705
            categorycode => undef,
1706
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1706
            itemtype     => undef,
1707
            FROM default_branch_item_rules
1707
        },
1708
            WHERE itemtype = ?', $itemtype],
1708
        {
1709
        ['SELECT holdallowed, returnbranch, hold_fulfillment_policy
1709
            branchcode   => undef,
1710
            FROM default_circ_rules'],
1710
            categorycode => undef,
1711
            itemtype     => $itemtype,
1712
        },
1713
        {
1714
            branchcode   => undef,
1715
            categorycode => undef,
1716
            itemtype     => undef,
1717
        },
1711
    );
1718
    );
1712
1719
1713
    foreach my $attempt (@attempts) {
1720
    # Initialize default values
1714
        my ($query, @bind_params) = @{$attempt};
1721
    my $rules = {
1715
        my $search_result = $dbh->selectrow_hashref ( $query , {}, @bind_params )
1722
        holdallowed             => undef,
1716
          or next;
1723
        hold_fulfillment_policy => undef,
1717
1724
        returnbranch            => undef,
1718
        # Since branch/category and branch/itemtype use the same per-branch
1725
    };
1719
        # defaults tables, we have to check that the key we want is set, not
1726
1720
        # just that a row was returned
1727
    # Search for rules!
1721
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1728
    foreach my $rule_name (qw( holdallowed hold_fulfillment_policy returnbranch )) {
1722
        $result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} );
1729
        foreach my $params (@params) {
1723
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1730
            my $rule = Koha::CirculationRules->search(
1731
                {
1732
                    rule_name => $rule_name,
1733
                    %$params,
1734
                }
1735
            )->next();
1736
1737
            if ( $rule ) {
1738
                $rules->{$rule_name} = $rule->rule_value;
1739
                last;
1740
            }
1741
        }
1724
    }
1742
    }
1725
    
1743
1726
    # built-in default circulation rule
1744
    # built-in default circulation rule
1727
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1745
    $rules->{holdallowed} = 2                 unless ( defined $rules->{holdallowed} );
1728
    $result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} );
1746
    $rules->{hold_fulfillment_policy} = 'any' unless ( defined $rules->{hold_fulfillment_policy} );
1729
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
1747
    $rules->{returnbranch} = 'homebranch'     unless ( defined $rules->{returnbranch} );
1730
1748
1731
    return $result;
1749
    return $rules;
1732
}
1750
}
1733
1751
1734
=head2 AddReturn
1752
=head2 AddReturn
(-)a/admin/smart-rules.pl (-201 / +164 lines)
Lines 78-124 elsif ($op eq 'delete-branch-cat') { Link Here
78
    my $categorycode  = $input->param('categorycode');
78
    my $categorycode  = $input->param('categorycode');
79
    if ($branch eq "*") {
79
    if ($branch eq "*") {
80
        if ($categorycode eq "*") {
80
        if ($categorycode eq "*") {
81
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
81
            Koha::CirculationRules->set_rules(
82
            $sth_delete->execute();
82
                {
83
                    categorycode => undef,
84
                    branchcode   => undef,
85
                    itemtype     => undef,
86
                    rules        => {
87
                        maxissueqty             => undef,
88
                        maxonsiteissueqty       => undef,
89
                        holdallowed             => undef,
90
                        hold_fulfillment_policy => undef,
91
                        returnbranch            => undef,
92
                    }
93
                }
94
            );
95
        } else {
96
            Koha::CirculationRules->set_rules(
97
                {
98
                    categorycode => $categorycode,
99
                    branchcode   => undef,
100
                    itemtype     => undef,
101
                    rules        => {
102
                        max_holds         => undef,
103
                        maxissueqty       => undef,
104
                        maxonsiteissueqty => undef,
105
                    }
106
                }
107
            );
83
        }
108
        }
84
    } elsif ($categorycode eq "*") {
109
    } elsif ($categorycode eq "*") {
85
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
110
        Koha::CirculationRules->set_rules(
86
                                        WHERE branchcode = ?");
111
            {
87
        $sth_delete->execute($branch);
112
                categorycode => undef,
88
    }
113
                branchcode   => $branch,
89
    Koha::CirculationRules->set_rules(
114
                itemtype     => undef,
90
        {
115
                rules        => {
91
            categorycode => $categorycode eq '*' ? undef : $categorycode,
116
                    maxissueqty             => undef,
92
            branchcode   => $branch eq '*'       ? undef : $branch,
117
                    maxonsiteissueqty       => undef,
93
            itemtype     => undef,
118
                    holdallowed             => undef,
94
            rules        => {
119
                    hold_fulfillment_policy => undef,
95
                max_holds         => undef,
120
                    returnbranch            => undef,
96
                maxissueqty       => undef,
121
                }
97
                maxonsiteissueqty => undef,
98
            }
122
            }
99
        }
123
        );
100
    );
124
    } else {
125
        Koha::CirculationRules->set_rules(
126
            {
127
                categorycode => $categorycode,
128
                branchcode   => $branch,
129
                itemtype     => undef,
130
                rules        => {
131
                    max_holds         => undef,
132
                    maxissueqty       => undef,
133
                    maxonsiteissueqty => undef,
134
                }
135
            }
136
        );
137
    }
101
}
138
}
102
elsif ($op eq 'delete-branch-item') {
139
elsif ($op eq 'delete-branch-item') {
103
    my $itemtype  = $input->param('itemtype');
140
    my $itemtype  = $input->param('itemtype');
104
    if ($branch eq "*") {
141
    if ($branch eq "*") {
105
        if ($itemtype eq "*") {
142
        if ($itemtype eq "*") {
106
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
143
            Koha::CirculationRules->set_rules(
107
            $sth_delete->execute();
144
                {
145
                    categorycode => undef,
146
                    branchcode   => undef,
147
                    itemtype     => undef,
148
                    rules        => {
149
                        maxissueqty             => undef,
150
                        maxonsiteissueqty       => undef,
151
                        holdallowed             => undef,
152
                        hold_fulfillment_policy => undef,
153
                        returnbranch            => undef,
154
                    }
155
                }
156
            );
108
        } else {
157
        } else {
109
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
158
            Koha::CirculationRules->set_rules(
110
                                            WHERE itemtype = ?");
159
                {
111
            $sth_delete->execute($itemtype);
160
                    categorycode => undef,
161
                    branchcode   => undef,
162
                    itemtype     => $itemtype,
163
                    rules        => {
164
                        holdallowed             => undef,
165
                        hold_fulfillment_policy => undef,
166
                        returnbranch            => undef,
167
                    }
168
                }
169
            );
112
        }
170
        }
113
    } elsif ($itemtype eq "*") {
171
    } elsif ($itemtype eq "*") {
114
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
172
        Koha::CirculationRules->set_rules(
115
                                        WHERE branchcode = ?");
173
            {
116
        $sth_delete->execute($branch);
174
                categorycode => undef,
175
                branchcode   => $branch,
176
                itemtype     => undef,
177
                rules        => {
178
                    maxissueqty             => undef,
179
                    maxonsiteissueqty       => undef,
180
                    holdallowed             => undef,
181
                    hold_fulfillment_policy => undef,
182
                    returnbranch            => undef,
183
                }
184
            }
185
        );
117
    } else {
186
    } else {
118
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
187
        Koha::CirculationRules->set_rules(
119
                                        WHERE branchcode = ?
188
            {
120
                                        AND itemtype = ?");
189
                categorycode => undef,
121
        $sth_delete->execute($branch, $itemtype);
190
                branchcode   => $branch,
191
                itemtype     => $itemtype,
192
                rules        => {
193
                    holdallowed             => undef,
194
                    hold_fulfillment_policy => undef,
195
                    returnbranch            => undef,
196
                }
197
            }
198
        );
122
    }
199
    }
123
}
200
}
124
# save the values entered
201
# save the values entered
Lines 231-289 elsif ($op eq "set-branch-defaults") { Link Here
231
    $holdallowed = undef if $holdallowed !~ /^\d+/;
308
    $holdallowed = undef if $holdallowed !~ /^\d+/;
232
309
233
    if ($branch eq "*") {
310
    if ($branch eq "*") {
234
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
235
                                        FROM default_circ_rules");
236
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
237
                                        (holdallowed, hold_fulfillment_policy, returnbranch)
238
                                        VALUES (?, ?, ?)");
239
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
240
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
241
242
        $sth_search->execute();
243
        my $res = $sth_search->fetchrow_hashref();
244
        if ($res->{total}) {
245
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
246
        } else {
247
            $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
248
        }
249
250
        Koha::CirculationRules->set_rules(
311
        Koha::CirculationRules->set_rules(
251
            {
312
            {
252
                categorycode => undef,
313
                categorycode => undef,
253
                itemtype     => undef,
314
                itemtype     => undef,
254
                branchcode   => undef,
315
                branchcode   => undef,
255
                rules        => {
316
                rules        => {
256
                    maxissueqty       => $maxissueqty,
317
                    maxissueqty             => $maxissueqty,
257
                    maxonsiteissueqty => $maxonsiteissueqty,
318
                    maxonsiteissueqty       => $maxonsiteissueqty,
319
                    holdallowed             => $holdallowed,
320
                    hold_fulfillment_policy => $hold_fulfillment_policy,
321
                    returnbranch            => $returnbranch,
258
                }
322
                }
259
            }
323
            }
260
        );
324
        );
261
    } else {
325
    } else {
262
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
263
                                        FROM default_branch_circ_rules
264
                                        WHERE branchcode = ?");
265
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
266
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
267
                                        VALUES (?, ?, ?, ?)");
268
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
269
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
270
                                        WHERE branchcode = ?");
271
        $sth_search->execute($branch);
272
        my $res = $sth_search->fetchrow_hashref();
273
        if ($res->{total}) {
274
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
275
        } else {
276
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
277
        }
278
279
        Koha::CirculationRules->set_rules(
326
        Koha::CirculationRules->set_rules(
280
            {
327
            {
281
                categorycode => undef,
328
                categorycode => undef,
282
                itemtype     => undef,
329
                itemtype     => undef,
283
                branchcode   => $branch,
330
                branchcode   => $branch,
284
                rules        => {
331
                rules        => {
285
                    maxissueqty       => $maxissueqty,
332
                    maxissueqty             => $maxissueqty,
286
                    maxonsiteissueqty => $maxonsiteissueqty,
333
                    maxonsiteissueqty       => $maxonsiteissueqty,
334
                    holdallowed             => $holdallowed,
335
                    hold_fulfillment_policy => $hold_fulfillment_policy,
336
                    returnbranch            => $returnbranch,
287
                }
337
                }
288
            }
338
            }
289
        );
339
        );
Lines 368-443 elsif ($op eq "add-branch-item") { Link Here
368
418
369
    if ($branch eq "*") {
419
    if ($branch eq "*") {
370
        if ($itemtype eq "*") {
420
        if ($itemtype eq "*") {
371
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
421
            Koha::CirculationRules->set_rules(
372
                                            FROM default_circ_rules");
422
                {
373
            my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
423
                    categorycode => undef,
374
                                            (holdallowed, hold_fulfillment_policy, returnbranch)
424
                    itemtype     => undef,
375
                                            VALUES (?, ?, ?)");
425
                    branchcode   => undef,
376
            my $sth_update = $dbh->prepare("UPDATE default_circ_rules
426
                    rules        => {
377
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?");
427
                        holdallowed             => $holdallowed,
378
428
                        hold_fulfillment_policy => $hold_fulfillment_policy,
379
            $sth_search->execute();
429
                        returnbranch            => $returnbranch,
380
            my $res = $sth_search->fetchrow_hashref();
430
                    }
381
            if ($res->{total}) {
431
                }
382
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
432
            );
383
            } else {
384
                $sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch);
385
            }
386
        } else {
433
        } else {
387
            my $sth_search = $dbh->prepare("SELECT count(*) AS total
434
            Koha::CirculationRules->set_rules(
388
                                            FROM default_branch_item_rules
435
                {
389
                                            WHERE itemtype = ?");
436
                    categorycode => undef,
390
            my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules
437
                    itemtype     => $itemtype,
391
                                            (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
438
                    branchcode   => undef,
392
                                            VALUES (?, ?, ?, ?)");
439
                    rules        => {
393
            my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules
440
                        holdallowed             => $holdallowed,
394
                                            SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
441
                        hold_fulfillment_policy => $hold_fulfillment_policy,
395
                                            WHERE itemtype = ?");
442
                        returnbranch            => $returnbranch,
396
            $sth_search->execute($itemtype);
443
                    }
397
            my $res = $sth_search->fetchrow_hashref();
444
                }
398
            if ($res->{total}) {
445
            );
399
                $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype);
400
            } else {
401
                $sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
402
            }
403
        }
446
        }
404
    } elsif ($itemtype eq "*") {
447
    } elsif ($itemtype eq "*") {
405
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
448
            Koha::CirculationRules->set_rules(
406
                                        FROM default_branch_circ_rules
449
                {
407
                                        WHERE branchcode = ?");
450
                    categorycode => undef,
408
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
451
                    itemtype     => undef,
409
                                        (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
452
                    branchcode   => $branch,
410
                                        VALUES (?, ?, ?, ?)");
453
                    rules        => {
411
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
454
                        holdallowed             => $holdallowed,
412
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
455
                        hold_fulfillment_policy => $hold_fulfillment_policy,
413
                                        WHERE branchcode = ?");
456
                        returnbranch            => $returnbranch,
414
        $sth_search->execute($branch);
457
                    }
415
        my $res = $sth_search->fetchrow_hashref();
458
                }
416
        if ($res->{total}) {
459
            );
417
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch);
418
        } else {
419
            $sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch);
420
        }
421
    } else {
460
    } else {
422
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
461
        Koha::CirculationRules->set_rules(
423
                                        FROM branch_item_rules
462
            {
424
                                        WHERE branchcode = ?
463
                categorycode => undef,
425
                                        AND   itemtype = ?");
464
                itemtype     => $itemtype,
426
        my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules
465
                branchcode   => $branch,
427
                                        (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
466
                rules        => {
428
                                        VALUES (?, ?, ?, ?, ?)");
467
                    holdallowed             => $holdallowed,
429
        my $sth_update = $dbh->prepare("UPDATE branch_item_rules
468
                    hold_fulfillment_policy => $hold_fulfillment_policy,
430
                                        SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?
469
                    returnbranch            => $returnbranch,
431
                                        WHERE branchcode = ?
470
                }
432
                                        AND itemtype = ?");
471
            }
433
472
        );
434
        $sth_search->execute($branch, $itemtype);
435
        my $res = $sth_search->fetchrow_hashref();
436
        if ($res->{total}) {
437
            $sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype);
438
        } else {
439
            $sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch);
440
        }
441
    }
473
    }
442
}
474
}
443
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
475
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
Lines 520-595 while (my $row = $sth2->fetchrow_hashref) { Link Here
520
552
521
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
553
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
522
554
523
my $sth_branch_item;
524
if ($branch eq "*") {
525
    $sth_branch_item = $dbh->prepare("
526
        SELECT default_branch_item_rules.*,
527
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
528
        FROM default_branch_item_rules
529
        JOIN itemtypes USING (itemtype)
530
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
531
            AND localization.entity = 'itemtypes'
532
            AND localization.lang = ?
533
    ");
534
    $sth_branch_item->execute($language);
535
} else {
536
    $sth_branch_item = $dbh->prepare("
537
        SELECT branch_item_rules.*,
538
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
539
        FROM branch_item_rules
540
        JOIN itemtypes USING (itemtype)
541
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
542
            AND localization.entity = 'itemtypes'
543
            AND localization.lang = ?
544
        WHERE branch_item_rules.branchcode = ?
545
    ");
546
    $sth_branch_item->execute($language, $branch);
547
}
548
549
my @branch_item_rules = ();
550
while (my $row = $sth_branch_item->fetchrow_hashref) {
551
    push @branch_item_rules, $row;
552
}
553
my @sorted_branch_item_rules = sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @branch_item_rules;
554
555
# note undef holdallowed so that template can deal with them
556
foreach my $entry (@sorted_branch_item_rules) {
557
    $entry->{holdallowed_any}  = 1 if ( $entry->{holdallowed} == 2 );
558
    $entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 );
559
}
560
561
$template->param(show_branch_cat_rule_form => 1);
555
$template->param(show_branch_cat_rule_form => 1);
562
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules);
563
564
my $sth_defaults;
565
if ($branch eq "*") {
566
    $sth_defaults = $dbh->prepare("
567
        SELECT *
568
        FROM default_circ_rules
569
    ");
570
    $sth_defaults->execute();
571
} else {
572
    $sth_defaults = $dbh->prepare("
573
        SELECT *
574
        FROM default_branch_circ_rules
575
        WHERE branchcode = ?
576
    ");
577
    $sth_defaults->execute($branch);
578
}
579
580
my $defaults = $sth_defaults->fetchrow_hashref;
581
582
if ($defaults) {
583
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
584
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
585
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
586
    $template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} );
587
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
588
    $template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} );
589
    $template->param( default_returnbranch      => $defaults->{returnbranch} );
590
}
591
592
$template->param(default_rules => ($defaults ? 1 : 0));
593
556
594
$template->param(
557
$template->param(
595
    patron_categories => $patron_categories,
558
    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 (-59 / +79 lines)
Lines 458-500 $(document).ready(function() { Link Here
458
                    <th>Actions</th>
458
                    <th>Actions</th>
459
                </tr>
459
                </tr>
460
                <tr>
460
                <tr>
461
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
461
                    <td><em>Defaults</em></td>
462
                    <td>
462
                    <td>
463
                        [% SET maxissueqty  = CirculationRules.Get( branchcode, undef, undef, 'maxissueqty' ) %]
463
                        [% SET maxissueqty = CirculationRules.Get( branchcode, undef, undef, 'maxissueqty' ) %]
464
                        <input type="text" name="maxissueqty" size="3" value="[% maxissueqty %]"/>
464
                        <input type="text" name="maxissueqty" size="3" value="[% maxissueqty %]"/>
465
                    </td>
465
                    </td>
466
                    <td>
466
                    <td>
467
                        [% SET maxonsiteissueqty  = CirculationRules.Get( branchcode, undef, undef, 'maxonsiteissueqty' ) %]
467
                        [% SET maxonsiteissueqty = CirculationRules.Get( branchcode, undef, undef, 'maxonsiteissueqty' ) %]
468
                        <input type="text" name="maxonsiteissueqty" size="3" value="[% maxonsiteissueqty %]"/>
468
                        <input type="text" name="maxonsiteissueqty" size="3" value="[% maxonsiteissueqty %]"/>
469
                    </td>
469
                    </td>
470
                    <td>
470
                    <td>
471
                        <select name="holdallowed">
471
                        <select name="holdallowed">
472
                            [% IF ( default_holdallowed_any ) %]
472
                            [% SET holdallowed = CirculationRules.Get( branchcode, undef, undef, 'holdallowed' ) %]
473
                            <option value="2" selected="selected">
473
                            <option value="">
474
                                Not set
475
                            </option>
476
477
                            [% IF holdallowed == 2 %]
478
                                <option value="2" selected="selected">
474
                            [% ELSE %]
479
                            [% ELSE %]
475
                            <option value="2">
480
                                <option value="2">
476
                            [% END %]
481
                            [% END %]
477
                                From any library
482
                                From any library
478
                            </option>
483
                            </option>
479
                            [% IF ( default_holdallowed_same ) %]
484
480
                            <option value="1" selected="selected">
485
                            [% IF holdallowed == 1 %]
486
                                <option value="1" selected="selected">
481
                            [% ELSE %]
487
                            [% ELSE %]
482
                            <option value="1">
488
                                <option value="1">
483
                            [% END %]
489
                            [% END %]
484
                                From home library
490
                                From home library
485
                            </option>
491
                            </option>
486
                            [% IF ( default_holdallowed_none ) %]
492
487
                            <option value="0" selected="selected">
493
                            [% IF holdallowed == 0 %]
494
                                <option value="0" selected="selected">
488
                            [% ELSE %]
495
                            [% ELSE %]
489
                            <option value="0">
496
                                <option value="0">
490
                            [% END %]
497
                            [% END %]
491
                                No holds allowed
498
                                No holds allowed
492
                            </option>
499
                            </option>
500
493
                        </select>
501
                        </select>
494
                    </td>
502
                    </td>
495
                    <td>
503
                    <td>
496
                        <select name="hold_fulfillment_policy">
504
                        <select name="hold_fulfillment_policy">
497
                            [% IF default_hold_fulfillment_policy == 'any' %]
505
                            [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, undef, 'hold_fulfillment_policy' ) %]
506
507
                            <option value="">
508
                                Not set
509
                            </option>
510
511
                            [% IF hold_fulfillment_policy == 'any' %]
498
                                <option value="any" selected="selected">
512
                                <option value="any" selected="selected">
499
                                    any library
513
                                    any library
500
                                </option>
514
                                </option>
Lines 504-510 $(document).ready(function() { Link Here
504
                                </option>
518
                                </option>
505
                            [% END %]
519
                            [% END %]
506
520
507
                            [% IF default_hold_fulfillment_policy == 'homebranch' %]
521
                            [% IF hold_fulfillment_policy == 'homebranch' %]
508
                                <option value="homebranch" selected="selected">
522
                                <option value="homebranch" selected="selected">
509
                                    item's home library
523
                                    item's home library
510
                                </option>
524
                                </option>
Lines 514-520 $(document).ready(function() { Link Here
514
                                </option>
528
                                </option>
515
                            [% END %]
529
                            [% END %]
516
530
517
                            [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
531
                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
518
                                <option value="holdingbranch" selected="selected">
532
                                <option value="holdingbranch" selected="selected">
519
                                    item's holding library
533
                                    item's holding library
520
                                </option>
534
                                </option>
Lines 527-547 $(document).ready(function() { Link Here
527
                    </td>
541
                    </td>
528
                    <td>
542
                    <td>
529
                        <select name="returnbranch">
543
                        <select name="returnbranch">
530
                            [% IF ( default_returnbranch == 'homebranch' ) %]
544
                            [% SET returnbranch = CirculationRules.Get( branchcode, undef, undef, 'returnbranch' ) %]
545
546
                            <option value="">
547
                                Not set
548
                            </option>
549
550
                            [% IF returnbranch == 'homebranch' %]
531
                            <option value="homebranch" selected="selected">
551
                            <option value="homebranch" selected="selected">
532
                            [% ELSE %]
552
                            [% ELSE %]
533
                            <option value="homebranch">
553
                            <option value="homebranch">
534
                            [% END %]
554
                            [% END %]
535
                                Item returns home
555
                                Item returns home
536
                            </option>
556
                            </option>
537
                            [% IF ( default_returnbranch == 'holdingbranch' ) %]
557
                            [% IF returnbranch == 'holdingbranch' %]
538
                            <option value="holdingbranch" selected="selected">
558
                            <option value="holdingbranch" selected="selected">
539
                            [% ELSE %]
559
                            [% ELSE %]
540
                            <option value="holdingbranch">
560
                            <option value="holdingbranch">
541
                            [% END %]
561
                            [% END %]
542
                                Item returns to issuing library
562
                                Item returns to issuing library
543
                            </option>
563
                            </option>
544
                            [% IF ( default_returnbranch == 'noreturn' ) %]
564
                            [% IF returnbranch == 'noreturn' %]
545
                            <option value="noreturn" selected="selected">
565
                            <option value="noreturn" selected="selected">
546
                            [% ELSE %]
566
                            [% ELSE %]
547
                            <option value="noreturn">
567
                            <option value="noreturn">
Lines 747-794 $(document).ready(function() { Link Here
747
                    <th>Return policy</th>
767
                    <th>Return policy</th>
748
                    <th>&nbsp;</th>
768
                    <th>&nbsp;</th>
749
                </tr>
769
                </tr>
750
                [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
770
                [% FOREACH i IN itemtypeloop %]
751
                    [% UNLESS ( loop.odd ) %]
771
                    [% SET holdallowed = CirculationRules.Get( branchcode, undef, i.itemtype, 'holdallowed' ) %]
752
                    <tr class="highlight">
772
                    [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
753
                    [% ELSE %]
773
                    [% SET returnbranch = CirculationRules.Get( branchcode, undef, i.itemtype, 'returnbranch' ) %]
754
                    <tr>
774
775
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
776
                        <tr>
777
                            <td>
778
                                [% i.translated_description %]
779
                            </td>
780
                            <td>
781
                                [% IF holdallowed == 2 %]
782
                                    From any library
783
                                [% ELSIF holdallowed == 1 %]
784
                                    From home library
785
                                [% ELSE %]
786
                                    No holds allowed
787
                                [% END %]
788
                            </td>
789
                            <td>
790
                                [% IF hold_fulfillment_policy == 'any' %]
791
                                    any library
792
                                [% ELSIF hold_fulfillment_policy == 'homebranch' %]
793
                                    item's home library
794
                                [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
795
                                    item's holding library
796
                                [% END %]
797
                            </td>
798
                            <td>
799
                                [% IF returnbranch == 'homebranch' %]
800
                                    Item returns home
801
                                [% ELSIF returnbranch == 'holdingbranch' %]
802
                                    Item returns to issuing branch
803
                                [% ELSIF returnbranch == 'noreturn' %]
804
                                    Item floats
805
                                [% END %]
806
                            </td>
807
                            <td class="actions">
808
                                <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>
809
                            </td>
810
                        </tr>
755
                    [% END %]
811
                    [% END %]
756
                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
757
                                <em>Default</em>
758
                            [% ELSE %]
759
                                [% branch_item_rule_loo.translated_description %]
760
                            [% END %]
761
                        </td>
762
                        <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
763
                                From any library
764
                            [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
765
                                From home library
766
                            [% ELSE %]
767
                                No holds allowed
768
                            [% END %]
769
                        </td>
770
                        <td>[% IF ( branch_item_rule_loo.hold_fulfillment_policy == 'any' ) %]
771
                                any library
772
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'homebranch' ) %]
773
                                item's home library
774
                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'holdingbranch' ) %]
775
                                item's holding library
776
                            [% END %]
777
                        </td>
778
                        <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
779
                                Item returns home
780
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
781
                                Item returns to issuing branch
782
                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
783
                                Item floats
784
                            [% ELSE %]
785
                                Error - unknown option
786
                            [% END %]
787
                        </td>
788
                        <td class="actions">
789
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
790
                        </td>
791
                    </tr>
792
                [% END %]
812
                [% END %]
793
                <tr>
813
                <tr>
794
                    <td>
814
                    <td>
(-)a/t/db_dependent/Circulation/Branch.t (-31 / +36 lines)
Lines 43-48 can_ok( 'C4::Circulation', qw( Link Here
43
my $schema = Koha::Database->schema;
43
my $schema = Koha::Database->schema;
44
$schema->storage->txn_begin;
44
$schema->storage->txn_begin;
45
my $dbh = C4::Context->dbh;
45
my $dbh = C4::Context->dbh;
46
my $query;
46
47
47
$dbh->do(q|DELETE FROM issues|);
48
$dbh->do(q|DELETE FROM issues|);
48
$dbh->do(q|DELETE FROM items|);
49
$dbh->do(q|DELETE FROM items|);
Lines 51-60 $dbh->do(q|DELETE FROM branches|); Link Here
51
$dbh->do(q|DELETE FROM categories|);
52
$dbh->do(q|DELETE FROM categories|);
52
$dbh->do(q|DELETE FROM accountlines|);
53
$dbh->do(q|DELETE FROM accountlines|);
53
$dbh->do(q|DELETE FROM itemtypes|);
54
$dbh->do(q|DELETE FROM itemtypes|);
54
$dbh->do(q|DELETE FROM branch_item_rules|);
55
$dbh->do(q|DELETE FROM circulation_rules|);
55
$dbh->do(q|DELETE FROM default_branch_circ_rules|);
56
$dbh->do(q|DELETE FROM default_circ_rules|);
57
$dbh->do(q|DELETE FROM default_branch_item_rules|);
58
56
59
my $builder = t::lib::TestBuilder->new();
57
my $builder = t::lib::TestBuilder->new();
60
58
Lines 162-173 Koha::CirculationRules->set_rules( Link Here
162
    }
160
    }
163
);
161
);
164
162
165
my $query = q|
166
    INSERT INTO default_branch_circ_rules
167
    (branchcode, holdallowed, returnbranch)
168
    VALUES( ?, ?, ? )
169
|;
170
$dbh->do( $query, {}, $samplebranch2->{branchcode}, 1, 'holdingbranch' );
171
Koha::CirculationRules->set_rules(
163
Koha::CirculationRules->set_rules(
172
    {
164
    {
173
        branchcode   => $samplebranch2->{branchcode},
165
        branchcode   => $samplebranch2->{branchcode},
Lines 176-191 Koha::CirculationRules->set_rules( Link Here
176
        rules        => {
168
        rules        => {
177
            maxissueqty       => 3,
169
            maxissueqty       => 3,
178
            maxonsiteissueqty => 2,
170
            maxonsiteissueqty => 2,
171
            holdallowed       => 1,
172
            returnbranch      => 'holdingbranch',
179
        }
173
        }
180
    }
174
    }
181
);
175
);
182
176
183
$query = q|
184
    INSERT INTO default_circ_rules
185
    (singleton, holdallowed, returnbranch)
186
    VALUES( ?, ?, ? )
187
|;
188
$dbh->do( $query, {}, 'singleton', 3, 'homebranch' );
189
Koha::CirculationRules->set_rules(
177
Koha::CirculationRules->set_rules(
190
    {
178
    {
191
        branchcode   => undef,
179
        branchcode   => undef,
Lines 194-220 Koha::CirculationRules->set_rules( Link Here
194
        rules        => {
182
        rules        => {
195
            maxissueqty       => 4,
183
            maxissueqty       => 4,
196
            maxonsiteissueqty => 5,
184
            maxonsiteissueqty => 5,
185
            holdallowed       => 3,
186
            returnbranch      => 'homebranch',
197
        }
187
        }
198
    }
188
    }
199
);
189
);
200
190
201
$query =
191
Koha::CirculationRules->set_rules(
202
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)";
192
    {
203
my $sth = $dbh->prepare($query);
193
        branchcode   => $samplebranch1->{branchcode},
204
$sth->execute(
194
        categorycode => undef,
205
    $samplebranch1->{branchcode},
195
        itemtype     => $sampleitemtype1->{itemtype},
206
    $sampleitemtype1->{itemtype},
196
        rules        => {
207
    5, 'homebranch'
197
            holdallowed       => 5,
198
            returnbranch      => 'homebranch',
199
        }
200
    }
208
);
201
);
209
$sth->execute(
202
Koha::CirculationRules->set_rules(
210
    $samplebranch2->{branchcode},
203
    {
211
    $sampleitemtype1->{itemtype},
204
        branchcode   => $samplebranch2->{branchcode},
212
    5, 'holdingbranch'
205
        categorycode => undef,
206
        itemtype     => $sampleitemtype1->{itemtype},
207
        rules        => {
208
            holdallowed       => 5,
209
            returnbranch      => 'holdingbranch',
210
        }
211
    }
213
);
212
);
214
$sth->execute(
213
Koha::CirculationRules->set_rules(
215
    $samplebranch2->{branchcode},
214
    {
216
    $sampleitemtype2->{itemtype},
215
        branchcode   => $samplebranch2->{branchcode},
217
    5, 'noreturn'
216
        categorycode => undef,
217
        itemtype     => $sampleitemtype2->{itemtype},
218
        rules        => {
219
            holdallowed       => 5,
220
            returnbranch      => 'noreturn',
221
        }
222
    }
218
);
223
);
219
224
220
#Test GetBranchBorrowerCircRule
225
#Test GetBranchBorrowerCircRule
(-)a/t/db_dependent/Holds.t (-12 / +24 lines)
Lines 42-47 my $borrowers_count = 5; Link Here
42
42
43
$dbh->do('DELETE FROM itemtypes');
43
$dbh->do('DELETE FROM itemtypes');
44
$dbh->do('DELETE FROM reserves');
44
$dbh->do('DELETE FROM reserves');
45
$dbh->do('DELETE FROM circulation_rules');
45
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
46
my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)');
46
$insert_sth->execute('CAN');
47
$insert_sth->execute('CAN');
47
$insert_sth->execute('CANNOT');
48
$insert_sth->execute('CANNOT');
Lines 401-424 ok( Link Here
401
# Test branch item rules
402
# Test branch item rules
402
403
403
$dbh->do('DELETE FROM issuingrules');
404
$dbh->do('DELETE FROM issuingrules');
405
$dbh->do('DELETE FROM circulation_rules');
404
$dbh->do(
406
$dbh->do(
405
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
407
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
406
      VALUES (?, ?, ?, ?)},
408
      VALUES (?, ?, ?, ?)},
407
    {},
409
    {},
408
    '*', '*', '*', 25
410
    '*', '*', '*', 25
409
);
411
);
410
$dbh->do('DELETE FROM branch_item_rules');
412
Koha::CirculationRules->set_rules(
411
$dbh->do('DELETE FROM default_branch_circ_rules');
413
    {
412
$dbh->do('DELETE FROM default_branch_item_rules');
414
        branchcode => $branch_1,
413
$dbh->do('DELETE FROM default_circ_rules');
415
        itemtype   => 'CANNOT',
414
$dbh->do(q{
416
        categorycode => undef,
415
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
417
        rules => {
416
    VALUES (?, ?, ?, ?)
418
            holdallowed => 0,
417
}, {}, $branch_1, 'CANNOT', 0, 'homebranch');
419
            returnbranch => 'homebranch',
418
$dbh->do(q{
420
        }
419
    INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
421
    }
420
    VALUES (?, ?, ?, ?)
422
);
421
}, {}, $branch_1, 'CAN', 1, 'homebranch');
423
Koha::CirculationRules->set_rules(
424
    {
425
        branchcode => $branch_1,
426
        itemtype   => 'CAN',
427
        categorycode => undef,
428
        rules => {
429
            holdallowed => 1,
430
            returnbranch => 'homebranch',
431
        }
432
    }
433
);
422
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
434
($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
423
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
435
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
424
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
436
    { homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum);
(-)a/t/db_dependent/Holds/HoldFulfillmentPolicy.t (-10 / +38 lines)
Lines 3-8 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use C4::Context;
5
use C4::Context;
6
use Koha::CirculationRules;
6
7
7
use Test::More tests => 10;
8
use Test::More tests => 10;
8
9
Lines 46-55 my $library_C = $library3->{branchcode}; Link Here
46
$dbh->do("DELETE FROM transport_cost");
47
$dbh->do("DELETE FROM transport_cost");
47
$dbh->do("DELETE FROM tmp_holdsqueue");
48
$dbh->do("DELETE FROM tmp_holdsqueue");
48
$dbh->do("DELETE FROM hold_fill_targets");
49
$dbh->do("DELETE FROM hold_fill_targets");
49
$dbh->do("DELETE FROM default_branch_circ_rules");
50
$dbh->do("DELETE FROM circulation_rules");
50
$dbh->do("DELETE FROM default_branch_item_rules");
51
$dbh->do("DELETE FROM default_circ_rules");
52
$dbh->do("DELETE FROM branch_item_rules");
53
51
54
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
52
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
55
53
Lines 72-79 my $itemnumber = Link Here
72
  or BAIL_OUT("Cannot find newly created item");
70
  or BAIL_OUT("Cannot find newly created item");
73
71
74
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
72
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
75
$dbh->do("DELETE FROM default_circ_rules");
73
$dbh->do("DELETE FROM circulation_rules");
76
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
74
Koha::CirculationRules->set_rules(
75
    {
76
        categorycode => undef,
77
        branchcode   => undef,
78
        itemtype     => undef,
79
        rules        => {
80
            holdallowed             => 2,
81
            hold_fulfillment_policy => 'homebranch',
82
        }
83
    }
84
);
77
85
78
# Home branch matches pickup branch
86
# Home branch matches pickup branch
79
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
87
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 94-101 is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); Link Here
94
CancelReserve( { reserve_id => $reserve_id } );
102
CancelReserve( { reserve_id => $reserve_id } );
95
103
96
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
104
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
97
$dbh->do("DELETE FROM default_circ_rules");
105
$dbh->do("DELETE FROM circulation_rules");
98
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
106
Koha::CirculationRules->set_rules(
107
    {
108
        categorycode => undef,
109
        branchcode   => undef,
110
        itemtype     => undef,
111
        rules        => {
112
            holdallowed             => 2,
113
            hold_fulfillment_policy => 'holdingbranch',
114
        }
115
    }
116
);
99
117
100
# Home branch matches pickup branch
118
# Home branch matches pickup branch
101
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
119
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 116-123 is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); Link Here
116
CancelReserve( { reserve_id => $reserve_id } );
134
CancelReserve( { reserve_id => $reserve_id } );
117
135
118
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
136
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
119
$dbh->do("DELETE FROM default_circ_rules");
137
$dbh->do("DELETE FROM circulation_rules");
120
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
138
Koha::CirculationRules->set_rules(
139
    {
140
        categorycode => undef,
141
        branchcode   => undef,
142
        itemtype     => undef,
143
        rules        => {
144
            holdallowed             => 2,
145
            hold_fulfillment_policy => 'any',
146
        }
147
    }
148
);
121
149
122
# Home branch matches pickup branch
150
# Home branch matches pickup branch
123
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
151
$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 62-71 $dbh->do("DELETE FROM biblioitems"); Link Here
62
$dbh->do("DELETE FROM transport_cost");
63
$dbh->do("DELETE FROM transport_cost");
63
$dbh->do("DELETE FROM tmp_holdsqueue");
64
$dbh->do("DELETE FROM tmp_holdsqueue");
64
$dbh->do("DELETE FROM hold_fill_targets");
65
$dbh->do("DELETE FROM hold_fill_targets");
65
$dbh->do("DELETE FROM default_branch_circ_rules");
66
$dbh->do("DELETE FROM default_branch_item_rules");
67
$dbh->do("DELETE FROM default_circ_rules");
68
$dbh->do("DELETE FROM branch_item_rules");
69
66
70
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
67
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$bib_title', '2011-02-01')");
71
68
Lines 87-94 my $itemnumber = Link Here
87
  $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber")
84
  $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber")
88
  or BAIL_OUT("Cannot find newly created item");
85
  or BAIL_OUT("Cannot find newly created item");
89
86
90
$dbh->do("DELETE FROM default_circ_rules");
87
$dbh->do("DELETE FROM circulation_rules");
91
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
88
Koha::CirculationRules->set_rules(
89
    {
90
        itemtype     => undef,
91
        categorycode => undef,
92
        branchcode   => undef,
93
        rules        => {
94
            holdallowed             => 2,
95
            hold_fulfillment_policy => 'any',
96
        }
97
    }
98
);
92
99
93
# Itemtypes match
100
# Itemtypes match
94
my $reserve_id = AddReserve( $branchcode, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype );
101
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 17-22 use C4::Members; Link Here
17
use Koha::Database;
17
use Koha::Database;
18
use Koha::DateUtils;
18
use Koha::DateUtils;
19
use Koha::Items;
19
use Koha::Items;
20
use Koha::CirculationRules;
20
21
21
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
22
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 31-36 BEGIN { Link Here
31
my $schema = Koha::Database->schema;
32
my $schema = Koha::Database->schema;
32
$schema->storage->txn_begin;
33
$schema->storage->txn_begin;
33
my $dbh = C4::Context->dbh;
34
my $dbh = C4::Context->dbh;
35
$dbh->do("DELETE FROM circulation_rules");
34
36
35
my $builder = t::lib::TestBuilder->new;
37
my $builder = t::lib::TestBuilder->new;
36
38
Lines 171-179 $schema->txn_begin; Link Here
171
### Test holds queue builder does not violate holds policy ###
173
### Test holds queue builder does not violate holds policy ###
172
174
173
# Clear out existing rules relating to holdallowed
175
# Clear out existing rules relating to holdallowed
174
$dbh->do("DELETE FROM default_branch_circ_rules");
176
$dbh->do("DELETE FROM circulation_rules");
175
$dbh->do("DELETE FROM default_branch_item_rules");
176
$dbh->do("DELETE FROM default_circ_rules");
177
177
178
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
178
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
179
179
Lines 286-293 $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ) Link Here
286
286
287
my $holds_queue;
287
my $holds_queue;
288
288
289
$dbh->do("DELETE FROM default_circ_rules");
289
$dbh->do("DELETE FROM circulation_rules");
290
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 1 )");
290
Koha::CirculationRules->set_rule(
291
    {
292
        rule_name    => 'holdallowed',
293
        rule_value   => 1,
294
        branchcode   => undef,
295
        categorycode => undef,
296
        itemtype     => undef,
297
    }
298
);
291
C4::HoldsQueue::CreateQueue();
299
C4::HoldsQueue::CreateQueue();
292
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
300
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
293
is( @$holds_queue, 2, "Holds queue filling correct number for default holds policy 'from home library'" );
301
is( @$holds_queue, 2, "Holds queue filling correct number for default holds policy 'from home library'" );
Lines 316-323 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
316
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
324
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
317
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
325
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
318
326
319
$dbh->do("DELETE FROM default_circ_rules");
327
$dbh->do("DELETE FROM circulation_rules");
320
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
328
Koha::CirculationRules->set_rule(
329
    {
330
        rule_name    => 'holdallowed',
331
        rule_value   => 2,
332
        branchcode   => undef,
333
        categorycode => undef,
334
        itemtype     => undef,
335
    }
336
);
321
C4::HoldsQueue::CreateQueue();
337
C4::HoldsQueue::CreateQueue();
322
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
338
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
323
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
339
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
Lines 336-343 t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 0 ); Link Here
336
## Test LocalHoldsPriority
352
## Test LocalHoldsPriority
337
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
353
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
338
354
339
$dbh->do("DELETE FROM default_circ_rules");
355
$dbh->do("DELETE FROM circulation_rules");
340
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
356
Koha::CirculationRules->set_rule(
357
    {
358
        rule_name    => 'holdallowed',
359
        rule_value   => 2,
360
        branchcode   => undef,
361
        categorycode => undef,
362
        itemtype     => undef,
363
    }
364
);
341
$dbh->do("DELETE FROM issues");
365
$dbh->do("DELETE FROM issues");
342
366
343
# Test homebranch = patron branch
367
# Test homebranch = patron branch
Lines 426-435 $dbh->do("DELETE FROM biblioitems"); Link Here
426
$dbh->do("DELETE FROM transport_cost");
450
$dbh->do("DELETE FROM transport_cost");
427
$dbh->do("DELETE FROM tmp_holdsqueue");
451
$dbh->do("DELETE FROM tmp_holdsqueue");
428
$dbh->do("DELETE FROM hold_fill_targets");
452
$dbh->do("DELETE FROM hold_fill_targets");
429
$dbh->do("DELETE FROM default_branch_circ_rules");
430
$dbh->do("DELETE FROM default_branch_item_rules");
431
$dbh->do("DELETE FROM default_circ_rules");
432
$dbh->do("DELETE FROM branch_item_rules");
433
453
434
$dbh->do("
454
$dbh->do("
435
    INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')
455
    INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')
Lines 454-463 $dbh->do(" Link Here
454
    VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype')
474
    VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype')
455
");
475
");
456
476
457
$dbh->do("
477
Koha::CirculationRules->set_rules(
458
    INSERT INTO branch_item_rules ( branchcode, itemtype, holdallowed, returnbranch ) VALUES
478
    {
459
    ( '$library_A', '$itemtype', 2, 'homebranch' ), ( '$library_B', '$itemtype', 1, 'homebranch' );
479
        branchcode   => $library_A,
460
");
480
        itemtype     => $itemtype,
481
        categorycode => undef,
482
        rules        => {
483
            holdallowed  => 2,
484
            returnbranch => 'homebranch',
485
        }
486
    }
487
);
461
488
462
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
489
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
463
    undef, join( ',', $library_B, $library_A, $library_C ) );
490
    undef, join( ',', $library_B, $library_A, $library_C ) );
Lines 482-491 $dbh->do("DELETE FROM biblioitems"); Link Here
482
$dbh->do("DELETE FROM transport_cost");
509
$dbh->do("DELETE FROM transport_cost");
483
$dbh->do("DELETE FROM tmp_holdsqueue");
510
$dbh->do("DELETE FROM tmp_holdsqueue");
484
$dbh->do("DELETE FROM hold_fill_targets");
511
$dbh->do("DELETE FROM hold_fill_targets");
485
$dbh->do("DELETE FROM default_branch_circ_rules");
486
$dbh->do("DELETE FROM default_branch_item_rules");
487
$dbh->do("DELETE FROM default_circ_rules");
488
$dbh->do("DELETE FROM branch_item_rules");
489
512
490
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
513
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
491
514
Lines 531-540 $dbh->do("DELETE FROM biblioitems"); Link Here
531
$dbh->do("DELETE FROM transport_cost");
554
$dbh->do("DELETE FROM transport_cost");
532
$dbh->do("DELETE FROM tmp_holdsqueue");
555
$dbh->do("DELETE FROM tmp_holdsqueue");
533
$dbh->do("DELETE FROM hold_fill_targets");
556
$dbh->do("DELETE FROM hold_fill_targets");
534
$dbh->do("DELETE FROM default_branch_circ_rules");
535
$dbh->do("DELETE FROM default_branch_item_rules");
536
$dbh->do("DELETE FROM default_circ_rules");
537
$dbh->do("DELETE FROM branch_item_rules");
538
557
539
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
558
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
540
559
Lines 553-560 $dbh->do(" Link Here
553
");
572
");
554
573
555
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
574
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
556
$dbh->do("DELETE FROM default_circ_rules");
575
$dbh->do("DELETE FROM circulation_rules");
557
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
576
Koha::CirculationRules->set_rules(
577
    {
578
        branchcode   => undef,
579
        itemtype     => undef,
580
        categorycode => undef,
581
        rules        => {
582
            holdallowed             => 2,
583
            hold_fulfillment_policy => 'homebranch',
584
        }
585
    }
586
);
558
587
559
# Home branch matches pickup branch
588
# Home branch matches pickup branch
560
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
589
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 578-585 is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted Link Here
578
CancelReserve( { reserve_id => $reserve_id } );
607
CancelReserve( { reserve_id => $reserve_id } );
579
608
580
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
609
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
581
$dbh->do("DELETE FROM default_circ_rules");
610
$dbh->do("DELETE FROM circulation_rules");
582
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'holdingbranch' )");
611
Koha::CirculationRules->set_rules(
612
    {
613
        branchcode   => undef,
614
        itemtype     => undef,
615
        categorycode => undef,
616
        rules        => {
617
            holdallowed             => 2,
618
            hold_fulfillment_policy => 'holdingbranch',
619
        }
620
    }
621
);
583
622
584
# Home branch matches pickup branch
623
# Home branch matches pickup branch
585
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
624
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 603-610 is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted Link Here
603
CancelReserve( { reserve_id => $reserve_id } );
642
CancelReserve( { reserve_id => $reserve_id } );
604
643
605
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
644
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
606
$dbh->do("DELETE FROM default_circ_rules");
645
$dbh->do("DELETE FROM circulation_rules");
607
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
646
Koha::CirculationRules->set_rules(
647
    {
648
        branchcode   => undef,
649
        itemtype     => undef,
650
        categorycode => undef,
651
        rules        => {
652
            holdallowed             => 2,
653
            hold_fulfillment_policy => 'any',
654
        }
655
    }
656
);
608
657
609
# Home branch matches pickup branch
658
# Home branch matches pickup branch
610
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
659
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Lines 643-652 $dbh->do("DELETE FROM biblioitems"); Link Here
643
$dbh->do("DELETE FROM transport_cost");
692
$dbh->do("DELETE FROM transport_cost");
644
$dbh->do("DELETE FROM tmp_holdsqueue");
693
$dbh->do("DELETE FROM tmp_holdsqueue");
645
$dbh->do("DELETE FROM hold_fill_targets");
694
$dbh->do("DELETE FROM hold_fill_targets");
646
$dbh->do("DELETE FROM default_branch_circ_rules");
647
$dbh->do("DELETE FROM default_branch_item_rules");
648
$dbh->do("DELETE FROM default_circ_rules");
649
$dbh->do("DELETE FROM branch_item_rules");
650
695
651
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
696
$dbh->do("INSERT INTO biblio (frameworkcode, author, title, datecreated) VALUES ('', 'Koha test', '$TITLE', '2011-02-01')");
652
697
Lines 665-672 $dbh->do(" Link Here
665
");
710
");
666
711
667
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
712
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
668
$dbh->do("DELETE FROM default_circ_rules");
713
$dbh->do("DELETE FROM circulation_rules");
669
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
714
Koha::CirculationRules->set_rules(
715
    {
716
        branchcode   => undef,
717
        itemtype     => undef,
718
        categorycode => undef,
719
        rules        => {
720
            holdallowed             => 2,
721
            hold_fulfillment_policy => 'any',
722
        }
723
    }
724
);
670
725
671
# Home branch matches pickup branch
726
# Home branch matches pickup branch
672
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
727
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $wrong_itemtype );
Lines 700-709 t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); Link Here
700
$dbh->do("DELETE FROM tmp_holdsqueue");
755
$dbh->do("DELETE FROM tmp_holdsqueue");
701
$dbh->do("DELETE FROM hold_fill_targets");
756
$dbh->do("DELETE FROM hold_fill_targets");
702
$dbh->do("DELETE FROM reserves");
757
$dbh->do("DELETE FROM reserves");
703
$dbh->do("DELETE FROM default_branch_circ_rules");
704
$dbh->do("DELETE FROM default_branch_item_rules");
705
$dbh->do("DELETE FROM default_circ_rules");
706
$dbh->do("DELETE FROM branch_item_rules");
707
758
708
my $item = Koha::Items->find( { biblionumber => $biblionumber } );
759
my $item = Koha::Items->find( { biblionumber => $biblionumber } );
709
$item->holdingbranch( $item->homebranch );
760
$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 198-207 $requesters{$branch_3} = AddMember( Link Here
198
# to fill holds from anywhere.
200
# to fill holds from anywhere.
199
201
200
$dbh->do('DELETE FROM issuingrules');
202
$dbh->do('DELETE FROM issuingrules');
201
$dbh->do('DELETE FROM branch_item_rules');
202
$dbh->do('DELETE FROM default_branch_item_rules');
203
$dbh->do('DELETE FROM default_branch_circ_rules');
204
$dbh->do('DELETE FROM default_circ_rules');
205
$dbh->do(
203
$dbh->do(
206
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
204
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
207
      VALUES (?, ?, ?, ?)},
205
      VALUES (?, ?, ?, ?)},
Lines 210-228 $dbh->do( Link Here
210
);
208
);
211
209
212
# CPL allows only its own patrons to request its items
210
# CPL allows only its own patrons to request its items
213
$dbh->do(
211
Koha::CirculationRules->set_rules(
214
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
212
    {
215
      VALUES (?, ?, ?)},
213
        branchcode   => $branch_1,
216
    {},
214
        categorycode => undef,
217
    $branch_1, 1, 'homebranch',
215
        itemtype     => undef,
216
        rules        => {
217
            holdallowed  => 1,
218
            returnbranch => 'homebranch',
219
        }
220
    }
218
);
221
);
219
222
220
# ... while FPL allows anybody to request its items
223
# ... while FPL allows anybody to request its items
221
$dbh->do(
224
Koha::CirculationRules->set_rules(
222
    q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, returnbranch)
225
    {
223
      VALUES (?, ?, ?)},
226
        branchcode   => $branch_2,
224
    {},
227
        categorycode => undef,
225
    $branch_2, 2, 'homebranch',
228
        itemtype     => undef,
229
        rules        => {
230
            holdallowed  => 2,
231
            returnbranch => 'homebranch',
232
        }
233
    }
226
);
234
);
227
235
228
# helper biblio for the bug 10272 regression test
236
# helper biblio for the bug 10272 regression test
229
- 

Return to bug 18928