X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=updateitem.pl;h=d300a5d940a3f26dd171e712e1ecc166deedc3b0;hb=9c7e383156fb277672bfa975b02de4af355e79ed;hp=150ef7ce7e4cb7996f2c5843ad94d37bf4b2ff01;hpb=d0374d003716dfb40796caad6390a4d69bfb0376;p=koha.git diff --git a/updateitem.pl b/updateitem.pl index 150ef7ce7e..d300a5d940 100755 --- a/updateitem.pl +++ b/updateitem.pl @@ -1,18 +1,35 @@ #!/usr/bin/perl -use C4::Database; -use CGI; +# $Id$ + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + use strict; -use C4::Acquisitions; +use CGI; +use C4::Context; +use C4::Biblio; use C4::Output; +use C4::Circulation::Circ2; +use C4::Accounts2; +my $env; my $input= new CGI; -#print $input->header; -#print $input->dump; - -#my $title=checkinp($input->param('Title')); -#my $author=checkinp($input->param('Author')); my $bibnum=checkinp($input->param('bibnum')); my $itemnum=checkinp($input->param('itemnumber')); my $copyright=checkinp($input->param('Copyright')); @@ -23,10 +40,8 @@ my $notes=checkinp($input->param('ItemNotes')); #need to do barcode check my $barcode=$input->param('Barcode'); -#modbiblio($bibnum,$title,$author,$copyright,$seriestitle,$serial,$unititle,$notes); my $bibitemnum=checkinp($input->param('bibitemnum')); -#my $olditemtype my $itemtype=checkinp($input->param('Item')); my $isbn=checkinp($input->param('ISBN')); my $publishercode=checkinp($input->param('Publisher')); @@ -38,11 +53,11 @@ my $wthdrawn=$input->param('withdrawn'); my $classification; my $dewey; my $subclass; +my $override=$input->param('override'); if ($itemtype ne 'NF'){ $classification=$class; } if ($class =~/[0-9]+/){ -# print $class; $dewey= $class; $dewey=~ s/[a-z]+//gi; my @temp; @@ -53,7 +68,6 @@ if ($class =~/[0-9]+/){ } $classification=$temp[0]; $subclass=$temp[1]; -# print $classification,$dewey,$subclass; }else{ $dewey=''; } @@ -61,21 +75,78 @@ my $illus=checkinp($input->param('Illustrations')); my $pages=checkinp($input->param('Pages')); my $volumeddesc=checkinp($input->param('Volume')); -#have to check how many items are attached to this bibitem, if one, just change it, -#if more than one, we must create a new one. -#my $number=countitems($bibitemnum); -#if ($number > 1){ -# print $number; - #check if bibitemneeds modifying -# my $needsmod=needsmod($bibitemnum,$itemtype); -# if ($needsmod != 1){ -# $bibitemnum=newbiblioitem($bibnum,$itemtype,$volumeddesc,$classification); -# } -#} -#modbibitem($bibitemnum,$itemtype,$isbn,$publishercode,$publicationdate,$classification,$dewey,$subclass,$illus,$pages,$volumeddesc); -moditem('loan',$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn); +if ($wthdrawn == 0 && $override ne 'yes'){ + moditem( { biblionumber => $bibnum, + loan =>'loan', + itemnum => $itemnum, + bibitemnum => $bibitemnum, + barcode => $barcode, + notes => $notes, + homebranch => $homebranch, + lost => $lost, + wthdranw => $wthdrawn + }); + if ($lost ==1){ + 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 $sth2=$dbh->prepare("Insert into accountlines + (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) + values + (?,?,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 $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum"); +# print "marking cancelled"; + #need to check if it is on reserve or issued + my $dbh = C4::Context->dbh; + my $flag=0; + my ($resbor,$resrec)=C4::Circulation::Circ2::checkreserve($env,$dbh,$itemnum); + # print $resbor; + if ($resbor){ + print $input->header; + 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=?) and (returndate is null)"); + $sth->execute($itemnum); + my $data=$sth->fetchrow_hashref; + if ($data->{'borrowernumber'} ne '') { + print $input->header; + print "

Item is on issue"; + $flag=1; + } + $sth->finish; + if ($flag == 1){ + my $url=$input->self_url; + $url.="&override=yes"; + print "

Cancel Anyway   or Back"; + }else { + 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"); + } +} #print $bibitemnum; sub checkinp{ @@ -84,3 +155,5 @@ sub checkinp{ $inp=~ s/\"/\\\"/g; return($inp); } + +#sub checkissue{