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'));
44 my $author=validate($input->param('author'));
45 $search{'author'}=$author;
46 my $subject=validate($input->param('subject'));
47 $search{'subject'}=$subject;
48 my $itemnumber=validate($input->param('item'));
49 $search{'item'}=$itemnumber;
50 my $isbn=validate($input->param('isbn'));
51 $search{'isbn'}=$isbn;
52 my $datebefore=validate($input->param('date-before'));
53 $search{'date-before'};
54 my $class=$input->param('class');
55 $search{'class'}=$class;
56 $search{'ttype'}=$ttype;
57 my $dewey=validate($input->param('dewey'));
58 $search{'dewey'}=$dewey;
60 my $offset=$input->param('offset');
64 my $num=$input->param('num');
69 print startmenu($type);
70 #print $search{'ttype'};
72 print mkheadr(1,'Catalogue Search Results');
74 print mkheadr(1,'Opac Search Results');
79 if ($itemnumber ne '' || $isbn ne ''){
80 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
83 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
87 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
88 } elsif ($search{'front'} ne '') {
89 $search{'keyword'}=$search{'front'};
90 ($count,@results)&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
92 }elsif ($title ne '' || $author ne '' || $dewey ne '' || $class ne '') {
93 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
98 print "You searched on ";
99 while ( my ($key, $value) = each %search) {
100 if ($value ne '' && $key ne 'ttype'){
102 print bold("$key $value,");
105 print " $count results found";
106 my $offset2=$num+$offset;
107 my $dispnum=$offset+1;
108 print "<br> Results $dispnum to $offset2 displayed";
110 if ($type ne 'opac'){
112 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
114 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
118 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
120 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
124 if ($keyword ne '' && $offset > 0){
125 $count2=$count-$offset;
133 while ($i < $count2){
134 # print $results[$i]."\n";
135 my @stuff=split('\t',$results[$i]);
136 $stuff[1]=~ s/\`/\\\'/g;
137 my $title2=$stuff[1];
141 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
144 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
147 $word=~ s/\,/\,%20/g;
149 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
150 $stuff[0]=mklink($url,$stuff[0]);
151 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
154 $stuff[5]=$stuff[5]."On Loan";
156 $stuff[5]=$stuff[5]." ($nacount)";
161 $stuff[5]=$stuff[5]."Levin";
163 $stuff[5]=$stuff[5]." ($lcount)";
168 $stuff[5]=$stuff[5]."Foxton";
170 $stuff[5]=$stuff[5]." ($fcount)";
175 $stuff[5]=$stuff[5]."Shannon";
177 $stuff[5]=$stuff[5]." ($scount)";
182 $stuff[5]=$stuff[5]."Lost";
184 $stuff[5]=$stuff[5]." ($lostcount)";
189 $stuff[5]=$stuff[5]."Mending";
191 $stuff[5]=$stuff[5]." ($mending)";
196 $stuff[5]=$stuff[5]."In Transiit";
198 $stuff[5]=$stuff[5]." ($transit)";
203 $stuff[5]=$stuff[5]."On Order";
205 $stuff[5]=$stuff[5]." ($ocount)";
210 if ($type ne 'opac'){
211 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
217 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
222 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
225 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
230 $offset=$num+$offset;
231 if ($type ne 'opac'){
232 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
234 print mktablerow(6,$main,' ',' ',' ',' ','','');
239 $search="num=$num&offset=$offset&type=$type";
241 $subject=~ s/ /%20/g;
242 $search=$search."&subject=$subject";
246 $search=$search."&title=$title";
250 $search=$search."&author=$author";
253 $keyword=~ s/ /%20/g;
254 $search=$search."&keyword=$keyword";
257 $keyword=~ s/ /%20/g;
258 $search=$search."&class=$class";
261 $search=$search."&dewey=$dewey";
263 $search.="&ttype=$ttype";
264 if ($offset < $count){
265 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
271 for (my $i=1;$i<$pages;$i++){
274 $search=~ s/offset=[0-9]+/offset=$temp/;
275 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
280 print endmenu($type);
286 $input=~ s/\<[a-z]+\>//gi;
287 $input=~ s/\<\/[a-z]+\>//gi;