Bugzilla – Attachment 160079 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 Koha Object(s) for Float Limits
Bug-28530-Add-Koha-Objects-for-Float-Limits.patch (text/plain), 4.85 KB, created by
ByWater Sandboxes
on 2023-12-19 19:38:33 UTC
(
hide
)
Description:
Bug 28530: Add Koha Object(s) for Float Limits
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2023-12-19 19:38:33 UTC
Size:
4.85 KB
patch
obsolete
>From 05008dfb2c4b20501458f80def4f1e1f5b1caae0 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 18 Dec 2023 14:19:40 -0500 >Subject: [PATCH] Bug 28530: Add Koha Object(s) for Float Limits > >Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> >--- > Koha/Library/FloatLimit.pm | 46 ++++++++++++++++ > Koha/Library/FloatLimits.pm | 104 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 150 insertions(+) > create mode 100644 Koha/Library/FloatLimit.pm > create mode 100644 Koha/Library/FloatLimits.pm > >diff --git a/Koha/Library/FloatLimit.pm b/Koha/Library/FloatLimit.pm >new file mode 100644 >index 0000000000..b7bd64bd90 >--- /dev/null >+++ b/Koha/Library/FloatLimit.pm >@@ -0,0 +1,46 @@ >+package Koha::Library::FloatLimit; >+ >+# Copyright ByWater Solutions 2023 >+# >+# 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 base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Library::FloatLimit - Koha Library::FloatLimit object class >+ >+=head1 API >+ >+=head2 Internal methods >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'LibraryFloatLimit'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Library/FloatLimits.pm b/Koha/Library/FloatLimits.pm >new file mode 100644 >index 0000000000..5697b38b1c >--- /dev/null >+++ b/Koha/Library/FloatLimits.pm >@@ -0,0 +1,104 @@ >+## Please see file perltidy.ERR >+## Please see file perltidy.ERR >+package Koha::Library::FloatLimits; >+ >+# Copyright ByWater Solutions 2016 >+# >+# 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 Koha::Database; >+ >+use Koha::Library::FloatLimit; >+use C4::Circulation qw(IsBranchTransferAllowed); >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Library::FloatLimits - Koha Library::FloatLimit object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=head3 lowest_ratio_library >+ >+=cut >+ >+sub lowest_ratio_library { >+ my ( $self, $item, $branchcode ) = @_; >+ >+ my $field = C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'; >+ my $query = qq{ >+ SELECT branchcode >+ FROM library_float_limits >+ LEFT JOIN items ON ( items.itype = library_float_limits.itemtype AND items.holdingbranch = library_float_limits.branchcode ) >+ LEFT JOIN biblioitems ON ( items.biblioitemnumber = biblioitems.biblioitemnumber ) >+ WHERE library_float_limits.itemtype = ? >+ AND ( $field = ? OR $field IS NULL ) >+ AND library_float_limits.float_limit != 0 >+ GROUP BY branchcode >+ ORDER BY COUNT(items.holdingbranch)/library_float_limits.float_limit ASC, library_float_limits.float_limit DESC; >+ }; >+ >+ my $results = C4::Context->dbh->selectall_arrayref( >+ $query, { Slice => {} }, $item->effective_itemtype, >+ $item->effective_itemtype >+ ); >+ >+ my $UseBranchTransferLimits = C4::Context->preference("UseBranchTransferLimits"); >+ my $BranchTransferLimitsType = >+ C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode'; >+ >+ foreach my $r (@$results) { >+ if ($UseBranchTransferLimits) { >+ my $allowed = C4::Circulation::IsBranchTransferAllowed( >+ $r->{branchcode}, # to >+ $branchcode, # from >+ $item->$BranchTransferLimitsType >+ ); >+ return $r->{branchcode} if $allowed; >+ } else { >+ return $r->{branchcode}; >+ } >+ } >+} >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'LibraryFloatLimit'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Library::FloatLimit'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >-- >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