2 #script to provide intranet (librarian) advanced search facility
14 #whether it is called from the opac or the intranet
15 my $type=$input->param('type');if ($type eq ''){
19 my $ttype=$input->param('ttype');
37 #build hash of users input
38 my $title=validate($input->param('title'));
39 $search{'title'}=$title;
41 my $keyword=validate($input->param('keyword'));
42 $search{'keyword'}=$keyword;
44 $search{'front'}=validate($input->param('front'));
46 my $author=validate($input->param('author'));
47 $search{'author'}=$author;
49 my $illustrator=validate($input->param('illustrator'));
50 $search{'illustrator'}=$illustrator;
52 my $subject=validate($input->param('subject'));
53 $search{'subject'}=$subject;
55 my $itemnumber=validate($input->param('item'));
56 $search{'item'}=$itemnumber;
58 my $isbn=validate($input->param('isbn'));
59 $search{'isbn'}=$isbn;
61 my $datebefore=validate($input->param('date-before'));
62 $search{'date-before'}=$datebefore;
64 my $class=$input->param('class');
65 $search{'class'}=$class;
67 $search{'ttype'}=$ttype;
69 my $dewey=validate($input->param('dewey'));
70 $search{'dewey'}=$dewey;
72 my $branch=validate($input->param('branch'));
73 $search{'branch'}=$branch;
76 my $offset=$input->param('offset');
80 my $num=$input->param('num');
85 print startmenu($type);
87 #print $search{'ttype'};
88 if ($type eq 'intra'){
89 print mkheadr(1,'Catalogue Search Results');
90 } elsif ($type eq 'catmain'){
91 print mkheadr(1,'Catalogue Maintenance');
93 print mkheadr(1,'Opac Search Results');
97 if ($itemnumber ne '' || $isbn ne ''){
98 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
101 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
104 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
105 }elsif ($title ne '' || $author ne '' || $illustrator ne '' || $dewey ne '' || $class ne '') {
106 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
110 print "You searched on ";
111 while ( my ($key, $value) = each %search) {
112 if ($value ne '' && $key ne 'ttype'){
114 print bold("$key $value,");
117 print " $count results found";
118 my $offset2=$num+$offset;
119 my $dispnum=$offset+1;
120 print "<br> Results $dispnum to $offset2 displayed";
122 if ($type ne 'opac'){
124 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
125 } elsif ($illustrator ne '') {
126 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
128 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
132 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
133 } elsif ($illustrator ne '') {
134 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
136 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
140 if ($keyword ne '' && $offset > 0){
141 $count2=$count-$offset;
149 while ($i < $count2){
150 # print $results[$i]."\n";
151 my @stuff=split('\t',$results[$i]);
152 $stuff[1]=~ s/\`/\\\'/g;
153 my $title2=$stuff[1];
157 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
160 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
163 $word=~ s/\,/\,%20/g;
165 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
168 $stuff[0]=mklink($url,$stuff[0]);
169 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
172 $stuff[5]=$stuff[5]."On Loan";
174 $stuff[5]=$stuff[5]." ($nacount)";
179 $stuff[5]=$stuff[5]."Levin";
181 $stuff[5]=$stuff[5]." ($lcount)";
186 $stuff[5]=$stuff[5]."Foxton";
188 $stuff[5]=$stuff[5]." ($fcount)";
193 $stuff[5]=$stuff[5]."Shannon";
195 $stuff[5]=$stuff[5]." ($scount)";
200 $stuff[5]=$stuff[5]."Lost";
202 $stuff[5]=$stuff[5]." ($lostcount)";
207 $stuff[5]=$stuff[5]."Mending";
209 $stuff[5]=$stuff[5]." ($mending)";
214 $stuff[5]=$stuff[5]."In Transiit";
216 $stuff[5]=$stuff[5]." ($transit)";
221 $stuff[5]=$stuff[5]."On Order";
223 $stuff[5]=$stuff[5]." ($ocount)";
228 if ($type ne 'opac'){
229 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
235 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
241 print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
243 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
248 print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
250 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
256 $offset=$num+$offset;
257 if ($type ne 'opac'){
259 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
261 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
265 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
267 print mktablerow(6,$main,' ',' ',' ',' ','','');
273 $search="num=$num&offset=$offset&type=$type";
275 $subject=~ s/ /%20/g;
276 $search=$search."&subject=$subject";
280 $search=$search."&title=$title";
284 $search=$search."&author=$author";
287 $keyword=~ s/ /%20/g;
288 $search=$search."&keyword=$keyword";
291 $keyword=~ s/ /%20/g;
292 $search=$search."&class=$class";
295 $search=$search."&dewey=$dewey";
297 $search.="&ttype=$ttype";
298 if ($offset < $count){
299 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
305 for (my $i=1;$i<$pages;$i++){
308 $search=~ s/offset=[0-9]+/offset=$temp/;
309 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
314 print endmenu($type);
320 $input=~ s/\<[a-z]+\>//gi;
321 $input=~ s/\<\/[a-z]+\>//gi;