*** empty log message ***
[koha.git] / subjectsearch.pl
1 #!/usr/bin/perl
2
3 #script to display detailed information
4 #written 8/11/99
5
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use strict;
25 #use DBI;
26 use C4::Search;
27 use CGI;
28 use C4::Output;
29
30 my $input = new CGI;
31 print $input->header;
32 my $type=$input->param('type');
33 print startpage();
34 print startmenu($type);
35 my $blah;
36 my $env;
37 my $subject=$input->param('subject');
38 #my $title=$input->param('title');
39
40 my $main;                                                                                                                                 
41 my $secondary;                                                                                                                            
42 if ($type eq 'opac'){                                                                                                                     
43   $main='#99cccc';                                                                                                                        
44   $secondary='#efe5ef';                                                                                                                   
45 } else {                                                                                                                                  
46   $main='#99cc33';                                                                                                                        
47   $secondary='#ffffcc';                                                                                                                   
48 }      
49
50 my @items=subsearch(\$blah,$subject);
51 #print @items;
52 my $count=@items;
53 my $i=0;
54 print center();
55 print mktablehdr;
56 if ($type ne 'opac'){
57   print mktablerow(5,$main,bold('TITLE'),bold('AUTHOR'),bold('COUNT'),bold('LOCATION'),' ',"/images/background-mem.gif"); 
58 } else {
59   print mktablerow(5,$main,bold('TITLE'),bold('AUTHOR'),bold('COUNT'),bold('BRANCH'),'   '); 
60 }
61 my $colour=1;
62 while ($i < $count){
63   my @results=split('\t',$items[$i]);
64   $results[0]=mklink("/cgi-bin/koha/detail.pl?bib=$results[2]&type=$type",$results[0]);
65   my $word=$results[1];
66   $word=~ s/ /%20/g;
67   #$word=~ s/\,/\,%20/;
68   $results[1]=mklink("/cgi-bin/koha/search.pl?author=$word&type=$type",$results[1]);
69   my ($count,$lcount,$nacount,$fcount,$scount)=itemcount($env,$results[2]);                                                                     
70   $results[3]=$count;                                                                                                                           
71   if ($nacount > 0){                                                                                                                          
72     $results[4]=$results[4]."On Loan";                                                                                                          
73     if ($nacount > 1){
74       $results[4].=" $nacount";
75     }
76     $results[4].=" ";
77   }                                                                                                                                           
78   if ($lcount > 0){                                                                                                                           
79     $results[4]=$results[4]." Levin";                                                                                                          
80     if ($lcount > 1){
81       $results[4].=" $lcount";
82     }
83     $results[4].=" ";
84   }                                                                                                                                           
85   if ($fcount > 0){                                                                                                                           
86     $results[4]=$results[4]." Foxton";                                                                                                          
87     if ($fcount > 1){
88       $results[4].=" $fcount";
89     }
90     $results[4].=" ";
91   }                                                                                                                                           
92   if ($scount > 0){                                                                                                                           
93     $results[4]=$results[4]." Shannon";                                                                                                          
94     if ($scount > 1){
95       $results[4].=" $scount";
96     }
97     $results[4].=" ";
98   }             
99   if ($type ne 'opac'){
100     $results[6]=mklink("/cgi-bin/koha/request.pl?bib=$results[2]","Request");
101   }
102   if ($colour == 1){                                                                          
103     print mktablerow(5,$secondary,$results[0],$results[1],$results[3],$results[4],$results[6]);                                        
104     $colour=0;                                                                   
105   } else{                                                                        
106     print mktablerow(5,'white',$results[0],$results[1],$results[3],$results[4],$results[6]);                                     
107     $colour=1;                                                                                
108   }
109    $i++;
110 }
111 print endcenter();
112 print mktableft();
113 print endmenu($type);
114 print endpage();