Browse Source

Fixing searches

master
chris 23 years ago
parent
commit
79d81be2a4
  1. 78
      C4/Search.pm
  2. 2
      C4/Stats.pm
  3. 6
      detail.pl
  4. 37
      reports.pl
  5. 2
      search.pl

78
C4/Search.pm

@ -73,7 +73,7 @@ sub KeywordSearch {
$count++;
}
$sth->finish;
$query=$query." limit $num,$offset";
# $query=$query." limit $num,$offset";
$sth=$dbh->prepare($query);
$sth->execute;
# print $query;
@ -94,24 +94,32 @@ sub CatSearch {
my $dbh = &C4Connect;
my $query = '';
if ($type eq 'loose') {
$query="Select count(*) from biblio,catalogueentry";
# $query="Select count(*) from biblio,catalogueentry";
if ($search->{'author'} ne ''){
$query=$query." where ((catalogueentry.catalogueentry = biblio.author)
$query="select biblio.biblionumber,title,author from
biblio,catalogueentry
where ((catalogueentry.catalogueentry = biblio.author)
and (catalogueentry.catalogueentry like '$search->{'author'}%')
and (entrytype = 'a'))";
if ($search->{'title'} ne ''){
$query= "Select biblionumber,title from biblio,catalogueentry where ((catalogueentry.catalogueentry = biblio.author)
and (catalogueentry.catalogueentry like '$search->{'author'}%')
and (entrytype = 'a')) intersect select biblionumber,title from
biblio,catalogueentry where ((catalogueentry.catalogueentry = biblio.title)
and (catalogueentry.catalogueentry like '%$search->{'title'}%')
and (entrytype = 't'))";
}
and (entrytype = 'a')) union
select biblio.biblionumber,title,author from biblio,biblioanalysis
where
biblioanalysis.analyticalauthor like '$search->{'author'}%'
and biblioanalysis.biblionumber=
biblio.biblionumber";
# if ($search->{'title'} ne ''){
# }
} else {
if ($search->{'title'} ne ''){
$query=$query." where ((catalogueentry.catalogueentry = biblio.title)
$query="select biblio.biblionumber,title,author from biblio,catalogueentry where ((catalogueentry.catalogueentry = biblio.title)
and (catalogueentry.catalogueentry like '%$search->{'title'}%')
and (entrytype = 't'))";
and (entrytype = 't')) union select
biblio.biblionumber,title,author from
biblioanalysis,biblio where analyticaltitle like
'%$search->{'title'}%' and biblio.biblionumber=biblioanalysis.biblionumber
union select biblio.biblionumber,title,author from
biblio,bibliosubtitle where subtitle like '%$search->{'title'}%' and
biblio.biblionumber=bibliosubtitle.biblionumber";
}
}
}
@ -148,7 +156,7 @@ sub CatSearch {
my $sth=$dbh->prepare($query);
$sth->execute;
my $count2=0;
if ($type ne 'subject'){
if ($type eq 'precise'){
my $count=$sth->fetchrow_hashref;
$count2=$count->{'count'};
} else {
@ -159,7 +167,7 @@ sub CatSearch {
$sth->finish;
$query=~ s/count\(\*\)/\*/g;
if ($type ne 'precise' && $type ne 'subject'){
$query=$query." order by catalogueentry.catalogueentry limit $num,$offset";
$query=$query." order by title limit $num,$offset";
} else {
if ($type eq 'subject'){
$query=$query." order by subject limit $num,$offset";
@ -168,16 +176,28 @@ sub CatSearch {
$sth=$dbh->prepare($query);
$sth->execute;
my $i=0;
my $i2=0;
my $limit=$num+$offset;
my @results;
while (my $data=$sth->fetchrow_hashref){
if ($type ne 'subject'){
$results[$i]="$data->{'biblionumber'}\t$data->{'title'}\t
$data->{'author'}";
} else {
$results[$i]="$data->{'biblionumber'}\t$data->{'subject'}\t
$data->{'author'}";
}
$i++;
if ($search->{'title'} ne '' || $search->{'author'} ne ''){
while ((my $data=$sth->fetchrow_hashref) && $i < $limit){
if ($i >= $offset){
$results[$i2]="$data->{'biblionumber'}\t$data->{'title'}\t$data->{'author'}";
$i2++;
}
$i++;
}
} else {
while (my $data=$sth->fetchrow_hashref){
if ($type ne 'subject'){
$results[$i]="$data->{'biblionumber'}\t$data->{'title'}\t
$data->{'author'}";
} else {
$results[$i]="$data->{'biblionumber'}\t$data->{'subject'}\t
$data->{'author'}";
}
$i++;
}
}
$sth->finish;
# print "$query\n";
@ -195,11 +215,13 @@ sub updatesearchstats{
sub subsearch {
my ($env,$subject)=@_;
my $dbh=C4Connect();
my $query="Select * from bibliosubject,biblio where subject='$subject'
and bibliosubject.biblionumber=biblio.biblionumber";
my $query="Select * from biblio,bibliosubject where
biblio.biblionumber=bibliosubject.biblionumber and
bibliosubject.subject='$subject'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $i=0;
# print $query;
my @results;
while (my $data=$sth->fetchrow_hashref){
$results[$i]="$data->{'title'}\t$data->{'author'}\t$data->{'biblionumber'}";
@ -235,7 +257,7 @@ sub ItemInfo {
}
$isth->finish;
$results[$i]="$data->{'title'}\t$data->{'itemnumber'}\t$datedue\t$data->{'branchname'}";
$results[$i]="$data->{'title'}\t$data->{'barcode'}\t$datedue\t$data->{'branchname'}\t$data->{'dewey'}";
$i++;
}
$sth->finish;

2
C4/Stats.pm

@ -63,6 +63,8 @@ sub UpdateStats {
sub statsreport {
#module to return a list of stats for a given day,time,branch type
#or to return search stats
}
END { } # module clean-up code here (global destructor)

6
detail.pl

@ -24,7 +24,7 @@ my $count=@items;
my $i=0;
print center();
print mktablehdr;
print mktablerow(4,'#cccc99','Title','Item Number','DateDue','Location');
print mktablerow(5,'#cccc99','Title','Barcode','DateDue','Location','Dewey');
my $colour=1;
while ($i < $count){
my @results=split('\t',$items[$i]);
@ -32,10 +32,10 @@ while ($i < $count){
$results[2]='Available';
}
if ($colour == 1){
print mktablerow(4,'#ffffcc',@results);
print mktablerow(5,'#ffffcc',@results);
$colour=0;
} else{
print mktablerow(4,'white',@results);
print mktablerow(5,'white',@results);
$colour=1;
}
$i++;

37
reports.pl

@ -1,46 +1,23 @@
#!/usr/bin/perl
#script to display detailed information
#script to display reports
#written 8/11/99
use strict;
#use DBI;
use C4::Search;
use CGI;
use C4::Output;
use C4::Stats;
my $input = new CGI;
print $input->header;
my $type=$input->param('type');
print startpage();
print startmenu();
my $blah;
if ($type eq 'search'){
my $data=updatestats('search','something');
}
if ($type eq
my $bib=$input->param('bib');
my $title=$input->param('title');
my @items=ItemInfo(\$blah,$bib,$title);
#print @items;
my $count=@items;
my $i=0;
print center();
print mktablehdr;
print mktablerow(4,'#cccc99','Title','Item Number','DateDue','Location');
my $colour=1;
while ($i < $count){
my @results=split('\t',$items[$i]);
if ($results[2] eq ''){
$results[2]='Available';
}
if ($colour == 1){
print mktablerow(4,'#ffffcc',@results);
$colour=0;
} else{
print mktablerow(4,'white',@results);
$colour=1;
}
$i++;
}
print endcenter();
print mktableft();
print endmenu();
print endpage();

2
search.pl

@ -88,7 +88,7 @@ while ($i < $count2){
$stuff[2]=mklink($url,$stuff[2]);
} else {
my $word=$stuff[1];
$word=~ s/ /%20/;
$word=~ s/ /%20/g;
$stuff[1]=mklink("/cgi-bin/kumara/subjectsearch.pl?subject=$word",$stuff[1]);
}
if ($colour == 1){

Loading…
Cancel
Save