Merged changes from rel-1-2. Abstracted table structure changes by alan.
[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 print startpage();
16 print startmenu($type);
17 my $blah;
18 my $env;
19 my $subject=$input->param('subject');
20 #my $title=$input->param('title');
21
22 my $main;                                                                                                                                 
23 my $secondary;                                                                                                                            
24 if ($type eq 'opac'){                                                                                                                     
25   $main='#99cccc';                                                                                                                        
26   $secondary='#efe5ef';                                                                                                                   
27 } else {                                                                                                                                  
28   $main='#99cc33';                                                                                                                        
29   $secondary='#ffffcc';                                                                                                                   
30 }      
31
32 my @items=subsearch(\$blah,$subject);
33 #print @items;
34 my $count=@items;
35 my $i=0;
36 print center();
37 print mktablehdr;
38 if ($type ne 'opac'){
39   print mktablerow(5,$main,bold('TITLE'),bold('AUTHOR'),bold('COUNT'),bold('LOCATION'),' ',"/images/background-mem.gif"); 
40 } else {
41   print mktablerow(5,$main,bold('TITLE'),bold('AUTHOR'),bold('COUNT'),bold('BRANCH'),'   '); 
42 }
43 my $colour=1;
44 while ($i < $count){
45   my @results=split('\t',$items[$i]);
46   $results[0]=mklink("/cgi-bin/koha/detail.pl?bib=$results[2]&type=$type",$results[0]);
47   my $word=$results[1];
48   $word=~ s/ //g;
49   $word=~ s/\,/\,%20/;
50   $results[1]=mklink("/cgi-bin/koha/search.pl?author=$word&type=$type",$results[1]);
51   my ($count,$lcount,$nacount,$fcount,$scount)=itemcount($env,$results[2]);                                                                     
52   $results[3]=$count;                                                                                                                           
53   if ($nacount > 0){                                                                                                                          
54     $results[4]=$results[4]."On Loan";                                                                                                          
55     if ($nacount > 1){
56       $results[4].=" $nacount";
57     }
58     $results[4].=" ";
59   }                                                                                                                                           
60   if ($lcount > 0){                                                                                                                           
61     $results[4]=$results[4]." Levin";                                                                                                          
62     if ($lcount > 1){
63       $results[4].=" $lcount";
64     }
65     $results[4].=" ";
66   }                                                                                                                                           
67   if ($fcount > 0){                                                                                                                           
68     $results[4]=$results[4]." Foxton";                                                                                                          
69     if ($fcount > 1){
70       $results[4].=" $fcount";
71     }
72     $results[4].=" ";
73   }                                                                                                                                           
74   if ($scount > 0){                                                                                                                           
75     $results[4]=$results[4]." Shannon";                                                                                                          
76     if ($scount > 1){
77       $results[4].=" $scount";
78     }
79     $results[4].=" ";
80   }             
81   if ($type ne 'opac'){
82     $results[6]=mklink("/cgi-bin/koha/request.pl?bib=$results[2]","Request");
83   }
84   if ($colour == 1){                                                                          
85     print mktablerow(5,$secondary,$results[0],$results[1],$results[3],$results[4],$results[6]);                                        
86     $colour=0;                                                                   
87   } else{                                                                        
88     print mktablerow(5,'white',$results[0],$results[1],$results[3],$results[4],$results[6]);                                     
89     $colour=1;                                                                                
90   }
91    $i++;
92 }
93 print endcenter();
94 print mktableft();
95 print endmenu($type);
96 print endpage();