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 my $result=$results[$i];
154 $result->{'title'}=~ s/\`/\\\'/g;
155 my $title2=$result->{'title'};
160 $result->{'title'}=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$result->{'biblionumber'}&title=$title2",$result->{'title'});
161 my $word=$result->{'author'};
162 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
165 $word=~ s/\,/\,%20/g;
167 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
168 $result->{'author'}=mklink($url,$result->{'author'});
169 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$result->{'biblionumber'},$type);
172 # Fix this chunk below, remove all hardcoded branch references
173 # need to fix itemcount as well
176 $location=$location."On Loan";
178 $location=$location." ($nacount)";
183 $location=$location."Levin";
185 $location=$location." ($lcount)";
190 $location=$location."Foxton";
192 $location=$location." ($fcount)";
197 $location=$location."Shannon";
199 $location=$location." ($scount)";
204 $location=$location."Lost";
206 $location=$location." ($lostcount)";
211 $location=$location."Mending";
213 $location=$location." ($mending)";
218 $location=$location."In Transiit";
220 $location=$location." ($transit)";
225 $location=$location."On Order";
227 $location=$location." ($ocount)";
232 # if ($type ne 'opac'){
233 # $result->{'request'}=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
236 my $word=$result->{'subject'};
239 $result->{'title'}=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$result->{'subject'});
245 print mktablerow(7,$secondary,$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
247 print mktablerow(6,$secondary,$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
252 print mktablerow(7,'white',$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
254 print mktablerow(6,'white',$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
260 $offset=$num+$offset;
261 if ($type ne 'opac'){
263 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
265 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
269 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
271 print mktablerow(6,$main,' ',' ',' ',' ','','');
277 $search="num=$num&offset=$offset&type=$type";
279 $subject=~ s/ /%20/g;
280 $search=$search."&subject=$subject";
284 $search=$search."&title=$title";
288 $search=$search."&author=$author";
291 $keyword=~ s/ /%20/g;
292 $search=$search."&keyword=$keyword";
295 $keyword=~ s/ /%20/g;
296 $search=$search."&class=$class";
299 $search=$search."&dewey=$dewey";
301 $search.="&ttype=$ttype";
302 if ($offset < $count){
303 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
309 for (my $i=1;$i<$pages;$i++){
312 $search=~ s/offset=[0-9]+/offset=$temp/;
313 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
318 print endmenu($type);
324 $input=~ s/\<[a-z]+\>//gi;
325 $input=~ s/\<\/[a-z]+\>//gi;