2 #script to provide intranet (librarian) advanced search facility
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
32 #whether it is called from the opac or the intranet
33 my $type=$input->param('type');if ($type eq ''){
37 my $ttype=$input->param('ttype');
55 #build hash of users input
56 my $title=validate($input->param('title'));
57 $search{'title'}=$title;
59 my $keyword=validate($input->param('keyword'));
60 $search{'keyword'}=$keyword;
62 $search{'front'}=validate($input->param('front'));
64 my $author=validate($input->param('author'));
65 $search{'author'}=$author;
67 my $illustrator=validate($input->param('illustrator'));
68 $search{'illustrator'}=$illustrator;
70 my $subject=validate($input->param('subject'));
71 $search{'subject'}=$subject;
73 my $itemnumber=validate($input->param('item'));
74 $search{'item'}=$itemnumber;
76 my $isbn=validate($input->param('isbn'));
77 $search{'isbn'}=$isbn;
79 my $datebefore=validate($input->param('date-before'));
80 $search{'date-before'};
82 my $class=$input->param('class');
83 $search{'class'}=$class;
85 $search{'ttype'}=$ttype;
87 my $dewey=validate($input->param('dewey'));
88 $search{'dewey'}=$dewey;
90 my $branch=validate($input->param('branch'));
91 $search{'branch'}=$branch;
94 my $offset=$input->param('offset');
98 my $num=$input->param('num');
103 print startmenu($type);
105 #print $search{'ttype'};
106 if ($type eq 'intra'){
107 print mkheadr(1,'Catalogue Search Results');
108 } elsif ($type eq 'catmain'){
109 print mkheadr(1,'Catalogue Maintenance');
111 print mkheadr(1,'Opac Search Results');
116 if ($itemnumber ne '' || $isbn ne ''){
117 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
120 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
123 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
124 }elsif ($title ne '' || $author ne '' || $illustrator ne '' || $dewey ne '' || $class ne '') {
125 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
129 print "You searched on ";
130 while ( my ($key, $value) = each %search) {
131 if ($value ne '' && $key ne 'ttype'){
133 print bold("$key $value,");
136 print " $count results found";
137 my $offset2=$num+$offset;
138 my $dispnum=$offset+1;
139 print "<br> Results $dispnum to $offset2 displayed";
141 if ($type ne 'opac'){
143 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
144 } elsif ($illustrator ne '') {
145 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
147 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
151 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
152 } elsif ($illustrator ne '') {
153 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
155 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
159 if ($keyword ne '' && $offset > 0){
160 $count2=$count-$offset;
168 while ($i < $count2){
169 # print $results[$i]."\n";
170 # my @stuff=split('\t',$results[$i]);
171 my $result=$results[$i];
172 $result->{'title'}=~ s/\`/\\\'/g;
173 my $title2=$result->{'title'};
178 $result->{'title'}=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$result->{'biblionumber'}&title=$title2",$result->{'title'});
179 my $word=$result->{'author'};
180 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
183 $word=~ s/\,/\,%20/g;
185 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
186 $result->{'author'}=mklink($url,$result->{'author'});
187 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$result->{'biblionumber'},$type);
190 # Fix this chunk below, remove all hardcoded branch references
191 # need to fix itemcount as well
194 $location=$location."On Loan";
196 $location=$location." ($nacount)";
201 $location=$location."Levin";
203 $location=$location." ($lcount)";
208 $location=$location."Foxton";
210 $location=$location." ($fcount)";
215 $location=$location."Shannon";
217 $location=$location." ($scount)";
222 $location=$location."Lost";
224 $location=$location." ($lostcount)";
229 $location=$location."Mending";
231 $location=$location." ($mending)";
236 $location=$location."In Transiit";
238 $location=$location." ($transit)";
243 $location=$location."On Order";
245 $location=$location." ($ocount)";
250 # if ($type ne 'opac'){
251 # $result->{'request'}=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
254 my $word=$result->{'subject'};
257 $result->{'title'}=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$result->{'subject'});
263 print mktablerow(7,$secondary,$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
265 print mktablerow(6,$secondary,$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
270 print mktablerow(7,'white',$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
272 print mktablerow(6,'white',$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
278 $offset=$num+$offset;
279 if ($type ne 'opac'){
281 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
283 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
287 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
289 print mktablerow(6,$main,' ',' ',' ',' ','','');
295 $search="num=$num&offset=$offset&type=$type";
297 $subject=~ s/ /%20/g;
298 $search=$search."&subject=$subject";
302 $search=$search."&title=$title";
306 $search=$search."&author=$author";
309 $keyword=~ s/ /%20/g;
310 $search=$search."&keyword=$keyword";
313 $keyword=~ s/ /%20/g;
314 $search=$search."&class=$class";
317 $search=$search."&dewey=$dewey";
319 $search.="&ttype=$ttype";
320 if ($offset < $count){
321 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
327 for (my $i=1;$i<$pages;$i++){
330 $search=~ s/offset=[0-9]+/offset=$temp/;
331 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
336 print endmenu($type);
342 $input=~ s/\<[a-z]+\>//gi;
343 $input=~ s/\<\/[a-z]+\>//gi;