@@ -, +, @@ values at the list of items. Note which ones are available for hold and which ones aren't. cannot be reserved by patrons, and need override permission for staff to reserve. --- C4/Reserves.pm | 7 +++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../intranet-tmpl/prog/en/modules/admin/preferences/opac.pref | 5 +++++ 4 files changed, 20 insertions(+) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -470,6 +470,13 @@ sub CanItemBeReserved{ # item->{itype} will come for biblioitems if necessery my $item = GetItem($itemnumber); + if ((my $PreventHolds = C4::Context->preference('PreventItemHoldsFieldvalues'))) { + foreach my $part (split(/\|/, $PreventHolds)) { + my ($field, $val) = split(/=/, $part); + return 0 if (defined $item->{$field} && $item->{$field} eq $val); + } + } + # If an item is damaged and we don't allow holds on damaged items, we can stop right here return 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -317,6 +317,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'), ('Persona','0','','Use Mozilla Persona for login','YesNo'), ('PrefillItem','0','','When a new item is added, should it be prefilled with last created item values?','YesNo'), +('PreventItemHoldsFieldvalues', '', NULL, 'This is a pipe-delimited list of \"fieldname=value\", where fieldname is one of the fields from items -table in the database. If the field has the exact value, the item cannot be reserved. For example, \"ccode=PILA|location=OHE\" would prevent reserving the item if it\'s collection code is \'PILA\' or if it\'s location is \'OHE\'.', 'free') ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'), ('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'), ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -8551,6 +8551,13 @@ if (CheckVersion($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.17.00.XXX"; +if (CheckVersion($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('PreventItemHoldsFieldvalues', '', NULL, 'This is a pipe-delimited list of \"fieldname=value\", where fieldname is one of the fields from items -table in the database. If the field has the exact value, the item cannot be reserved. For example, \"ccode=PILA|location=OHE\" would prevent reserving the item if it''s collection code is ''PILA'' or if it''s location is ''OHE''.', 'free');"); + print "Upgrade to $DBversion done (Bug 12354 - Prevent reserving items based on item field values)\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 @@ -386,6 +386,11 @@ OPAC: no: "Don't allow" - patrons to access a list of the most checked out items on the OPAC. Note that this is somewhat experimental, and should be avoided if your collection has a large number of items. - + - Prevent reserving items with the following field values: + - pref: PreventItemHoldsFieldvalues + - . This is a pipe-delimited list of "fieldname=value", where fieldname is one of the fields from items -table in the database. If the field has the exact value, the item cannot be reserved. + - For example, "ccode=PILA|location=OHE" would prevent reserving the item if it's collection code is 'PILA' or if it's location is 'OHE'. + - - pref: suggestion choices: yes: Allow --