Bug 14557: Add holds count to holds tab
authorKyle M Hall <kyle@bywatersolutions.com>
Fri, 17 Jul 2015 11:37:33 +0000 (07:37 -0400)
committerTomas Cohen Arazi <tomascohen@theke.io>
Wed, 26 Aug 2015 13:56:02 +0000 (10:56 -0300)
Some librarians have expressed that it would be helpful if the holds tab
displayed the count of holds for a record.

Test Plan:
1) Apply this patch
2) Note the Holds tab for a record now displays the number of holds for that record

Signed-off-by: Jason Robb <jrobb@sekls.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Koha/Template/Plugin/Biblio.pm [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc

diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm
new file mode 100644 (file)
index 0000000..3f9cc4f
--- /dev/null
@@ -0,0 +1,35 @@
+package Koha::Template::Plugin::Biblio;
+
+# Copyright ByWater Solutions 2015
+
+# 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 Template::Plugin;
+use base qw( Template::Plugin );
+
+use Koha::Holds;
+
+sub HoldsCount {
+    my ( $self, $biblionumber ) = @_;
+
+    my $holds = Koha::Holds->search( { biblionumber => $biblionumber } );
+
+    return $holds->count();
+}
+
+1;
index 158827f..4258aa3 100644 (file)
@@ -1,3 +1,4 @@
+[% USE Biblio %]
 [% SET biblio_object_id = object || biblionumber %]
 <div id="menu">
 <ul>
@@ -22,7 +23,7 @@
     [% IF ( moredetailview ) %]<li class="active">[% ELSE %]<li>[% END %]
     <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio_object_id %]">Items</a></li>
     [% IF ( CAN_user_reserveforothers ) %]
-    [% IF ( holdsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio_object_id %]">Holds</a></li>
+    [% IF ( holdsview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio_object_id %]">Holds ([% Biblio.HoldsCount( biblio_object_id ) %])</a></li>
     [% END %]
     [% IF ( EasyAnalyticalRecords ) %][% IF ( analyze ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio_object_id %]&amp;analyze=1">Analytics</a></li>[% END %]