2 #script to provide intranet (librarian) advanced search facility
13 #whether it is called from the opac of the intranet
14 my $type=$input->param('type');
18 my $ttype=$input->param('ttype');
33 #build hash of users input
34 my $title=validate($input->param('title'));
35 $search{'title'}=$title;
36 my $keyword=validate($input->param('keyword'));
37 $search{'keyword'}=$keyword;
38 $search{'front'}=validate($input->param('front'));
39 my $author=validate($input->param('author'));
40 $search{'author'}=$author;
41 my $illustrator=validate($input->param('illustrator'));
42 $search{'illustrator'}=$illustrator;
43 my $subject=validate($input->param('subject'));
44 $search{'subject'}=$subject;
45 my $itemnumber=validate($input->param('item'));
46 $search{'item'}=$itemnumber;
47 my $isbn=validate($input->param('isbn'));
48 $search{'isbn'}=$isbn;
49 my $datebefore=validate($input->param('date-before'));
50 $search{'date-before'};
51 my $class=$input->param('class');
52 $search{'class'}=$class;
53 $search{'ttype'}=$ttype;
54 my $dewey=validate($input->param('dewey'));
55 $search{'dewey'}=$dewey;
56 my $branch=validate($input->param('branch'));
57 $search{'branch'}=$branch;
59 my $offset=$input->param('offset');
63 my $num=$input->param('num');
68 print startmenu($type);
70 #print $search{'ttype'};
71 if ($type eq 'intra'){
72 print mkheadr(1,'Catalogue Search Results');
73 } elsif ($type eq 'catmain'){
74 print mkheadr(1,'Catalogue Maintenance');
76 print mkheadr(1,'Opac Search Results');
81 if ($itemnumber ne '' || $isbn ne ''){
82 ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
85 ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
88 ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
89 }elsif ($title ne '' || $author ne '' || $illustrator ne '' || $dewey ne '' || $class ne '') {
90 ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
94 print "You searched on ";
95 while ( my ($key, $value) = each %search) {
96 if ($value ne '' && $key ne 'ttype'){
98 print bold("$key $value,");
101 print " $count results found";
102 my $offset2=$num+$offset;
103 my $dispnum=$offset+1;
104 print "<br> Results $dispnum to $offset2 displayed";
106 if ($type ne 'opac'){
108 print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
109 } elsif ($illustrator ne '') {
110 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
112 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
116 print mktablerow(6,$main,'<b>SUBJECT</b>',' ',' ');
117 } elsif ($illustrator ne '') {
118 print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
120 print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('©'),'<b>COUNT</b>',bold('BRANCH'),'');
124 if ($keyword ne '' && $offset > 0){
125 $count2=$count-$offset;
133 while ($i < $count2){
134 # print $results[$i]."\n";
135 my @stuff=split('\t',$results[$i]);
136 $stuff[1]=~ s/\`/\\\'/g;
137 my $title2=$stuff[1];
141 $stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
144 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
147 $word=~ s/\,/\,%20/g;
149 my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
152 $stuff[0]=mklink($url,$stuff[0]);
153 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type);
156 $stuff[5]=$stuff[5]."On Loan";
158 $stuff[5]=$stuff[5]." ($nacount)";
163 $stuff[5]=$stuff[5]."Levin";
165 $stuff[5]=$stuff[5]." ($lcount)";
170 $stuff[5]=$stuff[5]."Foxton";
172 $stuff[5]=$stuff[5]." ($fcount)";
177 $stuff[5]=$stuff[5]."Shannon";
179 $stuff[5]=$stuff[5]." ($scount)";
184 $stuff[5]=$stuff[5]."Lost";
186 $stuff[5]=$stuff[5]." ($lostcount)";
191 $stuff[5]=$stuff[5]."Mending";
193 $stuff[5]=$stuff[5]." ($mending)";
198 $stuff[5]=$stuff[5]."In Transiit";
200 $stuff[5]=$stuff[5]." ($transit)";
205 $stuff[5]=$stuff[5]."On Order";
207 $stuff[5]=$stuff[5]." ($ocount)";
212 if ($type ne 'opac'){
213 $stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
219 $stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
225 print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
227 print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
232 print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
234 print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
240 $offset=$num+$offset;
241 if ($type ne 'opac'){
243 print mktablerow(7,$main,' ',' ',' ',' ','','','','/images/background-mem.gif');
245 print mktablerow(6,$main,' ',' ',' ',' ','','','/images/background-mem.gif');
249 print mktablerow(7,$main,' ',' ',' ',' ','', '','');
251 print mktablerow(6,$main,' ',' ',' ',' ','','');
257 $search="num=$num&offset=$offset&type=$type";
259 $subject=~ s/ /%20/g;
260 $search=$search."&subject=$subject";
264 $search=$search."&title=$title";
268 $search=$search."&author=$author";
271 $keyword=~ s/ /%20/g;
272 $search=$search."&keyword=$keyword";
275 $keyword=~ s/ /%20/g;
276 $search=$search."&class=$class";
279 $search=$search."&dewey=$dewey";
281 $search.="&ttype=$ttype";
282 if ($offset < $count){
283 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
289 for (my $i=1;$i<$pages;$i++){
292 $search=~ s/offset=[0-9]+/offset=$temp/;
293 my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
298 print endmenu($type);
304 $input=~ s/\<[a-z]+\>//gi;
305 $input=~ s/\<\/[a-z]+\>//gi;