X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=updateitem.pl;h=d300a5d940a3f26dd171e712e1ecc166deedc3b0;hb=9c7e383156fb277672bfa975b02de4af355e79ed;hp=f3948ff696b2ab2aa56ad65e20ff0d483cab4fd5;hpb=1e67687742e36bbb90746ecdd78a0c6a63aad890;p=koha.git diff --git a/updateitem.pl b/updateitem.pl index f3948ff696..d300a5d940 100755 --- a/updateitem.pl +++ b/updateitem.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl +# $Id$ # Copyright 2000-2002 Katipo Communications # @@ -18,10 +19,9 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -use C4::Database; -use CGI; use strict; -use C4::Acquisitions; +use CGI; +use C4::Context; use C4::Biblio; use C4::Output; use C4::Circulation::Circ2; @@ -76,37 +76,43 @@ my $pages=checkinp($input->param('Pages')); my $volumeddesc=checkinp($input->param('Volume')); if ($wthdrawn == 0 && $override ne 'yes'){ - moditem('loan',$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn); + moditem( { biblionumber => $bibnum, + loan =>'loan', + itemnum => $itemnum, + bibitemnum => $bibitemnum, + barcode => $barcode, + notes => $notes, + homebranch => $homebranch, + lost => $lost, + wthdranw => $wthdrawn + }); if ($lost ==1){ - my $dbh=C4Connect; - my $sth=$dbh->prepare("Select * from issues where (itemnumber='$itemnum') and (returndate is null)"); - $sth->execute; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)"); + $sth->execute($itemnum); my $data=$sth->fetchrow_hashref; if ($data->{'borrowernumber'} ne '') { #item on issue add replacement cost to borrowers record my $accountno=getnextacctno($env,$data->{'borrowernumber'},$dbh); my $item=getiteminformation($env, $itemnum); - my $account="Insert into accountlines + my $sth2=$dbh->prepare("Insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) values - ('$data->{'borrowernumber'}','$accountno',now(),'$item->{'replacementprice'}', - 'Lost Item $item->{'title'} $item->{'barcode'}','L', - '$item->{'replacementprice'}','$itemnum')"; - my $sth2=$dbh->prepare($account); -# print $input->header; -# print $account; - $sth2->execute; + (?,?,now(),?,?,'L',?,?)"); + $sth2->execute($data->{'borrowernumber'},$accountno,$item->{'replacementprice'}, + "Lost Item $item->{'title'} $item->{'barcode'}", + $item->{'replacementprice'},$itemnum); $sth2->finish; } $sth->finish; } print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum"); } else { - + # print "marking cancelled"; #need to check if it is on reserve or issued - my $dbh=C4Connect; - my $flag=0; + my $dbh = C4::Context->dbh; + my $flag=0; my ($resbor,$resrec)=C4::Circulation::Circ2::checkreserve($env,$dbh,$itemnum); # print $resbor; if ($resbor){ @@ -114,8 +120,8 @@ if ($wthdrawn == 0 && $override ne 'yes'){ print "The biblio or biblioitem this item belongs to has a reserve on it"; $flag=1; } - my $sth=$dbh->prepare("Select * from issues where (itemnumber='$itemnum') and (returndate is null)"); - $sth->execute; + my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)"); + $sth->execute($itemnum); my $data=$sth->fetchrow_hashref; if ($data->{'borrowernumber'} ne '') { print $input->header; @@ -123,13 +129,21 @@ if ($wthdrawn == 0 && $override ne 'yes'){ $flag=1; } $sth->finish; - $dbh->disconnect; if ($flag == 1){ my $url=$input->self_url; $url.="&override=yes"; print "

Cancel Anyway   or Back"; }else { - moditem('loan',$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn); + moditem({ biblionumber => $bibnum, + loan => 'loan', + itemnum => $itemnum, + bibitemnum => $bibitemnum, + barcode => $barcode, + notes => $notes, + homebranch => $homebranch, + lost => $lost, + wthdrawn => $wthdrawn + }); print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum"); } } @@ -143,4 +157,3 @@ sub checkinp{ } #sub checkissue{ -