From 13136a90caaec8598fbe637cff6b6a8727435187 Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Mon, 12 Mar 2012 15:31:08 +1300 Subject: [PATCH] bug7398: OPACShowHoldsCount syspref Show holds count on OPAC detail if OPACShowHoldsCount is yes --- installer/data/mysql/sysprefs.sql | 3 ++- installer/data/mysql/updatedatabase.pl | 7 +++++++ .../prog/en/modules/admin/preferences/opac.pref | 6 ++++++ koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 9 +++++++++ opac/opac-detail.pl | 10 ++++++++++ 5 files changed, 34 insertions(+), 1 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index d16ff81..21f6de4 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -347,4 +347,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo'); -INSERT INTO systempreferences` (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelayCharge', '0', NULL , 'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.', 'free') +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelayCharge', '0', NULL , 'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.', 'free'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACShowHoldsCount',0,'Show the total number of holds in the OPAC details',NULL,'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index b844560..38d19e1 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4892,6 +4892,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.07.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACShowHoldsCount',0,'Show the total number of holds in the OPAC details',NULL,'YesNo')"); + print "Upgrade to $DBversion done (Added system preference OPACShowHoldsCount)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 1acc414..339107e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -343,6 +343,12 @@ OPAC: no: "Don't allow" - patrons to place holds on specific items in the OPAC. If this is disabled, users can only put a hold on the next available item. - + - pref: OPACShowHoldsCount + choices: + yes: Show + no: "Don't show" + - the total number of holds on the details page + - - pref: OpacRenewalAllowed choices: yes: Allow diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index 7af60a0..40c5389 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -589,6 +589,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () { Status [% IF ( itemdata_itemnotes ) %]Notes[% END %] Date Due + [% IF holds_count.defined %] + Holds + [% END %] [% FOREACH ITEM_RESULT IN ITEM_RESULTS %] [% IF ( item_level_itypes ) %][% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %][% ITEM_RESULT.description %][% END %][% END %] [% ITEM_RESULT.description %][% END %] @@ -601,10 +604,16 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% INCLUDE 'item-status.inc' item = ITEM_RESULT %] [% IF ( itemdata_itemnotes ) %][% ITEM_RESULT.itemnotes %][% END %] [% ITEM_RESULT.datedue %] + [% IF holds_count.defined %] + [% ITEM_RESULT.holds_count %] + [% END %] [% END %] [% END %] + [% IF holds_count.defined %] +
Holds: [% holds_count %]
+ [% END %] [% ELSE %] [% IF ( ALTERNATEHOLDINGS ) %] [% FOREACH ALTERNATEHOLDING IN ALTERNATEHOLDINGS %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 27684d4..b07c240 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -479,10 +479,20 @@ if ($dat->{'count'} >= 50 && !$viewallitems) { my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) ); +my %item_reserves; +if ( C4::Context->preference("OPACShowHoldsCount") ) { + my ($reserve_count,$reserves) = GetReservesFromBiblionumber($biblionumber); + $template->param( holds_count => $reserve_count ); + foreach (@$reserves) { + $item_reserves{ $_->{itemnumber} }++ if $_->{itemnumber}; + } +} + my $norequests = 1; my $branches = GetBranches(); my %itemfields; for my $itm (@items) { + $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; $norequests = 0 if ( (not $itm->{'wthdrawn'} ) && (not $itm->{'itemlost'} ) -- 1.6.5