From c0fc669126b6853a04bc885c0d78046e8fa687f7 Mon Sep 17 00:00:00 2001 From: rangi Date: Mon, 6 May 2002 23:12:25 +0000 Subject: [PATCH] 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 --- C4/Search.pm | 172 +++++---------------------------------------------- 1 file changed, 16 insertions(+), 156 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 9cb1c4a0e8..07b08eeba7 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -296,156 +296,6 @@ sub KeywordSearch { return($count,@res2); } -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,@res2); -} - sub CatSearch { my ($env,$type,$search,$num,$offset)=@_; my $dbh = &C4Connect; @@ -737,7 +587,8 @@ sub ItemInfo { items.holdingbranch "; # print $type; if ($type ne 'intra'){ - $query.=" and (items.itemlost<>1 or items.itemlost is NULL) + $query.=" and ((items.itemlost<>1 and items.itemlost <> 2) + or items.itemlost is NULL) and (wthdrawn <> 1 or wthdrawn is NULL)"; } $query=$query."order by items.dateaccessioned desc"; @@ -757,7 +608,7 @@ sub ItemInfo { my @temp=split('-',$idata->{'date_due'}); $datedue = "$temp[2]/$temp[1]/$temp[0]"; } - if ($data->{'itemlost'} eq '1'){ + if ($data->{'itemlost'} eq '1' || $data->{'itemlost'} eq '2'){ $datedue='Itemlost'; } if ($data->{'wthdrawn'} eq '1'){ @@ -1187,7 +1038,7 @@ sub itemcount { my $query="Select * from items where biblionumber=$bibnum "; if ($type ne 'intra'){ - $query.=" and (itemlost <>1 or itemlost is NULL) and + $query.=" and ((itemlost <>1 and itemlost <> 2) or itemlost is NULL) and (wthdrawn <> 1 or wthdrawn is NULL)"; } my $sth=$dbh->prepare($query); @@ -1206,8 +1057,10 @@ sub itemcount { $count++; 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)"; + 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; if (my $data2=$sth2->fetchrow_hashref){ @@ -1225,6 +1078,9 @@ sub itemcount { if ($data->{'itemlost'} eq '1'){ $lostcount++; } + if ($data->{'itemlost'} eq '2'){ + $lostcount++; + } if ($data->{'holdingbranch'} eq 'FM'){ $mending++; } @@ -1281,10 +1137,14 @@ sub bibitems { } sub barcodes{ + #called from request.pl my ($biblioitemnumber)=@_; my $dbh=C4Connect; my $query="Select barcode from items where - biblioitemnumber='$biblioitemnumber'"; + 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; my @barcodes; -- 2.39.5