[Koha-cvs] CVS: koha/C4/Circulation Circ2.pm,1.29,1.30

Chris Cormack rangi at users.sourceforge.net
Wed Jul 3 01:31:35 CEST 2002


Update of /cvsroot/koha/koha/C4/Circulation
In directory usw-pr-cvs1:/tmp/cvs-serv27719/C4/Circulation

Modified Files:
	Circ2.pm 
Log Message:
Fixed so datelastseen is updated on the item record for every issue or return


Index: Circ2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** Circ2.pm	20 Jun 2002 20:10:08 -0000	1.29
--- Circ2.pm	2 Jul 2002 23:31:33 -0000	1.30
***************
*** 26,30 ****
      
  @ISA = qw(Exporter);
! @EXPORT = qw(&getbranches &getprinters &getpatroninformation &currentissues &getissues &getiteminformation &findborrower &issuebook &returnbook &find_reserves &transferbook &decode);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  		  
--- 26,31 ----
      
  @ISA = qw(Exporter);
! @EXPORT = qw(&getbranches &getprinters &getpatroninformation &currentissues &getissues &getiteminformation &findborrower &issuebook &returnbook &find_reserves &transferbook &decode
! calc_charges);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  		  
***************
*** 457,461 ****
  	$sth->finish;
  	$iteminformation->{'issues'}++;
! 	$sth=$dbh->prepare("update items set issues=$iteminformation->{'issues'} where itemnumber=$iteminformation->{'itemnumber'}");
  	$sth->execute;
  	$sth->finish;
--- 458,462 ----
  	$sth->finish;
  	$iteminformation->{'issues'}++;
! 	$sth=$dbh->prepare("update items set issues=$iteminformation->{'issues'},datelastseen=now() where itemnumber=$iteminformation->{'itemnumber'}");
  	$sth->execute;
  	$sth->finish;
***************
*** 541,544 ****
--- 542,550 ----
      $sth->execute;
      $sth->finish;
+     $query="update items set datelastseen=now() where itemnumber=$itm";
+     $sth=$dbh->prepare($query);
+     $sth->execute;
+     $sth->finish;
+     $dbh->disconnect;
      return;
  }
***************
*** 877,881 ****
                       and items.biblioitemnumber = biblioitems.biblioitemnumber 
                       and issues.returndate is null
!                          order by issues.timestamp desc";
  #    print $select;
      my $sth=$dbh->prepare($select);
--- 883,887 ----
                       and items.biblioitemnumber = biblioitems.biblioitemnumber 
                       and issues.returndate is null
!                          order by issues.date_due";
  #    print $select;
      my $sth=$dbh->prepare($select);
***************
*** 1026,1037 ****
  # calculate charges due
      my ($env, $dbh, $itemno, $bornum)=@_;
      my $charge=0;
      my $item_type;
!     my $q1 = "select itemtypes.itemtype,rentalcharge from items,biblioitems,itemtypes where (items.itemnumber ='$itemno') and (biblioitems.biblioitemnumber = items.biblioitemnumber) and (biblioitems.itemtype = itemtypes.itemtype)";
      my $sth1= $dbh->prepare($q1);
      $sth1->execute;
      if (my $data1=$sth1->fetchrow_hashref) {
  	$item_type = $data1->{'itemtype'};
  	$charge = $data1->{'rentalcharge'};
  	my $q2 = "select rentaldiscount from borrowers,categoryitem 
  	where (borrowers.borrowernumber = '$bornum') 
--- 1032,1052 ----
  # calculate charges due
      my ($env, $dbh, $itemno, $bornum)=@_;
+ #    if (!$dbh){
+ #      $dbh=C4Connect();
+ #    }
      my $charge=0;
+ #    open (FILE,">>/tmp/charges");
      my $item_type;
!     my $q1 = "select itemtypes.itemtype,rentalcharge from items,biblioitems,itemtypes 
!     where (items.itemnumber ='$itemno')
!     and (biblioitems.biblioitemnumber = items.biblioitemnumber) 
!     and (biblioitems.itemtype = itemtypes.itemtype)";
      my $sth1= $dbh->prepare($q1);
+ #    print FILE "$q1\n";
      $sth1->execute;
      if (my $data1=$sth1->fetchrow_hashref) {
  	$item_type = $data1->{'itemtype'};
  	$charge = $data1->{'rentalcharge'};
+ #	print FILE "charge is $charge\n";
  	my $q2 = "select rentaldiscount from borrowers,categoryitem 
  	where (borrowers.borrowernumber = '$bornum') 
***************
*** 1039,1045 ****
--- 1054,1065 ----
  	and (categoryitem.itemtype = '$item_type')";
  	my $sth2=$dbh->prepare($q2);
+ #	warn $q2;
  	$sth2->execute;
  	if (my $data2=$sth2->fetchrow_hashref) {
  	    my $discount = $data2->{'rentaldiscount'};
+ #	    print FILE "discount is $discount";
+ 	    if ($discount eq 'NULL') {
+ 	      $discount=0;
+ 	    }
  	    $charge = ($charge *(100 - $discount)) / 100;
  	}
***************
*** 1047,1050 ****
--- 1067,1071 ----
      }      
      $sth1->finish;
+ #    close FILE;
      return ($charge);
  }





More information about the Koha-cvs mailing list