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

(-)a/C4/Circulation.pm (-2 / +2 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->{patron_maxissueqty})) {
518
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
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 538-544 sub TooMany { Link Here
538
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
538
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
539
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_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 $max_onsite_checkouts_allowed ne '' ) {
542
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
542
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
543
                return {
543
                return {
544
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
544
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
(-)a/admin/smart-rules.pl (-4 / +4 lines)
Lines 232-240 elsif ($op eq "set-branch-defaults") { Link Here
232
    my $returnbranch  = $input->param('returnbranch');
232
    my $returnbranch  = $input->param('returnbranch');
233
    my $max_holds = $input->param('max_holds');
233
    my $max_holds = $input->param('max_holds');
234
    $patron_maxissueqty =~ s/\s//g;
234
    $patron_maxissueqty =~ s/\s//g;
235
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
235
    $patron_maxissueqty = '' if $patron_maxissueqty !~ /^\d+/;
236
    $patron_maxonsiteissueqty =~ s/\s//g;
236
    $patron_maxonsiteissueqty =~ s/\s//g;
237
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
237
    $patron_maxonsiteissueqty = '' if $patron_maxonsiteissueqty !~ /^\d+/;
238
    $holdallowed =~ s/\s//g;
238
    $holdallowed =~ s/\s//g;
239
    $holdallowed = undef if $holdallowed !~ /^\d+/;
239
    $holdallowed = undef if $holdallowed !~ /^\d+/;
240
    $max_holds =~ s/\s//g;
240
    $max_holds =~ s/\s//g;
Lines 314-322 elsif ($op eq "add-branch-cat") { Link Here
314
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
314
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
315
    my $max_holds = $input->param('max_holds');
315
    my $max_holds = $input->param('max_holds');
316
    $patron_maxissueqty =~ s/\s//g;
316
    $patron_maxissueqty =~ s/\s//g;
317
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
317
    $patron_maxissueqty = '' if $patron_maxissueqty !~ /^\d+/;
318
    $patron_maxonsiteissueqty =~ s/\s//g;
318
    $patron_maxonsiteissueqty =~ s/\s//g;
319
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
319
    $patron_maxonsiteissueqty = '' if $patron_maxonsiteissueqty !~ /^\d+/;
320
    $max_holds =~ s/\s//g;
320
    $max_holds =~ s/\s//g;
321
    $max_holds = '' if $max_holds !~ /^\d+/;
321
    $max_holds = '' if $max_holds !~ /^\d+/;
322
322
(-)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 509-522 Link Here
509
                            [% END %]
509
                            [% END %]
510
                        </td>
510
                        </td>
511
                        <td>
511
                        <td>
512
                            [% IF patron_maxissueqty  %]
512
                            [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
513
                                [% patron_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 patron_maxonsiteissueqty  %]
519
                            [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
520
                                [% patron_maxonsiteissueqty %]
520
                                [% patron_maxonsiteissueqty %]
521
                            [% ELSE %]
521
                            [% ELSE %]
522
                                Unlimited
522
                                Unlimited
523
- 

Return to bug 18925