[Koha-cvs] koha/C4 Biblio.pm Search.pm [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Tue Aug 29 11:39:40 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/08/29 09:39:40

Modified files:
	C4             : Biblio.pm Search.pm 

Log message:
	ItemInfo renamed to GetItemsInfo and moved from Search.pm to Biblio.pm

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.178.2.1&r2=1.178.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.120&r2=1.120.2.1

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.178.2.1
retrieving revision 1.178.2.2
diff -u -b -r1.178.2.1 -r1.178.2.2
--- Biblio.pm	25 Aug 2006 12:32:40 -0000	1.178.2.1
+++ Biblio.pm	29 Aug 2006 09:39:39 -0000	1.178.2.2
@@ -48,7 +48,8 @@
   &getbiblio &getstacks
   &GetBiblioItemByBiblioNumber
   &getbiblioitembybiblionumber
-  getbibliofromitemnumber
+  &getbibliofromitemnumber
+  &GetItemsInfo
   &getbiblioitem &getitemsbybiblioitem
   &skip &getitemtypes
   &get_itemnumbers_of
@@ -2302,6 +2303,156 @@
     return ($error);
 }
 
+=item GetItemsInfo
+
+  @results = &GetItemsInfo($biblionumber, $type);
+
+Returns information about books with the given biblionumber.
+
+C<$type> may be either C<intra> or anything else. If it is not set to
+C<intra>, then the search will exclude lost, very overdue, and
+withdrawn items.
+
+C<&GetItemsInfo> returns a list of references-to-hash. Each element
+contains a number of keys. Most of them are table items from the
+C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
+Koha database. Other keys include:
+
+=over 4
+
+=item C<$data-E<gt>{branchname}>
+
+The name (not the code) of the branch to which the book belongs.
+
+=item C<$data-E<gt>{datelastseen}>
+
+This is simply C<items.datelastseen>, except that while the date is
+stored in YYYY-MM-DD format in the database, here it is converted to
+DD/MM/YYYY format. A NULL date is returned as C<//>.
+
+=item C<$data-E<gt>{datedue}>
+
+=item C<$data-E<gt>{class}>
+
+This is the concatenation of C<biblioitems.classification>, the book's
+Dewey code, and C<biblioitems.subclass>.
+
+=item C<$data-E<gt>{ocount}>
+
+I think this is the number of copies of the book available.
+
+=item C<$data-E<gt>{order}>
+
+If this is set, it is set to C<One Order>.
+
+=back
+
+=cut
+
+#'
+sub GetItemsInfo {
+	my ($biblionumber,$type) = @_;
+	my $dbh   = C4::Context->dbh;
+	my $query = "SELECT *,items.notforloan as itemnotforloan
+	             FROM items, biblio, biblioitems 
+				 LEFT JOIN itemtypes on biblioitems.itemtype = itemtypes.itemtype
+				WHERE items.biblionumber = ?
+				    AND biblioitems.biblioitemnumber = items.biblioitemnumber
+				    AND biblio.biblionumber = items.biblionumber
+				ORDER BY items.dateaccessioned desc
+				 ";
+	my $sth=$dbh->prepare($query);
+	$sth->execute($biblionumber);
+	my $i=0;
+	my @results;
+    my ($date_due, $count_reserves);
+	while (my $data=$sth->fetchrow_hashref){
+		my $datedue = '';
+		my $isth=$dbh->prepare(
+		   "SELECT issues.*,borrowers.cardnumber
+		    FROM   issues, borrowers
+		    WHERE  itemnumber = ?
+		        AND returndate IS NULL
+		        AND issues.borrowernumber=borrowers.borrowernumber"
+		);
+		$isth->execute($data->{'itemnumber'});
+		if (my $idata=$isth->fetchrow_hashref){
+    		$data->{borrowernumber} = $idata->{borrowernumber};
+	    	$data->{cardnumber} = $idata->{cardnumber};
+	    	$datedue = format_date($idata->{'date_due'});
+		}
+		if ($datedue eq ''){
+	        #$datedue="Available";
+			my ($restype,$reserves)=C4::Reserves2::CheckReserves($data->{'itemnumber'});
+			if ($restype) {
+                #$datedue=$restype;
+				$count_reserves = $restype;
+			}
+		}
+		$isth->finish;
+		
+	    #get branch information.....
+		my $bsth=$dbh->prepare(
+		    "SELECT * FROM branches WHERE branchcode = ?
+		");
+		$bsth->execute($data->{'holdingbranch'});
+		if (my $bdata=$bsth->fetchrow_hashref){
+			$data->{'branchname'} = $bdata->{'branchname'};
+		}
+		my $date=format_date($data->{'datelastseen'});
+		$data->{'datelastseen'}=$date;
+		$data->{'datedue'}=$datedue;
+		$data->{'count_reserves'} = $count_reserves;
+		
+    	# get notforloan complete status if applicable
+		my $sthnflstatus = $dbh->prepare(
+		    'SELECT authorised_value
+		    FROM   marc_subfield_structure
+		    WHERE  kohafield="items.notforloan"
+		');
+		 
+		$sthnflstatus->execute;
+		my ($authorised_valuecode) = $sthnflstatus->fetchrow;
+		if ($authorised_valuecode) {
+			$sthnflstatus = $dbh->prepare(
+			    "SELECT lib FROM authorised_values
+			     WHERE  category=?
+			     AND authorised_value=?"
+			);
+			$sthnflstatus->execute($authorised_valuecode,$data->{itemnotforloan});
+			my ($lib) = $sthnflstatus->fetchrow;
+			$data->{notforloan} = $lib;
+		}
+
+        # my stack procedures
+		my $stackstatus = $dbh->prepare(
+		    'SELECT authorised_value
+		     FROM   marc_subfield_structure
+		     WHERE  kohafield="items.stack"
+		');
+		$stackstatus->execute;
+		
+		($authorised_valuecode) = $stackstatus->fetchrow;
+		if ($authorised_valuecode) {
+			$stackstatus = $dbh->prepare(
+			    "SELECT lib
+			     FROM   authorised_values
+			     WHERE  category=?
+			     AND    authorised_value=?
+			");
+			$stackstatus->execute($authorised_valuecode,$data->{stack});
+			
+			my ($lib) = $stackstatus->fetchrow;
+			$data->{stack} = $lib;
+		}
+		$results[$i]=$data;
+		$i++;
+	}
+	$sth->finish;
+
+	return(@results);
+}
+
 sub countitems {
     my ($bibitemnum) = @_;
     my $dbh   = C4::Context->dbh;
@@ -2444,31 +2595,6 @@
     return ( $count, @results );
 }    # sub
 
-=head2 getitemtypes
-
-FIXME :: do not use this function : use C4::Koha::GetItemTypes;
-
-=cut 
-
-sub getitemtypes {
-    my $dbh   = C4::Context->dbh;
-    my $query = "select * from itemtypes order by description";
-    my $sth   = $dbh->prepare($query);
-
-    # || die "Cannot prepare $query" . $dbh->errstr;      
-    my @results;
-
-    $sth->execute;
-
-    # || die "Cannot execute $query\n" . $sth->errstr;
-    while ( my $data = $sth->fetchrow_hashref ) {
-		push @results, $data;
-    }    # while
-
-    $sth->finish;
-    return @results;
-}    # sub getitemtypes
-
 sub getstacks{
   my $dbh   = C4::Context->dbh;
   my $i=0;
@@ -3015,8 +3141,11 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.178.2.1 2006/08/25 12:32:40 btoumi Exp $
+# $Id: Biblio.pm,v 1.178.2.2 2006/08/29 09:39:39 toins Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.178.2.2  2006/08/29 09:39:39  toins
+# ItemInfo renamed to GetItemsInfo and moved from Search.pm to Biblio.pm
+#
 # Revision 1.178.2.1  2006/08/25 12:32:40  btoumi
 # bug fix:add declaration of function (getbibliofromitemnumber)
 #

Index: Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.120
retrieving revision 1.120.2.1
diff -u -b -r1.120 -r1.120.2.1
--- Search.pm	10 Aug 2006 12:49:37 -0000	1.120
+++ Search.pm	29 Aug 2006 09:39:39 -0000	1.120.2.1
@@ -36,7 +36,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.120 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.120.2.1 $' =~ /\d+/g;
           shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -66,7 +66,7 @@
 @ISA = qw(Exporter);
 @EXPORT = qw(
 
-&CatSearch &BornameSearch &ItemInfo &KeywordSearch &subsearch
+&CatSearch &BornameSearch &GetItemInfo &KeywordSearch &subsearch
 &itemdata &bibdata &GetItems &borrdata &itemnodata &itemcount
 &borrdata2 &borrdata3 &NewBorrowerNumber &bibitemdata &borrissues
 &getboracctrecord &ItemType &itemissues &subject &subtitle
@@ -2657,128 +2657,6 @@
   return(@results);
 }
 
-=item ItemInfo
-
-  @results = &ItemInfo($env, $biblionumber, $type);
-
-Returns information about books with the given biblionumber.
-
-C<$type> may be either C<intra> or anything else. If it is not set to
-C<intra>, then the search will exclude lost, very overdue, and
-withdrawn items.
-
-C<$env> is ignored.
-
-C<&ItemInfo> returns a list of references-to-hash. Each element
-contains a number of keys. Most of them are table items from the
-C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
-Koha database. Other keys include:
-
-=over 4
-
-=item C<$data-E<gt>{branchname}>
-
-The name (not the code) of the branch to which the book belongs.
-
-=item C<$data-E<gt>{datelastseen}>
-
-This is simply C<items.datelastseen>, except that while the date is
-stored in YYYY-MM-DD format in the database, here it is converted to
-DD/MM/YYYY format. A NULL date is returned as C<//>.
-
-=item C<$data-E<gt>{datedue}>
-
-=item C<$data-E<gt>{class}>
-
-This is the concatenation of C<biblioitems.classification>, the book's
-Dewey code, and C<biblioitems.subclass>.
-
-=item C<$data-E<gt>{ocount}>
-
-I think this is the number of copies of the book available.
-
-=item C<$data-E<gt>{order}>
-
-If this is set, it is set to C<One Order>.
-
-=back
-
-=cut
-#'
-sub ItemInfo {
-	my ($env,$biblionumber,$type) = @_;
-	my $dbh   = C4::Context->dbh;
-	my $query = "SELECT *,items.notforloan as itemnotforloan FROM items, biblio, biblioitems 
-					left join itemtypes on biblioitems.itemtype = itemtypes.itemtype
-					WHERE items.biblionumber = ?
-					AND biblioitems.biblioitemnumber = items.biblioitemnumber
-					AND biblio.biblionumber = items.biblionumber";
-	$query .= " order by items.dateaccessioned desc";
-	my $sth=$dbh->prepare($query);
-	$sth->execute($biblionumber);
-	my $i=0;
-	my @results;
-my ($date_due, $count_reserves);
-	while (my $data=$sth->fetchrow_hashref){
-		my $datedue = '';
-		my $isth=$dbh->prepare("Select issues.*,borrowers.cardnumber from issues,borrowers where itemnumber = ? and returndate is null and issues.borrowernumber=borrowers.borrowernumber");
-		$isth->execute($data->{'itemnumber'});
-		if (my $idata=$isth->fetchrow_hashref){
-		$data->{borrowernumber} = $idata->{borrowernumber};
-		$data->{cardnumber} = $idata->{cardnumber};
-		$datedue = format_date($idata->{'date_due'});
-		}
-		if ($datedue eq ''){
-	#	$datedue="Available";
-			my ($restype,$reserves)=C4::Reserves2::CheckReserves($data->{'itemnumber'});
-			if ($restype) {
-#				$datedue=$restype;
-				$count_reserves = $restype;
-			}
-		}
-		$isth->finish;
-	#get branch information.....
-		my $bsth=$dbh->prepare("SELECT * FROM branches WHERE branchcode = ?");
-		$bsth->execute($data->{'holdingbranch'});
-		if (my $bdata=$bsth->fetchrow_hashref){
-			$data->{'branchname'} = $bdata->{'branchname'};
-		}
-		my $date=format_date($data->{'datelastseen'});
-		$data->{'datelastseen'}=$date;
-		$data->{'datedue'}=$datedue;
-		$data->{'count_reserves'} = $count_reserves;
-	# get notforloan complete status if applicable
-		my $sthnflstatus = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield="items.notforloan"');
-		$sthnflstatus->execute;
-		my ($authorised_valuecode) = $sthnflstatus->fetchrow;
-		if ($authorised_valuecode) {
-			$sthnflstatus = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=?");
-			$sthnflstatus->execute($authorised_valuecode,$data->{itemnotforloan});
-			my ($lib) = $sthnflstatus->fetchrow;
-			$data->{notforloan} = $lib;
-		}
-
-# my stack procedures
-
-		my $stackstatus = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield="items.stack"');
-		$stackstatus->execute;
-		
-		($authorised_valuecode) = $stackstatus->fetchrow;
-		if ($authorised_valuecode) {
-			$stackstatus = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=?");
-			$stackstatus->execute($authorised_valuecode,$data->{stack});
-			
-			my ($lib) = $stackstatus->fetchrow;
-			$data->{stack} = $lib;
-		}
-		$results[$i]=$data;
-		$i++;
-	}
-	$sth->finish;
-
-	return(@results);
-}
-
 =item GetItems
 
   @results = &GetItems($env, $biblionumber);





More information about the Koha-cvs mailing list