[Koha-devel] CVS: koha/C4 Search.pm,1.19,1.20

Chris Cormack rangi at users.sourceforge.net
Mon May 6 16:13:05 CEST 2002


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

Modified Files:
	Search.pm 
Log Message:
Removing keywordsearch2 (no longer used)
Fixing glitches in counting lost items.
In items
itemlost=1 item marked lost by a librarian
itemlost=2 item marked lost by kohas automatic this item is over 4 weeks
overdue routine.

To the borrowers (ie in the opac) they should just show as lost


Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Search.pm	2 May 2002 00:08:53 -0000	1.19
--- Search.pm	6 May 2002 23:12:25 -0000	1.20
***************
*** 297,450 ****
  }
  
- sub KeywordSearch2 {
-   my ($env,$type,$search,$num,$offset)=@_;
-   my $dbh = &C4Connect;
-   $search->{'keyword'}=~ s/ +$//;
-   $search->{'keyword'}=~ s/'/\\'/;
-   my @key=split(' ',$search->{'keyword'});
-   my $count=@key;
-   my $i=1;
-   my @results;
-   my $query ="Select * from biblio,bibliosubtitle,biblioitems where
-   biblio.biblionumber=biblioitems.biblionumber and
-   biblio.biblionumber=bibliosubtitle.biblionumber and
-   (((title like '$key[0]%' or title like '% $key[0]%')";
-   while ($i < $count){
-     $query=$query." and (title like '$key[$i]%' or title like '% $key[$i]%')";
-     $i++;
-   }
-   $query.= ") or ((subtitle like '$key[0]%' or subtitle like '% $key[0]%')";
-   for ($i=1;$i<$count;$i++){
-     $query.= " and (subtitle like '$key[$i]%' or subtitle like '% $key[$i]%')";
-   }
-   $query.= ") or ((seriestitle like '$key[0]%' or seriestitle like '% $key[0]%')";
-   for ($i=1;$i<$count;$i++){
-     $query.=" and (seriestitle like '$key[$i]%' or seriestitle like '% $key[$i]%')";
-   }
-   $query.= ") or ((biblio.notes like '$key[0]%' or biblio.notes like '% $key[0]%')";
-   for ($i=1;$i<$count;$i++){
-     $query.=" and (biblio.notes like '$key[$i]%' or biblio.notes like '% $key[$i]%')";
-   }
-   $query.= ") or ((biblioitems.notes like '$key[0]%' or biblioitems.notes like '% $key[0]%')";
-   for ($i=1;$i<$count;$i++){
-     $query.=" and (biblioitems.notes like '$key[$i]%' or biblioitems.notes like '% $key[$i]%')";
-   }
-   if ($search->{'keyword'} =~ /new zealand/i){
-     $query.= "or (title like 'nz%' or title like '% nz %' or title like '% nz' or subtitle like 'nz%'
-     or subtitle like '% nz %' or subtitle like '% nz' or author like 'nz %' 
-     or author like '% nz %' or author like '% nz')"
-   }
-   if ($search->{'keyword'} eq  'nz' || $search->{'keyword'} eq 'NZ' ||
-   $search->{'keyword'} =~ /nz /i || $search->{'keyword'} =~ / nz /i ||
-   $search->{'keyword'} =~ / nz/i){
-     $query.= "or (title like 'new zealand%' or title like '% new zealand %'
-     or title like '% new zealand' or subtitle like 'new zealand%' or
-     subtitle like '% new zealand %'
-     or subtitle like '% new zealand' or author like 'new zealand%' 
-     or author like '% new zealand %' or author like '% new zealand' or 
-     seriestitle like 'new zealand%' or seriestitle like '% new zealand %'
-     or seriestitle like '% new zealand')"
-   }
-   $query=$query."))";
-   if ($search->{'class'} ne ''){
-     my @temp=split(/\|/,$search->{'class'});
-     my $count=@temp;
-     $query.= "and ( itemtype='$temp[0]'";
-     for (my $i=1;$i<$count;$i++){
-       $query.=" or itemtype='$temp[$i]'";
-      }
-   $query.=")"; 
-   }
-   if ($search->{'dewey'} ne ''){
-     $query.= "and (dewey like '$search->{'dewey'}%') ";
-   }
-    $query.="group by biblio.biblionumber";
-    #$query.=" order by author,title";
- #  print $query;
-   my $sth=$dbh->prepare($query);
-   $sth->execute;
-   $i=0;
-   while (my $data=$sth->fetchrow_hashref){
- #    my $sti=$dbh->prepare("select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'}
- #    ");
- #    $sti->execute;
- #    my ($dewey, $subclass) = $sti->fetchrow;
-     my $dewey=$data->{'dewey'};
-     my $subclass=$data->{'subclass'};
-     $dewey=~s/\.*0*$//;
-     ($dewey == 0) && ($dewey='');
-     ($dewey) && ($dewey.=" $subclass");
- #    $sti->finish;
-     $results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey";
- #      print $results[$i];
-     $i++;
-   }
-   $sth->finish;
-   $sth=$dbh->prepare("Select biblionumber from bibliosubject where subject
-   like '%$search->{'keyword'}%' group by biblionumber");
-   $sth->execute;
-   while (my $data=$sth->fetchrow_hashref){
-     $query="Select * from biblio,biblioitems where
-     biblio.biblionumber=$data->{'biblionumber'} and
-     biblio.biblionumber=biblioitems.biblionumber ";
-     if ($search->{'class'} ne ''){
-       my @temp=split(/\|/,$search->{'class'});
-       my $count=@temp;
-       $query.= " and ( itemtype='$temp[0]'";
-       for (my $i=1;$i<$count;$i++){
-         $query.=" or itemtype='$temp[$i]'";
-       }
-       $query.=")"; 
-       
-     }
-     if ($search->{'dewey'} ne ''){
-       $query.= "and (dewey like '$search->{'dewey'}%') ";
-     }
-     my $sth2=$dbh->prepare($query);
-     $sth2->execute;
- #    print $query;
-     while (my $data2=$sth2->fetchrow_hashref){
-       my $dewey= $data2->{'dewey'};
-       my $subclass=$data2->{'subclass'};
-       $dewey=~s/\.*0*$//;          
-       ($dewey == 0) && ($dewey='');              
-       ($dewey) && ($dewey.=" $subclass") ;                  
- #      $sti->finish;              
-        $results[$i]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey";
- #      print $results[$i];
-       $i++;   
-     }
-     $sth2->finish;
-   }    
-   my $i2=1;
-   @results=sort @results;
-   my @res;
-   my $count=@results;
-   $i=1;
-   if ($count > 0){
-     $res[0]=$results[0];
-   }
-   while ($i2 < $count){
-     if ($results[$i2] ne $res[$i-1]){
-       $res[$i]=$results[$i2];
-       $i++;
-     }
-     $i2++;
-   }
-   $i2=0;
-   my @res2;
-   $count=@res;
-   while ($i2 < $num && $i2 < $count){
-     $res2[$i2]=$res[$i2+$offset];
- #    print $res2[$i2];
-     $i2++;
-   }
-   $sth->finish;
-   $dbh->disconnect;
- #  $i--;
- #  $i++;
-   return($i, at res2);
- }
- 
  sub CatSearch  {
    my ($env,$type,$search,$num,$offset)=@_;
--- 297,300 ----
***************
*** 738,742 ****
  #  print $type;
    if ($type ne 'intra'){
!     $query.=" and (items.itemlost<>1 or items.itemlost is NULL)
      and (wthdrawn <> 1 or wthdrawn is NULL)";
    }
--- 588,593 ----
  #  print $type;
    if ($type ne 'intra'){
!     $query.=" and ((items.itemlost<>1 and items.itemlost <> 2)
!     or items.itemlost is NULL)
      and (wthdrawn <> 1 or wthdrawn is NULL)";
    }
***************
*** 758,762 ****
        $datedue = "$temp[2]/$temp[1]/$temp[0]";
      }
!     if ($data->{'itemlost'} eq '1'){
          $datedue='Itemlost';
      }
--- 609,613 ----
        $datedue = "$temp[2]/$temp[1]/$temp[0]";
      }
!     if ($data->{'itemlost'} eq '1' || $data->{'itemlost'} eq '2'){
          $datedue='Itemlost';
      }
***************
*** 1188,1192 ****
    biblionumber=$bibnum ";
    if ($type ne 'intra'){
!     $query.=" and (itemlost <>1 or itemlost is NULL) and
      (wthdrawn <> 1 or wthdrawn is NULL)";      
    }
--- 1039,1043 ----
    biblionumber=$bibnum ";
    if ($type ne 'intra'){
!     $query.=" and ((itemlost <>1 and itemlost <> 2) or itemlost is NULL) and
      (wthdrawn <> 1 or wthdrawn is NULL)";      
    }
***************
*** 1207,1212 ****
      my $query2="select * from issues,items where issues.itemnumber=                          
      '$data->{'itemnumber'}' and returndate is NULL
!     and items.itemnumber=issues.itemnumber and (items.itemlost <>1 or
!     items.itemlost is NULL)"; 
      my $sth2=$dbh->prepare($query2);     
      $sth2->execute;         
--- 1058,1065 ----
      my $query2="select * from issues,items where issues.itemnumber=                          
      '$data->{'itemnumber'}' and returndate is NULL
!     and items.itemnumber=issues.itemnumber and ((items.itemlost <>1 and
!     items.itemlost <> 2) or items.itemlost is NULL) 
!     and (wthdrawn <> 1 or wthdrawn is NULL)"; 
!     
      my $sth2=$dbh->prepare($query2);     
      $sth2->execute;         
***************
*** 1226,1229 ****
--- 1079,1085 ----
          $lostcount++;
        }
+       if ($data->{'itemlost'} eq '2'){
+         $lostcount++;
+       }
        if ($data->{'holdingbranch'} eq 'FM'){
          $mending++;
***************
*** 1282,1289 ****
  
  sub barcodes{
    my ($biblioitemnumber)=@_;
    my $dbh=C4Connect;
    my $query="Select barcode from items where
!    biblioitemnumber='$biblioitemnumber'";
    my $sth=$dbh->prepare($query);
    $sth->execute;
--- 1138,1149 ----
  
  sub barcodes{
+   #called from request.pl
    my ($biblioitemnumber)=@_;
    my $dbh=C4Connect;
    my $query="Select barcode from items where
!    biblioitemnumber='$biblioitemnumber'
!    and ((itemlost <> 1 and itemlost <> 2) or itemlost is NULL) and
!    (wthdrawn <> 1 or wthdrawn is NULL)";
! #   print $query;
    my $sth=$dbh->prepare($query);
    $sth->execute;





More information about the Koha-devel mailing list