@@ -, +, @@ 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/BiblioForceItemHold.pm | 53 ++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 10 ++++ installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 15 ++++++ .../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 | 19 +++++++- 9 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 Koha/Schema/Result/BiblioForceItemHold.pm --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -2440,6 +2440,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 $rs = Koha::Database->new()->schema()->resultset('BiblioForceItemHold'); + return 1 if $rs->find( $biblionumber ); +} + =head1 AUTHOR Koha Development Team --- a/Koha/Schema/Result/BiblioForceItemHold.pm +++ a/Koha/Schema/Result/BiblioForceItemHold.pm @@ -0,0 +1,53 @@ +use utf8; +package Koha::Schema::Result::BiblioForceItemHold; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::BiblioForceItemHold + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("biblio_force_item_holds"); + +=head1 ACCESSORS + +=head2 biblionumber + + data_type: 'integer' + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns("biblionumber", { data_type => "integer", is_nullable => 0 }); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("biblionumber"); + + +# Created by DBIx::Class::Schema::Loader v0.07036 @ 2014-12-18 10:00:44 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fJDe98uyvYlbqjrElzM/rQ + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -132,6 +132,16 @@ CREATE TABLE `biblio` ( -- table that stores bibliographic information ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- +-- Table structure for table `biblio_force_item_holds` +-- + +DROP TABLE IF EXISTS `biblio_force_item_holds`; +CREATE TABLE `biblio_force_item_holds` ( -- biblios with forced item holds + `biblionumber` int NOT NULL, -- primary key + PRIMARY KEY (`biblionumber`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -- Table structure for table `biblio_framework` -- --- 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/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -9585,6 +9585,21 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } + +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(qq| + CREATE TABLE biblio_force_item_holds + (biblionumber int NOT NULL PRIMARY KEY); + |); + $dbh->do(qq| + UPDATE systempreferences SET explanation = '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.' + WHERE variable = 'OPACItemHolds'; + |); + print "Upgrade to $DBversion done (Update OPACItemHolds description)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -494,7 +494,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 ) %] @@ -243,7 +243,7 @@ [% END # / IF OpacHoldNotes %] - [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %] + [% IF OPACItemHolds %]