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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 502-508 sub TooMany { Link Here
502
502
503
    # Now count total loans against the limit for the branch
503
    # Now count total loans against the limit for the branch
504
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
504
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
505
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty})) {
505
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
506
        my @bind_params = ();
506
        my @bind_params = ();
507
        my $branch_count_query = q|
507
        my $branch_count_query = q|
508
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
508
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
Lines 525-531 sub TooMany { Link Here
525
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
525
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
526
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
526
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
527
527
528
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
528
        if ( $onsite_checkout and $max_onsite_checkouts_allowed ne '' ) {
529
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
529
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
530
                return {
530
                return {
531
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
531
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
(-)a/admin/smart-rules.pl (-4 / +4 lines)
Lines 224-232 elsif ($op eq "set-branch-defaults") { Link Here
224
    my $returnbranch  = $input->param('returnbranch');
224
    my $returnbranch  = $input->param('returnbranch');
225
    my $max_holds = $input->param('max_holds');
225
    my $max_holds = $input->param('max_holds');
226
    $patron_maxissueqty =~ s/\s//g;
226
    $patron_maxissueqty =~ s/\s//g;
227
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
227
    $patron_maxissueqty = '' if $patron_maxissueqty !~ /^\d+/;
228
    $patron_maxonsiteissueqty =~ s/\s//g;
228
    $patron_maxonsiteissueqty =~ s/\s//g;
229
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
229
    $patron_maxonsiteissueqty = '' if $patron_maxonsiteissueqty !~ /^\d+/;
230
    $holdallowed =~ s/\s//g;
230
    $holdallowed =~ s/\s//g;
231
    $holdallowed = undef if $holdallowed !~ /^\d+/;
231
    $holdallowed = undef if $holdallowed !~ /^\d+/;
232
    $max_holds =~ s/\s//g;
232
    $max_holds =~ s/\s//g;
Lines 306-314 elsif ($op eq "add-branch-cat") { Link Here
306
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
306
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
307
    my $max_holds = $input->param('max_holds');
307
    my $max_holds = $input->param('max_holds');
308
    $patron_maxissueqty =~ s/\s//g;
308
    $patron_maxissueqty =~ s/\s//g;
309
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
309
    $patron_maxissueqty = '' if $patron_maxissueqty !~ /^\d+/;
310
    $patron_maxonsiteissueqty =~ s/\s//g;
310
    $patron_maxonsiteissueqty =~ s/\s//g;
311
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
311
    $patron_maxonsiteissueqty = '' if $patron_maxonsiteissueqty !~ /^\d+/;
312
    $max_holds =~ s/\s//g;
312
    $max_holds =~ s/\s//g;
313
    $max_holds = '' if $max_holds !~ /^\d+/;
313
    $max_holds = '' if $max_holds !~ /^\d+/;
314
314
(-)a/installer/data/mysql/atomicupdate/bug_18925.perl (-22 / +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, 'patron_maxissueqty', maxissueqty
6
            SELECT categorycode, branchcode, NULL, 'patron_maxissueqty', COALESCE( 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, 'patron_maxonsiteissueqty', maxonsiteissueqty
11
            SELECT categorycode, branchcode, NULL, 'patron_maxonsiteissueqty', COALESCE( 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, 'patron_maxissueqty', maxissueqty
20
            SELECT categorycode, NULL, NULL, 'patron_maxissueqty', COALESCE( 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, 'patron_maxonsiteissueqty', maxonsiteissueqty
25
            SELECT categorycode, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( 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, 'patron_maxissueqty', maxissueqty
34
            SELECT NULL, NULL, NULL, 'patron_maxissueqty', COALESCE( 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, 'patron_maxonsiteissueqty', maxonsiteissueqty
39
            SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( 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-75 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, 'patron_maxissueqty', maxissueqty
48
            SELECT NULL, branchcode, NULL, 'patron_maxissueqty', COALESCE( 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, 'patron_maxonsiteissueqty', maxonsiteissueqty
53
            SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( 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");
57
    }
57
    }
58
58
59
    if ( column_exists( 'issuingrules', 'maxissueqty' ) ) {
60
        $dbh->do("
61
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
62
            SELECT categorycode, branchcode, itemtype, 'maxissueqty', maxissueqty
63
            FROM issuingrules
64
        ");
65
        $dbh->do("
66
            INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
67
            SELECT categorycode, branchcode, itemtype, 'maxonsiteissueqty', maxonsiteissueqty
68
            FROM issuingrules
69
        ");
70
        $dbh->do("ALTER TABLE issuingrules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
71
    }
72
73
    SetVersion( $DBversion );
59
    SetVersion( $DBversion );
74
    print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n";
60
    print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n";
75
}
61
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-3 / +2 lines)
Lines 506-519 Link Here
506
                            [% END %]
506
                            [% END %]
507
                        </td>
507
                        </td>
508
                        <td>
508
                        <td>
509
                            [% IF patron_maxissueqty  %]
509
                            [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
510
                                [% patron_maxissueqty %]
510
                                [% patron_maxissueqty %]
511
                            [% ELSE %]
511
                            [% ELSE %]
512
                                Unlimited
512
                                Unlimited
513
                            [% END %]
513
                            [% END %]
514
                        </td>
514
                        </td>
515
                        <td>
515
                        <td>
516
                            [% IF patron_maxonsiteissueqty  %]
516
                            [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
517
                                [% patron_maxonsiteissueqty %]
517
                                [% patron_maxonsiteissueqty %]
518
                            [% ELSE %]
518
                            [% ELSE %]
519
                                Unlimited
519
                                Unlimited
520
- 

Return to bug 18925