2 # NOTE: Use standard 8-space tabs for this file (indents are 4 spaces)
6 # Copyright 2000-2003 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
30 use C4::Interface::CGI::Output;
35 use C4::Circulation::Circ2;
37 my $dbh=C4::Context->dbh;
41 my ($template, $loggedinuser, $cookie) = get_template_and_user({
42 template_name => ( 'catalogue/moredetail.tmpl'),
46 flagsrequired => {catalogue => 1},
50 my $op=$query->param('op');
51 my $lost=$query->param('lost');
52 my $withdrawn=$query->param('withdrawn');
53 my $override=$query->param('override');
54 my $itemnumber=$query->param('itemnumber');
55 my $barcode=$query->param('barcode');
57 my $title=$query->param('title');
58 my $biblionumber=$query->param('biblionumber');
59 my ($record)=XMLgetbibliohash($dbh,$biblionumber);
60 my $data=XMLmarc2koha_onerecord($dbh,$record,"biblios");
61 my $dewey = $data->{'dewey'};
62 # FIXME Dewey is a string, not a number, & we should use a function
64 if ($dewey eq "000.") { $dewey = "";};
65 if ($dewey < 10){$dewey='00'.$dewey;}
66 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
71 $data->{'dewey'}=$dewey;
78 ##Do Lost or Withdraw here
80 my ($resbor,$resrec)=C4::Reserves2::CheckReserves($env,$dbh,$itemnumber);
81 if ($override ne "yes"){
83 # print $query->header;
84 $template->param(error => "This item has a reserve on it");
85 $template->param(biblionumber =>$biblionumber);
86 $template->param(itemnumber =>$itemnumber);
87 $template->param(lost =>$lost);
88 $template->param(withdrawn =>$withdrawn);
91 my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
92 $sth->execute($itemnumber);
94 if (my $data=$sth->fetchrow_hashref) {
95 $template->param(biblionumber =>$biblionumber);
96 $template->param(itemnumber =>$itemnumber);
97 $template->param(error => "This item is On Loan to a member");
98 $template->param(lost =>$lost);
99 $template->param(withdrawn =>$withdrawn);
103 if ($flag != 0 && $override ne "yes"){
108 XMLmoditemonefield($dbh,$biblionumber,$itemnumber,'wthdrawn',$withdrawn,1);
109 XMLmoditemonefield($dbh,$biblionumber,$itemnumber,'itemlost',$lost);
111 if ($lost ==1 && $flag ==2){
112 my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
113 $sth->execute($itemnumber);
114 my $data=$sth->fetchrow_hashref;
115 if ($data->{'borrowernumber'} ne '') {
116 #item on issue add replacement cost to borrowers record
117 my $accountno=getnextacctno($env,$data->{'borrowernumber'},$dbh);
118 my $item=getiteminformation($env, $itemnumber);
119 my $sth2=$dbh->prepare("Insert into accountlines
120 (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
122 (?,?,now(),?,?,'L',?,?)");
123 $sth2->execute($data->{'borrowernumber'},$accountno,$item->{'replacementprice'},
124 "Lost Item $item->{'title'} $item->{'barcode'}",
125 $item->{'replacementprice'},$itemnumber);
130 foreach my $res ($resrec){
131 C4::Reserves2::CancelReseve(undef,$res->{itemnumber},$res->{borrowernumber});
137 my @itemrecords=XMLgetallitems($dbh,$biblionumber);
138 foreach my $itemrecord (@itemrecords){
139 $itemrecord=XML_xml2hash_onerecord($itemrecord);
140 my $items = XMLmarc2koha_onerecord($dbh,$itemrecord,"holdings");
141 $items->{itemtype}=$data->{itemtype};
142 $items->{biblionumber}=$biblionumber;
143 $items=itemissues($dbh,$items,$items->{'itemnumber'});
147 $data->{'count'}=$count;
148 my ($order,$ordernum)=GetOrder($biblionumber,$barcode);
155 foreach my $item (@items){
156 $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
157 $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
158 $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
159 $item->{'datelastseen'} = format_date($item->{'datelastseen'});
160 $item->{'ordernumber'} = $ordernum;
161 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
163 if ($item->{'date_due'} gt '0000-00-00'){
164 $item->{'date_due'} = format_date($item->{'date_due'});
166 $item->{'borrowernumber'} = $item->{'borrower'};
167 $item->{'cardnumber'} = $item->{'card'};
174 $template->param(BIBITEM_DATA => \@results);
175 $template->param(ITEM_DATA => \@items);
176 $template->param(loggedinuser => $loggedinuser);
178 output_html_with_http_headers $query, $cookie, $template->output;