[Koha-cvs] CVS: koha/C4 Search.pm,1.18.2.12,1.18.2.13

Finlay Thompson finlayt at users.sourceforge.net
Fri Oct 11 07:25:14 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv28125

Modified Files:
      Tag: rel-1-2
	Search.pm 
Log Message:

fixed itemcount2 and ItemInfo so that they give the same information about items.


Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.18.2.12
retrieving revision 1.18.2.13
diff -C2 -r1.18.2.12 -r1.18.2.13
*** Search.pm	3 Oct 2002 04:14:04 -0000	1.18.2.12
--- Search.pm	11 Oct 2002 05:25:12 -0000	1.18.2.13
***************
*** 223,227 ****
  	      }
  	  } else {
! 	      $locationtext.="$_";
  	      my $c=$data->{'locationhash'}->{$_};
  	      if ($totalitemcounts>1) {
--- 223,227 ----
  	      }
  	  } else {
! 	      $locationtext .= ($_) ? "$_" : "unknown branch";
  	      my $c=$data->{'locationhash'}->{$_};
  	      if ($totalitemcounts>1) {
***************
*** 1233,1237 ****
      my $dbh   = &C4Connect;
      my $query = "SELECT * FROM items, biblio, biblioitems
!                   WHERE items.biblionumber = '$biblionumber'
                      AND biblioitems.biblioitemnumber = items.biblioitemnumber
                      AND biblio.biblionumber = items.biblionumber";
--- 1233,1237 ----
      my $dbh   = &C4Connect;
      my $query = "SELECT * FROM items, biblio, biblioitems
!                   WHERE items.biblionumber = ?
                      AND biblioitems.biblioitemnumber = items.biblioitemnumber
                      AND biblio.biblionumber = items.biblionumber";
***************
*** 1242,1250 ****
    }
    $query .= " order by items.dateaccessioned desc";
    my $sth=$dbh->prepare($query);
!   $sth->execute;
    my $i=0;
    my @results;
- #  print $query;
    while (my $data=$sth->fetchrow_hashref){
      my $iquery = "Select * from issues
--- 1242,1250 ----
    }
    $query .= " order by items.dateaccessioned desc";
+     #warn $query;
    my $sth=$dbh->prepare($query);
!   $sth->execute($biblionumber);
    my $i=0;
    my @results;
    while (my $data=$sth->fetchrow_hashref){
      my $iquery = "Select * from issues
***************
*** 1260,1275 ****
        $datedue = "$temp[2]/$temp[1]/$temp[0]";
      }
!     if ($data->{'itemlost'} eq '1' || $data->{'itemlost'} eq '2'){
!         $datedue='Itemlost';
      }
      if ($data->{'wthdrawn'} eq '1'){
!       $datedue="Cancelled";
      }
      if ($datedue eq ''){
!        $datedue="Available";
!        my ($restype,$reserves)=CheckReserves($data->{'itemnumber'});
!        if ($restype){                                
!           $datedue=$restype;
!        }
      }
      $isth->finish;
--- 1260,1278 ----
        $datedue = "$temp[2]/$temp[1]/$temp[0]";
      }
!     if ($data->{'itemlost'} eq '2'){
!         $datedue='Very Overdue';
!     }
!     if ($data->{'itemlost'} eq '1'){
!         $datedue='Lost';
      }
      if ($data->{'wthdrawn'} eq '1'){
! 	$datedue="Cancelled";
      }
      if ($datedue eq ''){
! 	$datedue="Available";
! 	my ($restype,$reserves)=CheckReserves($data->{'itemnumber'});
! 	if ($restype){
! 	    $datedue=$restype;
! 	}
      }
      $isth->finish;
***************
*** 1282,1285 ****
--- 1285,1297 ----
  	$data->{'branchname'} = $bdata->{'branchname'};
      }
+ # get the itemtype description.
+     my $bquery = "SELECT * FROM itemtypes
+                           WHERE itemtype = '$data->{'itemtype'}'";
+     my $bsth=$dbh->prepare($bquery);
+     $bsth->execute;
+     if (my $bdata=$bsth->fetchrow_hashref){
+ 	$data->{'description'} = $bdata->{'description'};
+     }
+ 
  
      my $class = $data->{'classification'};
***************
*** 1312,1321 ****
   $sth->finish;
    my $query2="Select * from aqorders where biblionumber=$biblionumber";
!   my $sth2=$dbh->prepare($query2);         
!   $sth2->execute;                                        
    my $data;
    my $ocount;
!   if ($data=$sth2->fetchrow_hashref){                   
!     $ocount=$data->{'quantity'} - $data->{'quantityreceived'};                                                  
      if ($ocount > 0){
        $data->{'ocount'}=$ocount;
--- 1324,1333 ----
   $sth->finish;
    my $query2="Select * from aqorders where biblionumber=$biblionumber";
!   my $sth2=$dbh->prepare($query2);
!   $sth2->execute;
    my $data;
    my $ocount;
!   if ($data=$sth2->fetchrow_hashref){
!     $ocount=$data->{'quantity'} - $data->{'quantityreceived'};
      if ($ocount > 0){
        $data->{'ocount'}=$ocount;
***************
*** 1323,1330 ****
        $results[$i]=$data;
      }
!   } 
    $sth2->finish;
  
-   $dbh->disconnect;
    return(@results);
  }
--- 1335,1341 ----
        $results[$i]=$data;
      }
!   }
    $sth2->finish;
  
    return(@results);
  }
***************
*** 2140,2145 ****
    my ($env,$bibnum,$type)=@_; 
    my $dbh=C4Connect;   
!   my $query="Select * from items,branches where     
!   biblionumber=$bibnum and items.holdingbranch=branches.branchcode";
    if ($type ne 'intra'){
      $query.=" and ((itemlost <>1 and itemlost <> 2) or itemlost is NULL) and
--- 2151,2155 ----
    my ($env,$bibnum,$type)=@_; 
    my $dbh=C4Connect;   
!   my $query="SELECT items.*, branches.branchname FROM items LEFT JOIN branches ON items.holdingbranch = branches.branchcode WHERE biblionumber = ?";
    if ($type ne 'intra'){
      $query.=" and ((itemlost <>1 and itemlost <> 2) or itemlost is NULL) and
***************
*** 2148,2152 ****
    my $sth=$dbh->prepare($query);         
    #  print $query;           
!   $sth->execute;           
    my %counts;
    $counts{'total'}=0;
--- 2158,2162 ----
    my $sth=$dbh->prepare($query);         
    #  print $query;           
!   $sth->execute($bibnum);           
    my %counts;
    $counts{'total'}=0;
***************
*** 2166,2172 ****
      if (my $data2=$sth2->fetchrow_hashref){         
         $counts{'notavailable'}++;         
!     } else {         
         $counts{$data->{'branchname'}}++;
!     }                             
      $sth2->finish;     
    } 
--- 2176,2184 ----
      if (my $data2=$sth2->fetchrow_hashref){         
         $counts{'notavailable'}++;         
!     } elsif ($data->{'branchname'}) {         
         $counts{$data->{'branchname'}}++;
!    } else {
!        $counts{'unknown branch'}++;
!    }
      $sth2->finish;     
    } 





More information about the Koha-cvs mailing list