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

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

Return to bug 18925