[Koha-cvs] koha/C4 Biblio.pm Date.pm Serials.pm Stats.pm C...

Tumer Garip tgarip at neu.edu.tr
Wed Nov 15 02:36:01 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	Tumer Garip <tgarip1957>	06/11/15 01:36:00

Modified files:
	C4             : Biblio.pm Date.pm Serials.pm Stats.pm 
	C4/Circulation : Circ2.pm Fines.pm 

Log message:
	Savannah seems out of sync. reloading.Mainly code cleaning and removing of Date::Manip

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&r1=1.186&r2=1.187
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Date.pm?cvsroot=koha&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Serials.pm?cvsroot=koha&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Stats.pm?cvsroot=koha&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Circ2.pm?cvsroot=koha&r1=1.122&r2=1.123
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Fines.pm?cvsroot=koha&r1=1.19&r2=1.20

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -b -r1.186 -r1.187
--- Biblio.pm	6 Nov 2006 21:01:43 -0000	1.186
+++ Biblio.pm	15 Nov 2006 01:36:00 -0000	1.187
@@ -75,6 +75,7 @@
 &XMLkoha2marc
 &XML_separate
 &XML_record_header
+&XMLmodLCindex
 &ZEBRAdelbiblio
 &ZEBRAgetrecord   
 &ZEBRAop 

Index: Date.pm
===================================================================
RCS file: /sources/koha/koha/C4/Date.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- Date.pm	6 Nov 2006 20:25:43 -0000	1.23
+++ Date.pm	15 Nov 2006 01:36:00 -0000	1.24
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Date.pm,v 1.23 2006/11/06 20:25:43 tgarip1957 Exp $
+# $Id: Date.pm,v 1.24 2006/11/15 01:36:00 tgarip1957 Exp $
 
 package C4::Date;
 
@@ -27,12 +27,12 @@
 use DateTime::Format::ISO8601;
 use DateTime::Format::Strptime;
 use DateTime::Format::Duration;
-
+use POSIX qw(ceil floor);
 require Exporter;
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
-$VERSION = do { my @v = '$Revision: 1.23 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.24 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 @ISA = qw(Exporter);
 
@@ -187,18 +187,21 @@
 }
 sub get_duration{
 my $period=shift;
+
 my $parse;
-if ($period=~/day/){
+if ($period=~/ays/){
 $parse="\%e days";
 }elsif ($period=~/week/){
 $parse="\%W weeks";
 }elsif ($period=~/year/){
 $parse="\%Y years";
-}elsif ($period=~/month/){
+}elsif ($period=~/onth/){
 $parse="\%m months";
 }
+
 my $parser=DateTime::Format::Duration->new(pattern => $parse  );
 	my $duration=$parser->parse_duration($period);
+
 return $duration;
 
 }
@@ -208,6 +211,6 @@
 my $dt2=DateTime::Format::ISO8601->parse_datetime($date2);
 my $dur=$dt2->subtract_datetime_absolute($dt1);## in seconds
 my $days=$dur->seconds/(60*60*24);
-return int($days);
+return floor($days);
 }
 1;

Index: Serials.pm
===================================================================
RCS file: /sources/koha/koha/C4/Serials.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- Serials.pm	6 Nov 2006 21:01:43 -0000	1.10
+++ Serials.pm	15 Nov 2006 01:36:00 -0000	1.11
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Serials.pm,v 1.10 2006/11/06 21:01:43 tgarip1957 Exp $
+# $Id: Serials.pm,v 1.11 2006/11/15 01:36:00 tgarip1957 Exp $
 
 use strict;
 use C4::Date;
@@ -30,7 +30,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.10 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.11 $' =~ /\d+/g;
         shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 
@@ -115,7 +115,7 @@
 
 =cut
 sub GetLateIssues {
-    my ($supplierid) = @_;
+    my ($supplierid) = shift;
     my $dbh = C4::Context->dbh;
     my $sth;
     if ($supplierid) {
@@ -390,8 +390,8 @@
 
 =cut
 sub GetSubscriptions {
-    my ($title,$ISSN,$biblionumber) = @_;
-    return unless $title or $ISSN or $biblionumber;
+    my ($title,$ISSN,$biblionumber,$supplierid) = @_;
+    return unless $title or $ISSN or $biblionumber or $supplierid;
     my $dbh = C4::Context->dbh;
     my $sth;
     if ($biblionumber) {
@@ -404,10 +404,9 @@
         );
     $sth = $dbh->prepare($query);
     $sth->execute($biblionumber);
-    } else {
-        if ($ISSN and $title){
+    } elsif ($ISSN and $title){
             my $query = qq|
-                SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber
+                SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber,aqbooksellerid
                 FROM   subscription,biblio
                 WHERE biblio.biblionumber= subscription.biblionumber
                     AND (biblio.title LIKE ? or biblio.issn = ?)
@@ -415,22 +414,29 @@
             |;
             $sth = $dbh->prepare($query);
             $sth->execute("%$title%",$ISSN);
-        }
-        else{
-            if ($ISSN){
+        } elsif ($ISSN){
                 my $query = qq(
-                    SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber
+                    SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber,aqbooksellerid
                     FROM   subscription,biblio
-                    WHERE  biblio.biblionumber = biblioitems.biblionumber
-                        AND biblio.biblionumber=subscription.biblionumber
-                        AND biblioitems.issn = ?
+                       WHERE biblio.biblionumber=subscription.biblionumber
+                        AND biblio.issn = ?
                     ORDER BY title
                 );
                 $sth = $dbh->prepare($query);
                 $sth->execute($ISSN);
+       }elsif ($supplierid){
+                my $query = qq(
+                    SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber,aqbooksellerid
+                    FROM   subscription,biblio
+                   WHERE biblio.biblionumber=subscription.biblionumber
+                        AND subscription.aqbooksellerid = ?
+                    ORDER BY title
+                );
+                $sth = $dbh->prepare($query);
+                $sth->execute($supplierid);
             } else {
                 my $query = qq(
-                    SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber
+                    SELECT subscription.subscriptionid,biblio.title,biblio.issn,subscription.notes,biblio.biblionumber,aqbooksellerid
                     FROM   subscription,biblio
                     WHERE biblio.biblionumber=subscription.biblionumber
                         AND biblio.title LIKE ?
@@ -439,8 +445,8 @@
                 $sth = $dbh->prepare($query);
                 $sth->execute("%$title%");
             }
-        }
-    }
+        
+   
     my @results;
     my $previoustitle="";
     my $odd=1;
@@ -599,7 +605,7 @@
 =back
 
 =cut
-sub GetNextSeq {
+sub Get_Next_Seq {
     my ($val) =@_;
     my ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3);
     $calculated = $val->{numberingmethod};
@@ -631,7 +637,7 @@
 }
 
 
-sub New_Get_Next_Seq {
+sub GetNextSeq {
     my ($val) =@_;
     my ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3);
     my $pattern = $val->{numberpattern};
@@ -708,44 +714,6 @@
 =back
 
 =cut
-sub GetNextDate(@) {
-    my ($planneddate,$subscription) = @_;
-    my $resultdate;
-   my $duration;
-    if ($subscription->{periodicity} == 1) {
-	$duration=get_duration("1 days");    
-    }
-    if ($subscription->{periodicity} == 2) {
-       $duration=get_duration("1 weeks");    
-    }
-    if ($subscription->{periodicity} == 3) {
-      $duration=get_duration("2 weeks");    
-    }
-    if ($subscription->{periodicity} == 4) {
-       $duration=get_duration("3 weeks");    
-    }
-    if ($subscription->{periodicity} == 5) {
-     $duration=get_duration("1 months");    
-    }
-    if ($subscription->{periodicity} == 6) {
-       $duration=get_duration("2 months");    
-    }
-    if ($subscription->{periodicity} == 7 || $subscription->{periodicity} == 8) {
-        $duration=get_duration("3 months");    
-    }
-    
-    if ($subscription->{periodicity} == 9) {
-         $duration=get_duration("6 months");    
-    }
-    if ($subscription->{periodicity} == 10) {
-          $duration=get_duration("1 years");    
-    }
-    if ($subscription->{periodicity} == 11) {
-        $duration=get_duration("2 years");    
-    }
- $resultdate=DATE_Add_Duration($planneddate,$duration);
-    return $resultdate;
-}
 
 =head2 GetSeq
 
@@ -799,9 +767,9 @@
         }
     }
     else {
-	my $duration=get_duration($subscription->{monthlength}." months") if ($subscription->{monthlength});
-	my $duration=get_duration($subscription->{weeklength}." weeks") if ($subscription->{weeklength});
-
+	my $duration;
+	 $duration=get_duration($subscription->{monthlength}." months") if ($subscription->{monthlength});
+	 $duration=get_duration($subscription->{weeklength}." weeks") if ($subscription->{weeklength});
         $enddate = DATE_Add_Duration($subscription->{startdate},$duration) ;
     }
     return $enddate;
@@ -930,8 +898,8 @@
         # next issue number
         my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = GetNextSeq($val);
         # next date (calculated from actual date & frequency parameters)
-          my $nextplanneddate = Get_Next_Date($planneddate,$val);
-          my $nextpublisheddate = Get_Next_Date($publisheddate,$val);
+          my $nextplanneddate = GetNextDate($planneddate,$val);
+          my $nextpublisheddate = GetNextDate($publisheddate,$val);
         NewIssue($newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextpublisheddate,$nextplanneddate,0);
         my $query = qq|
             UPDATE subscription
@@ -1193,7 +1161,7 @@
         my $val = $sth->fetchrow_hashref;
         # next issue number
         my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3) = New_Get_Next_Seq($val);
-        my $nextplanneddate = Get_Next_Date($planneddate,$val);
+        my $nextplanneddate = GetNextDate($planneddate,$val);
         NewIssue($newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextplanneddate);
         $sth = $dbh->prepare("update subscription set lastvalue1=?, lastvalue2=?,lastvalue3=? where subscriptionid = ?");
         $sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$subscriptionid);
@@ -1254,11 +1222,12 @@
         $sth->execute($subscriptionid);
         my $res = $sth->fetchrow;
         my $endofsubscriptiondate;
-	my $duration=get_duration($subscription->{monthlength}." months") if ($subscription->{monthlength});
-	my $duration=get_duration($subscription->{weeklength}." weeks") if ($subscription->{weeklength});
+	my $duration;
+	 $duration=get_duration($subscription->{monthlength}." months") if ($subscription->{monthlength});
+	$duration=get_duration($subscription->{weeklength}." weeks") if ($subscription->{weeklength});
 
         $endofsubscriptiondate = DATE_Add_Duration($subscription->{startdate},$duration) ;
-        return 1 if ($res >= $endofsubscriptiondate);
+        return 1 if ($res ge $endofsubscriptiondate);
         return 0;
     }
 }
@@ -1674,8 +1643,9 @@
 	$sth->execute($subscriptionid);
 	my $res = $sth->fetchrow;
 	my $endofsubscriptiondate;
-	my $duration=get_duration($subscription->{monthlength}." months") if ($subscription->{monthlength});
-	my $duration=get_duration($subscription->{weeklength}." weeks") if ($subscription->{weeklength});
+my $duration;
+	 $duration=get_duration($subscription->{monthlength}." months") if ($subscription->{monthlength});
+	 $duration=get_duration($subscription->{weeklength}." weeks") if ($subscription->{weeklength});
 
         $endofsubscriptiondate = DATE_Add_Duration($subscription->{startdate},$duration) ;
 	my $per = $subscription->{'periodicity'};
@@ -1700,15 +1670,13 @@
 
 
 
-=head2 Get_Next_Date
+=head2 GetNextDate
 
 =over 4
 
-($resultdate) = &Get_Next_Date($planneddate,$subscription)
+($resultdate) = &GetNextDate($planneddate,$subscription)
 
-this function is an extension of GetNextDate which allows for checking for irregularity
-
-it takes the planneddate and will return the next issue's date and will skip dates if there
+this function  takes the planneddate and will return the next issue's date and will skip dates if there
 exists an irregularity
 - eg if periodicity is monthly and $planneddate is 2007-02-10 but if March and April is to be 
 skipped then the returned date will be 2007-05-10
@@ -1719,21 +1687,24 @@
 =back
 
 =cut
-sub Get_Next_Date(@) {
+sub GetNextDate {
     my ($planneddate,$subscription) = @_;
     my @irreg = split(/\|/,$subscription->{irregularity});
  my $dateobj=DATE_obj($planneddate);
     my $dayofweek = $dateobj->day_of_week;
   my $month=$dateobj->month;
     my $resultdate;
-    #       warn "DOW $dayofweek";
 
     if ($subscription->{periodicity} == 1) {
+	my %irreghash;
+	for(my $i=0;$i<@irreg;$i++){
+	$irreghash{$irreg[$i]}=1;
+	}
 my $duration=get_duration("1 days");
 	for(my $i=0;$i<@irreg;$i++){
 	    if($dayofweek == 7){ $dayofweek = 0; }
 
-	    if(in_array(($dayofweek+1), @irreg)){
+	    if($irreghash{$dayofweek+1}){
 		$planneddate = DATE_Add_Duration($planneddate,$duration);
 		$dayofweek++;
 	    }
@@ -1788,7 +1759,6 @@
 	    }
 	}
 	$resultdate=DATE_Add_Duration($planneddate,$duration);
-	# warn "Planneddate2: $planneddate";
     }
     if ($subscription->{periodicity} == 6) {
 my $duration=get_duration("2 months");

Index: Stats.pm
===================================================================
RCS file: /sources/koha/koha/C4/Stats.pm,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- Stats.pm	6 Sep 2006 16:21:03 -0000	1.27
+++ Stats.pm	15 Nov 2006 01:36:00 -0000	1.28
@@ -1,6 +1,6 @@
 package C4::Stats;
 
-# $Id: Stats.pm,v 1.27 2006/09/06 16:21:03 tgarip1957 Exp $
+# $Id: Stats.pm,v 1.28 2006/11/15 01:36:00 tgarip1957 Exp $
 # Modified by TG
 # Copyright 2000-2002 Katipo Communications
 #
@@ -74,15 +74,17 @@
         #module to insert stats data into stats table
         my ($env,$branch,$type,$amount,$other,$itemnum,$itemtype,$borrowernumber,$accountno)=@_;
         my $dbh = C4::Context->dbh;
+	$env=C4::Context->userenv unless $env;
         if ($branch eq ''){
                 $branch=$env->{'branchcode'};
         }
-        my $user = $env->{'usercode'};
-        print $borrowernumber;
+        my $user = C4::Context->userenv;
+#        print $borrowernumber;
+	my $userid=$user->{'cardnumber'} if $user;
         # FIXME - Use $dbh->do() instead
         my $sth=$dbh->prepare("Insert into statistics (datetime,branch,type,usercode,value,
                                         other,itemnumber,itemtype,borrowernumber,proccode) values (now(),?,?,?,?,?,?,?,?,?)");
-        $sth->execute($branch,$type,$user,$amount,$other,$itemnum,$itemtype,$borrowernumber,$accountno);
+        $sth->execute($branch,$type,$userid,$amount,$other,$itemnum,$itemtype,$borrowernumber,$accountno);
         $sth->finish;
 }
 

Index: Circulation/Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- Circulation/Circ2.pm	6 Nov 2006 21:01:43 -0000	1.122
+++ Circulation/Circ2.pm	15 Nov 2006 01:36:00 -0000	1.123
@@ -3,7 +3,7 @@
 
 package C4::Circulation::Circ2;
 
-# $Id: Circ2.pm,v 1.122 2006/11/06 21:01:43 tgarip1957 Exp $
+# $Id: Circ2.pm,v 1.123 2006/11/15 01:36:00 tgarip1957 Exp $
 
 #package to deal with circulation
 #written 3/11/99 by olwen at katipo.co.nz
@@ -165,10 +165,26 @@
 	$data->{'datelastborrowed'} = $data2->{'issue_date'};
             $data->{'card'}     = $data2->{'cardnumber'};
 	    $data->{'borrower'}     = $data2->{'borrowernumber'};
+	$data->{issues}++;
         } 
 
         $sth2->finish;
+	 my $sth2   = $dbh->prepare("select * from reserveissue,borrowers
+where itemnumber = ?
+and rettime is NULL
+and reserveissue.borrowernumber = borrowers.borrowernumber");
 
+        $sth2->execute($itemnumber);
+        if (my $data2 = $sth2->fetchrow_hashref) {
+
+  	$data->{'date_due'}=$data2->{'duetime'};
+	$data->{'datelastborrowed'} = $data2->{'restime'};
+            $data->{'card'}     = $data2->{'cardnumber'};
+	    $data->{'borrower'}     = $data2->{'borrowernumber'};
+	$data->{issues}++;
+        } 
+
+        $sth2->finish;
         # Find the last 2 people who borrowed this item.
         $sth2 = $dbh->prepare("select * from issues, borrowers
 						where itemnumber = ?
@@ -176,7 +192,6 @@
 									and returndate is not NULL
 									order by returndate desc,timestamp desc limit 2") ;
         $sth2->execute($itemnumber) ;
-#        for (my $i2 = 0; $i2 < 2; $i2++) { # FIXME : error if there is less than 3 pple borrowing this item
 my $i2=0;
           while (my $data2  = $sth2->fetchrow_hashref) {
                 $data->{"timestamp$i2"} = $data2->{'timestamp'};
@@ -185,7 +200,6 @@
 $data->{'datelastborrowed'} = $data2->{'issue_date'} unless $data->{'datelastborrowed'};
 	$i2++;
             } # while
-#       } # for
 
         $sth2->finish;
     return($data);
@@ -969,7 +983,7 @@
 				} else {
 					my $tobrcd = ReserveWaiting($res->{'itemnumber'}, $res->{'borrowernumber'});
 					transferbook($tobrcd,$barcode, 1);
-					warn "transferbook";
+#					warn "transferbook";
 				}
 			}
 		}
@@ -1148,7 +1162,7 @@
 	if (not $itemrecord) {
 		$messages->{'BadBarcode'} = $barcode;
 		$doreturn = 0;
-	return ($doreturn, $messages, "", "");
+	return ($doreturn, $messages, undef, undef);
 	}
 	my $iteminformation=XMLmarc2koha_onerecord($dbh,$itemrecord,"holdings");
               $iteminformation->{'itemtype'}=MARCfind_itemtype($dbh,$iteminformation->{biblionumber});
@@ -1168,7 +1182,7 @@
 	# check that the book has been cancelled
 	if ($iteminformation->{'wthdrawn'}) {
 		$messages->{'wthdrawn'} = 1;
-		$doreturn = 0;
+	#	$doreturn = 0;
 	}
 	# update issues, thereby returning book (should push this out into another subroutine
 	my ($borrower) = getpatroninformation(\%env, $currentborrower, 0);
@@ -1178,10 +1192,11 @@
 		$messages->{'WasReturned'} = 1; # FIXME is the "= 1" right?
 	
 		$sth->finish;
+	}
 	$itemrecord=XML_writeline($itemrecord, "date_due", "","holdings");
 	$itemrecord=XML_writeline($itemrecord, "onloan", "0","holdings");
 	$itemrecord=XML_writeline($itemrecord, "borrowernumber", "","holdings");
-	}
+	
 	my ($transfered, $mess, $item) = transferbook($branch, $barcode, 1);
 	my ($sec,$min,$hour,$mday,$mon,$year) = localtime();
 		$year += 1900;
@@ -1715,7 +1730,7 @@
 	my $renews = 1;
 	my $resfound;
 	my $resrec;
-	my $renewokay; ##
+	my $renewokay=0; ##
 	# Look in the issues table for this item, lent to this borrower,
 	# and not yet returned.
 my $borrower=C4::Members::getpatroninformation($dbh,$bornum,undef);
@@ -1728,7 +1743,8 @@
 								and returndate is null
 								and items.itemnumber=issues.itemnumber");
 	$sth1->execute($bornum,$itemnumber);
-	if (my $data1 = $sth1->fetchrow_hashref) {
+my $data1 = $sth1->fetchrow_hashref;
+	if ($data1 ) {
 		# Found a matching item
 	if (C4::Context->preference("LibraryName") eq "NEU Grand Library"){
 		##privileged get renewal whatever the case may be
@@ -1759,7 +1775,6 @@
 			       $renewokay = 0;
          			 }
 		}
-	}## item found
 		 ($resfound, $resrec) = CheckReserves($itemnumber);
                		 if ($resfound) {
               		 	 if (C4::Context->preference("strictrenewals")){
@@ -1768,9 +1783,7 @@
 			   	   		 $renewokay = 0;
           				  }
 					}	
-#	}
-	$sth1->finish;
-if (C4::Context->preference("strictrenewals")){
+     if (C4::Context->preference("strictrenewals")){
 	### A new system pref "allowRenewalsBefore" prevents the renewal before a set amount of days left before expiry
 	## Try to find whether book can be renewed at this date
 	my $loanlength;
@@ -1788,7 +1801,10 @@
 	if  ($difference < 0) {
 	$renewokay=2 ;
 	}
-}##strictrenewals
+     }##strictrenewals	
+	}##item found
+	$sth1->finish;
+
 	return($renewokay);
 }
 
@@ -1850,7 +1866,7 @@
 	&XMLmoditemonefield($dbh,$iteminformation->{'biblionumber'},$iteminformation->{'itemnumber'},'date_due',$datedue);
 		
 	# Log the renewal
-	UpdateStats($env,$env->{'branchcode'},'renew','','',$itemnumber,'',$bornum);
+	UpdateStats($env,$env->{'branchcode'},'renew','','',$itemnumber,$iteminformation->{'itemtype'},$bornum);
 
 	# Charge a new rental fee, if applicable?
 	my ($charge,$type)=calc_charges($env, $itemnumber, $bornum);

Index: Circulation/Fines.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Fines.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- Circulation/Fines.pm	27 Sep 2006 19:53:52 -0000	1.19
+++ Circulation/Fines.pm	15 Nov 2006 01:36:00 -0000	1.20
@@ -1,6 +1,6 @@
 package C4::Circulation::Fines;
 
-# $Id: Fines.pm,v 1.19 2006/09/27 19:53:52 tgarip1957 Exp $
+# $Id: Fines.pm,v 1.20 2006/11/15 01:36:00 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -93,20 +93,7 @@
 members might get a longer grace period between the first and second
 reminders that a book is overdue).
 
-The fine is calculated as follows: if it is time for the first
-reminder, the fine is the value listed for the given (branch, item type,
-borrower code) combination. If it is time for the second reminder, the
-fine is doubled. Finally, if it is time to send the account to a
-collection agency, the fine is set to 5 local monetary units (a really
-good deal for the patron if the library is in Italy). Otherwise, the
-fine is 0.
-
-Note that the way this function is currently implemented, it only
-returns a nonzero value on the notable days listed above. That is, if
-the issuingruless entry says to send a first reminder 7 days after the
-book is due, then if you call C<&CalcFine> 7 days after the book is
-due, it will give a nonzero fine. If you call C<&CalcFine> the next
-day, however, it will say that the fine is 0.
+
 
 C<$itemnumber> is the book's item number.
 
@@ -133,16 +120,7 @@
   my $dbh = C4::Context->dbh;
   # Look up the issuingrules record for this book's item type and the
   # given borrwer type.
-  # The reason this query is so messy is that it's a messy question:
-  # given the barcode, we can find the book's items record. This gives
-  # us the biblio record, which gives us a set of issuingrules
-  # records. Then we select the one that corresponds to the desired
-  # borrower type.
-
-  # FIXME - Is it really necessary to get absolutely everything from
-  # all four tables? It looks as if this code only wants
-  # firstremind, chargeperiod, accountsent, and chargename from the
-  # issuingrules table.
+ 
 
   my $sth=$dbh->prepare("Select * from items,biblio,itemtypes,issuingrules where items.itemnumber=?
   and items.biblionumber=biblio.biblionumber and
@@ -159,38 +137,26 @@
   my $amount=0;
   my $printout;
 
-  # Is it time to send out the first reminder?
-  # FIXME - I'm not sure the "=="s are correct here. Let's say that
-  # $data->{firstremind} is today, but 'fines2.pl' doesn't run for
-  # some reason (the cron daemon died, the server crashed, the
-  # sysadmin had the machine down for maintenance, or whatever).
-  #
-  # Then the next day, the book is $data->{firstremind}+1 days
-  # overdue. But this function returns $amount == 0, $printout ==
-  # undef, on the assumption that 'fines2.pl' ran the previous day. So
-  # the first thing the patron gets is a second notice, but that's a
-  # week after the server crash, so people may not connect the two
-  # events.
   if ($difference > $data->{'firstremind'}){
     # Yes. Set the fine as listed.
-    $amount=$data->{'fine'}* $difference;
+$amount=$data->{'fine'}* $difference;
+
     $printout="First Notice";
   }
 
   # Is it time to send out a second reminder?
-  my $second=$data->{'firstremind'}+$data->{'chargeperiod'};
+  my $second=$data->{'firstremind'}+$data->{chargeperiod};
   if ($difference == $second){
-#    # Yes. The fine is double.
-#    $amount=$data->{'fine'}*2;
+$amount=$data->{'fine'}* $difference;
+
     $printout="Second Notice";
   }
 
   # Is it time to send the account to a collection agency?
-  # FIXME - At least, I *think* that's what this code is doing.
-  if ($difference == $data->{'accountsent'} && $data->{'fine'} > 0){
-    # Yes. Set the fine at 5 local monetary units.
-    # FIXME - This '5' shouldn't be hard-wired.
+  # FIXME -This $data->{'accountsent'} is not seemed to be set in the DB
+  if ($difference == $data->{'accountsent'}){
     $amount=$data->{'fine'}* $difference;
+
     $printout="Final Notice";
   }
   return($amount,$data->{'chargename'},$printout);





More information about the Koha-cvs mailing list