Added a system preference to turn on/off this feature.
By default the system allow the patron to place holds even if it is in his possession.
Script to place holds check if the system preference is off and if patron has at least one item to block holds.
Messages to say that are already in patron possession added to templates.
Method to check if patron has one issue from one record added to C4::Circulation
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
);
}
+=head2 CheckIfIssuedToPatron
+
+ CheckIfIssuedToPatron($borrowernumber, $biblionumber)
+
+ Return 1 if any record item is issued to patron, otherwise return 0
+
+=cut
+
+sub CheckIfIssuedToPatron {
+ my ($borrowernumber, $biblionumber) = @_;
+ my $isissued = 0;
+
+ my $items = GetItemsByBiblioitemnumber($biblionumber);
+
+ foreach my $item (@{$items}) {
+ $isissued = 1 if ($item->{borrowernumber} && $item->{borrowernumber} eq $borrowernumber);
+ }
+
+ return $isissued;
+}
+
1;
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RenewalSendNotice','0', NULL, '', 'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HTML5MediaEnabled','not','Show a tab with a HTML5 media player for files catalogued in field 856','not|opac|staff|both','Choice');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','Media file extensions','','free');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldsOnPatronsPossessions', '1', 'Allow holds on records that patron have items of it',NULL,'YesNo');
print "Upgrade to $DBversion done (Bug 8782: Add field subscription.closed)\n";
SetVersion($DBversion);
}
+$DBversion = "XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldsOnPatronsPossessions', '1', 'Allow holds on records that patron have items of it',NULL,'YesNo')"
+ print "Upgrade to $DBversion done (Bug 9206: Only allow place holds in records that the patron don't have in his possession)\n";
+ SetVersion($DBversion);
+}
+
+
$DBversion = "3.11.00.005";
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
- pref: decreaseLoanHighHoldsValue
class: integer
- holds.
+ -
+ - pref: AllowHoldsOnPatronsPossessions
+ choices:
+ yes: Allow
+ no: "Don't allow"
+ - patrons to place holds on records that he already have any item of it in his possession.
Fines Policy:
-
- Calculate fines based on days overdue
[% IF ( none_available ) %]
<li> <strong>No copies are available</strong> to be placed on hold</li>
[% END %]
+ [% IF ( alreadypossession ) %]
+ <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>is already in possesion</strong> of one item</li>
+ [% END %]
</ul>
[% ELSE %]
<h3>Cannot place hold on some items</h3>
[% UNLESS ( bibitemloo.bib_available ) %]
<div class="bibmessage">No available items.</div>
[% ELSE %]
- <div class="bibmessage">This title cannot be requested.</div>
- [% END %]
+ [% IF ( bibitemloo.already_patron_possession ) %]
+ <div class="bibmessage">This title cannot be requested because it's already in your possession.</div>
+ [% ELSE %]
+ <div class="bibmessage">This title cannot be requested.</div>
+ [% END %]
+ [% END %]
[% END %]
$biblioLoopIter{holdable} = undef;
$anyholdable = undef;
}
+ if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) {
+ $biblioLoopIter{holdable} = undef;
+ $biblioLoopIter{already_patron_possession} = 1;
+ $anyholdable = undef;
+ }
push @$biblioLoop, \%biblioLoopIter;
}
$warnings = 1;
$maxreserves = 1;
}
+ if (not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowerinfo->{borrowernumber},$biblionumber)) {
+ $warnings = 1;
+ $alreadypossession = 1;
+ }
+
# get existing reserves .....
my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
my $totalcount = $count;
$template->param( alreadyreserved => $alreadyreserved,
messages => $messages,
warnings => $warnings,
- maxreserves=>$maxreserves
+ maxreserves=>$maxreserves,
+ alreadypossession => $alreadypossession,
);