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

(-)a/C4/Circulation.pm (-11 / +11 lines)
Lines 515-521 sub TooMany { Link Here
515
515
516
    # Now count total loans against the limit for the branch
516
    # Now count total loans against the limit for the branch
517
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
517
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
518
    if (defined($branch_borrower_circ_rule->{maxissueqty})) {
518
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty})) {
519
        my @bind_params = ();
519
        my @bind_params = ();
520
        my $branch_count_query = q|
520
        my $branch_count_query = q|
521
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
521
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
Lines 535-542 sub TooMany { Link Here
535
            push @bind_params, $branch;
535
            push @bind_params, $branch;
536
        }
536
        }
537
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $branch_count_query, {}, @bind_params );
537
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $branch_count_query, {}, @bind_params );
538
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{maxissueqty};
538
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
539
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{maxonsiteissueqty};
539
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
540
540
541
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
541
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
542
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
542
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
Lines 567-573 sub TooMany { Link Here
567
        }
567
        }
568
    }
568
    }
569
569
570
    if ( not defined( $maxissueqty_rule ) and not defined($branch_borrower_circ_rule->{maxissueqty}) ) {
570
    if ( not defined( $maxissueqty_rule ) and not defined($branch_borrower_circ_rule->{patron_maxissueqty}) ) {
571
        return { reason => 'NO_RULE_DEFINED', max_allowed => 0 };
571
        return { reason => 'NO_RULE_DEFINED', max_allowed => 0 };
572
    }
572
    }
573
573
Lines 1591-1601 Retrieves circulation rule attributes that apply to the given Link Here
1591
branch and patron category, regardless of item type.  
1591
branch and patron category, regardless of item type.  
1592
The return value is a hashref containing the following key:
1592
The return value is a hashref containing the following key:
1593
1593
1594
maxissueqty - maximum number of loans that a
1594
patron_maxissueqty - maximum number of loans that a
1595
patron of the given category can have at the given
1595
patron of the given category can have at the given
1596
branch.  If the value is undef, no limit.
1596
branch.  If the value is undef, no limit.
1597
1597
1598
maxonsiteissueqty - maximum of on-site checkouts that a
1598
patron_maxonsiteissueqty - maximum of on-site checkouts that a
1599
patron of the given category can have at the given
1599
patron of the given category can have at the given
1600
branch.  If the value is undef, no limit.
1600
branch.  If the value is undef, no limit.
1601
1601
Lines 1608-1615 default branch and category Link Here
1608
If no rule has been found in the database, it will default to
1608
If no rule has been found in the database, it will default to
1609
the buillt in rule:
1609
the buillt in rule:
1610
1610
1611
maxissueqty - undef
1611
patron_maxissueqty - undef
1612
maxonsiteissueqty - undef
1612
patron_maxonsiteissueqty - undef
1613
1613
1614
C<$branchcode> and C<$categorycode> should contain the
1614
C<$branchcode> and C<$categorycode> should contain the
1615
literal branch code and patron category code, respectively - no
1615
literal branch code and patron category code, respectively - no
Lines 1646-1657 sub GetBranchBorrowerCircRule { Link Here
1646
1646
1647
    # Initialize default values
1647
    # Initialize default values
1648
    my $rules = {
1648
    my $rules = {
1649
        maxissueqty       => undef,
1649
        patron_maxissueqty       => undef,
1650
        maxonsiteissueqty => undef,
1650
        patron_maxonsiteissueqty => undef,
1651
    };
1651
    };
1652
1652
1653
    # Search for rules!
1653
    # Search for rules!
1654
    foreach my $rule_name (qw( maxissueqty maxonsiteissueqty )) {
1654
    foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) {
1655
        foreach my $params (@params) {
1655
        foreach my $params (@params) {
1656
            my $rule = Koha::CirculationRules->search(
1656
            my $rule = Koha::CirculationRules->search(
1657
                {
1657
                {
(-)a/admin/smart-rules.pl (-46 / +112 lines)
Lines 85-126 elsif ($op eq 'delete-branch-cat') { Link Here
85
    my $categorycode  = $input->param('categorycode');
85
    my $categorycode  = $input->param('categorycode');
86
    if ($branch eq "*") {
86
    if ($branch eq "*") {
87
        if ($categorycode eq "*") {
87
        if ($categorycode eq "*") {
88
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
88
            Koha::CirculationRules->set_rules(
89
            $sth_delete->execute();
89
                {
90
                    categorycode => undef,
91
                    branchcode   => undef,
92
                    itemtype     => undef,
93
                    rules        => {
94
                        patron_maxissueqty             => undef,
95
                        patron_maxonsiteissueqty       => undef,
96
                        holdallowed             => undef,
97
                        hold_fulfillment_policy => undef,
98
                        returnbranch            => undef,
99
                    }
100
                }
101
            );
102
        } else {
103
            Koha::CirculationRules->set_rules(
104
                {
105
                    categorycode => $categorycode,
106
                    branchcode   => undef,
107
                    itemtype     => undef,
108
                    rules        => {
109
                        max_holds         => undef,
110
                        patron_maxissueqty       => undef,
111
                        patron_maxonsiteissueqty => undef,
112
                    }
113
                }
114
            );
90
        }
115
        }
91
    } elsif ($categorycode eq "*") {
116
    } elsif ($categorycode eq "*") {
92
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
117
        Koha::CirculationRules->set_rules(
93
                                        WHERE branchcode = ?");
118
            {
94
        $sth_delete->execute($branch);
119
                categorycode => undef,
95
    }
120
                branchcode   => $branch,
96
    Koha::CirculationRules->set_rules(
121
                itemtype     => undef,
97
        {
122
                rules        => {
98
            categorycode => $categorycode eq '*' ? undef : $categorycode,
123
                    patron_maxissueqty             => undef,
99
            branchcode   => $branch eq '*'       ? undef : $branch,
124
                    patron_maxonsiteissueqty       => undef,
100
            itemtype     => undef,
125
                    holdallowed             => undef,
101
            rules        => {
126
                    hold_fulfillment_policy => undef,
102
                max_holds         => undef,
127
                    returnbranch            => undef,
103
                maxissueqty       => undef,
128
                }
104
                maxonsiteissueqty => undef,
105
            }
129
            }
106
        }
130
        );
107
    );
131
    } else {
132
        Koha::CirculationRules->set_rules(
133
            {
134
                categorycode => $categorycode,
135
                branchcode   => $branch,
136
                itemtype     => undef,
137
                rules        => {
138
                    max_holds         => undef,
139
                    patron_maxissueqty       => undef,
140
                    patron_maxonsiteissueqty => undef,
141
                }
142
            }
143
        );
144
    }
108
}
145
}
109
elsif ($op eq 'delete-branch-item') {
146
elsif ($op eq 'delete-branch-item') {
110
    my $itemtype  = $input->param('itemtype');
147
    my $itemtype  = $input->param('itemtype');
111
    if ($branch eq "*") {
148
    if ($branch eq "*") {
112
        if ($itemtype eq "*") {
149
        if ($itemtype eq "*") {
113
            my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules");
150
            Koha::CirculationRules->set_rules(
114
            $sth_delete->execute();
151
                {
152
                    categorycode => undef,
153
                    branchcode   => undef,
154
                    itemtype     => undef,
155
                    rules        => {
156
                        patron_maxissueqty             => undef,
157
                        patron_maxonsiteissueqty       => undef,
158
                        holdallowed             => undef,
159
                        hold_fulfillment_policy => undef,
160
                        returnbranch            => undef,
161
                    }
162
                }
163
            );
115
        } else {
164
        } else {
116
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
165
            my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules
117
                                            WHERE itemtype = ?");
166
                                            WHERE itemtype = ?");
118
            $sth_delete->execute($itemtype);
167
            $sth_delete->execute($itemtype);
119
        }
168
        }
120
    } elsif ($itemtype eq "*") {
169
    } elsif ($itemtype eq "*") {
121
        my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules
170
        Koha::CirculationRules->set_rules(
122
                                        WHERE branchcode = ?");
171
            {
123
        $sth_delete->execute($branch);
172
                categorycode => undef,
173
                branchcode   => $branch,
174
                itemtype     => undef,
175
                rules        => {
176
                    patron_maxissueqty             => undef,
177
                    patron_maxonsiteissueqty       => undef,
178
                    holdallowed             => undef,
179
                    hold_fulfillment_policy => undef,
180
                    returnbranch            => undef,
181
                }
182
            }
183
        );
124
    } else {
184
    } else {
125
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
185
        my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules
126
                                        WHERE branchcode = ?
186
                                        WHERE branchcode = ?
Lines 225-240 elsif ($op eq 'add') { Link Here
225
}
285
}
226
elsif ($op eq "set-branch-defaults") {
286
elsif ($op eq "set-branch-defaults") {
227
    my $categorycode  = $input->param('categorycode');
287
    my $categorycode  = $input->param('categorycode');
228
    my $maxissueqty   = $input->param('maxissueqty');
288
    my $patron_maxissueqty   = $input->param('patron_maxissueqty');
229
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
289
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
230
    my $holdallowed   = $input->param('holdallowed');
290
    my $holdallowed   = $input->param('holdallowed');
231
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
291
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
232
    my $returnbranch  = $input->param('returnbranch');
292
    my $returnbranch  = $input->param('returnbranch');
233
    my $max_holds = $input->param('max_holds');
293
    my $max_holds = $input->param('max_holds');
234
    $maxissueqty =~ s/\s//g;
294
    $patron_maxissueqty =~ s/\s//g;
235
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
295
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
236
    $maxonsiteissueqty =~ s/\s//g;
296
    $patron_maxonsiteissueqty =~ s/\s//g;
237
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
297
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
238
    $holdallowed =~ s/\s//g;
298
    $holdallowed =~ s/\s//g;
239
    $holdallowed = undef if $holdallowed !~ /^\d+/;
299
    $holdallowed = undef if $holdallowed !~ /^\d+/;
240
    $max_holds =~ s/\s//g;
300
    $max_holds =~ s/\s//g;
Lines 263-270 elsif ($op eq "set-branch-defaults") { Link Here
263
                itemtype     => undef,
323
                itemtype     => undef,
264
                branchcode   => undef,
324
                branchcode   => undef,
265
                rules        => {
325
                rules        => {
266
                    maxissueqty       => $maxissueqty,
326
                    patron_maxissueqty             => $patron_maxissueqty,
267
                    maxonsiteissueqty => $maxonsiteissueqty,
327
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
328
                    holdallowed             => $holdallowed,
329
                    hold_fulfillment_policy => $hold_fulfillment_policy,
330
                    returnbranch            => $returnbranch,
268
                }
331
                }
269
            }
332
            }
270
        );
333
        );
Lines 292-299 elsif ($op eq "set-branch-defaults") { Link Here
292
                itemtype     => undef,
355
                itemtype     => undef,
293
                branchcode   => $branch,
356
                branchcode   => $branch,
294
                rules        => {
357
                rules        => {
295
                    maxissueqty       => $maxissueqty,
358
                    patron_maxissueqty             => $patron_maxissueqty,
296
                    maxonsiteissueqty => $maxonsiteissueqty,
359
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
360
                    holdallowed             => $holdallowed,
361
                    hold_fulfillment_policy => $hold_fulfillment_policy,
362
                    returnbranch            => $returnbranch,
297
                }
363
                }
298
            }
364
            }
299
        );
365
        );
Lines 310-322 elsif ($op eq "set-branch-defaults") { Link Here
310
}
376
}
311
elsif ($op eq "add-branch-cat") {
377
elsif ($op eq "add-branch-cat") {
312
    my $categorycode  = $input->param('categorycode');
378
    my $categorycode  = $input->param('categorycode');
313
    my $maxissueqty   = $input->param('maxissueqty');
379
    my $patron_maxissueqty   = $input->param('patron_maxissueqty');
314
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
380
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
315
    my $max_holds = $input->param('max_holds');
381
    my $max_holds = $input->param('max_holds');
316
    $maxissueqty =~ s/\s//g;
382
    $patron_maxissueqty =~ s/\s//g;
317
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
383
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
318
    $maxonsiteissueqty =~ s/\s//g;
384
    $patron_maxonsiteissueqty =~ s/\s//g;
319
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
385
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
320
    $max_holds =~ s/\s//g;
386
    $max_holds =~ s/\s//g;
321
    $max_holds = undef if $max_holds !~ /^\d+/;
387
    $max_holds = undef if $max_holds !~ /^\d+/;
322
388
Lines 329-336 elsif ($op eq "add-branch-cat") { Link Here
329
                    branchcode   => undef,
395
                    branchcode   => undef,
330
                    rules        => {
396
                    rules        => {
331
                        max_holds         => $max_holds,
397
                        max_holds         => $max_holds,
332
                        maxissueqty       => $maxissueqty,
398
                        patron_maxissueqty       => $patron_maxissueqty,
333
                        maxonsiteissueqty => $maxonsiteissueqty,
399
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
334
                    }
400
                    }
335
                }
401
                }
336
            );
402
            );
Lines 342-349 elsif ($op eq "add-branch-cat") { Link Here
342
                    itemtype     => undef,
408
                    itemtype     => undef,
343
                    rules        => {
409
                    rules        => {
344
                        max_holds         => $max_holds,
410
                        max_holds         => $max_holds,
345
                        maxissueqty       => $maxissueqty,
411
                        patron_maxissueqty       => $patron_maxissueqty,
346
                        maxonsiteissueqty => $maxonsiteissueqty,
412
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
347
                    }
413
                    }
348
                }
414
                }
349
            );
415
            );
Lines 356-363 elsif ($op eq "add-branch-cat") { Link Here
356
                branchcode   => $branch,
422
                branchcode   => $branch,
357
                rules        => {
423
                rules        => {
358
                    max_holds         => $max_holds,
424
                    max_holds         => $max_holds,
359
                    maxissueqty       => $maxissueqty,
425
                    patron_maxissueqty       => $patron_maxissueqty,
360
                    maxonsiteissueqty => $maxonsiteissueqty,
426
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
361
                }
427
                }
362
            }
428
            }
363
        );
429
        );
Lines 369-376 elsif ($op eq "add-branch-cat") { Link Here
369
                branchcode   => $branch,
435
                branchcode   => $branch,
370
                rules        => {
436
                rules        => {
371
                    max_holds         => $max_holds,
437
                    max_holds         => $max_holds,
372
                    maxissueqty       => $maxissueqty,
438
                    patron_maxissueqty       => $patron_maxissueqty,
373
                    maxonsiteissueqty => $maxonsiteissueqty,
439
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
374
                }
440
                }
375
            }
441
            }
376
        );
442
        );
(-)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 372-383 Link Here
372
                <tr>
372
                <tr>
373
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
373
                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
374
                    <td>
374
                    <td>
375
                        [% SET maxissueqty  = CirculationRules.Get( branchcode, undef, undef, 'maxissueqty' ) %]
375
                        [% SET patron_maxissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxissueqty' ) %]
376
                        <input type="text" name="maxissueqty" size="3" value="[% maxissueqty %]"/>
376
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty %]"/>
377
                    </td>
377
                    </td>
378
                    <td>
378
                    <td>
379
                        [% SET maxonsiteissueqty  = CirculationRules.Get( branchcode, undef, undef, 'maxonsiteissueqty' ) %]
379
                        [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxonsiteissueqty' ) %]
380
                        <input type="text" name="maxonsiteissueqty" size="3" value="[% maxonsiteissueqty %]"/>
380
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty %]"/>
381
                    </td>
381
                    </td>
382
                    <td>
382
                    <td>
383
                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
383
                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
Lines 495-505 Link Here
495
                    <th>&nbsp;</th>
495
                    <th>&nbsp;</th>
496
                </tr>
496
                </tr>
497
                [% FOREACH c IN categorycodes %]
497
                [% FOREACH c IN categorycodes %]
498
                    [% SET maxissueqty = CirculationRules.Get( branchcode, c, undef, 'maxissueqty' ) %]
498
                    [% SET patron_maxissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxissueqty' ) %]
499
                    [% SET maxonsiteissueqty = CirculationRules.Get( branchcode, c, undef, 'maxonsiteissueqty' ) %]
499
                    [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
500
                    [% SET max_holds = CirculationRules.Get( branchcode, c, undef, 'max_holds' ) %]
500
                    [% SET max_holds = CirculationRules.Get( branchcode, c, undef, 'max_holds' ) %]
501
501
502
                    [% IF maxissueqty || maxissueqty || max_holds %]
502
                    [% IF patron_maxissueqty || patron_maxonsiteissueqty || max_holds %]
503
                    <tr>
503
                    <tr>
504
                        <td>
504
                        <td>
505
                            [% IF c == '*'%]
505
                            [% IF c == '*'%]
Lines 509-523 Link Here
509
                            [% END %]
509
                            [% END %]
510
                        </td>
510
                        </td>
511
                        <td>
511
                        <td>
512
                            [% IF maxissueqty  %]
512
                            [% IF patron_maxissueqty  %]
513
                                [% maxissueqty %]
513
                                [% patron_maxissueqty %]
514
                            [% ELSE %]
514
                            [% ELSE %]
515
                                Unlimited
515
                                Unlimited
516
                            [% END %]
516
                            [% END %]
517
                        </td>
517
                        </td>
518
                        <td>
518
                        <td>
519
                            [% IF maxonsiteissueqty  %]
519
                            [% IF patron_maxonsiteissueqty  %]
520
                                [% maxonsiteissueqty %]
520
                                [% patron_maxonsiteissueqty %]
521
                            [% ELSE %]
521
                            [% ELSE %]
522
                                Unlimited
522
                                Unlimited
523
                            [% END %]
523
                            [% END %]
Lines 544-551 Link Here
544
                        [% END %]
544
                        [% END %]
545
                        </select>
545
                        </select>
546
                    </td>
546
                    </td>
547
                    <td><input name="maxissueqty" size="3" /></td>
547
                    <td><input name="patron_maxissueqty" size="3" /></td>
548
                    <td><input name="maxonsiteissueqty" size="3" /></td>
548
                    <td><input name="patron_maxonsiteissueqty" size="3" /></td>
549
                    <td><input name="max_holds" size="3" /></td>
549
                    <td><input name="max_holds" size="3" /></td>
550
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
550
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
551
                </tr>
551
                </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