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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2202-2208 sub AddReturn { Link Here
2202
        my $limit = Koha::Library::FloatLimits->find( { itemtype => $effective_itemtype, branchcode => $branch } );
2202
        my $limit = Koha::Library::FloatLimits->find( { itemtype => $effective_itemtype, branchcode => $branch } );
2203
        if ($limit) {
2203
        if ($limit) {
2204
            my $count = Koha::Items->count( { itype => $limit->itemtype } );
2204
            my $count = Koha::Items->count( { itype => $limit->itemtype } );
2205
            if ( $count >= $limit->limit ) {
2205
            if ( $count >= $limit->float_limit ) {
2206
                my $transfer_branchcode = Koha::Library::FloatLimits->lowest_ratio_library( $item, $branch );
2206
                my $transfer_branchcode = Koha::Library::FloatLimits->lowest_ratio_library( $item, $branch );
2207
                if ( $transfer_branchcode ne $branch ) {
2207
                if ( $transfer_branchcode ne $branch ) {
2208
                    $returnbranch     = $transfer_branchcode;
2208
                    $returnbranch     = $transfer_branchcode;
(-)a/Koha/Library/FloatLimits.pm (-2 / +3 lines)
Lines 50-58 sub lowest_ratio_library { Link Here
50
        LEFT JOIN items ON ( items.itype = library_float_limits.itemtype AND items.holdingbranch = library_float_limits.branchcode )
50
        LEFT JOIN items ON ( items.itype = library_float_limits.itemtype AND items.holdingbranch = library_float_limits.branchcode )
51
        LEFT JOIN biblioitems ON ( items.biblioitemnumber = biblioitems.biblioitemnumber )
51
        LEFT JOIN biblioitems ON ( items.biblioitemnumber = biblioitems.biblioitemnumber )
52
        WHERE library_float_limits.itemtype = ?
52
        WHERE library_float_limits.itemtype = ?
53
              AND $field = ?
53
              AND ( $field = ? OR $field IS NULL )
54
              AND library_float_limits.float_limit != 0
54
        GROUP BY branchcode
55
        GROUP BY branchcode
55
        ORDER BY COUNT(items.holdingbranch)/library_float_limits.limit
56
        ORDER BY COUNT(items.holdingbranch)/library_float_limits.float_limit ASC, library_float_limits.float_limit DESC;
56
    };
57
    };
57
58
58
    my $results = C4::Context->dbh->selectall_arrayref(
59
    my $results = C4::Context->dbh->selectall_arrayref(
(-)a/admin/float_limits.pl (-5 / +5 lines)
Lines 60-71 if ( $op eq 'set_float_limits' ) { Link Here
60
                    my $limit = $input->param( "limit_" . $branchcode . "_" . $itype );
60
                    my $limit = $input->param( "limit_" . $branchcode . "_" . $itype );
61
                    Koha::Library::FloatLimit->new(
61
                    Koha::Library::FloatLimit->new(
62
                        {
62
                        {
63
                            branchcode => $branchcode,
63
                            branchcode  => $branchcode,
64
                            itemtype   => $itype,
64
                            itemtype    => $itype,
65
                            limit      => $limit
65
                            float_limit => $limit,
66
                        }
66
                        }
67
                    )->store()
67
                    )->store()
68
                        if $limit;    # update or insert
68
                        if $limit ne q{};    # update or insert
69
                }
69
                }
70
            }
70
            }
71
            $template->param( float_limits_updated => 1 );
71
            $template->param( float_limits_updated => 1 );
Lines 76-82 if ( $op eq 'set_float_limits' ) { Link Here
76
my $limits_hash = {};
76
my $limits_hash = {};
77
my $limits      = Koha::Library::FloatLimits->search();
77
my $limits      = Koha::Library::FloatLimits->search();
78
while ( my $l = $limits->next ) {
78
while ( my $l = $limits->next ) {
79
    $limits_hash->{ $l->branchcode }->{ $l->itemtype } = $l->limit;
79
    $limits_hash->{ $l->branchcode }->{ $l->itemtype } = $l->float_limit;
80
}
80
}
81
$template->param( limits => $limits_hash );
81
$template->param( limits => $limits_hash );
82
82
(-)a/installer/data/mysql/atomicupdate/bug_28530.pl (-2 / +2 lines)
Lines 21-33 return { Link Here
21
        );
21
        );
22
        say $out "Added new system preference 'UseLibraryFloatLimits'";
22
        say $out "Added new system preference 'UseLibraryFloatLimits'";
23
23
24
        unless ( TableExists('search_filters') ) {
24
        unless ( TableExists('library_float_limits') ) {
25
            $dbh->do(
25
            $dbh->do(
26
                q{
26
                q{
27
                CREATE TABLE `library_float_limits` (
27
                CREATE TABLE `library_float_limits` (
28
                `branchcode` varchar(10) NOT NULL,
28
                `branchcode` varchar(10) NOT NULL,
29
                `itemtype` varchar(10) NOT NULL,
29
                `itemtype` varchar(10) NOT NULL,
30
                `limit` int(11) NULL DEFAULT NULL,
30
                `float_limit` int(11) NULL DEFAULT NULL,
31
                PRIMARY KEY (`branchcode`,`itemtype`),
31
                PRIMARY KEY (`branchcode`,`itemtype`),
32
                CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
32
                CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
33
                CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
33
                CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 6363-6369 DROP TABLE IF EXISTS `library_float_limits`; Link Here
6363
CREATE TABLE `library_float_limits` (
6363
CREATE TABLE `library_float_limits` (
6364
  `branchcode` varchar(10) NOT NULL,
6364
  `branchcode` varchar(10) NOT NULL,
6365
  `itemtype` varchar(10) NOT NULL,
6365
  `itemtype` varchar(10) NOT NULL,
6366
  `limit` int(11) NULL DEFAULT NULL,
6366
  `float_limit` int(11) NULL DEFAULT NULL,
6367
  PRIMARY KEY (`branchcode`,`itemtype`),
6367
  PRIMARY KEY (`branchcode`,`itemtype`),
6368
  CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6368
  CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6369
  CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
6369
  CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (+1 lines)
Lines 41-46 Link Here
41
            [% IF ( CAN_user_parameters_manage_transfers ) %]
41
            [% IF ( CAN_user_parameters_manage_transfers ) %]
42
                <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
42
                <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
43
                <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li>
43
                <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li>
44
                <li><a href="/cgi-bin/koha/admin/float_limits.pl">Library float limits</a></li>
44
            [% END %]
45
            [% END %]
45
            [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %]
46
            [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %]
46
                <li><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></li>
47
                <li><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></li>
(-)a/t/db_dependent/Circulation/Returns.t (-9 / +9 lines)
Lines 429-453 subtest 'Test library float limits' => sub { Link Here
429
429
430
    my $limit1 = Koha::Library::FloatLimit->new(
430
    my $limit1 = Koha::Library::FloatLimit->new(
431
        {
431
        {
432
            branchcode => $library1->{branchcode},
432
            branchcode  => $library1->{branchcode},
433
            itemtype   => $itemtype->itemtype,
433
            itemtype    => $itemtype->itemtype,
434
            limit      => 1,
434
            float_limit => 1,
435
        }
435
        }
436
    )->store();
436
    )->store();
437
437
438
    my $limit2 = Koha::Library::FloatLimit->new(
438
    my $limit2 = Koha::Library::FloatLimit->new(
439
        {
439
        {
440
            branchcode => $library2->{branchcode},
440
            branchcode  => $library2->{branchcode},
441
            itemtype   => $itemtype->itemtype,
441
            itemtype    => $itemtype->itemtype,
442
            limit      => 100,
442
            float_limit => 100,
443
        }
443
        }
444
    )->store();
444
    )->store();
445
445
446
    my $limit3 = Koha::Library::FloatLimit->new(
446
    my $limit3 = Koha::Library::FloatLimit->new(
447
        {
447
        {
448
            branchcode => $library3->{branchcode},
448
            branchcode  => $library3->{branchcode},
449
            itemtype   => $itemtype->itemtype,
449
            itemtype    => $itemtype->itemtype,
450
            limit      => 1000,
450
            float_limit => 1000,
451
        }
451
        }
452
    )->store();
452
    )->store();
453
453
(-)a/t/db_dependent/Koha/Library/FloatLimits.t (-12 / +11 lines)
Lines 87-111 my $item = $builder->build_sample_item( Link Here
87
87
88
my $limit1 = Koha::Library::FloatLimit->new(
88
my $limit1 = Koha::Library::FloatLimit->new(
89
    {
89
    {
90
        branchcode => $library1->{branchcode},
90
        branchcode  => $library1->{branchcode},
91
        itemtype   => $itemtype->itemtype,
91
        itemtype    => $itemtype->itemtype,
92
        limit      => 1,
92
        float_limit => 1,
93
    }
93
    }
94
)->store();
94
)->store();
95
95
96
my $limit2 = Koha::Library::FloatLimit->new(
96
my $float_limit2 = Koha::Library::FloatLimit->new(
97
    {
97
    {
98
        branchcode => $library2->{branchcode},
98
        branchcode  => $library2->{branchcode},
99
        itemtype   => $itemtype->itemtype,
99
        itemtype    => $itemtype->itemtype,
100
        limit      => 100,
100
        float_limit => 100,
101
    }
101
    }
102
)->store();
102
)->store();
103
103
104
my $limit3 = Koha::Library::FloatLimit->new(
104
my $float_limit3 = Koha::Library::FloatLimit->new(
105
    {
105
    {
106
        branchcode => $library3->{branchcode},
106
        branchcode  => $library3->{branchcode},
107
        itemtype   => $itemtype->itemtype,
107
        itemtype    => $itemtype->itemtype,
108
        limit      => 1000,
108
        float_limit => 1000,
109
    }
109
    }
110
)->store();
110
)->store();
111
111
112
- 

Return to bug 28530