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'};
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');
98 if ($itemnumber ne '' || $isbn ne ''){
99 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
102 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
105 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
106 }elsif ($title ne '' || $author ne '' || $illustrator ne '' || $dewey ne '' || $class ne '') {
107 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
111 print "You searched on ";
112 while ( my ($key, $value) = each %search) {
113 if ($value ne '' && $key ne 'ttype'){
115 print bold("$key $value,");
118 print " $count results found";
119 my $offset2=$num+$offset;
120 my $dispnum=$offset+1;
121 print "<br> Results $dispnum to $offset2 displayed";
123 if ($type ne 'opac'){
125 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
126 } elsif ($illustrator ne '') {
127 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
129 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
133 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
134 } elsif ($illustrator ne '') {
135 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
137 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
141 if ($keyword ne '' && $offset > 0){
142 $count2=$count-$offset;
150 while ($i < $count2){
151 # print $results[$i]."\n";
152 my @stuff=split('\t',$results[$i]);
153 $stuff[1]=~ s/\`/\\\'/g;
154 my $title2=$stuff[1];
158 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
161 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
164 $word=~ s/\,/\,%20/g;
166 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
169 $stuff[0]=mklink($url,$stuff[0]);
170 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
173 $stuff[5]=$stuff[5]."On Loan";
175 $stuff[5]=$stuff[5]." ($nacount)";
180 $stuff[5]=$stuff[5]."Levin";
182 $stuff[5]=$stuff[5]." ($lcount)";
187 $stuff[5]=$stuff[5]."Foxton";
189 $stuff[5]=$stuff[5]." ($fcount)";
194 $stuff[5]=$stuff[5]."Shannon";
196 $stuff[5]=$stuff[5]." ($scount)";
201 $stuff[5]=$stuff[5]."Lost";
203 $stuff[5]=$stuff[5]." ($lostcount)";
208 $stuff[5]=$stuff[5]."Mending";
210 $stuff[5]=$stuff[5]." ($mending)";
215 $stuff[5]=$stuff[5]."In Transiit";
217 $stuff[5]=$stuff[5]." ($transit)";
222 $stuff[5]=$stuff[5]."On Order";
224 $stuff[5]=$stuff[5]." ($ocount)";
229 if ($type ne 'opac'){
230 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
236 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
242 print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
244 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
249 print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
251 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
257 $offset=$num+$offset;
258 if ($type ne 'opac'){
260 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
262 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
266 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
268 print mktablerow(6,$main,' ',' ',' ',' ','','');
274 $search="num=$num&offset=$offset&type=$type";
276 $subject=~ s/ /%20/g;
277 $search=$search."&subject=$subject";
281 $search=$search."&title=$title";
285 $search=$search."&author=$author";
288 $keyword=~ s/ /%20/g;
289 $search=$search."&keyword=$keyword";
292 $keyword=~ s/ /%20/g;
293 $search=$search."&class=$class";
296 $search=$search."&dewey=$dewey";
298 $search.="&ttype=$ttype";
299 if ($offset < $count){
300 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
306 for (my $i=1;$i<$pages;$i++){
309 $search=~ s/offset=[0-9]+/offset=$temp/;
310 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
315 print endmenu($type);
321 $input=~ s/\<[a-z]+\>//gi;
322 $input=~ s/\<\/[a-z]+\>//gi;