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,$branchcount)=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 foreach my $branchcode (sort keys %$branchcount) {
201 my $branchname=branchname($branchcode);
202 my $c=$branchcount->{$branchcode};
203 $stuff[5].="$branchname";
209 if ($lostcount > 0) {
210 $stuff[5]=$stuff[5]."Lost";
212 $stuff[5]=$stuff[5]." ($lostcount)";
217 $stuff[5]=$stuff[5]."Mending";
219 $stuff[5]=$stuff[5]." ($mending)";
224 $stuff[5]=$stuff[5]."In Transiit";
226 $stuff[5]=$stuff[5]." ($transit)";
231 $stuff[5]=$stuff[5]."On Order";
233 $stuff[5]=$stuff[5]." ($ocount)";
238 if ($type ne 'opac'){
239 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
245 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
251 print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
253 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
258 print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
260 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
266 $offset=$num+$offset;
267 if ($type ne 'opac'){
269 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
271 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
275 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
277 print mktablerow(6,$main,' ',' ',' ',' ','','');
283 $search="num=$num&offset=$offset&type=$type";
285 $subject=~ s/ /%20/g;
286 $search=$search."&subject=$subject";
290 $search=$search."&title=$title";
294 $search=$search."&author=$author";
297 $keyword=~ s/ /%20/g;
298 $search=$search."&keyword=$keyword";
301 $keyword=~ s/ /%20/g;
302 $search=$search."&class=$class";
305 $search=$search."&dewey=$dewey";
307 $search.="&ttype=$ttype";
308 if ($offset < $count){
309 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
315 for (my $i=1;$i<$pages;$i++){
318 $search=~ s/offset=[0-9]+/offset=$temp/;
319 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
324 print endmenu($type);
330 $input=~ s/\<[a-z]+\>//gi;
331 $input=~ s/\<\/[a-z]+\>//gi;