2 #script to provide intranet (librarian) advanced search facility
3 #modified 9/11/1999 by chris@katipo.co.nz
4 #adding an extra comment to play with CVS (Si, 19/11/99)
5 #modified 29/12/99 by chris@katipo.co.nz to be usavle by opac as well
6 #modified by chris 10/11/00 to fix dewey search
17 #whether it is called from the opac of the intranet
18 my $type=$input->param('type');
22 my $ttype=$input->param('ttype');
37 #build hash of users input
38 my $title=validate($input->param('title'));
39 $search{'title'}=$title;
40 my $keyword=validate($input->param('keyword'));
41 $search{'keyword'}=$keyword;
42 $search{'front'}=validate($input->param('front'));
43 my $author=validate($input->param('author'));
44 $search{'author'}=$author;
45 my $subject=validate($input->param('subject'));
46 $search{'subject'}=$subject;
47 my $itemnumber=validate($input->param('item'));
48 $search{'item'}=$itemnumber;
49 my $isbn=validate($input->param('isbn'));
50 $search{'isbn'}=$isbn;
51 my $datebefore=validate($input->param('date-before'));
52 $search{'date-before'};
53 my $class=$input->param('class');
54 $search{'class'}=$class;
55 $search{'ttype'}=$ttype;
56 my $dewey=validate($input->param('dewey'));
57 $search{'dewey'}=$dewey;
59 my $offset=$input->param('offset');
63 my $num=$input->param('num');
68 print startmenu($type);
69 #print $search{'ttype'};
71 print mkheadr(1,'Catalogue Search Results');
73 print mkheadr(1,'Opac Search Results');
78 if ($itemnumber ne '' || $isbn ne ''){
79 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
82 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
86 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
87 } elsif ($search{'front'} ne '') {
88 ($count,@results)&FrontSearch(\$blah,'intra',\%search,$num,$offset);
90 }elsif ($title ne '' || $author ne '' || $dewey ne '' || $class ne '') {
91 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
96 print "You searched on ";
97 while ( my ($key, $value) = each %search) {
98 if ($value ne '' && $key ne 'ttype'){
100 print bold("$key $value,");
103 print " $count results found";
104 my $offset2=$num+$offset;
105 my $dispnum=$offset+1;
106 print "<br> Results $dispnum to $offset2 displayed";
108 if ($type ne 'opac'){
110 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
112 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
116 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
118 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
122 if ($keyword ne '' && $offset > 0){
123 $count2=$count-$offset;
131 while ($i < $count2){
132 # print $results[$i]."\n";
133 my @stuff=split('\t',$results[$i]);
134 $stuff[1]=~ s/\`/\\\'/g;
135 my $title2=$stuff[1];
139 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
142 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
145 $word=~ s/\,/\,%20/g;
147 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
148 $stuff[0]=mklink($url,$stuff[0]);
149 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
152 $stuff[5]=$stuff[5]."On Loan";
154 $stuff[5]=$stuff[5]." ($nacount)";
159 $stuff[5]=$stuff[5]."Levin";
161 $stuff[5]=$stuff[5]." ($lcount)";
166 $stuff[5]=$stuff[5]."Foxton";
168 $stuff[5]=$stuff[5]." ($fcount)";
173 $stuff[5]=$stuff[5]."Shannon";
175 $stuff[5]=$stuff[5]." ($scount)";
180 $stuff[5]=$stuff[5]."Lost";
182 $stuff[5]=$stuff[5]." ($lostcount)";
187 $stuff[5]=$stuff[5]."Mending";
189 $stuff[5]=$stuff[5]." ($mending)";
194 $stuff[5]=$stuff[5]."In Transiit";
196 $stuff[5]=$stuff[5]." ($transit)";
201 $stuff[5]=$stuff[5]."On Order";
203 $stuff[5]=$stuff[5]." ($ocount)";
208 if ($type ne 'opac'){
209 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
215 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
220 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
223 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
228 $offset=$num+$offset;
229 if ($type ne 'opac'){
230 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
232 print mktablerow(6,$main,' ',' ',' ',' ','','');
237 $search="num=$num&offset=$offset&type=$type";
239 $subject=~ s/ /%20/g;
240 $search=$search."&subject=$subject";
244 $search=$search."&title=$title";
248 $search=$search."&author=$author";
251 $keyword=~ s/ /%20/g;
252 $search=$search."&keyword=$keyword";
255 $keyword=~ s/ /%20/g;
256 $search=$search."&class=$class";
259 $search=$search."&dewey=$dewey";
261 $search.="&ttype=$ttype";
262 if ($offset < $count){
263 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
269 for (my $i=1;$i<$pages;$i++){
272 $search=~ s/offset=[0-9]+/offset=$temp/;
273 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
278 print endmenu($type);
284 $input=~ s/\<[a-z]+\>//gi;
285 $input=~ s/\<\/[a-z]+\>//gi;