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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 505-511 sub TooMany { Link Here
505
505
506
    # Now count total loans against the limit for the branch
506
    # Now count total loans against the limit for the branch
507
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
507
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
508
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty})) {
508
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
509
        my @bind_params = ();
509
        my @bind_params = ();
510
        my $branch_count_query = q|
510
        my $branch_count_query = q|
511
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
511
            SELECT COUNT(*) AS total, COALESCE(SUM(onsite_checkout), 0) AS onsite_checkouts
Lines 528-534 sub TooMany { Link Here
528
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
528
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
529
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
529
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
530
530
531
        if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
531
        if ( $onsite_checkout and $max_onsite_checkouts_allowed ne '' ) {
532
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
532
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
533
                return {
533
                return {
534
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
534
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
(-)a/admin/smart-rules.pl (-4 / +4 lines)
Lines 244-252 elsif ($op eq "set-branch-defaults") { Link Here
244
    my $returnbranch  = $input->param('returnbranch');
244
    my $returnbranch  = $input->param('returnbranch');
245
    my $max_holds = $input->param('max_holds');
245
    my $max_holds = $input->param('max_holds');
246
    $patron_maxissueqty =~ s/\s//g;
246
    $patron_maxissueqty =~ s/\s//g;
247
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
247
    $patron_maxissueqty = '' if $patron_maxissueqty !~ /^\d+/;
248
    $patron_maxonsiteissueqty =~ s/\s//g;
248
    $patron_maxonsiteissueqty =~ s/\s//g;
249
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
249
    $patron_maxonsiteissueqty = '' if $patron_maxonsiteissueqty !~ /^\d+/;
250
    $holdallowed =~ s/\s//g;
250
    $holdallowed =~ s/\s//g;
251
    $holdallowed = undef if $holdallowed !~ /^\d+/;
251
    $holdallowed = undef if $holdallowed !~ /^\d+/;
252
    $max_holds =~ s/\s//g;
252
    $max_holds =~ s/\s//g;
Lines 326-334 elsif ($op eq "add-branch-cat") { Link Here
326
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
326
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
327
    my $max_holds = $input->param('max_holds');
327
    my $max_holds = $input->param('max_holds');
328
    $patron_maxissueqty =~ s/\s//g;
328
    $patron_maxissueqty =~ s/\s//g;
329
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
329
    $patron_maxissueqty = '' if $patron_maxissueqty !~ /^\d+/;
330
    $patron_maxonsiteissueqty =~ s/\s//g;
330
    $patron_maxonsiteissueqty =~ s/\s//g;
331
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
331
    $patron_maxonsiteissueqty = '' if $patron_maxonsiteissueqty !~ /^\d+/;
332
    $max_holds =~ s/\s//g;
332
    $max_holds =~ s/\s//g;
333
    $max_holds = undef if $max_holds !~ /^\d+/;
333
    $max_holds = undef if $max_holds !~ /^\d+/;
334
334
(-)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 547-560 Link Here
547
                            [% END %]
547
                            [% END %]
548
                        </td>
548
                        </td>
549
                        <td>
549
                        <td>
550
                            [% IF patron_maxissueqty  %]
550
                            [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
551
                                [% patron_maxissueqty | html %]
551
                                [% patron_maxissueqty | html %]
552
                            [% ELSE %]
552
                            [% ELSE %]
553
                                <span>Unlimited</span>
553
                                <span>Unlimited</span>
554
                            [% END %]
554
                            [% END %]
555
                        </td>
555
                        </td>
556
                        <td>
556
                        <td>
557
                            [% IF patron_maxonsiteissueqty  %]
557
                            [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
558
                                [% patron_maxonsiteissueqty | html %]
558
                                [% patron_maxonsiteissueqty | html %]
559
                            [% ELSE %]
559
                            [% ELSE %]
560
                                <span>Unlimited</span>
560
                                <span>Unlimited</span>
561
- 

Return to bug 18925