-
-my @items;
-if ($op eq "update"){
-my $env;
-##Do Lost or Withdraw here
-my $flag=0;
- my ($resbor,$resrec)=C4::Reserves2::CheckReserves($env,$dbh,$itemnumber);
-if ($override ne "yes"){
- if ($resbor){
-# print $query->header;
- $template->param(error => "This item has a reserve on it");
- $template->param(biblionumber =>$biblionumber);
- $template->param(itemnumber =>$itemnumber);
- $template->param(lost =>$lost);
- $template->param(withdrawn =>$withdrawn);
- $flag=1;
- }
- my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
- $sth->execute($itemnumber);
-
- if (my $data=$sth->fetchrow_hashref) {
- $template->param(biblionumber =>$biblionumber);
- $template->param(itemnumber =>$itemnumber);
- $template->param(error => "This item is On Loan to a member");
- $template->param(lost =>$lost);
- $template->param(withdrawn =>$withdrawn);
- $flag=2;
- }
-}
-if ($flag != 0 && $override ne "yes"){
-
- }else {
- ##UPDATE here
-
-XMLmoditemonefield($dbh,$biblionumber,$itemnumber,'wthdrawn',$withdrawn,1);
-XMLmoditemonefield($dbh,$biblionumber,$itemnumber,'itemlost',$lost);
-
- if ($lost ==1 && $flag ==2){
- my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
- $sth->execute($itemnumber);
- 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, $itemnumber);
- 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'},$itemnumber);
- $sth2->finish;
- }
- }
- if ($flag==1){
- foreach my $res ($resrec){
- C4::Reserves2::CancelReseve(undef,$res->{itemnumber},$res->{borrowernumber});
- }
- }
-
- }
-}
-my @itemrecords=XMLgetallitems($dbh,$biblionumber);
-foreach my $itemrecord (@itemrecords){
-$itemrecord=XML_xml2hash_onerecord($itemrecord);
-my $items = XMLmarc2koha_onerecord($dbh,$itemrecord,"holdings");
-$items->{itemtype}=$data->{itemtype};
-$items->{biblionumber}=$biblionumber;
-$items=itemissues($dbh,$items,$items->{'itemnumber'});
-push @items,$items;
-}