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

(-)a/C4/Circulation.pm (-11 / +11 lines)
Lines 513-519 sub TooMany { Link Here
513
513
514
    # Now count total loans against the limit for the branch
514
    # Now count total loans against the limit for the branch
515
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
515
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
516
    if (defined($branch_borrower_circ_rule->{maxissueqty})) {
516
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty})) {
517
        my @bind_params = ();
517
        my @bind_params = ();
518
        my $branch_count_query = q|
518
        my $branch_count_query = q|
519
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
519
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
Lines 533-540 sub TooMany { Link Here
533
            push @bind_params, $branch;
533
            push @bind_params, $branch;
534
        }
534
        }
535
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $branch_count_query, {}, @bind_params );
535
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $branch_count_query, {}, @bind_params );
536
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{maxissueqty};
536
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
537
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{maxonsiteissueqty};
537
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
538
538
539
        if ( $onsite_checkout ) {
539
        if ( $onsite_checkout ) {
540
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
540
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
Lines 565-571 sub TooMany { Link Here
565
        }
565
        }
566
    }
566
    }
567
567
568
    if ( not defined( $maxissueqty_rule ) and not defined($branch_borrower_circ_rule->{maxissueqty}) ) {
568
    if ( not defined( $maxissueqty_rule ) and not defined($branch_borrower_circ_rule->{patron_maxissueqty}) ) {
569
        return { reason => 'NO_RULE_DEFINED', max_allowed => 0 };
569
        return { reason => 'NO_RULE_DEFINED', max_allowed => 0 };
570
    }
570
    }
571
571
Lines 1586-1596 Retrieves circulation rule attributes that apply to the given Link Here
1586
branch and patron category, regardless of item type.  
1586
branch and patron category, regardless of item type.  
1587
The return value is a hashref containing the following key:
1587
The return value is a hashref containing the following key:
1588
1588
1589
maxissueqty - maximum number of loans that a
1589
patron_maxissueqty - maximum number of loans that a
1590
patron of the given category can have at the given
1590
patron of the given category can have at the given
1591
branch.  If the value is undef, no limit.
1591
branch.  If the value is undef, no limit.
1592
1592
1593
maxonsiteissueqty - maximum of on-site checkouts that a
1593
patron_maxonsiteissueqty - maximum of on-site checkouts that a
1594
patron of the given category can have at the given
1594
patron of the given category can have at the given
1595
branch.  If the value is undef, no limit.
1595
branch.  If the value is undef, no limit.
1596
1596
Lines 1603-1610 default branch and category Link Here
1603
If no rule has been found in the database, it will default to
1603
If no rule has been found in the database, it will default to
1604
the buillt in rule:
1604
the buillt in rule:
1605
1605
1606
maxissueqty - undef
1606
patron_maxissueqty - undef
1607
maxonsiteissueqty - undef
1607
patron_maxonsiteissueqty - undef
1608
1608
1609
C<$branchcode> and C<$categorycode> should contain the
1609
C<$branchcode> and C<$categorycode> should contain the
1610
literal branch code and patron category code, respectively - no
1610
literal branch code and patron category code, respectively - no
Lines 1641-1652 sub GetBranchBorrowerCircRule { Link Here
1641
1641
1642
    # Initialize default values
1642
    # Initialize default values
1643
    my $rules = {
1643
    my $rules = {
1644
        maxissueqty       => undef,
1644
        patron_maxissueqty       => undef,
1645
        maxonsiteissueqty => undef,
1645
        patron_maxonsiteissueqty => undef,
1646
    };
1646
    };
1647
1647
1648
    # Search for rules!
1648
    # Search for rules!
1649
    foreach my $rule_name (qw( maxissueqty maxonsiteissueqty )) {
1649
    foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) {
1650
        foreach my $params (@params) {
1650
        foreach my $params (@params) {
1651
            my $rule = Koha::CirculationRules->search(
1651
            my $rule = Koha::CirculationRules->search(
1652
                {
1652
                {
(-)a/admin/smart-rules.pl (-46 / +112 lines)
Lines 78-119 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
                        patron_maxissueqty             => undef,
88
                        patron_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
                        patron_maxissueqty       => undef,
104
                        patron_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
                    patron_maxissueqty             => undef,
92
            branchcode   => $branch eq '*'       ? undef : $branch,
117
                    patron_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
                    patron_maxissueqty       => undef,
133
                    patron_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
                        patron_maxissueqty             => undef,
150
                        patron_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
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
110
                                            WHERE itemtype = ?");
159
                                            WHERE itemtype = ?");
111
            $sth_delete->execute($itemtype);
160
            $sth_delete->execute($itemtype);
112
        }
161
        }
113
    } elsif ($itemtype eq "*") {
162
    } elsif ($itemtype eq "*") {
114
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
163
        Koha::CirculationRules->set_rules(
115
                                        WHERE branchcode = ?");
164
            {
116
        $sth_delete->execute($branch);
165
                categorycode => undef,
166
                branchcode   => $branch,
167
                itemtype     => undef,
168
                rules        => {
169
                    patron_maxissueqty             => undef,
170
                    patron_maxonsiteissueqty       => undef,
171
                    holdallowed             => undef,
172
                    hold_fulfillment_policy => undef,
173
                    returnbranch            => undef,
174
                }
175
            }
176
        );
117
    } else {
177
    } else {
118
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
178
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
119
                                        WHERE branchcode = ?
179
                                        WHERE branchcode = ?
Lines 218-233 elsif ($op eq 'add') { Link Here
218
}
278
}
219
elsif ($op eq "set-branch-defaults") {
279
elsif ($op eq "set-branch-defaults") {
220
    my $categorycode  = $input->param('categorycode');
280
    my $categorycode  = $input->param('categorycode');
221
    my $maxissueqty   = $input->param('maxissueqty');
281
    my $patron_maxissueqty   = $input->param('patron_maxissueqty');
222
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
282
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
223
    my $holdallowed   = $input->param('holdallowed');
283
    my $holdallowed   = $input->param('holdallowed');
224
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
284
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
225
    my $returnbranch  = $input->param('returnbranch');
285
    my $returnbranch  = $input->param('returnbranch');
226
    my $max_holds = $input->param('max_holds');
286
    my $max_holds = $input->param('max_holds');
227
    $maxissueqty =~ s/\s//g;
287
    $patron_maxissueqty =~ s/\s//g;
228
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
288
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
229
    $maxonsiteissueqty =~ s/\s//g;
289
    $patron_maxonsiteissueqty =~ s/\s//g;
230
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
290
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
231
    $holdallowed =~ s/\s//g;
291
    $holdallowed =~ s/\s//g;
232
    $holdallowed = undef if $holdallowed !~ /^\d+/;
292
    $holdallowed = undef if $holdallowed !~ /^\d+/;
233
    $max_holds =~ s/\s//g;
293
    $max_holds =~ s/\s//g;
Lines 256-263 elsif ($op eq "set-branch-defaults") { Link Here
256
                itemtype     => undef,
316
                itemtype     => undef,
257
                branchcode   => undef,
317
                branchcode   => undef,
258
                rules        => {
318
                rules        => {
259
                    maxissueqty       => $maxissueqty,
319
                    patron_maxissueqty             => $patron_maxissueqty,
260
                    maxonsiteissueqty => $maxonsiteissueqty,
320
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
321
                    holdallowed             => $holdallowed,
322
                    hold_fulfillment_policy => $hold_fulfillment_policy,
323
                    returnbranch            => $returnbranch,
261
                }
324
                }
262
            }
325
            }
263
        );
326
        );
Lines 285-292 elsif ($op eq "set-branch-defaults") { Link Here
285
                itemtype     => undef,
348
                itemtype     => undef,
286
                branchcode   => $branch,
349
                branchcode   => $branch,
287
                rules        => {
350
                rules        => {
288
                    maxissueqty       => $maxissueqty,
351
                    patron_maxissueqty             => $patron_maxissueqty,
289
                    maxonsiteissueqty => $maxonsiteissueqty,
352
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
353
                    holdallowed             => $holdallowed,
354
                    hold_fulfillment_policy => $hold_fulfillment_policy,
355
                    returnbranch            => $returnbranch,
290
                }
356
                }
291
            }
357
            }
292
        );
358
        );
Lines 303-315 elsif ($op eq "set-branch-defaults") { Link Here
303
}
369
}
304
elsif ($op eq "add-branch-cat") {
370
elsif ($op eq "add-branch-cat") {
305
    my $categorycode  = $input->param('categorycode');
371
    my $categorycode  = $input->param('categorycode');
306
    my $maxissueqty   = $input->param('maxissueqty');
372
    my $patron_maxissueqty   = $input->param('patron_maxissueqty');
307
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
373
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
308
    my $max_holds = $input->param('max_holds');
374
    my $max_holds = $input->param('max_holds');
309
    $maxissueqty =~ s/\s//g;
375
    $patron_maxissueqty =~ s/\s//g;
310
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
376
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
311
    $maxonsiteissueqty =~ s/\s//g;
377
    $patron_maxonsiteissueqty =~ s/\s//g;
312
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
378
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
313
    $max_holds =~ s/\s//g;
379
    $max_holds =~ s/\s//g;
314
    $max_holds = undef if $max_holds !~ /^\d+/;
380
    $max_holds = undef if $max_holds !~ /^\d+/;
315
381
Lines 322-329 elsif ($op eq "add-branch-cat") { Link Here
322
                    branchcode   => undef,
388
                    branchcode   => undef,
323
                    rules        => {
389
                    rules        => {
324
                        max_holds         => $max_holds,
390
                        max_holds         => $max_holds,
325
                        maxissueqty       => $maxissueqty,
391
                        patron_maxissueqty       => $patron_maxissueqty,
326
                        maxonsiteissueqty => $maxonsiteissueqty,
392
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
327
                    }
393
                    }
328
                }
394
                }
329
            );
395
            );
Lines 335-342 elsif ($op eq "add-branch-cat") { Link Here
335
                    itemtype     => undef,
401
                    itemtype     => undef,
336
                    rules        => {
402
                    rules        => {
337
                        max_holds         => $max_holds,
403
                        max_holds         => $max_holds,
338
                        maxissueqty       => $maxissueqty,
404
                        patron_maxissueqty       => $patron_maxissueqty,
339
                        maxonsiteissueqty => $maxonsiteissueqty,
405
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
340
                    }
406
                    }
341
                }
407
                }
342
            );
408
            );
Lines 349-356 elsif ($op eq "add-branch-cat") { Link Here
349
                branchcode   => $branch,
415
                branchcode   => $branch,
350
                rules        => {
416
                rules        => {
351
                    max_holds         => $max_holds,
417
                    max_holds         => $max_holds,
352
                    maxissueqty       => $maxissueqty,
418
                    patron_maxissueqty       => $patron_maxissueqty,
353
                    maxonsiteissueqty => $maxonsiteissueqty,
419
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
354
                }
420
                }
355
            }
421
            }
356
        );
422
        );
Lines 362-369 elsif ($op eq "add-branch-cat") { Link Here
362
                branchcode   => $branch,
428
                branchcode   => $branch,
363
                rules        => {
429
                rules        => {
364
                    max_holds         => $max_holds,
430
                    max_holds         => $max_holds,
365
                    maxissueqty       => $maxissueqty,
431
                    patron_maxissueqty       => $patron_maxissueqty,
366
                    maxonsiteissueqty => $maxonsiteissueqty,
432
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
367
                }
433
                }
368
            }
434
            }
369
        );
435
        );
(-)a/installer/data/mysql/atomicupdate/bug_18925.perl (-8 / +8 lines)
Lines 3-14 if( CheckVersion( $DBversion ) ) { Link Here
3
    if ( column_exists( 'branch_borrower_circ_rules', 'maxissueqty' ) ) {
3
    if ( column_exists( 'branch_borrower_circ_rules', 'maxissueqty' ) ) {
4
        $dbh->do("
4
        $dbh->do("
5
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
5
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
6
            SELECT categorycode, branchcode, NULL, 'maxissueqty', maxissueqty
6
            SELECT categorycode, branchcode, NULL, 'patron_maxissueqty', maxissueqty
7
            FROM branch_borrower_circ_rules
7
            FROM branch_borrower_circ_rules
8
        ");
8
        ");
9
        $dbh->do("
9
        $dbh->do("
10
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
10
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
11
            SELECT categorycode, branchcode, NULL, 'maxonsiteissueqty', maxonsiteissueqty
11
            SELECT categorycode, branchcode, NULL, 'patron_maxonsiteissueqty', maxonsiteissueqty
12
            FROM branch_borrower_circ_rules
12
            FROM branch_borrower_circ_rules
13
        ");
13
        ");
14
        $dbh->do("DROP TABLE branch_borrower_circ_rules");
14
        $dbh->do("DROP TABLE branch_borrower_circ_rules");
Lines 17-28 if( CheckVersion( $DBversion ) ) { Link Here
17
    if ( column_exists( 'default_borrower_circ_rules', 'maxissueqty' ) ) {
17
    if ( column_exists( 'default_borrower_circ_rules', 'maxissueqty' ) ) {
18
        $dbh->do("
18
        $dbh->do("
19
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
19
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
20
            SELECT categorycode, NULL, NULL, 'maxissueqty', maxissueqty
20
            SELECT categorycode, NULL, NULL, 'patron_maxissueqty', maxissueqty
21
            FROM default_borrower_circ_rules
21
            FROM default_borrower_circ_rules
22
        ");
22
        ");
23
        $dbh->do("
23
        $dbh->do("
24
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
24
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
25
            SELECT categorycode, NULL, NULL, 'maxonsiteissueqty', maxonsiteissueqty
25
            SELECT categorycode, NULL, NULL, 'patron_maxonsiteissueqty', maxonsiteissueqty
26
            FROM default_borrower_circ_rules
26
            FROM default_borrower_circ_rules
27
        ");
27
        ");
28
        $dbh->do("DROP TABLE default_borrower_circ_rules");
28
        $dbh->do("DROP TABLE default_borrower_circ_rules");
Lines 31-42 if( CheckVersion( $DBversion ) ) { Link Here
31
    if ( column_exists( 'default_circ_rules', 'maxissueqty' ) ) {
31
    if ( column_exists( 'default_circ_rules', 'maxissueqty' ) ) {
32
        $dbh->do("
32
        $dbh->do("
33
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
33
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
34
            SELECT NULL, NULL, NULL, 'maxissueqty', maxissueqty
34
            SELECT NULL, NULL, NULL, 'patron_maxissueqty', maxissueqty
35
            FROM default_circ_rules
35
            FROM default_circ_rules
36
        ");
36
        ");
37
        $dbh->do("
37
        $dbh->do("
38
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
38
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
39
            SELECT NULL, NULL, NULL, 'maxonsiteissueqty', maxonsiteissueqty
39
            SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', maxonsiteissueqty
40
            FROM default_circ_rules
40
            FROM default_circ_rules
41
        ");
41
        ");
42
        $dbh->do("ALTER TABLE default_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
42
        $dbh->do("ALTER TABLE default_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
Lines 45-56 if( CheckVersion( $DBversion ) ) { Link Here
45
    if ( column_exists( 'default_branch_circ_rules', 'maxissueqty' ) ) {
45
    if ( column_exists( 'default_branch_circ_rules', 'maxissueqty' ) ) {
46
        $dbh->do("
46
        $dbh->do("
47
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
47
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
48
            SELECT NULL, branchcode, NULL, 'maxissueqty', maxissueqty
48
            SELECT NULL, branchcode, NULL, 'patron_maxissueqty', maxissueqty
49
            FROM default_branch_circ_rules
49
            FROM default_branch_circ_rules
50
        ");
50
        ");
51
        $dbh->do("
51
        $dbh->do("
52
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
52
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
53
            SELECT NULL, NULL, NULL, 'maxonsiteissueqty', maxonsiteissueqty
53
            SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', maxonsiteissueqty
54
            FROM default_branch_circ_rules
54
            FROM default_branch_circ_rules
55
        ");
55
        ");
56
        $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
56
        $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-13 / +13 lines)
Lines 474-485 $(document).ready(function() { Link Here
474
                <tr>
474
                <tr>
475
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
475
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
476
                    <td>
476
                    <td>
477
                        [% SET maxissueqty  = CirculationRules.Get( branchcode, undef, undef, 'maxissueqty' ) %]
477
                        [% SET patron_maxissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxissueqty' ) %]
478
                        <input type="text" name="maxissueqty" size="3" value="[% maxissueqty %]"/>
478
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty %]"/>
479
                    </td>
479
                    </td>
480
                    <td>
480
                    <td>
481
                        [% SET maxonsiteissueqty  = CirculationRules.Get( branchcode, undef, undef, 'maxonsiteissueqty' ) %]
481
                        [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxonsiteissueqty' ) %]
482
                        <input type="text" name="maxonsiteissueqty" size="3" value="[% maxonsiteissueqty %]"/>
482
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty %]"/>
483
                    </td>
483
                    </td>
484
                    <td>
484
                    <td>
485
                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
485
                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
Lines 597-607 $(document).ready(function() { Link Here
597
                    <th>&nbsp;</th>
597
                    <th>&nbsp;</th>
598
                </tr>
598
                </tr>
599
                [% FOREACH c IN categorycodes %]
599
                [% FOREACH c IN categorycodes %]
600
                    [% SET maxissueqty = CirculationRules.Get( branchcode, c, undef, 'maxissueqty' ) %]
600
                    [% SET patron_maxissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxissueqty' ) %]
601
                    [% SET maxonsiteissueqty = CirculationRules.Get( branchcode, c, undef, 'maxonsiteissueqty' ) %]
601
                    [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
602
                    [% SET max_holds = CirculationRules.Get( branchcode, c, undef, 'max_holds' ) %]
602
                    [% SET max_holds = CirculationRules.Get( branchcode, c, undef, 'max_holds' ) %]
603
603
604
                    [% IF maxissueqty || maxissueqty || max_holds %]
604
                    [% IF patron_maxissueqty || patron_maxonsiteissueqty || max_holds %]
605
                    <tr>
605
                    <tr>
606
                        <td>
606
                        <td>
607
                            [% IF c == '*'%]
607
                            [% IF c == '*'%]
Lines 611-625 $(document).ready(function() { Link Here
611
                            [% END %]
611
                            [% END %]
612
                        </td>
612
                        </td>
613
                        <td>
613
                        <td>
614
                            [% IF maxissueqty  %]
614
                            [% IF patron_maxissueqty  %]
615
                                [% maxissueqty %]
615
                                [% patron_maxissueqty %]
616
                            [% ELSE %]
616
                            [% ELSE %]
617
                                Unlimited
617
                                Unlimited
618
                            [% END %]
618
                            [% END %]
619
                        </td>
619
                        </td>
620
                        <td>
620
                        <td>
621
                            [% IF maxonsiteissueqty  %]
621
                            [% IF patron_maxonsiteissueqty  %]
622
                                [% maxonsiteissueqty %]
622
                                [% patron_maxonsiteissueqty %]
623
                            [% ELSE %]
623
                            [% ELSE %]
624
                                Unlimited
624
                                Unlimited
625
                            [% END %]
625
                            [% END %]
Lines 646-653 $(document).ready(function() { Link Here
646
                        [% END %]
646
                        [% END %]
647
                        </select>
647
                        </select>
648
                    </td>
648
                    </td>
649
                    <td><input name="maxissueqty" size="3" /></td>
649
                    <td><input name="patron_maxissueqty" size="3" /></td>
650
                    <td><input name="maxonsiteissueqty" size="3" /></td>
650
                    <td><input name="patron_maxonsiteissueqty" size="3" /></td>
651
                    <td><input name="max_holds" size="3" /></td>
651
                    <td><input name="max_holds" size="3" /></td>
652
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
652
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
653
                </tr>
653
                </tr>
(-)a/t/db_dependent/Circulation/Branch.t (-17 / +20 lines)
Lines 147-154 my $borrower_id1 = C4::Members::AddMember( Link Here
147
147
148
is_deeply(
148
is_deeply(
149
    GetBranchBorrowerCircRule(),
149
    GetBranchBorrowerCircRule(),
150
    { maxissueqty => undef, maxonsiteissueqty => undef },
150
    { patron_maxissueqty => undef, patron_maxonsiteissueqty => undef },
151
"Without parameter, GetBranchBorrower returns undef (unilimited) for maxissueqty and maxonsiteissueqty if no rules defined"
151
"Without parameter, GetBranchBorrower returns undef (unilimited) for patron_maxissueqty and patron_maxonsiteissueqty if no rules defined"
152
);
152
);
153
153
154
Koha::CirculationRules->set_rules(
154
Koha::CirculationRules->set_rules(
Lines 157-164 Koha::CirculationRules->set_rules( Link Here
157
        categorycode => $samplecat->{categorycode},
157
        categorycode => $samplecat->{categorycode},
158
        itemtype     => undef,
158
        itemtype     => undef,
159
        rules        => {
159
        rules        => {
160
            maxissueqty       => 5,
160
            patron_maxissueqty       => 5,
161
            maxonsiteissueqty => 6,
161
            patron_maxonsiteissueqty => 6,
162
        }
162
        }
163
    }
163
    }
164
);
164
);
Lines 175-182 Koha::CirculationRules->set_rules( Link Here
175
        categorycode => undef,
175
        categorycode => undef,
176
        itemtype     => undef,
176
        itemtype     => undef,
177
        rules        => {
177
        rules        => {
178
            maxissueqty       => 3,
178
            patron_maxissueqty       => 3,
179
            maxonsiteissueqty => 2,
179
            patron_maxonsiteissueqty => 2,
180
            holdallowed       => 1,
181
            returnbranch      => 'holdingbranch',
180
        }
182
        }
181
    }
183
    }
182
);
184
);
Lines 193-200 Koha::CirculationRules->set_rules( Link Here
193
        categorycode => undef,
195
        categorycode => undef,
194
        itemtype     => undef,
196
        itemtype     => undef,
195
        rules        => {
197
        rules        => {
196
            maxissueqty       => 4,
198
            patron_maxissueqty       => 4,
197
            maxonsiteissueqty => 5,
199
            patron_maxonsiteissueqty => 5,
200
            holdallowed       => 3,
201
            returnbranch      => 'homebranch',
198
        }
202
        }
199
    }
203
    }
200
);
204
);
Lines 221-246 $sth->execute( Link Here
221
#Test GetBranchBorrowerCircRule
225
#Test GetBranchBorrowerCircRule
222
is_deeply(
226
is_deeply(
223
    GetBranchBorrowerCircRule(),
227
    GetBranchBorrowerCircRule(),
224
    { maxissueqty => 4, maxonsiteissueqty => 5 },
228
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
225
"Without parameter, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of default_circ_rules"
229
"Without parameter, GetBranchBorrower returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
226
);
230
);
227
is_deeply(
231
is_deeply(
228
    GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ),
232
    GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ),
229
    { maxissueqty => 3, maxonsiteissueqty => 2 },
233
    { patron_maxissueqty => 3, patron_maxonsiteissueqty => 2 },
230
"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty corresponding"
234
"Without only the branchcode specified, GetBranchBorrower returns the patron_maxissueqty and patron_maxonsiteissueqty corresponding"
231
);
235
);
232
is_deeply(
236
is_deeply(
233
    GetBranchBorrowerCircRule(
237
    GetBranchBorrowerCircRule(
234
        $samplebranch1->{branchcode},
238
        $samplebranch1->{branchcode},
235
        $samplecat->{categorycode}
239
        $samplecat->{categorycode}
236
    ),
240
    ),
237
    { maxissueqty => 5, maxonsiteissueqty => 6 },
241
    { patron_maxissueqty => 5, patron_maxonsiteissueqty => 6 },
238
    "GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of the branch1 and the category1"
242
    "GetBranchBorrower returns the patron_maxissueqty and patron_maxonsiteissueqty of the branch1 and the category1"
239
);
243
);
240
is_deeply(
244
is_deeply(
241
    GetBranchBorrowerCircRule( -1, -1 ),
245
    GetBranchBorrowerCircRule( -1, -1 ),
242
    { maxissueqty => 4, maxonsiteissueqty => 5 },
246
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
243
"GetBranchBorrower with wrong parameters returns the maxissueqty and maxonsiteissueqty of default_circ_rules"
247
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
244
);
248
);
245
249
246
#Test GetBranchItemRule
250
#Test GetBranchItemRule
247
- 

Return to bug 18925