[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Serials.pm
From: |
Henri-Damien LAURENT |
Subject: |
[Koha-cvs] koha/C4 Serials.pm |
Date: |
Wed, 23 May 2007 19:57:47 +0000 |
CVSROOT: /cvsroot/koha
Module name: koha
Changes by: Henri-Damien LAURENT <hdl> 07/05/23 19:57:47
Modified files:
C4 : Serials.pm
Log message:
Bug Fixing.
irregular serials are now managed in HasSubscriptionExpired
and abouttoexpire.
Be WARN that Date::Calc is very picky about Date format.
So that null dates are throwing 500 Error.
But Now this should be seldom.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Serials.pm?cvsroot=koha&r1=1.17&r2=1.18
Patches:
Index: Serials.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Serials.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- Serials.pm 23 May 2007 17:35:59 -0000 1.17
+++ Serials.pm 23 May 2007 19:57:47 -0000 1.18
@@ -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.17 2007/05/23 17:35:59 tipaul Exp $
+# $Id: Serials.pm,v 1.18 2007/05/23 19:57:47 hdl Exp $
use strict;
use C4::Date;
@@ -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.17 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.18 $' =~ /\d+/g;
shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
};
@@ -1052,9 +1052,9 @@
# 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);
+# use Data::Dumper; warn Dumper($subscription);
- warn "dateCHECKRESERV :".$subscription->{startdate};
+# warn "dateCHECKRESERV :".$subscription->{startdate};
if ( $subscription->{numberlength} ) {
#calculate the date of the last issue.
my $length = $subscription->{numberlength};
@@ -1763,17 +1763,9 @@
|| (!$res));
return 0;
} else {
- if ($subscription->{numberlength}){
- my $query = qq|
- SELECT count(*)
- FROM serial
- WHERE subscriptionid=?
- AND serial.publisheddate>?
- |;
- my $sth=$dbh->prepare($query);
- $sth->execute($subscriptionid, $subscription->{startdate});
- my ($countreceived)=$sth->fetchrow;
- return 1 if ($countreceived) >$subscription->{numberlentgh}-3;
+ if ($subscription->{'numberlength'}){
+ my
$countreceived=countissuesfrom($subscriptionid,$subscription->{'startdate'});
+ return 1 if ($countreceived >$subscription->{'numberlentgh'});
return 0;
} else {
return 0;
@@ -2269,6 +2261,32 @@
return ( $count, @routinglist );
}
+=head2 countissuesfrom
+
+=over 4
+
+$result = &countissuesfrom($subscriptionid,$startdate)
+
+
+=back
+
+=cut
+
+sub countissuesfrom {
+ my ($subscriptionid,$startdate) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = qq|
+ SELECT count(*)
+ FROM serial
+ WHERE subscriptionid=?
+ AND serial.publisheddate>?
+ |;
+ my $sth=$dbh->prepare($query);
+ $sth->execute($subscriptionid, $startdate);
+ my ($countreceived)=$sth->fetchrow;
+ return $countreceived;
+}
+
=head2 abouttoexpire
=over 4
@@ -2288,6 +2306,8 @@
my ($subscriptionid) = @_;
my $dbh = C4::Context->dbh;
my $subscription = GetSubscription($subscriptionid);
+ my $per = $subscription->{'periodicity'};
+ if ($per>0){
my $expirationdate = GetExpirationDate($subscriptionid);
my $sth =
$dbh->prepare(
@@ -2320,6 +2340,9 @@
Delta_Days($res[0],$res[1],$res[2],
$endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2])
>= 0) );
return 0;
+ } elsif ($subscription->{numberlength}>0) {
+ return (countissuesfrom($subscriptionid,$subscription->{'startdate'})
>=$subscription->{numberlength}-1);
+ } else {return 0}
}
=head2 old_newsubscription
@@ -2562,7 +2585,7 @@
return :
$resultdate - then next date in the sequence
-FIXME : have to replace Date::Manip by Date::Calc in this function to improve
performances.
+Return 0 if periodicity==0
=cut
sub in_array { # used in next sub down
@@ -2587,6 +2610,9 @@
my @resultdate;
# warn "DOW $dayofweek";
+ if ( $subscription->{periodicity} == 0 ) {
+ return 0;
+ }
if ( $subscription->{periodicity} == 1 ) {
my $dayofweek = Day_of_Week( $year,$month, $day );
for ( my $i = 0 ; $i < @irreg ; $i++ ) {