Bugzilla – Attachment 160074 Details for
Bug 28530
Allow configuration of floating limits by item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28530: Add float limits editor
Bug-28530-Add-float-limits-editor.patch (text/plain), 9.92 KB, created by
Kyle M Hall (khall)
on 2023-12-19 19:11:00 UTC
(
hide
)
Description:
Bug 28530: Add float limits editor
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-12-19 19:11:00 UTC
Size:
9.92 KB
patch
obsolete
>From 7154b4673081d26af378a15b316c0fb80989bf61 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 18 Dec 2023 14:23:09 -0500 >Subject: [PATCH] Bug 28530: Add float limits editor > >--- > admin/float_limits.pl | 83 +++++++++++ > .../prog/en/includes/admin-menu.inc | 1 + > .../prog/en/modules/admin/float_limits.tt | 132 ++++++++++++++++++ > 3 files changed, 216 insertions(+) > create mode 100755 admin/float_limits.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/float_limits.tt > >diff --git a/admin/float_limits.pl b/admin/float_limits.pl >new file mode 100755 >index 00000000000..92133412f8c >--- /dev/null >+++ b/admin/float_limits.pl >@@ -0,0 +1,83 @@ >+## Please see file perltidy.ERR >+## Please see file perltidy.ERR >+## Please see file perltidy.ERR >+## Please see file perltidy.ERR >+#!/usr/bin/perl >+# Copyright 2023 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+ >+use C4::Context; >+use C4::Output qw( output_html_with_http_headers ); >+use C4::Auth qw( get_template_and_user ); >+ >+use Koha::ItemTypes; >+use Koha::Libraries; >+use Koha::Library::FloatLimits; >+ >+my $input = CGI->new; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "admin/float_limits.tt", >+ query => $input, >+ type => "intranet", >+ flagsrequired => { parameters => 'manage_transfers' }, >+ } >+); >+ >+my $op = $input->param('op'); >+ >+if ( $op eq 'set_float_limits' ) { >+ my $schema = Koha::Database->new()->schema(); >+ my @branches = Koha::Libraries->search()->as_list; >+ my @itemtypes = Koha::ItemTypes->search()->as_list; >+ >+ $schema->txn_do( >+ sub { >+ $schema->storage->dbh->do("DELETE FROM library_float_limits"); >+ foreach my $branch (@branches) { >+ foreach my $itemtype (@itemtypes) { >+ my $branchcode = $branch->id; >+ my $itype = $itemtype->id; >+ >+ my $limit = $input->param( "limit_" . $branchcode . "_" . $itype ); >+ Koha::Library::FloatLimit->new( >+ { >+ branchcode => $branchcode, >+ itemtype => $itype, >+ float_limit => $limit, >+ } >+ )->store() >+ if $limit ne q{}; # update or insert >+ } >+ } >+ $template->param( float_limits_updated => 1 ); >+ } >+ ); >+} >+ >+my $limits_hash = {}; >+my $limits = Koha::Library::FloatLimits->search(); >+while ( my $l = $limits->next ) { >+ $limits_hash->{ $l->branchcode }->{ $l->itemtype } = $l->float_limit; >+} >+$template->param( limits => $limits_hash ); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index c7caffc0143..71ecf63c6ba 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -41,6 +41,7 @@ > [% IF ( CAN_user_parameters_manage_transfers ) %] > <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li> > <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li> >+ <li><a href="/cgi-bin/koha/admin/float_limits.pl">Library float limits</a></li> > [% END %] > [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %] > <li><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/float_limits.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/float_limits.tt >new file mode 100644 >index 00000000000..454c022ee88 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/float_limits.tt >@@ -0,0 +1,132 @@ >+[% USE raw %] >+[% USE Asset %] >+[% USE Branches %] >+[% USE ItemTypes %] >+[% USE Koha %] >+[% SET footerjs = 1 %] >+[% PROCESS 'i18n.inc' %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>[% FILTER collapse %] >+ [% t("Library float limits") | html %] › >+ [% t("Administration") | html %] › >+ [% t("Koha") | html %] >+[% END %]</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<style> >+.disabled-transfer { >+ background-color: #FF8888; >+} >+</style> >+</head> >+ >+<body id="admin_library_float_limits" class="admin"> >+[% WRAPPER 'header.inc' %] >+ [% INCLUDE 'prefs-admin-search.inc' %] >+[% END %] >+ >+[% WRAPPER 'sub-header.inc' %] >+ [% WRAPPER breadcrumbs %] >+ [% WRAPPER breadcrumb_item %] >+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >+ [% END %] >+ [% WRAPPER breadcrumb_item bc_active= 1 %] >+ <span>Library float limits</span> >+ [% END %] >+ [% END #/ WRAPPER breadcrumbs %] >+[% END #/ WRAPPER sub-header.inc %] >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ >+ <h1 class="parameters"> >+ Library float limits >+ </h1> >+ >+ [% UNLESS Koha.Preference('UseLibraryFloatLimits') %] >+ <div class="dialog message"> >+ <p>Because the "UseLibraryFloatLimits" system preference is currently not enabled, float limits will not be enforced.</p> >+ <p> >+ Go to the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=UseLibraryFloatLimits">UseLibraryFloatLimits</a> >+ system preference if you wish to enable this feature. >+ </p> >+ </div> >+ [% END %] >+ >+ <form method="post" action="/cgi-bin/koha/admin/float_limits.pl" id="float_limit_form"> >+ <input type="hidden" name="op" value="set_float_limits" /> >+ <fieldset id="float_limits"> >+ <div class="help"> >+ <p>Specify the total number of items per itemtype that are allowed to float at each library.</p> >+ <p> >+ 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 its' limit for that type of item. >+ </p> >+ <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> >+ </div> >+ >+ <div class="form_validation_errors"><span></span></div> >+ >+ <table> >+ <tr> >+ <th>Item type \ Library</th> >+ [% FOR b IN Branches.all(unfiltered => 1) %] >+ <th>[% b.branchname | html %]</th> >+ [% END %] >+ </tr> >+ >+ [% FOR i IN ItemTypes.Get() %] >+ <tr> >+ <th>[% i.description | html %]</th> >+ >+ [% FOR b IN Branches.all(unfiltered => 1) %] >+ <td> >+ [% SET bc = b.branchcode %] >+ [% SET it = i.itemtype %] >+ <input name="limit_[% bc | html %]_[% it | html %]" size="4" class="float_limit" value="[% limits.$bc.$it | html %]" /> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </table> >+ </fieldset> >+ >+ <div class="form_validation_errors"><span></span></div> >+ >+ <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> >+ </form> >+ >+ </main> >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'admin-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ </div> <!-- /.row --> >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") | $raw %] >+ <script> >+ $(document).ready(function(){ >+ jQuery.validator.addClassRules("float_limit", { >+ digits: true >+ }); >+ >+ $("#float_limit_form").validate({ >+ errorContainer: ".form_validation_errors", >+ errorLabelContainer: ".form_validation_errors span", >+ }); >+ }); >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28530
:
160038
|
160039
|
160040
|
160041
|
160042
|
160043
|
160044
|
160045
|
160046
|
160047
|
160048
|
160049
|
160050
|
160053
|
160054
|
160055
|
160056
|
160057
|
160058
|
160061
|
160062
|
160063
|
160064
|
160065
|
160066
|
160067
|
160068
|
160071
|
160072
|
160073
|
160074
|
160075
|
160076
|
160077
|
160078
|
160079
|
160080
|
160081
|
160082
|
160083
|
160084
|
163919
|
168343
|
168344
|
168345
|
168346
|
168347
|
168348
|
168349
|
168350