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 $illustrator=validate($input->param('illustrator'));
46 $search{'illustrator'}=$illustrator;
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 ($count,@results)&FrontSearch(\$blah,'intra',\%search,$num,$offset);
92 }elsif ($title ne '' || $author ne '' || $illustrator 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');
113 } elsif ($illustrator ne '') {
114 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
116 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
120 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
121 } elsif ($illustrator ne '') {
122 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
124 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
128 if ($keyword ne '' && $offset > 0){
129 $count2=$count-$offset;
137 while ($i < $count2){
138 # print $results[$i]."\n";
139 my @stuff=split('\t',$results[$i]);
140 $stuff[1]=~ s/\`/\\\'/g;
141 my $title2=$stuff[1];
145 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
148 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
151 $word=~ s/\,/\,%20/g;
153 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
156 $stuff[0]=mklink($url,$stuff[0]);
157 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
160 $stuff[5]=$stuff[5]."On Loan";
162 $stuff[5]=$stuff[5]." ($nacount)";
167 $stuff[5]=$stuff[5]."Levin";
169 $stuff[5]=$stuff[5]." ($lcount)";
174 $stuff[5]=$stuff[5]."Foxton";
176 $stuff[5]=$stuff[5]." ($fcount)";
181 $stuff[5]=$stuff[5]."Shannon";
183 $stuff[5]=$stuff[5]." ($scount)";
188 $stuff[5]=$stuff[5]."Lost";
190 $stuff[5]=$stuff[5]." ($lostcount)";
195 $stuff[5]=$stuff[5]."Mending";
197 $stuff[5]=$stuff[5]." ($mending)";
202 $stuff[5]=$stuff[5]."In Transiit";
204 $stuff[5]=$stuff[5]." ($transit)";
209 $stuff[5]=$stuff[5]."On Order";
211 $stuff[5]=$stuff[5]." ($ocount)";
216 if ($type ne 'opac'){
217 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
223 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
229 print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
231 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
236 print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
238 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
244 $offset=$num+$offset;
245 if ($type ne 'opac'){
247 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
249 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
253 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
255 print mktablerow(6,$main,' ',' ',' ',' ','','');
261 $search="num=$num&offset=$offset&type=$type";
263 $subject=~ s/ /%20/g;
264 $search=$search."&subject=$subject";
268 $search=$search."&title=$title";
272 $search=$search."&author=$author";
275 $keyword=~ s/ /%20/g;
276 $search=$search."&keyword=$keyword";
279 $keyword=~ s/ /%20/g;
280 $search=$search."&class=$class";
283 $search=$search."&dewey=$dewey";
285 $search.="&ttype=$ttype";
286 if ($offset < $count){
287 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
293 for (my $i=1;$i<$pages;$i++){
296 $search=~ s/offset=[0-9]+/offset=$temp/;
297 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
302 print endmenu($type);
308 $input=~ s/\<[a-z]+\>//gi;
309 $input=~ s/\<\/[a-z]+\>//gi;