koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha C4/Serials.pm serials/checkexpiration.pl [rel_3_0]


From: Henri-Damien LAURENT
Subject: [Koha-cvs] koha C4/Serials.pm serials/checkexpiration.pl [rel_3_0]
Date: Tue, 16 Jan 2007 10:02:06 +0000

CVSROOT:        /cvsroot/koha
Module name:    koha
Branch:         rel_3_0
Changes by:     Henri-Damien LAURENT <hdl>      07/01/16 10:02:05

Modified files:
        C4             : Serials.pm 
        serials        : checkexpiration.pl 

Log message:
        BUG FIXING :
        GetNextDate did not work because $month was sometimes set to 0.
        
        Checkexpiration.pl now works.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Serials.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.5.2.24&r2=1.5.2.25
http://cvs.savannah.gnu.org/viewcvs/koha/serials/checkexpiration.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=1.1.2.2

Patches:
Index: C4/Serials.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Serials.pm,v
retrieving revision 1.5.2.24
retrieving revision 1.5.2.25
diff -u -b -r1.5.2.24 -r1.5.2.25
--- C4/Serials.pm       15 Jan 2007 14:59:09 -0000      1.5.2.24
+++ C4/Serials.pm       16 Jan 2007 10:02:05 -0000      1.5.2.25
@@ -17,11 +17,11 @@
 # 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.5.2.24 2007/01/15 14:59:09 hdl Exp $
+# $Id: Serials.pm,v 1.5.2.25 2007/01/16 10:02:05 hdl Exp $
 
 use strict;
 use C4::Date;
-use Date::Calc qw(Time_to_Date Date_to_Time check_date Add_Delta_YMD 
Add_Delta_YM Add_Delta_Days Delta_Days Week_of_Year Monday_of_Week Day_of_Week);
+use Date::Calc qw(:all);
 use POSIX qw(strftime);
 use C4::Suggestions;
 use C4::Koha;
@@ -35,7 +35,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.5.2.24 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.5.2.25 $' =~ /\d+/g;
     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
 };
 
@@ -955,31 +955,31 @@
     my $enddate          = $subscription->{startdate};
 
 # we don't do the same test if the subscription is based on X numbers or on X 
weeks/months
-    warn "SUBSCRIPTIONID :$subscriptionid";
-    use Data::Dumper; warn Dumper($subscription);
+#     warn "SUBSCRIPTIONID :$subscriptionid";
+#     use Data::Dumper; warn Dumper($subscription);
 
     if ( $subscription->{numberlength} ) {
         #calculate the date of the last issue.
         my $length = $subscription->{numberlength};
-        warn "ENDDATE ".$enddate;
+#         warn "ENDDATE ".$enddate;
         for ( my $i = 1 ; $i <= $length ; $i++ ) {
             $enddate = GetNextDate( $enddate, $subscription );
-            warn "AFTER ENDDATE ".$enddate;
+#             warn "AFTER ENDDATE ".$enddate;
         }
     }
     elsif ( $subscription->{monthlength} ){
-        warn "dateCHECKRESERV :".$subscription->{startdate};
+#         warn "dateCHECKRESERV :".$subscription->{startdate};
         my @date=split (/-/,$subscription->{startdate});
         my @enddate = 
Add_Delta_YM($date[0],$date[1],$date[2],0,$subscription->{monthlength}
           );
         $enddate=sprintf("%04d-%02d-%02d",$enddate[0],$enddate[1],$enddate[2]);
     } elsif ( $subscription->{weeklength} ){
         my @date=split (/-/,$subscription->{startdate});
-        warn "dateCHECKRESERV :".$subscription->{startdate};
+#         warn "dateCHECKRESERV :".$subscription->{startdate};
         my @enddate = 
Add_Delta_Days($date[0],$date[1],$date[2],0,$subscription->{weeklength}*7);
         $enddate=sprintf("%04d-%02d-%02d",$enddate[0],$enddate[1],$enddate[2]);
     }
-    
+#     warn "date de fin :$enddate";
     return $enddate;
 }
 
@@ -2516,7 +2516,7 @@
     if ( $subscription->{periodicity} == 1 ) {
         my $dayofweek = Day_of_Week( $year,$month, $day );
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $dayofweek == 7 ) { $dayofweek = 0; }
+            if ( $dayofweek == 7 ) { $dayofweek = 1; }
             if ( in_array( ( $dayofweek + 1 ), @irreg ) ) {
                 ($year,$month,$day) = Add_Delta_Days($year,$month, $day , 1 );
                 $dayofweek++;
@@ -2527,7 +2527,7 @@
     if ( $subscription->{periodicity} == 2 ) {
         my ($wkno,$year) = Week_of_Year( $year,$month, $day );
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $wkno > 52 ) { $wkno = 0; }    # need to rollover at January
+            if ( $wkno > 52 ) { $wkno = 1; }    # need to rollover at January
             if ( $irreg[$i] == ( $wkno + 1 ) ) {
                 ($year,$month,$day) = Add_Delta_Days($year,$month, $day , 7 );
                 $wkno++;
@@ -2538,7 +2538,7 @@
     if ( $subscription->{periodicity} == 3 ) {
         my ($wkno,$year) = Week_of_Year( $year,$month, $day );
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $wkno > 52 ) { $wkno = 0; $year++; }    # need to rollover at 
January
+            if ( $wkno > 52 ) { $wkno = 1; $year++; }    # need to rollover at 
January
             if ( $irreg[$i] == ( $wkno + 2 ) ) {
             ### BUGFIX was previously +1 ^
                 ($year,$month,$day) = Add_Delta_Days($year,$month, $day , 14 );
@@ -2550,7 +2550,7 @@
     if ( $subscription->{periodicity} == 4 ) {
         my ($wkno,$year) = Week_of_Year( $year,$month, $day );
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $wkno > 52 ) { $wkno = 0;$year++; }    # need to rollover at 
January
+            if ( $wkno > 52 ) { $wkno = 1;$year++; }    # need to rollover at 
January
             if ( $irreg[$i] == ( $wkno + 3 ) ) {
             ### BUGFIX was previously +1 ^
                 ($year,$month,$day) = Add_Delta_Days($year,$month, $day , 21 );
@@ -2563,8 +2563,8 @@
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
             # warn $irreg[$i];
             # warn $month;
-            if ( $month == 12 ) {
-                $month = 0;$year++;
+            if ( $month > 12 ) {
+                $month = 1;$year++;
             }    # need to rollover to check January
             if ( $irreg[$i] == ( $month + 1 ) )
             {    # check next one to see if is to be skipped
@@ -2572,62 +2572,64 @@
                 $month++;    # to check if following ones are to be skipped too
             }
         }
+        warn "annee mois jour $year $month $day";
         @resultdate = Add_Delta_YMD($year,$month, $day ,0,1,0 );
 
         # warn "Planneddate2: $planneddate";
     }
     if ( $subscription->{periodicity} == 6 ) {
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $month == 12 ) {
-                $month = 0;$year++;
-            }    # need to rollover to check January
-            if ( $irreg[$i] == ( $month + 1 ) )
+            if ( $irreg[$i] == ( ($month + 2) % 12) )
             {    # check next one to see if is to be skipped
                 ($year,$month,$day) = Add_Delta_YMD($year,$month, $day ,0,2,0 
);
-                $month++;    # to check if following ones are to be skipped too
+                $month+=2;    # to check if following ones are to be skipped 
too
             }
+            if ( $month > 12 ) {
+                $month = $month % 12;$year++;
+            }    # need to rollover to check January
         }
         @resultdate = Add_Delta_YMD($year,$month, $day, 0, 2,0 );
     }
     if ( $subscription->{periodicity} == 7 ) {
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $month == 12 ) {
-                $month = 0;$year++;
-            }    # need to rollover to check January
-            if ( $irreg[$i] == ( $month + 1 ) )
+            if ( $irreg[$i] == ( ($month + 3) % 12 ) )
             {    # check next one to see if is to be skipped
                 ($year,$month,$day) = Add_Delta_YMD($year,$month, $day, 0, 3,0 
);
-                $month++;    # to check if following ones are to be skipped too
+                $month+=3;    # to check if following ones are to be skipped 
too
             }
+            if ( $month > 12 ) {
+                $month = $month % 12;$year++;
+            }    # need to rollover to check January
         }
         @resultdate = Add_Delta_YMD($year,$month, $day, 0, 3, 0);
     }
     if ( $subscription->{periodicity} == 8 ) {
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $month == 12 ) {
-                $month = 0;$year++;
-            }    # need to rollover to check January
-            if ( $irreg[$i] == ( $month + 1 ) )
+            if ( $irreg[$i] == ( ($month + 6) % 12 ) )
             ### BUFIX Seems to need more Than One ?
             {    # check next one to see if is to be skipped
                 ($year,$month,$day) = Add_Delta_YMD($year,$month, $day, 0, 3, 
0 );
-                $month++;    # to check if following ones are to be skipped too
+                $month+=6;    # to check if following ones are to be skipped 
too
             }
+            if ( $month > 12 ) {
+                $month = $month % 12;$year++;
+            }    # need to rollover to check January
         }
         @resultdate = Add_Delta_YM($year,$month, $day, 0, 3, 0);
     }
     if ( $subscription->{periodicity} == 9 ) {
         for ( my $i = 0 ; $i < @irreg ; $i++ ) {
-            if ( $month == 12 ) {
-                $month = 0;$year++;
-            }    # need to rollover to check January
-            if ( $irreg[$i] == ( $month + 1 ) )
+            if ( $irreg[$i] == ( ($month + 6) % 12 ) )
+            ### BUFIX Seems to need more Than One ?
             {    # check next one to see if is to be skipped
-                ($year,$month,$day) = Add_Delta_YMD($year,$month, $day, 0, 6, 
0 );
-                $month++;    # to check if following ones are to be skipped too
+                ($year,$month,$day) = Add_Delta_YM($year,$month, $day, 0, 6 );
+                $month+=6;    # to check if following ones are to be skipped 
too
             }
+            if ( $month > 12 ) {
+                $month = $month % 12;$year++;
+            }    # need to rollover to check January
         }
-        @resultdate = Add_Delta_YM($year,$month, $day, 0, 6, 0 );
+        @resultdate = Add_Delta_YM($year,$month, $day, 0, 6);
     }
     if ( $subscription->{periodicity} == 10 ) {
         @resultdate = Add_Delta_YM($year,$month, $day, 1, 0 );

Index: serials/checkexpiration.pl
===================================================================
RCS file: /cvsroot/koha/koha/serials/Attic/checkexpiration.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- serials/checkexpiration.pl  22 Dec 2006 14:38:59 -0000      1.1.2.1
+++ serials/checkexpiration.pl  16 Jan 2007 10:02:05 -0000      1.1.2.2
@@ -16,7 +16,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: checkexpiration.pl,v 1.1.2.1 2006/12/22 14:38:59 toins Exp $
+# $Id: checkexpiration.pl,v 1.1.2.2 2007/01/16 10:02:05 hdl Exp $
 
 =head1 NAME
 
@@ -76,17 +76,13 @@
     my @subscriptions_loop;
 
     foreach my $subscription ( @subscriptions ) {
-    
         my $subscriptionid = $subscription->{'subscriptionid'};
         my $expirationdate = GetExpirationDate($subscriptionid);
 
         $subscription->{expirationdate} = $expirationdate;
-        
         next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in good 
format.
-        
-        if ($expirationdate < $date &&
+        if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split 
"-",$date) &&
              Date_to_Days(split "-",$expirationdate) > Date_to_Days(split 
"-",$today) ) {
-             
             push @subscriptions_loop,$subscription;             
         }
     }




reply via email to

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