[Koha-cvs] koha/C4 Reserves2.pm [dev_week]

Chris Cormack crc at liblime.com
Fri Jun 22 01:27:39 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Chris Cormack <rangi>	07/06/21 23:27:39

Modified files:
	C4             : Reserves2.pm 

Log message:
	Checking for notforresreve when finding reserves

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Reserves2.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.38.4.4&r2=1.38.4.5

Patches:
Index: Reserves2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Attic/Reserves2.pm,v
retrieving revision 1.38.4.4
retrieving revision 1.38.4.5
diff -u -b -r1.38.4.4 -r1.38.4.5
--- Reserves2.pm	11 Jun 2007 23:48:25 -0000	1.38.4.4
+++ Reserves2.pm	21 Jun 2007 23:27:39 -0000	1.38.4.5
@@ -3,7 +3,7 @@
 
 package C4::Reserves2;
 
-# $Id: Reserves2.pm,v 1.38.4.4 2007/06/11 23:48:25 rangi Exp $
+# $Id: Reserves2.pm,v 1.38.4.5 2007/06/21 23:27:39 rangi Exp $
 
 # Copyright 2000-2002 Katipo Communications
 # Copyright 2007 Liblime
@@ -71,6 +71,7 @@
     &getreservetitle
     &getAllreservenotes
     &Findgroupreserve
+	CanBeReserved
 );
 
 # make all your functions, whether exported or not;
@@ -210,11 +211,11 @@
     my $dbh = C4::Context->dbh;
     my ( $sth, $query ) ;
     if (C4::Context->preference("item-level_itypes") ) {
-		$query = "SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan
+		$query = "SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan, itemtypes.notforreserve
                              FROM items, itemtypes
                             WHERE  items.itype = itemtypes.itemtype " ;
 	} else {
-		$query = "SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan
+		$query = "SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan, itemtypes.notforreserve
                              FROM items, biblioitems, itemtypes
                             WHERE items.biblioitemnumber = biblioitems.biblioitemnumber
                               AND biblioitems.itemtype = itemtypes.itemtype ";
@@ -231,10 +232,12 @@
 
 #	# FIXME - This function uses $item later on. Ought to set it here.
     
-    my ($biblio, $bibitem, $notforloan) = $sth->fetchrow_array;
+    my ($biblio, $bibitem, $notforloan, $notforreserve) = $sth->fetchrow_array;
     $sth->finish;
 # if item is not for loan it cannot be reserved either.....
     return (0, 0) if ($notforloan);
+    # if item cant be reserved
+    return (0, 0) if ($notforreserve);
 # get the reserves...
     # Find this item in the reserves
     my ($count, @reserves) = Findgroupreserve($bibitem, $biblio);
@@ -812,3 +815,30 @@
  $sth->finish;
  return($data);
 }
+
+# Checks if an item (or itemtype) can be reserved
+
+sub CanBeReserved {
+	my ($itemnumber,$itemtype) = @_;
+	my $dbh = C4::Context->dbh();
+	if ($itemtype){
+		# we have an itemtype so just need to check that
+		my $query = "SELECT notforreserve FROM itemtypes WHERE itemtype = ?";
+		my $sth = $dbh->prepare($query);
+		$sth->execute($itemtype);
+		my $data=$sth->fetchrow_hashref();
+		if ($data->{'notforreserve'} == 1){
+			return 0;
+		}
+		else {
+			return 1; # can be reserved
+		}
+		$sth->finish();
+	} 
+	elsif ($itemnumber){
+		# check first at item level then if needed get itemtype and check that
+		}
+	else {
+		return 0; #nothing passsed in, dont call the function this way
+	}
+}





More information about the Koha-cvs mailing list