[Koha-cvs] koha/C4/Circulation Circ2.pm [rel_3_0]

LAURIN arnaud alaurin at ouestprovence.fr
Mon Feb 26 11:38:59 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	LAURIN arnaud <alaurin>	07/02/26 10:38:58

Modified files:
	C4/Circulation : Circ2.pm 

Log message:
	bugfixing for displaying info for GetOverduesForBranch process, separating with two distinct functions for display information ...
	
	two steps , first : get all informations for overdues informations , step two : check if the document hasn't already been notified .
	
	warn : this programm, wasn't buggy in test mode, but in production, for us , the informations were displayed only 1 time for 5 tries .
	
	and worth in rush time in libraries ..., should be optimized .....

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Circ2.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.114.2.42&r2=1.114.2.43

Patches:
Index: Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.114.2.42
retrieving revision 1.114.2.43
diff -u -b -r1.114.2.42 -r1.114.2.43
--- Circ2.pm	14 Feb 2007 14:20:23 -0000	1.114.2.42
+++ Circ2.pm	26 Feb 2007 10:38:57 -0000	1.114.2.43
@@ -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: Circ2.pm,v 1.114.2.42 2007/02/14 14:20:23 btoumi Exp $
+# $Id: Circ2.pm,v 1.114.2.43 2007/02/26 10:38:57 alaurin Exp $
 
 use strict;
 require Exporter;
@@ -41,7 +41,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.114.2.42 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.114.2.43 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -2876,6 +2876,27 @@
     return (@tranferts);
 }
 
+=head2 CheckItemNotify
+
+Sql request to check if the document has alreday been notified
+this function is not exported, only used with GetOverduesForBranch
+
+=cut
+
+sub CheckItemNotify {
+	my ($notify_id,$notify_level,$itemnumber) = @_;
+	my $dbh = C4::Context->dbh;
+ 	my $sth = $dbh->prepare("
+	  SELECT COUNT(*) FROM notifys
+ WHERE notify_id  = ?
+ AND notify_level  = ? 
+  AND  itemnumber  =  ? ");
+ $sth->execute($notify_id,$notify_level,$itemnumber);
+	my $notified = $sth->fetchrow;
+$sth->finish;
+return ($notified);
+}
+
 =head2 GetOverduesForBranch
 
 Sql request for display all information for branchoverdues.pl
@@ -2885,10 +2906,10 @@
 =cut
 
 sub GetOverduesForBranch {
-    my ( $branch, $departement ) = @_;
+    my ( $branch, $departement) = @_;
     if ( not $departement ) {
         my $dbh = C4::Context->dbh;
-        my $sth = $dbh->prepare( "
+        my $sth = $dbh->prepare("
             SELECT 
                 borrowers.surname,
                 borrowers.firstname,
@@ -2910,35 +2931,34 @@
                 items.location,
                 accountlines.amountoutstanding
             FROM  issues,borrowers,biblio,biblioitems,itemtypes,items,branches,accountlines
-            WHERE ((( issues.returndate  is null)
+            WHERE ( issues.returndate  is null)
               AND ( accountlines.amountoutstanding  != '0.000000')
-              AND ( accountlines.accounttype  = 'FU')))
-              AND (( issues.borrowernumber = accountlines.borrowernumber )
+              AND ( accountlines.accounttype  = 'FU')
+              AND ( issues.borrowernumber = accountlines.borrowernumber )
               AND ( issues.itemnumber = accountlines.itemnumber )
               AND ( borrowers.borrowernumber = issues.borrowernumber )
               AND ( biblio.biblionumber = biblioitems.biblionumber )
               AND ( biblioitems.biblionumber = items.biblionumber )
               AND ( itemtypes.itemtype = biblioitems.itemtype )
               AND ( items.itemnumber = issues.itemnumber )
-              AND ( branches.branchcode = issues.branchcode ) )
+              AND ( branches.branchcode = issues.branchcode )
               AND (issues.branchcode = ?)
-              AND issues.date_due <= now()
-              AND NOT EXISTS (
-                SELECT * FROM notifys
-                WHERE ( accountlines.notify_id  =  notifys.notify_id )
-                  AND ( accountlines.notify_level  =  notifys.notify_level )
-                  AND ( accountlines.itemnumber  =  notifys.itemnumber ) )
+              AND (issues.date_due <= NOW())
             ORDER BY  borrowers.surname 
         ");
         $sth->execute($branch);
         my @getoverdues;
         my $i = 0;
         while ( my $data = $sth->fetchrow_hashref ) {
+	#check if the document has already been notified
+	my $countnotify = CheckItemNotify($data->{'notify_id'},$data->{'notify_level'},$data->{'itemnumber'});
+	if ($countnotify eq '0'){
             $getoverdues[$i] = $data;
             $i++;
         }
-        $sth->finish;
+        }
         return (@getoverdues);
+	$sth->finish;
     }
     else {
         my $dbh = C4::Context->dbh;
@@ -2963,38 +2983,38 @@
                     items.location,
                     accountlines.amountoutstanding
            FROM  issues,borrowers,biblio,biblioitems,itemtypes,items,branches,accountlines
-           WHERE ((( issues.returndate  is null)
+           WHERE ( issues.returndate  is null )
              AND ( accountlines.amountoutstanding  != '0.000000')
-             AND ( accountlines.accounttype  = 'FU')))
-             AND (( issues.borrowernumber = accountlines.borrowernumber )
+             AND ( accountlines.accounttype  = 'FU')
+             AND ( issues.borrowernumber = accountlines.borrowernumber )
              AND ( issues.itemnumber = accountlines.itemnumber )
              AND ( borrowers.borrowernumber = issues.borrowernumber )
              AND ( biblio.biblionumber = biblioitems.biblionumber )
              AND ( biblioitems.biblionumber = items.biblionumber )
              AND ( itemtypes.itemtype = biblioitems.itemtype )
              AND ( items.itemnumber = issues.itemnumber )
-             AND ( branches.branchcode = issues.branchcode ) )
+             AND ( branches.branchcode = issues.branchcode )
              AND (issues.branchcode = ? AND items.location = ?)
-             AND issues.date_due <= now()
-             AND NOT EXISTS (
-                SELECT * FROM  notifys  
-                WHERE ( accountlines.notify_id  =  notifys.notify_id )
-                  AND ( accountlines.notify_level  =  notifys.notify_level )
-                  AND ( accountlines.itemnumber  =  notifys.itemnumber ) )
+             AND (issues.date_due <= NOW())
            ORDER BY  borrowers.surname 
         " );
-        $sth->execute( $branch, $departement );
+        $sth->execute( $branch, $departement);
         my @getoverdues;
         my $i = 0;
         while ( my $data = $sth->fetchrow_hashref ) {
+	#check if the document has already been notified
+	  my $countnotify = CheckItemNotify($data->{'notify_id'},$data->{'notify_level'},$data->{'itemnumber'});
+	  if ($countnotify eq '0'){	                
             $getoverdues[$i] = $data;
             $i++;
         }
+        }
         $sth->finish;
         return (@getoverdues);
     }
 }
 
+
 =head2 AddNotifyLine
 
 &AddNotifyLine($borrowernumber, $itemnumber, $overduelevel, $method, $notifyId)





More information about the Koha-cvs mailing list