Consistency check between Makefile.pl and about.pl We weren't picking up JSOM so...
[koha.git] / catalogue / moredetail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2003 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20
21 use strict;
22 use C4::Koha;
23 use CGI;
24 use C4::Biblio;
25 use C4::Items;
26 use C4::Branch;
27 use C4::Acquisition;
28 use C4::Output;             # contains gettemplate
29 use C4::Auth;
30 use C4::Serials;
31 use C4::Dates qw/format_date/;
32 use C4::Circulation;  # to use itemissues
33
34 my $query=new CGI;
35
36 # FIXME  subject is not exported to the template?
37 my $subject=$query->param('subject');
38
39 # if its a subject we need to use the subject.tmpl
40 my ($template, $loggedinuser, $cookie) = get_template_and_user({
41     template_name   => ($subject? 'catalogue/subject.tmpl':
42                       'catalogue/moredetail.tmpl'),
43     query           => $query,
44     type            => "intranet",
45     authnotrequired => 0,
46     flagsrequired   => {catalogue => 1},
47     });
48
49 # get variables
50
51 my $biblionumber=$query->param('biblionumber');
52 my $title=$query->param('title');
53 my $itemnumber=$query->param('itemnumber');
54 my $bi=$query->param('bi');
55 # $bi = $biblionumber unless $bi;
56 my $data=GetBiblioData($biblionumber);
57 my $dewey = $data->{'dewey'};
58
59 #coping with subscriptions
60 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
61
62 # FIXME Dewey is a string, not a number, & we should use a function
63 # $dewey =~ s/0+$//;
64 # if ($dewey eq "000.") { $dewey = "";};
65 # if ($dewey < 10){$dewey='00'.$dewey;}
66 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
67 # if ($dewey <= 0){
68 #      $dewey='';
69 # }
70 # $dewey=~ s/\.$//;
71 # $data->{'dewey'}=$dewey;
72
73 my @results;
74 my $fw = GetFrameworkCode($biblionumber);
75 my @items= GetItemsInfo($biblionumber);
76 my $count=@items;
77 $data->{'count'}=$count;
78
79 my $ordernum = GetOrderNumber($biblionumber);
80 my $order = GetOrder($ordernum);
81 my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
82 my $itemtypes = GetItemTypes;
83
84 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
85 $results[0]=$data;
86 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
87 foreach my $item (@items){
88     $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
89     $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
90     $item->{'collection'} = $ccodes->{$item->{ccode}};
91     $item->{'itype'} = $itemtypes->{$item->{'itype'}}->{'description'}; 
92     $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
93     $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
94     $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
95     $item->{'datelastseen'} = format_date($item->{'datelastseen'});
96     $item->{'ordernumber'} = $ordernum;
97     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
98     $item->{'copyvol'} = $item->{'copynumber'};
99     if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
100         $item->{status_advisory} = 1;
101     }
102
103     if (C4::Context->preference("IndependantBranches")) {
104         #verifying rights
105         my $userenv = C4::Context->userenv();
106         unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
107                 $item->{'nomod'}=1;
108         }
109     }
110     $item->{'homebranchname'} = GetBranchName($item->{'homebranch'});
111     $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'});
112     if ($item->{'onloan'} eq ''){
113         $item->{'issue'}= 0;
114     } else {
115         $item->{'onloan'} = format_date($item->{'onloan'});
116         $item->{'issue'}= 1;
117     }
118 }
119 $template->param(count => $data->{'count'},
120         subscriptionsnumber => $subscriptionsnumber,
121     subscriptiontitle   => $data->{title},
122 );
123 $template->param(BIBITEM_DATA => \@results);
124 $template->param(ITEM_DATA => \@items);
125 $template->param(moredetailview => 1);
126 $template->param(loggedinuser => $loggedinuser);
127 $template->param(biblionumber => $biblionumber);
128 $template->param(biblioitemnumber => $bi);
129 $template->param(itemnumber => $itemnumber);
130 $template->param(ONLY_ONE => 1) if ( $itemnumber && $count != @items );
131
132 output_html_with_http_headers $query, $cookie, $template->output;
133