koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] CVS: koha/C4/Circulation Fines.pm,1.7,1.8


From: MJ Ray
Subject: [Koha-cvs] CVS: koha/C4/Circulation Fines.pm,1.7,1.8
Date: Wed, 03 Dec 2003 03:51:54 -0800

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

Modified Files:
        Fines.pm 
Log Message:
DBI fixes re bug 662. Removed worrying suggestion to use dbh->do in comments.

Index: Fines.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Fines.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Fines.pm    13 Oct 2002 08:31:21 -0000      1.7
--- Fines.pm    3 Dec 2003 11:51:52 -0000       1.8
***************
*** 67,73 ****
  sub Getoverdues{
    my $dbh = C4::Context->dbh;
!   my $query="Select * from issues where date_due < now() and returndate is
!   NULL order by borrowernumber";
!   my $sth=$dbh->prepare($query);
    $sth->execute;
    # FIXME - Use push @results
--- 67,72 ----
  sub Getoverdues{
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from issues where date_due < now() and 
returndate is
!   NULL order by borrowernumber");
    $sth->execute;
    # FIXME - Use push @results
***************
*** 148,160 ****
    # firstremind, chargeperiod, accountsent, and chargename from the
    # categoryitem table.
!   my $query="Select * from items,biblioitems,itemtypes,categoryitem where 
items.itemnumber=$itemnumber
    and items.biblioitemnumber=biblioitems.biblioitemnumber and
    biblioitems.itemtype=itemtypes.itemtype and
    categoryitem.itemtype=itemtypes.itemtype and
!   categoryitem.categorycode='$bortype' and (items.itemlost <> 1 or 
items.itemlost is NULL)";
! 
!   my $sth=$dbh->prepare($query);
  #  print $query;
!   $sth->execute;
    my $data=$sth->fetchrow_hashref;
        # FIXME - Error-checking: the item might be lost, or there
--- 147,158 ----
    # firstremind, chargeperiod, accountsent, and chargename from the
    # categoryitem table.
! 
!   my $sth=$dbh->prepare("Select * from 
items,biblioitems,itemtypes,categoryitem where items.itemnumber=?
    and items.biblioitemnumber=biblioitems.biblioitemnumber and
    biblioitems.itemtype=itemtypes.itemtype and
    categoryitem.itemtype=itemtypes.itemtype and
!   categoryitem.categorycode='?' and (items.itemlost <> 1 or items.itemlost is 
NULL)");
  #  print $query;
!   $sth->execute($itemnumber,$bortype);
    my $data=$sth->fetchrow_hashref;
        # FIXME - Error-checking: the item might be lost, or there
***************
*** 241,250 ****
    # Does it look up existing fines for this item?
    # FIXME - What are these various account types? ("FU", "O", "F", "M")
!   my $query="Select * from accountlines where itemnumber=$itemnum and
!   borrowernumber=$bornum and (accounttype='FU' or accounttype='O' or
!   accounttype='F' or accounttype='M') and description like '%$due%'";
!   my $sth=$dbh->prepare($query);
! #  print "$query\n";
!   $sth->execute;
  
    if (my $data=$sth->fetchrow_hashref){
--- 239,246 ----
    # Does it look up existing fines for this item?
    # FIXME - What are these various account types? ("FU", "O", "F", "M")
!   my $sth=$dbh->prepare("Select * from accountlines where itemnumber=? and
!   borrowernumber=? and (accounttype='FU' or accounttype='O' or
!   accounttype='F' or accounttype='M') and description like ?");
!   $sth->execute($itemnum,$bornum,"%$due%");
  
    if (my $data=$sth->fetchrow_hashref){
***************
*** 257,267 ****
        my $diff=$amount - $data->{'amount'};
        my $out=$data->{'amountoutstanding'}+$diff;
!       # FIXME - Use $dbh->do()
!       my $query2="update accountlines set date=now(), amount=$amount,
!       amountoutstanding=$out,accounttype='FU' where
!       borrowernumber=$data->{'borrowernumber'} and 
itemnumber=$data->{'itemnumber'}
!       and (accounttype='FU' or accounttype='O') and description like 
'%$due%'";
!       my $sth2=$dbh->prepare($query2);
!       $sth2->execute;
        $sth2->finish;
      } else {
--- 253,261 ----
        my $diff=$amount - $data->{'amount'};
        my $out=$data->{'amountoutstanding'}+$diff;
!       my $sth2=$dbh->prepare("update accountlines set date=now(), amount=?,
!       amountoutstanding=?,accounttype='FU' where
!       borrowernumber=? and itemnumber=?
!       and (accounttype='FU' or accounttype='O') and description like ?");
!       
$sth2->execute($amount,$out,$data->{'borrowernumber'},$data->{'itemnumber'},"%$due%");
        $sth2->finish;
      } else {
***************
*** 271,284 ****
      # I think this else-clause deals with the case where we're adding
      # a new fine.
!     my $query2="select title from biblio,items where items.itemnumber=$itemnum
!     and biblio.biblionumber=items.biblionumber";
!     my $sth4=$dbh->prepare($query2);
!     $sth4->execute;
      my $title=$sth4->fetchrow_hashref;
      $sth4->finish;
   #   print "not in account";
!     # FIXME - There's already a $query2 in this scope.
!     my $query2="Select max(accountno) from accountlines";
!     my $sth3=$dbh->prepare($query2);
      $sth3->execute;
      # FIXME - Make $accountno a scalar.
--- 265,275 ----
      # I think this else-clause deals with the case where we're adding
      # a new fine.
!     my $sth4=$dbh->prepare("select title from biblio,items where 
items.itemnumber=?
!     and biblio.biblionumber=items.biblionumber");
!     $sth4->execute($itemnum);
      my $title=$sth4->fetchrow_hashref;
      $sth4->finish;
   #   print "not in account";
!     my $sth3=$dbh->prepare("Select max(accountno) from accountlines");
      $sth3->execute;
      # FIXME - Make $accountno a scalar.
***************
*** 286,299 ****
      $sth3->finish;
      $accountno[0]++;
!     $title->{'title'}=~ s/\'/\\\'/g;
!               # FIXME - There are probably other characters that need
!               # to be escaped. Use $dbh->quote.
!     $query2="Insert into accountlines
      (borrowernumber,itemnumber,date,amount,
      description,accounttype,amountoutstanding,accountno) values
!     ($bornum,$itemnum,now(),$amount,'$type $title->{'title'} $due','FU',
!     $amount,$accountno[0])";
!     my $sth2=$dbh->prepare($query2);
!     $sth2->execute;
      $sth2->finish;
    }
--- 277,285 ----
      $sth3->finish;
      $accountno[0]++;
!     my $sth2=$dbh->prepare("Insert into accountlines
      (borrowernumber,itemnumber,date,amount,
      description,accounttype,amountoutstanding,accountno) values
!     (?,?,now(),?,?,'FU',?,?)");
!     $sth2->execute($bornum,$itemnum,$amount,"$type $title->{'title'} 
$due",$amount,$accountno[0]);
      $sth2->finish;
    }
***************
*** 317,325 ****
    my ($borrowernumber)address@hidden;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from borrowers,categories where
!   borrowernumber=$borrowernumber and
! borrowers.categorycode=categories.categorycode";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my $data=$sth->fetchrow_hashref;
    $sth->finish;
--- 303,310 ----
    my ($borrowernumber)address@hidden;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from borrowers,categories where
!   borrowernumber=? and
! borrowers.categorycode=categories.categorycode");
!   $sth->execute($borrowernumber);
    my $data=$sth->fetchrow_hashref;
    $sth->finish;
***************
*** 338,344 ****
    my ($itemnum)address@hidden;
    my $dbh = C4::Context->dbh;
!   my $query="Select replacementprice from items where itemnumber='$itemnum'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    # FIXME - Use fetchrow_array or something.
    my $data=$sth->fetchrow_hashref;
--- 323,328 ----
    my ($itemnum)address@hidden;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select replacementprice from items where 
itemnumber=?");
!   $sth->execute($itemnum);
    # FIXME - Use fetchrow_array or something.
    my $data=$sth->fetchrow_hashref;




reply via email to

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