Kumara - predecessor to Koha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
3.5 KiB

  1. #!/usr/bin/perl
  2. #script to provide intranet (librarian) advanced search facility
  3. #modified 9/11/1999 by chris@katipo.co.nz
  4. #adding an extra comment to play with CVS (Si, 19/11/99)
  5. use strict;
  6. #use DBI;
  7. use C4::Search;
  8. use CGI;
  9. use C4::Output;
  10. my $env;
  11. my $input = new CGI;
  12. print $input->header;
  13. #print $input->Dump;
  14. my $blah;
  15. my %search;
  16. #build hash of users input
  17. my $keyword=validateinp($input->param('keyword'));
  18. #my $keyword=$input->param('keyword');
  19. #$keyword=~ s/'/\'/g;
  20. $search{'keyword'}=$keyword;
  21. my @results;
  22. my $offset=$input->param('offset');
  23. if ($offset eq ''){
  24. $offset=0;
  25. }
  26. my $num=$input->param('num');
  27. if ($num eq ''){
  28. $num=10;
  29. }
  30. print startpage();
  31. print startmenu('opac');
  32. print mkheadr(1,"Opac Search Results for $keyword");
  33. print center();
  34. my $count;
  35. my @results;
  36. if ($search{'keyword'} ne ''){
  37. ($count,@results)=&OpacSearch(\$blah,'loose',\%search,$num,$offset);
  38. }
  39. #print "You searched on <b>$keyword</b>";
  40. print " $count results found";
  41. my $offset2=$num+$offset;
  42. my $disp=$offset+1;
  43. print ", Results $disp to $offset2 displayed";
  44. print mktablehdr;
  45. print mktablerow(4,'#99cccc','<b>TITLE</b>','<b>AUTHOR</b>','<b>COUNT</b>',bold('BRANCH'));
  46. my $count2=@results;
  47. my $i=0;
  48. my $colour=1;
  49. while ($i < $count2){
  50. my @stuff=split('\t',$results[$i]);
  51. $stuff[1]=~ s/\`/\'/g;
  52. my $title2=$stuff[1];
  53. $title2=~ s/ /%20/g;
  54. $stuff[1]=mklink("/cgi-bin/koha/detail.pl?bib=$stuff[2]&title=$title2&type=opac",$stuff[1]);
  55. my $word=$stuff[0];
  56. $word=~ s/ //g;
  57. $word=~ s/ /%20/g;
  58. $word=~ s/\,/\,%20/g;
  59. $word=~ s/\n//g;
  60. my $url="/cgi-bin/koha/search.pl?author=$word&type=opac";
  61. $stuff[0]=mklink($url,$stuff[0]);
  62. my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=itemcount($env,$stuff[2]);
  63. $stuff[3]=$count;
  64. if ($nacount > 0){
  65. $stuff[4]=$stuff[4]."On Loan";
  66. if ($nacount >1 ){
  67. $stuff[4]=$stuff[4]." ($nacount)";
  68. }
  69. $stuff[4].=" ";
  70. }
  71. if ($lcount > 0){
  72. $stuff[4]=$stuff[4]."Levin";
  73. if ($lcount >1 ){
  74. $stuff[4]=$stuff[4]." ($lcount)";
  75. }
  76. $stuff[4].=" ";
  77. }
  78. if ($fcount > 0){
  79. $stuff[4]=$stuff[4]."Foxton";
  80. if ($fcount >1 ){
  81. $stuff[4]=$stuff[4]." ($fcount)";
  82. }
  83. $stuff[4].=" ";
  84. }
  85. if ($scount > 0){
  86. $stuff[4]=$stuff[4]."Shannon";
  87. if ($scount >1 ){
  88. $stuff[4]=$stuff[4]." ($scount)";
  89. }
  90. $stuff[4].=" ";
  91. }
  92. if ($mending > 0){
  93. $stuff[4]=$stuff[4]."Mending";
  94. if ($mending >1 ){
  95. $stuff[4]=$stuff[4]." ($mending)";
  96. }
  97. $stuff[4].=" ";
  98. }
  99. if ($transit > 0){
  100. $stuff[4]=$stuff[4]."In Transit";
  101. if ($transit >1 ){
  102. $stuff[4]=$stuff[4]." ($transit)";
  103. }
  104. $stuff[4].=" ";
  105. }
  106. if ($colour == 1){
  107. print mktablerow(4,'#efe5ef',$stuff[1],$stuff[0],$stuff[3],$stuff[4]);
  108. $colour=0;
  109. } else{
  110. print mktablerow(4,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4]);
  111. $colour=1;
  112. }
  113. $i++;
  114. }
  115. $offset=$num+$offset;
  116. if ($offset < $count){
  117. $keyword=~ s/ /%20/g;
  118. my $search="num=$num&offset=$offset&keyword=$keyword";
  119. my $stuff=mklink("/cgi-bin/koha/opac-search.pl?$search",'Next Results');
  120. # print $stuff;
  121. print "<tr valign=top bgcolor=#99cccc><td colspan=4>$stuff
  122. </td></tr>";
  123. } else {
  124. print mktablerow(4,'#99cccc',' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp;');
  125. }
  126. print mktableft();
  127. print endcenter();
  128. print endmenu('opac');
  129. print endpage();
  130. sub validateinp {
  131. my ($input)=@_;
  132. $input=~ s/\<[a-z]+\>//gi;
  133. $input=~ s/\<\/[a-z]+\>//gi;
  134. $input=~ s/\<//g;
  135. $input=~ s/\>//g;
  136. $input=~ s/%//g;
  137. return($input);
  138. }