A little more refactoring....
[koha.git] / subjectsearch.pl
1 #!/usr/bin/perl
2
3 #script to display detailed information
4 #written 8/11/99
5
6 use strict;
7 #use DBI;
8 use C4::Search;
9 use CGI;
10 use C4::Output;
11
12 my $input = new CGI;
13 print $input->header;
14 my $type=$input->param('type');
15 (-e "opac") && ($type='opac');
16 print startpage();
17 print startmenu($type);
18 my $blah;
19 my $env;
20 my $subject=$input->param('subject');
21 #my $title=$input->param('title');
22
23 my $main;                                                                                                                                 
24 my $secondary;                                                                                                                            
25 if ($type eq 'opac'){                                                                                                                     
26   $main='#99cccc';                                                                                                                        
27   $secondary='#efe5ef';                                                                                                                   
28 } else {                                                                                                                                  
29   $main='#99cc33';                                                                                                                        
30   $secondary='#ffffcc';                                                                                                                   
31 }      
32
33 my @items=subsearch(\$blah,$subject);
34 #print @items;
35 my $count=@items;
36 my $i=0;
37 print center();
38 print mktablehdr;
39 if ($type ne 'opac'){
40   print mktablerow(5,$main,bold('TITLE'),bold('AUTHOR'),bold('COUNT'),bold('LOCATION'),' ',"/images/background-mem.gif"); 
41 } else {
42   print mktablerow(5,$main,bold('TITLE'),bold('AUTHOR'),bold('COUNT'),bold('BRANCH'),'   '); 
43 }
44 my $colour=1;
45 while ($i < $count){
46   my @results=split('\t',$items[$i]);
47   $results[0]=mklink("/cgi-bin/koha/detail.pl?bib=$results[2]&type=$type",$results[0]);
48   my $word=$results[1];
49   $word=~ s/ /%20/g;
50   #$word=~ s/\,/\,%20/;
51   $results[1]=mklink("/cgi-bin/koha/search.pl?author=$word&type=$type",$results[1]);
52   my ($count,$lcount,$nacount,$fcount,$scount)=itemcount($env,$results[2]);                                                                     
53   $results[3]=$count;                                                                                                                           
54   if ($nacount > 0){                                                                                                                          
55     $results[4]=$results[4]."On Loan";                                                                                                          
56     if ($nacount > 1){
57       $results[4].=" $nacount";
58     }
59     $results[4].=" ";
60   }                                                                                                                                           
61   if ($lcount > 0){                                                                                                                           
62     $results[4]=$results[4]." Levin";                                                                                                          
63     if ($lcount > 1){
64       $results[4].=" $lcount";
65     }
66     $results[4].=" ";
67   }                                                                                                                                           
68   if ($fcount > 0){                                                                                                                           
69     $results[4]=$results[4]." Foxton";                                                                                                          
70     if ($fcount > 1){
71       $results[4].=" $fcount";
72     }
73     $results[4].=" ";
74   }                                                                                                                                           
75   if ($scount > 0){                                                                                                                           
76     $results[4]=$results[4]." Shannon";                                                                                                          
77     if ($scount > 1){
78       $results[4].=" $scount";
79     }
80     $results[4].=" ";
81   }             
82   if ($type ne 'opac'){
83     $results[6]=mklink("/cgi-bin/koha/request.pl?bib=$results[2]","Request");
84   }
85   if ($colour == 1){                                                                          
86     print mktablerow(5,$secondary,$results[0],$results[1],$results[3],$results[4],$results[6]);                                        
87     $colour=0;                                                                   
88   } else{                                                                        
89     print mktablerow(5,'white',$results[0],$results[1],$results[3],$results[4],$results[6]);                                     
90     $colour=1;                                                                                
91   }
92    $i++;
93 }
94 print endcenter();
95 print mktableft();
96 print endmenu($type);
97 print endpage();