added a check in the returnbook subroutine that checks to see if a book has been...
[koha.git] / html-template / 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=$query->param('type');
35
36 # change back when ive fixed request.pl
37 my @items = ItemInfo(undef, $biblionumber, $type);
38 foreach my $dat (@items){
39     $dat->{'type'}=$type;
40 }
41 my $dat=bibdata($biblionumber);
42 my ($authorcount, $addauthor)= &addauthor($biblionumber);
43 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
44 my ($websitecount, @websites)             = &getwebsites($biblionumber);
45
46 $dat->{'count'}=@items;
47
48 $dat->{'additional'}=$addauthor->[0]->{'author'};
49 for (my $i = 1; $i < $authorcount; $i++) {
50         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
51 } # for
52
53 my @results;
54
55 $results[0]=$dat;
56
57 my $resultsarray=\@results;
58 my $itemsarray=\@items;
59 my $webarray=\@webbiblioitems;
60 my $sitearray=\@websites;
61
62 my $includes=$configfile{'includes'};
63 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
64 my $templatebase="catalogue/detail.tmpl";
65 my $startfrom=$query->param('startfrom');
66 ($startfrom) || ($startfrom=0);
67 my $theme=picktemplate($includes, $templatebase);
68
69 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
70
71 my $count=1;
72
73 # now to get the items into a hash we can use and whack that thru
74
75
76 $template->param(startfrom => $startfrom+1);
77 $template->param(endat => $startfrom+20);
78 $template->param(numrecords => $count);
79 my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
80 my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
81 $template->param(nextstartfrom => $nextstartfrom);
82 $template->param(prevstartfrom => $prevstartfrom);
83 # $template->param(template => $templatename);
84 # $template->param(search => $search);
85 $template->param(includesdir => $includes);
86 $template->param(BIBLIO_RESULTS => $resultsarray);
87 $template->param(ITEM_RESULTS => $itemsarray);
88 $template->param(WEB_RESULTS => $webarray);
89 $template->param(SITE_RESULTS => $sitearray);
90 print "Content-Type: text/html\n\n", $template->output;
91