merges from rel-1-2. Starting to get a little longer now. Being very
[koha.git] / detail.pl
1 #!/usr/bin/perl
2 use HTML::Template;
3 use strict;
4 require Exporter;
5 use C4::Database;
6 use C4::Output;  # contains picktemplate
7 use CGI;
8 use C4::Search;
9  
10 my $query=new CGI;
11
12
13 my $language='french';
14
15
16 my %configfile;
17 open (KC, "/etc/koha.conf");
18 while (<KC>) {
19  chomp;
20  (next) if (/^\s*#/);
21  if (/(.*)\s*=\s*(.*)/) {
22    my $variable=$1;
23    my $value=$2;
24    # Clean up white space at beginning and end
25    $variable=~s/^\s*//g;
26    $variable=~s/\s*$//g;
27    $value=~s/^\s*//g;
28    $value=~s/\s*$//g;
29    $configfile{$variable}=$value;
30  }
31 }
32
33 my $biblionumber=$query->param('bib');
34 my $type='intra';
35
36 # change back when ive fixed request.pl
37 my @items = ItemInfo(undef, $biblionumber, $type);
38 my $dat=bibdata($biblionumber);
39 my ($authorcount, $addauthor)= &addauthor($biblionumber);
40 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
41 my ($websitecount, @websites)             = &getwebsites($biblionumber);
42
43 $dat->{'count'}=@items;
44
45 $dat->{'additional'}=$addauthor->[0]->{'author'};
46 for (my $i = 1; $i < $authorcount; $i++) {
47         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
48 } # for
49
50 my @results;
51
52 $results[0]=$dat;
53
54 my $resultsarray=\@results;
55 my $itemsarray=\@items;
56 my $webarray=\@webbiblioitems;
57 my $sitearray=\@websites;
58
59 my $includes=$configfile{'includes'};
60 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
61 my $templatebase="catalogue/detail.tmpl";
62 my $startfrom=$query->param('startfrom');
63 ($startfrom) || ($startfrom=0);
64 my $theme=picktemplate($includes, $templatebase);
65
66 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
67
68 my $count=1;
69
70 # now to get the items into a hash we can use and whack that thru
71
72
73 $template->param(startfrom => $startfrom+1);
74 $template->param(endat => $startfrom+20);
75 $template->param(numrecords => $count);
76 my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
77 my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
78 $template->param(nextstartfrom => $nextstartfrom);
79 $template->param(prevstartfrom => $prevstartfrom);
80 # $template->param(template => $templatename);
81 # $template->param(search => $search);
82 $template->param(includesdir => $includes);
83 $template->param(BIBLIO_RESULTS => $resultsarray);
84 $template->param(ITEM_RESULTS => $itemsarray);
85 $template->param(WEB_RESULTS => $webarray);
86 $template->param(SITE_RESULTS => $sitearray);
87 print "Content-Type: text/html\n\n", $template->output;
88