koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4/Circulation Returns.pm,1.6,1.7


From: MJ Ray
Subject: [Koha-cvs] CVS: koha/C4/Circulation Returns.pm,1.6,1.7
Date: Mon, 08 Dec 2003 06:24:57 -0800

Update of /cvsroot/koha/koha/C4/Circulation
In directory sc8-pr-cvs1:/tmp/cvs-serv13572/C4/Circulation

Modified Files:
        Returns.pm 
Log Message:
DBI call fix for bug 662

Index: Returns.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Returns.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Returns.pm  13 Oct 2002 08:31:49 -0000      1.6
--- Returns.pm  8 Dec 2003 14:24:55 -0000       1.7
***************
*** 126,148 ****
    my $amt_owing;
    $item = uc $item;
!   my $query = "select * from items,biblio
!     where barcode = '$item'
!     and (biblio.biblionumber=items.biblionumber)";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    if ($itemrec=$sth->fetchrow_hashref) {
       $sth->finish;
       $itemno = $itemrec->{'itemnumber'};
!      $query = "select * from issues
!        where (itemnumber='$itemrec->{'itemnumber'}')
!        and (returndate is null)";
!      my $sth=$dbh->prepare($query);
!      $sth->execute;
       if (my $issuerec=$sth->fetchrow_hashref) {
         $sth->finish;
!        $query = "select * from borrowers where
!        (borrowernumber = '$issuerec->{'borrowernumber'}')";
!        my $sth= $dbh->prepare($query);
!        $sth->execute;
         $env->{'bornum'}=$issuerec->{'borrowernumber'};
         $borrower = $sth->fetchrow_hashref;
--- 126,145 ----
    my $amt_owing;
    $item = uc $item;
!   my $sth=$dbh->prepare("select * from items,biblio
!     where barcode = ?
!     and (biblio.biblionumber=items.biblionumber)");
!   $sth->execute($item);
    if ($itemrec=$sth->fetchrow_hashref) {
       $sth->finish;
       $itemno = $itemrec->{'itemnumber'};
!      my $sth=$dbh->prepare("select * from issues
!        where (itemnumber=?)
!        and (returndate is null)");
!      $sth->execute($itemrec->{'itemnumber'});
       if (my $issuerec=$sth->fetchrow_hashref) {
         $sth->finish;
!        my $sth= $dbh->prepare("select * from borrowers where
!        (borrowernumber = ?)");
!        $sth->execute($issuerec->{'borrowernumber'});
         $env->{'bornum'}=$issuerec->{'borrowernumber'};
         $borrower = $sth->fetchrow_hashref;
***************
*** 158,165 ****
       my ($resfound,$resrec) = 
find_reserves($env,$dbh,$itemrec->{'itemnumber'});
       if ($resfound eq "y") {
!        my $bquery = "select * from borrowers
!           where borrowernumber = '$resrec->{'borrowernumber'}'";
!        my $btsh = $dbh->prepare($bquery);
!        $btsh->execute;
         my $resborrower = $btsh->fetchrow_hashref;
         #printreserve($env,$resrec,$resborrower,$itemrec);
--- 155,161 ----
       my ($resfound,$resrec) = 
find_reserves($env,$dbh,$itemrec->{'itemnumber'});
       if ($resfound eq "y") {
!        my $btsh = $dbh->prepare("select * from borrowers
!           where borrowernumber = ?");
!        $btsh->execute($resrec->{'borrowernumber'});
         my $resborrower = $btsh->fetchrow_hashref;
         #printreserve($env,$resrec,$resborrower,$itemrec);
***************
*** 186,213 ****
    my @datearr = localtime(time);
    my $dateret = (1900+$datearr[5])."-".$datearr[4]."-".$datearr[3];
!   my $query = "update issues set returndate = now(), branchcode 
='$env->{'branchcode'}' where
!     (borrowernumber = '$bornum') and (itemnumber = '$itemno')
!     and (returndate is null)";
!   my $sth = $dbh->prepare($query);
!   $sth->execute;
    $sth->finish;
    updatelastseen($env,$dbh,$itemno);
    # check for overdue fine
    my $oduecharge;
!   my $query = "select * from accountlines
!     where (borrowernumber = '$bornum')
!     and (itemnumber = '$itemno')
!     and (accounttype = 'FU' or accounttype='O')";
!   my $sth = $dbh->prepare($query);
!     $sth->execute;
      if (my $data = $sth->fetchrow_hashref) {
         # alter fine to show that the book has been returned.
!        my $uquery = "update accountlines
           set accounttype = 'F'
!          where (borrowernumber = '$bornum')
!          and (itemnumber = '$itemno')
!          and (accountno = '$data->{'accountno'}') ";
!        my $usth = $dbh->prepare($uquery);
!        $usth->execute();
         $usth->finish();
         $oduecharge = $data->{'amountoutstanding'};
--- 182,206 ----
    my @datearr = localtime(time);
    my $dateret = (1900+$datearr[5])."-".$datearr[4]."-".$datearr[3];
!   my $sth = $dbh->prepare("update issues set returndate = now(), branchcode = 
? where
!     (borrowernumber = ?) and (itemnumber = ?)
!     and (returndate is null)");
!   $sth->execute($env->{'branchcode'},$bornum,$itemno);
    $sth->finish;
    updatelastseen($env,$dbh,$itemno);
    # check for overdue fine
    my $oduecharge;
!   my $sth = $dbh->prepare("select * from accountlines
!     where (borrowernumber = ?)
!     and (itemnumber = ?)
!     and (accounttype = 'FU' or accounttype='O')");
!     $sth->execute($bornum,$itemno);
      if (my $data = $sth->fetchrow_hashref) {
         # alter fine to show that the book has been returned.
!        my $usth = $dbh->prepare("update accountlines
           set accounttype = 'F'
!          where (borrowernumber = ?)
!          and (itemnumber = ?)
!          and (accountno = ?) ");
!        $usth->execute($bornum,$itemno,$data->{'accountno'});
         $usth->finish();
         $oduecharge = $data->{'amountoutstanding'};
***************
*** 215,224 ****
      $sth->finish;
    # check for charge made for lost book
!   my $query = "select * from accountlines
!     where (borrowernumber = '$bornum')
!     and (itemnumber = '$itemno')
!     and (accounttype = 'L')";
!   my $sth = $dbh->prepare($query);
!   $sth->execute;
    if (my $data = $sth->fetchrow_hashref) {
      # writeoff this amount
--- 208,216 ----
      $sth->finish;
    # check for charge made for lost book
!   my $sth = $dbh->prepare("select * from accountlines
!     where (borrowernumber = ?)
!     and (itemnumber = ?)
!     and (accounttype = 'L')");
!   $sth->execute($bornum,$itemno);
    if (my $data = $sth->fetchrow_hashref) {
      # writeoff this amount
***************
*** 234,258 ****
         $amountleft = $data->{'amountoutstanding'} - $amount;
      }
!     my $uquery = "update accountlines
        set accounttype = 'LR',amountoutstanding='0'
!       where (borrowernumber = '$bornum')
!       and (itemnumber = '$itemno')
!       and (accountno = '$acctno') ";
!     my $usth = $dbh->prepare($uquery);
!     $usth->execute();
      $usth->finish;
      my $nextaccntno = C4::Accounts::getnextacctno($env,$bornum,$dbh);
!     $uquery = "insert into accountlines
        
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
!       values ($bornum,$nextaccntno,now(),0-$amount,'Book Returned',
!       'CR',$amountleft)";
!     $usth = $dbh->prepare($uquery);
!     $usth->execute;
      $usth->finish;
      $uquery = "insert into accountoffsets
        (borrowernumber, accountno, offsetaccount,  offsetamount)
!       values ($bornum,$data->{'accountno'},$nextaccntno,$offset)";
!     $usth = $dbh->prepare($uquery);
!     $usth->execute;
      $usth->finish;
    }
--- 226,247 ----
         $amountleft = $data->{'amountoutstanding'} - $amount;
      }
!     my $usth = $dbh->prepare("update accountlines
        set accounttype = 'LR',amountoutstanding='0'
!       where (borrowernumber = ?)
!       and (itemnumber = ?)
!       and (accountno = ?) ");
!     $usth->execute($bornum,$itemno,$acctno);
      $usth->finish;
      my $nextaccntno = C4::Accounts::getnextacctno($env,$bornum,$dbh);
!     $usth = $dbh->prepare("insert into accountlines
        
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
!       values (?,?,now(),?,'Book Returned','CR',?)");
!     $usth->execute($bornum,$nextaccntno,0-$amount,$amountleft);
      $usth->finish;
      $uquery = "insert into accountoffsets
        (borrowernumber, accountno, offsetaccount,  offsetamount)
!       values (?,?,?,?)";
!     $usth = $dbh->prepare("");
!     $usth->execute($bornum,$data->{'accountno'},$nextaccntno,$offset);
      $usth->finish;
    }
***************
*** 279,287 ****
    my ($env,$dbh,$itemnumber)= @_;
    my $br = $env->{'branchcode'};
!   my $query = "update items
!     set datelastseen = now(), holdingbranch = '$br'
!     where (itemnumber = '$itemnumber')";
!   my $sth = $dbh->prepare($query);
!   $sth->execute;
    $sth->finish;
  
--- 268,275 ----
    my ($env,$dbh,$itemnumber)= @_;
    my $br = $env->{'branchcode'};
!   my $sth = $dbh->prepare("update items
!     set datelastseen = now(), holdingbranch = ?
!     where (itemnumber = ?)");
!   $sth->execute($br,$itemnumber);
    $sth->finish;
  
***************
*** 296,304 ****
    my ($env,$dbh,$itemno) = @_;
    my $itemdata = itemnodata($env,$dbh,$itemno);
!   my $query = "select * from reserves where found is null
!   and biblionumber = $itemdata->{'biblionumber'} and cancellationdate is NULL
!   order by priority,reservedate ";
!   my $sth = $dbh->prepare($query);
!   $sth->execute;
    my $resfound = "n";
    my $resrec;
--- 284,291 ----
    my ($env,$dbh,$itemno) = @_;
    my $itemdata = itemnodata($env,$dbh,$itemno);
!   my $sth = $dbh->prepare("select * from reserves where found is null
!   and biblionumber = ? and cancellationdate is NULL
!   order by priority,reservedate ");
!   $sth->execute($itemdata->{'biblionumber'};
    my $resfound = "n";
    my $resrec;
***************
*** 311,318 ****
        $resfound = "y";
      } else {
!       my $conquery = "select * from reserveconstraints where borrowernumber
! = $resrec->{'borrowernumber'} and reservedate = '$resrec->{'reservedate'}' 
and biblionumber = $resrec->{'biblionumber'} and biblioitemnumber = 
$itemdata->{'biblioitemnumber'}";
!       my $consth = $dbh->prepare($conquery);
!       $consth->execute;
        if (my $conrec=$consth->fetchrow_hashref) {
          if ($resrec->{'constrainttype'} eq "o") {
--- 298,303 ----
        $resfound = "y";
      } else {
!       my $consth = $dbh->prepare("select * from reserveconstraints where 
borrowernumber = ? and reservedate = ? and biblionumber = ? and 
biblioitemnumber = ?");
!       
$consth->execute($resrec->{'borrowernumber'},$resrec->{'reservedate'},$resrec->{'biblionumber'},$itemdata->{'biblioitemnumber'});
        if (my $conrec=$consth->fetchrow_hashref) {
          if ($resrec->{'constrainttype'} eq "o") {
***************
*** 327,345 ****
      }
      if ($resfound eq "y") {
!       my $updquery = "update reserves
!         set found = 'W',itemnumber='$itemno'
!         where borrowernumber = $resrec->{'borrowernumber'}
!         and reservedate = '$resrec->{'reservedate'}'
!         and biblionumber = $resrec->{'biblionumber'}";
!       my $updsth = $dbh->prepare($updquery);
!       $updsth->execute;
        $updsth->finish;
        my $itbr = $resrec->{'branchcode'};
        if ($resrec->{'branchcode'} ne $env->{'branchcode'}) {
!          my $updquery = "update items
            set holdingbranch = 'TR'
!         where itemnumber = $itemno";
!         my $updsth = $dbh->prepare($updquery);
!         $updsth->execute;
          $updsth->finish;
        }
--- 312,328 ----
      }
      if ($resfound eq "y") {
!       my $updsth = $dbh->prepare("update reserves
!         set found = 'W',itemnumber = ?
!         where borrowernumber = ?
!         and reservedate = ?
!         and biblionumber = ?");
!       
$updsth->execute($itemno,$resrec->{'borrowernumber'},$resrec->{'reservedate'},$resrec->{'biblionumber'});
        $updsth->finish;
        my $itbr = $resrec->{'branchcode'};
        if ($resrec->{'branchcode'} ne $env->{'branchcode'}) {
!         my $updsth = $dbh->prepare("update items
            set holdingbranch = 'TR'
!         where itemnumber = ?");
!         $updsth->execute($itemno);
          $updsth->finish;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]