@@ -, +, @@
you should not be able to ( default is 1 per record )
you should be able to place 3 holds for one patron on a given
record. A 4th hold should result in a message stating the patron
has placed the max number of holds allowed on this record.
---
C4/Reserves.pm | 59 ++++++++++++--------
installer/data/mysql/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 6 ++
.../en/modules/admin/preferences/circulation.pref | 7 ++-
.../prog/en/modules/reserve/request.tt | 25 ++++----
.../opac-tmpl/prog/en/modules/opac-reserve.tt | 6 ++-
opac/opac-reserve.pl | 29 ++++++----
reserve/request.pl | 9 +++-
8 files changed, 92 insertions(+), 50 deletions(-)
--- a/C4/Reserves.pm
+++ a/C4/Reserves.pm
@@ -373,36 +373,47 @@ sub GetReservesFromItemnumber {
=head2 GetReservesFromBorrowernumber
- $borrowerreserv = GetReservesFromBorrowernumber($borrowernumber,$tatus);
-
-TODO :: Descritpion
+ $borrowerreserv = GetReservesFromBorrowernumber($borrowernumber[,$status][,$biblionumber][,$itemnumber]);
=cut
sub GetReservesFromBorrowernumber {
- my ( $borrowernumber, $status ) = @_;
- my $dbh = C4::Context->dbh;
- my $sth;
- if ($status) {
- $sth = $dbh->prepare("
- SELECT *
- FROM reserves
- WHERE borrowernumber=?
- AND found =?
- ORDER BY reservedate
- ");
- $sth->execute($borrowernumber,$status);
- } else {
- $sth = $dbh->prepare("
- SELECT *
- FROM reserves
- WHERE borrowernumber=?
- ORDER BY reservedate
- ");
- $sth->execute($borrowernumber);
+ my ( $borrowernumber, $found, $biblionumber, $itemnumber ) = @_;
+
+ my @params;
+
+ my $sql = "SELECT * FROM reserves WHERE borrowernumber = ?";
+ push( @params, $borrowernumber );
+
+ if ( $biblionumber ) {
+ $sql .= " AND biblionumber = ? ";
+ push( @params, $biblionumber );
+ }
+
+ if ( $itemnumber ) {
+ $sql .= " AND itemnumber = ? ";
+ push( @params, $itemnumber );
+ }
+
+ if ( $found ) {
+ $sql .= " AND found = ? ";
+ push( @params, $found );
}
+
+ $sql .= " ORDER BY reservedate ";
+
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare( $sql );
+
+ $sth->execute( @params );
+
my $data = $sth->fetchall_arrayref({});
- return @$data;
+
+ if ( scalar @$data ) {
+ return @$data;
+ } else {
+ return ();
+ }
}
#-------------------------------------------------------------------------------------
=head2 CanBookBeReserved
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -423,3 +423,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES (
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('DisplayIconsXSLT', '1', '', 'If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.', 'YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice')
+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('MaxHoldsPerRecord', '1', 'The maximum number of holds allowed per bibliographic record per borrower', NULL, NULL);
--- a/installer/data/mysql/updatedatabase.pl
+++ a/installer/data/mysql/updatedatabase.pl
@@ -6771,6 +6771,12 @@ if ( CheckVersion($DBversion) ) {
SetVersion ($DBversion);
}
+$DBversion = "3.11.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('MaxHoldsPerRecord', '1', 'The maximum number of holds allowed per bibliographic record per borrower', NULL, NULL)");
+ print "Upgrade to $DBversion done (Add syspref MaxHoldsPerRecord)\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
@@ -404,7 +404,12 @@ Circulation:
- Patrons can only have
- pref: maxreserves
class: integer
- - holds at once.
+ - total holds at a time.
+ -
+ - Patrons can only place
+ - pref: MaxHoldsPerRecord
+ class: integer
+ - holds on a single record at a time.
-
- pref: emailLibrarianWhenHoldIsPlaced
choices:
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
@@ -55,7 +55,7 @@ function check() {
}
if (alreadyreserved > "0"){
- msg += (_("- This patron had already placed a hold on this item") + "\n" + _("Please cancel the previous hold first") + "\n");
+ msg += (_("This patron has already placed the maximum number of holds for this record.") + "\n\n" + _("Please cancel a previous hold first.") + "\n");
}
if (msg == "") return(true);
@@ -208,7 +208,7 @@ function checkMultiHold() {