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 usable by opac as well
6 #modified by chris 10/11/00 to fix dewey search
7 #modified by chris@katipo.co.nz 3/2/01 to fix glitch with " in titles
18 #whether it is called from the opac of the intranet
19 my $type=$input->param('type');
23 my $ttype=$input->param('ttype');
38 #build hash of users input
39 my $title=validate($input->param('title'));
40 $search{'title'}=$title;
41 my $keyword=validate($input->param('keyword'));
42 $search{'keyword'}=$keyword;
43 $search{'front'}=validate($input->param('front'));
45 my $author=validate($input->param('author'));
46 $search{'author'}=$author;
47 my $subject=validate($input->param('subject'));
48 $search{'subject'}=$subject;
49 my $itemnumber=validate($input->param('item'));
50 $search{'item'}=$itemnumber;
51 my $isbn=validate($input->param('isbn'));
52 $search{'isbn'}=$isbn;
53 my $datebefore=validate($input->param('date-before'));
54 $search{'date-before'};
55 my $class=$input->param('class');
56 $search{'class'}=$class;
57 $search{'ttype'}=$ttype;
58 my $dewey=validate($input->param('dewey'));
59 $search{'dewey'}=$dewey;
61 my $offset=$input->param('offset');
65 my $num=$input->param('num');
70 print startmenu($type);
71 #print $search{'ttype'};
73 print mkheadr(1,'Catalogue Search Results');
75 print mkheadr(1,'Opac Search Results');
80 if ($itemnumber ne '' || $isbn ne ''){
81 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
84 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
88 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
89 } elsif ($search{'front'} ne '') {
90 $search{'keyword'}=$search{'front'};
91 ($count,@results)&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
93 }elsif ($title ne '' || $author ne '' || $dewey ne '' || $class ne '') {
94 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
99 print "You searched on ";
100 while ( my ($key, $value) = each %search) {
101 if ($value ne '' && $key ne 'ttype'){
103 print bold("$key $value,");
106 print " $count results found";
107 my $offset2=$num+$offset;
108 my $dispnum=$offset+1;
109 print "<br> Results $dispnum to $offset2 displayed";
111 if ($type ne 'opac'){
113 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
115 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
119 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
121 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
125 if ($keyword ne '' && $offset > 0){
126 $count2=$count-$offset;
134 while ($i < $count2){
135 # print $results[$i]."\n";
136 my @stuff=split('\t',$results[$i]);
137 $stuff[1]=~ s/\`/\\\'/g;
138 my $title2=$stuff[1];
143 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
146 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
149 $word=~ s/\,/\,%20/g;
151 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
152 $stuff[0]=mklink($url,$stuff[0]);
153 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
156 $stuff[5]=$stuff[5]."On Loan";
158 $stuff[5]=$stuff[5]." ($nacount)";
163 $stuff[5]=$stuff[5]."Levin";
165 $stuff[5]=$stuff[5]." ($lcount)";
170 $stuff[5]=$stuff[5]."Foxton";
172 $stuff[5]=$stuff[5]." ($fcount)";
177 $stuff[5]=$stuff[5]."Shannon";
179 $stuff[5]=$stuff[5]." ($scount)";
184 $stuff[5]=$stuff[5]."Lost";
186 $stuff[5]=$stuff[5]." ($lostcount)";
191 $stuff[5]=$stuff[5]."Mending";
193 $stuff[5]=$stuff[5]." ($mending)";
198 $stuff[5]=$stuff[5]."In Transiit";
200 $stuff[5]=$stuff[5]." ($transit)";
205 $stuff[5]=$stuff[5]."On Order";
207 $stuff[5]=$stuff[5]." ($ocount)";
212 if ($type ne 'opac'){
213 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
219 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
224 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
227 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
232 $offset=$num+$offset;
233 if ($type ne 'opac'){
234 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
236 print mktablerow(6,$main,' ',' ',' ',' ','','');
241 $search="num=$num&offset=$offset&type=$type";
243 $subject=~ s/ /%20/g;
244 $search=$search."&subject=$subject";
248 $search=$search."&title=$title";
252 $search=$search."&author=$author";
255 $keyword=~ s/ /%20/g;
256 $search=$search."&keyword=$keyword";
259 $keyword=~ s/ /%20/g;
260 $search=$search."&class=$class";
263 $search=$search."&dewey=$dewey";
265 $search.="&ttype=$ttype";
266 if ($offset < $count){
267 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
273 for (my $i=1;$i<$pages;$i++){
276 $search=~ s/offset=[0-9]+/offset=$temp/;
277 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
282 print endmenu($type);
288 $input=~ s/\<[a-z]+\>//gi;
289 $input=~ s/\<\/[a-z]+\>//gi;