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