3 # Copyright 2000-2003 Katipo Communications
5 # This file is part of Koha.
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
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.
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
28 use C4::Output; # contains gettemplate
31 use C4::Dates qw/format_date/;
32 use C4::Circulation; # to use itemissues
36 # FIXME subject is not exported to the template?
37 my $subject=$query->param('subject');
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'),
46 flagsrequired => {catalogue => 1},
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 my $data=GetBiblioData($biblionumber);
56 my $dewey = $data->{'dewey'};
58 #coping with subscriptions
59 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
61 # FIXME Dewey is a string, not a number, & we should use a function
63 # if ($dewey eq "000.") { $dewey = "";};
64 # if ($dewey < 10){$dewey='00'.$dewey;}
65 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
70 # $data->{'dewey'}=$dewey;
73 my $fw = GetFrameworkCode($biblionumber);
74 my @items= GetItemsInfo($biblionumber);
76 $data->{'count'}=$count;
78 my $ordernum = GetOrderNumber($biblionumber);
79 my $order = GetOrder($ordernum);
80 my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
81 my $itemtypes = GetItemTypes;
83 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
85 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
86 foreach my $item (@items){
87 if ( $itemnumber && $itemnumber != $item->{'itemnumber'} ) {
91 $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
92 $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
93 $item->{'collection'} = $ccodes->{$item->{ccode}};
94 $item->{'itype'} = $itemtypes->{$item->{'itype'}}->{'description'};
95 $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
96 $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
97 $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
98 $item->{'datelastseen'} = format_date($item->{'datelastseen'});
99 $item->{'ordernumber'} = $ordernum;
100 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
101 $item->{'copyvol'} = $item->{'copynumber'};
102 if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
103 $item->{status_advisory} = 1;
106 if (C4::Context->preference("IndependantBranches")) {
108 my $userenv = C4::Context->userenv();
109 unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
113 $item->{'homebranchname'} = GetBranchName($item->{'homebranch'});
114 $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'});
115 if ($item->{'datedue'}) {
116 $item->{'datedue'} = format_date($item->{'datedue'});
122 $template->param(count => $data->{'count'},
123 subscriptionsnumber => $subscriptionsnumber,
124 subscriptiontitle => $data->{title},
126 $template->param(BIBITEM_DATA => \@results);
127 $template->param(ITEM_DATA => \@items);
128 $template->param(moredetailview => 1);
129 $template->param(loggedinuser => $loggedinuser);
130 $template->param(biblionumber => $biblionumber);
131 $template->param(biblioitemnumber => $bi);
132 $template->param(itemnumber => $itemnumber);
133 $template->param(ONLY_ONE => 1) if ( $itemnumber && $count != @items );
135 output_html_with_http_headers $query, $cookie, $template->output;