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

(-)a/admin/float_limits.pl (+83 lines)
Line 0 Link Here
1
## Please see file perltidy.ERR
2
## Please see file perltidy.ERR
3
## Please see file perltidy.ERR
4
## Please see file perltidy.ERR
5
#!/usr/bin/perl
6
# Copyright 2023 ByWater Solutions
7
#
8
# This file is part of Koha.
9
#
10
# Koha is free software; you can redistribute it and/or modify it
11
# under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 3 of the License, or
13
# (at your option) any later version.
14
#
15
# Koha is distributed in the hope that it will be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
23
use Modern::Perl;
24
use CGI qw ( -utf8 );
25
26
use C4::Context;
27
use C4::Output qw( output_html_with_http_headers );
28
use C4::Auth   qw( get_template_and_user );
29
30
use Koha::ItemTypes;
31
use Koha::Libraries;
32
use Koha::Library::FloatLimits;
33
34
my $input = CGI->new;
35
36
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37
    {
38
        template_name => "admin/float_limits.tt",
39
        query         => $input,
40
        type          => "intranet",
41
        flagsrequired => { parameters => 'manage_transfers' },
42
    }
43
);
44
45
my $op = $input->param('op');
46
47
if ( $op eq 'set_float_limits' ) {
48
    my $schema    = Koha::Database->new()->schema();
49
    my @branches  = Koha::Libraries->search()->as_list;
50
    my @itemtypes = Koha::ItemTypes->search()->as_list;
51
52
    $schema->txn_do(
53
        sub {
54
            $schema->storage->dbh->do("DELETE FROM library_float_limits");
55
            foreach my $branch (@branches) {
56
                foreach my $itemtype (@itemtypes) {
57
                    my $branchcode = $branch->id;
58
                    my $itype      = $itemtype->id;
59
60
                    my $limit = $input->param( "limit_" . $branchcode . "_" . $itype );
61
                    Koha::Library::FloatLimit->new(
62
                        {
63
                            branchcode  => $branchcode,
64
                            itemtype    => $itype,
65
                            float_limit => $limit,
66
                        }
67
                    )->store()
68
                        if $limit ne q{};    # update or insert
69
                }
70
            }
71
            $template->param( float_limits_updated => 1 );
72
        }
73
    );
74
}
75
76
my $limits_hash = {};
77
my $limits      = Koha::Library::FloatLimits->search();
78
while ( my $l = $limits->next ) {
79
    $limits_hash->{ $l->branchcode }->{ $l->itemtype } = $l->float_limit;
80
}
81
$template->param( limits => $limits_hash );
82
83
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (-33 / +34 lines)
Lines 24-62 Link Here
24
        </ul>
24
        </ul>
25
    [% END %]
25
    [% END %]
26
26
27
    [% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities || CAN_user_parameters_manage_curbside_pickups || CAN_user_parameters_manage_patron_restrictions ) %]
27
        [% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities || CAN_user_parameters_manage_curbside_pickups || CAN_user_parameters_manage_patron_restrictions ) %]
28
        <h5>Patrons and circulation</h5>
28
            <h5>Patrons and circulation</h5>
29
        <ul>
29
            <ul>
30
            [% IF ( CAN_user_parameters_manage_patron_categories ) %]
30
                [% IF ( CAN_user_parameters_manage_patron_categories ) %]
31
                <li><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></li>
31
                    <li><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></li>
32
            [% END %]
32
                [% END %]
33
            [% IF ( CAN_user_parameters_manage_circ_rules ) %]
33
                [% IF ( CAN_user_parameters_manage_circ_rules ) %]
34
                <li><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fine rules</a></li>
34
                    <li><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fine rules</a></li>
35
            [% END %]
35
                [% END %]
36
            [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
36
                [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
37
                <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
37
                    <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
38
            [% END %]
38
                [% END %]
39
            [% IF ( CAN_user_parameters_manage_transfers ) %]
39
                [% IF ( CAN_user_parameters_manage_transfers ) %]
40
                <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
40
                    <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
41
                <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li>
41
                    <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li>
42
            [% END %]
42
                    <li><a href="/cgi-bin/koha/admin/float_limits.pl">Library float limits</a></li>
43
            [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %]
43
                [% END %]
44
                <li><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></li>
44
                [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %]
45
            [% END %]
45
                    <li><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></li>
46
            [% IF ( Koha.Preference('UseCirculationDesks') && CAN_user_parameters_manage_libraries ) %]
46
                [% END %]
47
                <li><a href="/cgi-bin/koha/admin/desks.pl">Desks</a></li>
47
                [% IF ( Koha.Preference('UseCirculationDesks') && CAN_user_parameters_manage_libraries ) %]
48
            [% END %]
48
                    <li><a href="/cgi-bin/koha/admin/desks.pl">Desks</a></li>
49
            [% IF ( CAN_user_parameters_manage_cities ) %]
49
                [% END %]
50
                <li><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></li>
50
                [% IF ( CAN_user_parameters_manage_cities ) %]
51
            [% END %]
51
                    <li><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></li>
52
            [% IF ( CAN_user_parameters_manage_curbside_pickups ) %]
52
                [% END %]
53
                <li><a href="/cgi-bin/koha/admin/curbside_pickup.pl">Curbside pickup</a></li>
53
                [% IF ( CAN_user_parameters_manage_curbside_pickups ) %]
54
            [% END %]
54
                    <li><a href="/cgi-bin/koha/admin/curbside_pickup.pl">Curbside pickup</a></li>
55
            [% IF ( CAN_user_parameters_manage_patron_restrictions ) %]
55
                [% END %]
56
                <li><a href="/cgi-bin/koha/admin/restrictions.pl">Patron restriction types</a></li>
56
                [% IF ( CAN_user_parameters_manage_patron_restrictions ) %]
57
            [% END %]
57
                    <li><a href="/cgi-bin/koha/admin/restrictions.pl">Patron restriction types</a></li>
58
        </ul>
58
                [% END %]
59
    [% END %]
59
            </ul>
60
        [% END %]
60
61
61
    [% IF ( CAN_user_parameters_manage_accounts || ( Koha.Preference('UseCashRegisters') && CAN_user_parameters_manage_cash_registers ) ) %]
62
    [% IF ( CAN_user_parameters_manage_accounts || ( Koha.Preference('UseCashRegisters') && CAN_user_parameters_manage_cash_registers ) ) %]
62
        <h5>Accounting</h5>
63
        <h5>Accounting</h5>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/float_limits.tt (-1 / +125 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Branches %]
4
[% USE ItemTypes %]
5
[% USE Koha %]
6
[% SET footerjs = 1 %]
7
[% PROCESS 'i18n.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
9
<title
10
    >[% FILTER collapse %]
11
        [% t("Library float limits") | html %]
12
        &rsaquo; [% t("Administration") | html %] &rsaquo; [% t("Koha") | html %]
13
    [% END %]</title
14
>
15
[% INCLUDE 'doc-head-close.inc' %]
16
<style>
17
    .disabled-transfer {
18
        background-color: #ff8888;
19
    }
20
</style>
21
</head>
22
23
<body id="admin_library_float_limits" class="admin">
24
[% WRAPPER 'header.inc' %]
25
    [% INCLUDE 'prefs-admin-search.inc' %]
26
[% END %]
27
28
[% WRAPPER 'sub-header.inc' %]
29
    [% WRAPPER breadcrumbs %]
30
        [% WRAPPER breadcrumb_item %]
31
            <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
32
        [% END %]
33
        [% WRAPPER breadcrumb_item bc_active= 1 %]
34
            <span>Library float limits</span>
35
        [% END %]
36
    [% END #/ WRAPPER breadcrumbs %]
37
[% END #/ WRAPPER sub-header.inc %]
38
39
<div class="main container-fluid">
40
    <div class="row">
41
        <div class="col-sm-10 col-sm-push-2">
42
            <main>
43
                <h1 class="parameters"> Library float limits </h1>
44
45
                [% UNLESS Koha.Preference('UseLibraryFloatLimits') %]
46
                    <div class="dialog message">
47
                        <p>Because the "UseLibraryFloatLimits" system preference is currently not enabled, float limits will not be enforced.</p>
48
                        <p>
49
                            Go to the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=UseLibraryFloatLimits">UseLibraryFloatLimits</a>
50
                            system preference if you wish to enable this feature.
51
                        </p>
52
                    </div>
53
                [% END %]
54
55
                <form method="post" action="/cgi-bin/koha/admin/float_limits.pl" id="float_limit_form">
56
                    <input type="hidden" name="op" value="set_float_limits" />
57
                    <fieldset id="float_limits">
58
                        <div class="help">
59
                            <p>Specify the total number of items per itemtype that are allowed to float at each library.</p>
60
                            <p>
61
                                When an item is checked in, the librarian will get a request to transfer the item to the library with the lowest ratio of items held versus items allowed for that item type if the checkin library has reached
62
                                its' limit for that type of item.
63
                            </p>
64
                            <p> If a library and item type combination is left empty, that library will be ignored when finding the best library to transfer the item to. </p>
65
                        </div>
66
67
                        <div class="form_validation_errors"><span></span></div>
68
69
                        <table>
70
                            <tr>
71
                                <th>Item type \ Library</th>
72
                                [% FOR b IN Branches.all(unfiltered => 1) %]
73
                                    <th>[% b.branchname | html %]</th>
74
                                [% END %]
75
                            </tr>
76
77
                            [% FOR i IN ItemTypes.Get() %]
78
                                <tr>
79
                                    <th>[% i.description | html %]</th>
80
81
                                    [% FOR b IN Branches.all(unfiltered => 1) %]
82
                                        <td>
83
                                            [% SET bc = b.branchcode %]
84
                                            [% SET it = i.itemtype %]
85
                                            <input name="limit_[% bc | html %]_[% it | html %]" size="4" class="float_limit" value="[% limits.$bc.$it | html %]" />
86
                                        </td>
87
                                    [% END %]
88
                                </tr>
89
                            [% END %]
90
                        </table>
91
                    </fieldset>
92
93
                    <div class="form_validation_errors"><span></span></div>
94
95
                    <fieldset class="action"> <input type="submit" class="btn btn-primary" value="Save" /> <a href="/cgi-bin/koha/admin/float_limits.pl" class="cancel">Cancel</a> </fieldset>
96
                </form>
97
            </main>
98
        </div>
99
        <!-- /.col-sm-10.col-sm-push-2 -->
100
101
        <div class="col-sm-2 col-sm-pull-10">
102
            <aside> [% INCLUDE 'admin-menu.inc' %] </aside>
103
        </div>
104
        <!-- /.col-sm-2.col-sm-pull-10 -->
105
    </div>
106
    <!-- /.row -->
107
108
    [% MACRO jsinclude BLOCK %]
109
        [% Asset.js("js/admin-menu.js") | $raw %]
110
        <script>
111
            $(document).ready(function () {
112
                jQuery.validator.addClassRules("float_limit", {
113
                    digits: true,
114
                });
115
116
                $("#float_limit_form").validate({
117
                    errorContainer: ".form_validation_errors",
118
                    errorLabelContainer: ".form_validation_errors span",
119
                });
120
            });
121
        </script>
122
    [% END %]
123
124
    [% INCLUDE 'intranet-bottom.inc' %]</div
125
>

Return to bug 28530