Committing changes to add authentication and opac templating to rel-1-2 branch
[koha.git] / moredetail.pl
blob5757e0a52f2fc5694ea87862fb539e83232d16f9
1 #!/usr/bin/perl
2 use HTML::Template;
3 use strict;
4 require Exporter;
5 use C4::Koha;
6 use CGI;
7 use C4::Search;
8 use C4::Acquisitions;
9 use C4::Output; # contains picktemplate
11 my $query=new CGI;
14 my $language='french';
17 my %configfile;
18 open (KC, "/etc/koha.conf");
19 while (<KC>) {
20 chomp;
21 (next) if (/^\s*#/);
22 if (/(.*)\s*=\s*(.*)/) {
23 my $variable=$1;
24 my $value=$2;
25 # Clean up white space at beginning and end
26 $variable=~s/^\s*//g;
27 $variable=~s/\s*$//g;
28 $value=~s/^\s*//g;
29 $value=~s/\s*$//g;
30 $configfile{$variable}=$value;
34 my $includes=$configfile{'includes'};
35 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
36 my $templatebase="catalogue/moredetail.tmpl";
37 my $startfrom=$query->param('startfrom');
38 ($startfrom) || ($startfrom=0);
39 my $theme=picktemplate($includes, $templatebase);
41 my $subject=$query->param('subject');
42 # if its a subject we need to use the subject.tmpl
43 if ($subject){
44 $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
46 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
48 # get variables
50 my $biblionumber=$query->param('bib');
51 my $title=$query->param('title');
52 my $bi=$query->param('bi');
54 my $data=bibitemdata($bi);
55 my $dewey = $data->{'dewey'};
56 $dewey =~ s/0+$//;
57 if ($dewey eq "000.") { $dewey = "";};
58 if ($dewey < 10){$dewey='00'.$dewey;}
59 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
60 if ($dewey <= 0){
61 $dewey='';
63 $dewey=~ s/\.$//;
64 $data->{'dewey'}=$dewey;
66 my @results;
68 my (@items)=itemissues($bi);
69 my $count=@items;
70 $data->{'count'}=$count;
71 my ($order,$ordernum)=getorder($bi,$biblionumber);
73 my $env;
74 $env->{itemcount}=1;
76 $results[0]=$data;
78 foreach my $item (@items){
79 $item->{'itemlost'}=~ s/0/No/;
80 $item->{'itemlost'}=~ s/1/Yes/;
81 $item->{'withdrawn'}=~ s/0/No/;
82 $item->{'withdrawn'}=~ s/1/Yes/;
83 $item->{'replacementprice'}+=0.00;
84 my $year=substr($item->{'timestamp0'},0,4);
85 my $mon=substr($item->{'timestamp0'},4,2);
86 my $day=substr($item->{'timestamp0'},6,2);
87 $item->{'timestamp0'}="$day/$mon/$year";
88 $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
89 $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
90 if ($item->{'date_due'} = 'Available'){
91 $item->{'issue'}="<b>Currently on issue to:</b><br>";
92 } else {
93 $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
98 $template->param(includesdir => $includes);
99 $template->param(BIBITEM_DATA => \@results);
100 $template->param(ITEM_DATA => \@items);
101 print "Content-Type: text/html\n\n", $template->output;