@@ -, +, @@ don't have in his possession --- C4/Circulation.pm | 21 ++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../en/modules/admin/preferences/circulation.pref | 6 ++++++ .../prog/en/modules/reserve/request.tt | 3 +++ .../opac-tmpl/prog/en/modules/opac-reserve.tt | 8 ++++++-- opac/opac-reserve.pl | 5 +++++ reserve/request.pl | 8 +++++++- 8 files changed, 57 insertions(+), 3 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -3423,6 +3423,27 @@ sub TransferSlip { ); } +=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; --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -388,3 +388,4 @@ INSERT INTO systempreferences (variable, value, options, explanation, type) VALU INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z','Alphabet than can be expanded into browse links, e.g. on Home > Patrons',NULL,'free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RefundLostItemFeeOnReturn', '1', 'If enabled, the lost item fee charged to a borrower will be refunded when the lost item is returned.', NULL, 'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldsOnPatronsPossessions', '1', 'Allow holds on records that patron have items of it',NULL,'YesNo'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6113,6 +6113,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { 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); +} + + =head1 FUNCTIONS --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -435,6 +435,12 @@ Circulation: - 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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -213,6 +213,9 @@ function checkMultiHold() { [% IF ( none_available ) %]
  • No copies are available to be placed on hold
  • [% END %] + [% IF ( alreadypossession ) %] +
  • [% borrowerfirstname %] [% borrowersurname %] is already in possesion of one item
  • + [% END %] [% ELSE %]

    Cannot place hold on some items

    --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt @@ -292,8 +292,12 @@ [% UNLESS ( bibitemloo.bib_available ) %]
    No available items.
    [% ELSE %] -
    This title cannot be requested.
    - [% END %] + [% IF ( bibitemloo.already_patron_possession ) %] +
    This title cannot be requested because it's already in your possession.
    + [% ELSE %] +
    This title cannot be requested.
    + [% END %] + [% END %] [% END %] --- a/opac/opac-reserve.pl +++ a/opac/opac-reserve.pl @@ -537,6 +537,11 @@ foreach my $biblioNum (@biblionumbers) { $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; } --- a/reserve/request.pl +++ a/reserve/request.pl @@ -247,6 +247,11 @@ foreach my $biblionumber (@biblionumbers) { $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; @@ -268,7 +273,8 @@ foreach my $biblionumber (@biblionumbers) { $template->param( alreadyreserved => $alreadyreserved, messages => $messages, warnings => $warnings, - maxreserves=>$maxreserves + maxreserves=>$maxreserves, + alreadypossession => $alreadypossession, ); --