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
29 use C4::Output; # contains gettemplate
31 use C4::Interface::CGI::Output;
36 use C4::Circulation::Circ2;
38 my $dbh=C4::Context->dbh;
42 my ($template, $loggedinuser, $cookie) = get_template_and_user({
43 template_name => ( 'catalogue/moredetail.tmpl'),
47 flagsrequired => {catalogue => 1},
51 my $op=$query->param('op');
52 my $lost=$query->param('lost');
53 my $withdrawn=$query->param('withdrawn');
54 my $override=$query->param('override');
55 my $itemnumber=$query->param('itemnumber');
56 my $barcode=$query->param('barcode');
58 my $title=$query->param('title');
59 my $biblionumber=$query->param('biblionumber');
60 my ($record,)=MARCgetbiblio($dbh,$biblionumber);
61 my $data=MARCmarc2koha($dbh,$record,"biblios");
62 my $dewey = $data->{'dewey'};
63 # FIXME Dewey is a string, not a number, & we should use a function
65 if ($dewey eq "000.") { $dewey = "";};
66 if ($dewey < 10){$dewey='00'.$dewey;}
67 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
72 $data->{'dewey'}=$dewey;
79 ##Do Lost or Withdraw here
81 my ($resbor,$resrec)=C4::Reserves2::CheckReserves($env,$dbh,$itemnumber);
82 if ($override ne "yes"){
84 # print $query->header;
85 $template->param(error => "This item has a reserve on it");
86 $template->param(biblionumber =>$biblionumber);
87 $template->param(itemnumber =>$itemnumber);
88 $template->param(lost =>$lost);
89 $template->param(withdrawn =>$withdrawn);
92 my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
93 $sth->execute($itemnumber);
95 if (my $data=$sth->fetchrow_hashref) {
96 $template->param(biblionumber =>$biblionumber);
97 $template->param(itemnumber =>$itemnumber);
98 $template->param(error => "This item is On Loan to a member");
99 $template->param(lost =>$lost);
100 $template->param(withdrawn =>$withdrawn);
104 if ($flag != 0 && $override ne "yes"){
108 my $sth=$dbh->prepare("update items set itemlost=? ,wthdrawn=? where itemnumber=?");
109 $sth->execute($lost,$withdrawn,$itemnumber);
111 MARCmoditemonefield($dbh,$biblionumber,$itemnumber,'wthdrawn',$withdrawn,1);
112 MARCmoditemonefield($dbh,$biblionumber,$itemnumber,'itemlost',$lost);
114 if ($lost ==1 && $flag ==2){
115 my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
116 $sth->execute($itemnumber);
117 my $data=$sth->fetchrow_hashref;
118 if ($data->{'borrowernumber'} ne '') {
119 #item on issue add replacement cost to borrowers record
120 my $accountno=getnextacctno($env,$data->{'borrowernumber'},$dbh);
121 my $item=getiteminformation($env, $itemnumber);
122 my $sth2=$dbh->prepare("Insert into accountlines
123 (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
125 (?,?,now(),?,?,'L',?,?)");
126 $sth2->execute($data->{'borrowernumber'},$accountno,$item->{'replacementprice'},
127 "Lost Item $item->{'title'} $item->{'barcode'}",
128 $item->{'replacementprice'},$itemnumber);
133 foreach my $res ($resrec){
134 C4::Reserves2::CancelReseve(undef,$res->{itemnumber},$res->{borrowernumber});
140 my @itemrecords=MARCgetallitems($dbh,$biblionumber);
141 foreach my $itemrecord (@itemrecords){
143 my $items = MARCmarc2koha($dbh,$itemrecord,"holdings");
144 $items->{itemtype}=$data->{itemtype};
145 $items->{biblionumber}=$biblionumber;
146 $items=itemissues($dbh,$items,$biblionumber);
150 $data->{'count'}=$count;
151 my ($order,$ordernum)=GetOrder($biblionumber,$barcode);
158 foreach my $item (@items){
159 $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
160 $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
161 $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
162 $item->{'datelastseen'} = format_date($item->{'datelastseen'});
163 $item->{'ordernumber'} = $ordernum;
164 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
166 if ($item->{'date_due'} gt '0000-00-00'){
167 $item->{'date_due'} = format_date($item->{'date_due'});
169 $item->{'borrowernumber'} = $item->{'borrowernumber'};
170 $item->{'cardnumber'} = $item->{'card'};
177 $template->param(BIBITEM_DATA => \@results);
178 $template->param(ITEM_DATA => \@items);
179 $template->param(loggedinuser => $loggedinuser);
181 output_html_with_http_headers $query, $cookie, $template->output;