2 #script to provide intranet (librarian) advanced search facility
15 #whether it is called from the opac or the intranet
16 my $type=$input->param('type');if ($type eq ''){
20 my $ttype=$input->param('ttype');
38 #build hash of users input
39 my $title=validate($input->param('title'));
40 $search{'title'}=$title;
42 my $keyword=validate($input->param('keyword'));
43 $search{'keyword'}=$keyword;
45 $search{'front'}=validate($input->param('front'));
47 my $author=validate($input->param('author'));
48 $search{'author'}=$author;
50 my $illustrator=validate($input->param('illustrator'));
51 $search{'illustrator'}=$illustrator;
53 my $subject=validate($input->param('subject'));
54 $search{'subject'}=$subject;
56 my $itemnumber=validate($input->param('item'));
57 $search{'item'}=$itemnumber;
59 my $isbn=validate($input->param('isbn'));
60 $search{'isbn'}=$isbn;
62 my $datebefore=validate($input->param('date-before'));
63 $search{'date-before'}=$datebefore;
65 my $class=$input->param('class');
66 $search{'class'}=$class;
68 $search{'ttype'}=$ttype;
70 my $dewey=validate($input->param('dewey'));
71 $search{'dewey'}=$dewey;
73 my $branch=validate($input->param('branch'));
74 $search{'branch'}=$branch;
77 my $offset=$input->param('offset');
81 my $num=$input->param('num');
86 print startmenu($type);
88 #print $search{'ttype'};
89 if ($type eq 'intra'){
90 print mkheadr(1,'Catalogue Search Results');
91 } elsif ($type eq 'catmain'){
92 print mkheadr(1,'Catalogue Maintenance');
94 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('LOCATION'),'');
137 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'');
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,$branchcount)=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 my ($numbranches, @branches) = branches();
203 foreach (@branches) {
204 my $branchcode=$_->{'branchcode'};
205 my $branchname=$_->{'branchname'};
206 $branchinfo->{$branchcode}=$branchname;
208 if ($numbranches>1) {
209 foreach my $branchcode (sort keys %$branchcount) {
210 my $c=$branchcount->{$branchcode};
211 $stuff[5].=$branchinfo->{$branchcode};
218 my $shelfcount=$count-$nacount-$lostcount-$mending-$transit;
220 $stuff[5]="On Loan ";
222 $stuff[5].="($nacount) ";
228 $stuff[5].="($shelfcount) ";
232 if ($lostcount > 0) {
233 $stuff[5]=$stuff[5]."Lost";
235 $stuff[5]=$stuff[5]." ($lostcount)";
240 $stuff[5]=$stuff[5]."Mending";
242 $stuff[5]=$stuff[5]." ($mending)";
247 $stuff[5]=$stuff[5]."In Transit";
249 $stuff[5]=$stuff[5]." ($transit)";
254 $stuff[5]=$stuff[5]."On Order";
256 $stuff[5]=$stuff[5]." ($ocount)";
261 if ($type ne 'opac'){
262 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
268 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
274 print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
276 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
281 print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
283 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
289 $offset=$num+$offset;
290 if ($type ne 'opac'){
292 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
294 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
298 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
300 print mktablerow(6,$main,' ',' ',' ',' ','','');
306 $search="num=$num&offset=$offset&type=$type";
308 $subject=~ s/ /%20/g;
309 $search=$search."&subject=$subject";
313 $search=$search."&title=$title";
317 $search=$search."&author=$author";
320 $keyword=~ s/ /%20/g;
321 $search=$search."&keyword=$keyword";
324 $keyword=~ s/ /%20/g;
325 $search=$search."&class=$class";
328 $search=$search."&dewey=$dewey";
330 $search.="&ttype=$ttype";
331 if ($offset < $count){
332 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
338 for (my $i=1;$i<$pages;$i++){
341 $search=~ s/offset=[0-9]+/offset=$temp/;
342 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
347 print endmenu($type);
353 $input=~ s/\<[a-z]+\>//gi;
354 $input=~ s/\<\/[a-z]+\>//gi;