3 # Copyright 2000-2003 Katipo Communications
4 # parts copyright 2010 BibLibre
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #use warnings; FIXME - Bug 2505
30 use C4
::Output
; # contains gettemplate
33 use C4
::Dates qw
/format_date/;
34 use C4
::Circulation
; # to use itemissues
35 use C4
::Members
; # to use GetMember
36 use C4
::Search
; # enabled_staff_search_views
37 use C4
::Members qw
/GetHideLostItemsPreference/;
41 # FIXME subject is not exported to the template?
42 my $subject=$query->param('subject');
44 # if its a subject we need to use the subject.tmpl
45 my ($template, $loggedinuser, $cookie) = get_template_and_user
({
46 template_name
=> ($subject?
'catalogue/subject.tmpl':
47 'catalogue/moredetail.tmpl'),
51 flagsrequired
=> {catalogue
=> 1},
54 if($query->cookie("holdfor")){
55 my $holdfor_patron = GetMember
('borrowernumber' => $query->cookie("holdfor"));
57 holdfor
=> $query->cookie("holdfor"),
58 holdfor_surname
=> $holdfor_patron->{'surname'},
59 holdfor_firstname
=> $holdfor_patron->{'firstname'},
60 holdfor_cardnumber
=> $holdfor_patron->{'cardnumber'},
66 my $biblionumber=$query->param('biblionumber');
67 my $title=$query->param('title');
68 my $bi=$query->param('bi');
69 $bi = $biblionumber unless $bi;
70 my $itemnumber = $query->param('itemnumber');
71 my $data=GetBiblioData
($biblionumber);
72 my $dewey = $data->{'dewey'};
73 my $showallitems = $query->param('showallitems');
75 #coping with subscriptions
76 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
78 # FIXME Dewey is a string, not a number, & we should use a function
80 # if ($dewey eq "000.") { $dewey = "";};
81 # if ($dewey < 10){$dewey='00'.$dewey;}
82 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
87 # $data->{'dewey'}=$dewey;
90 my $fw = GetFrameworkCode
($biblionumber);
91 my @all_items= GetItemsInfo
($biblionumber);
93 for my $itm (@all_items) {
94 push @items, $itm unless ( $itm->{itemlost
} &&
95 GetHideLostItemsPreference
($loggedinuser) &&
97 ($itemnumber != $itm->{itemnumber
}));
100 my $totalcount=@all_items;
101 my $showncount=@items;
102 my $hiddencount = $totalcount - $showncount;
103 $data->{'count'}=$totalcount;
104 $data->{'showncount'}=$showncount;
105 $data->{'hiddencount'}=$hiddencount; # can be zero
107 my $ccodes= GetKohaAuthorisedValues
('items.ccode',$fw);
108 my $itemtypes = GetItemTypes
;
110 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
112 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
113 foreach my $item (@items){
114 $item->{itemlostloop
}= GetAuthorisedValues
(GetAuthValCode
('items.itemlost',$fw),$item->{itemlost
}) if GetAuthValCode
('items.itemlost',$fw);
115 $item->{itemdamagedloop
}= GetAuthorisedValues
(GetAuthValCode
('items.damaged',$fw),$item->{damaged
}) if GetAuthValCode
('items.damaged',$fw);
116 $item->{'collection'} = $ccodes->{ $item->{ccode
} } if ($ccodes);
117 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'description'};
118 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
119 $item->{'datelastborrowed'} = format_date
( $item->{'datelastborrowed'} );
120 $item->{'dateaccessioned'} = format_date
( $item->{'dateaccessioned'} );
121 $item->{'datelastseen'} = format_date
( $item->{'datelastseen'} );
122 $item->{'copyvol'} = $item->{'copynumber'};
124 my $order = GetOrderFromItemnumber
( $item->{'itemnumber'} );
125 $item->{'ordernumber'} = $order->{'ordernumber'};
126 $item->{'basketno'} = $order->{'basketno'};
127 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
129 if ($item->{notforloantext
} or $item->{itemlost
} or $item->{damaged
} or $item->{wthdrawn
}) {
130 $item->{status_advisory
} = 1;
133 if (C4
::Context
->preference("IndependantBranches")) {
135 my $userenv = C4
::Context
->userenv();
136 unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
140 $item->{'homebranchname'} = GetBranchName
($item->{'homebranch'});
141 $item->{'holdingbranchname'} = GetBranchName
($item->{'holdingbranch'});
142 if ($item->{'datedue'}) {
143 $item->{'datedue'} = format_date
($item->{'datedue'});
149 $template->param(count
=> $data->{'count'},
150 subscriptionsnumber
=> $subscriptionsnumber,
151 subscriptiontitle
=> $data->{title
},
152 C4
::Search
::enabled_staff_search_views
,
154 $template->param(BIBITEM_DATA
=> \
@results);
155 $template->param(ITEM_DATA
=> \
@items);
156 $template->param(moredetailview
=> 1);
157 $template->param(loggedinuser
=> $loggedinuser);
158 $template->param(biblionumber
=> $biblionumber);
159 $template->param(biblioitemnumber
=> $bi);
160 $template->param(itemnumber
=> $itemnumber);
161 $template->param(ONLY_ONE
=> 1) if ( $itemnumber && $showncount != @items );
162 $template->param(z3950_search_params
=> C4
::Search
::z3950_search_args
(GetBiblioData
($biblionumber)));
164 output_html_with_http_headers
$query, $cookie, $template->output;