@@ -, +, @@
UPDATE biblio SET forced_item_holds=1 WHERE biblionumber=?
Verify that you have two hold types for the single biblio and that
you have only item holds for the two other biblios.
---
C4/Reserves.pm | 17 +++++++++++++++
Koha/Schema/Result/Biblio.pm | 11 ++++++++-
installer/data/mysql/sysprefs.sql | 2 +-
.../prog/en/modules/admin/preferences/opac.pref | 3 +-
.../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 22 ++++++++++---------
opac/opac-reserve.pl | 3 ++
t/db_dependent/Reserves.t | 18 +++++++++++++++-
7 files changed, 61 insertions(+), 15 deletions(-)
--- a/C4/Reserves.pm
+++ a/C4/Reserves.pm
@@ -2434,6 +2434,23 @@ sub IsItemOnHoldAndFound {
return $found;
}
+=head2 CheckBiblioForceItemHolds
+
+ This subroutine returns true if item holds are forced for each biblio
+ by OPACItemHolds. If this pref is set to selective, the biblio should
+ be found in the designated table.
+ In other cases it returns undef.
+
+=cut
+
+sub CheckBiblioForceItemHolds {
+ my ( $biblionumber ) = @_;
+ return 1 if C4::Context->preference('OPACItemHolds') eq 'force';
+ return if C4::Context->preference('OPACItemHolds') ne 'selectiveforce';
+ my $rec = Koha::Database->new()->schema()->resultset('Biblio')->find( $biblionumber );
+ return 1 if $rec && $rec->force_item_holds;
+}
+
=head1 AUTHOR
Koha Development Team
--- a/Koha/Schema/Result/Biblio.pm
+++ a/Koha/Schema/Result/Biblio.pm
@@ -89,6 +89,11 @@ __PACKAGE__->table("biblio");
data_type: 'mediumtext'
is_nullable: 1
+=head2 force_item_holds
+
+ data_type: 'tinyint'
+ is_nullable: 1
+
=cut
__PACKAGE__->add_columns(
@@ -121,6 +126,8 @@ __PACKAGE__->add_columns(
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 },
"abstract",
{ data_type => "mediumtext", is_nullable => 1 },
+ "force_item_holds",
+ { data_type => "tinyint", is_nullable => 1 },
);
=head1 PRIMARY KEY
@@ -328,8 +335,8 @@ Composing rels: L -> set
__PACKAGE__->many_to_many("sets", "oai_sets_biblios", "set");
-# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0//8OGf7OteNnwT03g4QsA
+# Created by DBIx::Class::Schema::Loader v0.07036 @ 2015-03-05 11:43:19
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E+zNAx8qgwQKSj7JaYyDHg
__PACKAGE__->belongs_to(
"biblioitem",
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -262,7 +262,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'),
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'),
-('OPACItemHolds','1','0|1|force','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy.','Choice'),
+('OPACItemHolds','1','0|1|force|selectiveforce','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy. Selectiveforce works on specific biblios.','Choice'),
('OpacItemLocation','callnum','callnum|ccode|location','Show the shelving location of items in the opac','Choice'),
('OPACItemsResultsDisplay','0','','If OFF : show only the status of items in result list.If ON : show full location of items (branch+location+callnumber) as in staff interface','YesNo'),
('OpacKohaUrl','1',NULL,'Show \'Powered by Koha\' text on OPAC footer.',NULL),
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -499,7 +499,8 @@ OPAC:
no: "Don't allow"
yes: Allow
force: Force
- - 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. If this is forced, users must put a hold on a specific item.
+ selectiveforce: Selectively force
+ - 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. If this is forced, users must put a hold on a specific item. The 'selective force'-option works with a list of biblios with forced item holds.
-
- pref: OpacRenewalAllowed
choices:
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
@@ -119,7 +119,7 @@
[% FOREACH bibitemloo IN bibitemloop %]
-
+
[% IF ( bibitemloo.holdable ) %]
@@ -249,7 +249,7 @@
[% END # / IF OpacHoldNotes %]
- [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %]
+ [% IF OPACItemHolds %]
@@ -268,7 +268,7 @@
/>
[% END %]
- [% IF OPACItemHolds == "force" %]
+ [% IF bibitemloo.force_item_holds %]
- [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %]
+ [% IF OPACItemHolds %]
Select a specific item:
@@ -466,8 +466,8 @@
// Hides all 'specific copy' table rows on load.
$(".copiesrow").hide();
- [% IF OPACItemHolds == 'force' %]
- [% FOREACH bibitemloo IN bibitemloop %]
+ [% FOREACH bibitemloo IN bibitemloop %]
+ [% IF bibitemloo.force_item_holds %]
[% IF bibitemloo.holdable %]
$("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
$("#copiesrow_[% bibitemloo.biblionumber %]").show();
@@ -529,15 +529,17 @@
$("#place_on_hdr").show();
- [% IF OPACItemHolds == '1' %]
- $(".place_on_type").show();
+ [% FOREACH bibitemloo IN bibitemloop %]
+ [% IF OPACItemHolds == '1' OR !bibitemloo.force_item_holds %]
+ $("#holdrow_[% bibitemloo.biblionumber %]").find(".place_on_type").show();
// onload, selectany is checked
- $(".selectany").attr("checked", "checked");
+ $("#holdrow_[% bibitemloo.biblionumber %]").find(".selectany").attr("checked", "checked");
+ [% END %]
[% END %]
// If the user is *allowed* to choose a specific item
// The first one is preselected
- [% IF OPACItemHolds =="1" %]
+ [% IF OPACItemHolds %]
$("table.copiesrow").each(function(){
var id = suffixOf($(this).attr("id"), "_");
select_first_available(id);
--- a/opac/opac-reserve.pl
+++ a/opac/opac-reserve.pl
@@ -561,6 +561,9 @@ foreach my $biblioNum (@biblionumbers) {
if( $biblioLoopIter{holdable} ){ $anyholdable++; }
+ $biblioLoopIter{force_item_holds} =
+ C4::Reserves::CheckBiblioForceItemHolds( $biblioNum );
+
push @$biblioLoop, \%biblioLoopIter;
}
--- a/t/db_dependent/Reserves.t
+++ a/t/db_dependent/Reserves.t
@@ -17,7 +17,7 @@
use Modern::Perl;
-use Test::More tests => 53;
+use Test::More tests => 57;
use MARC::Record;
use DateTime::Duration;
@@ -506,6 +506,22 @@ is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 'OK', "Res
####### EO Bug 13113 <<<
####
+#Tests for CheckBiblioForceItemHolds
+$dbh->do('UPDATE biblio SET force_item_holds=NULL WHERE biblionumber=?',undef,($bibnum));
+C4::Context->set_preference('OPACItemHolds', 'force');
+is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
+ 'If OPACItemHolds==force, each bib should force item holds');
+C4::Context->set_preference('OPACItemHolds', 'selectiveforce');
+isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
+ 'For selectiveforce this bib should not be found');
+$dbh->do('UPDATE biblio SET force_item_holds=1 WHERE biblionumber=?',undef,($bibnum));
+is( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
+ 'For selectiveforce this bib should be found now');
+C4::Context->set_preference('OPACItemHolds', '1');
+isnt( C4::Reserves::CheckBiblioForceItemHolds($bibnum), 1,
+ 'For Allow this bib should return false again');
+#End of tests for CheckBiblioForceItemHolds
+
$dbh->rollback;
sub count_hold_print_messages {
--