[Koha-patches] [PATCH] (MT 3035) subscription created expired
Jean-André Santoni
jeanandre.santoni at biblibre.com
Mon Mar 1 09:29:09 CET 2010
From: Henri-Damien LAURENT <henridamien.laurent at biblibre.com>
Subscription expiration date was not calculated on creation of a subscription
(cherry picked from commit 263e9217c8cd736924f66d699981949e29b4c200)
---
C4/Serials.pm | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/C4/Serials.pm b/C4/Serials.pm
index d72e98c..439bd01 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -380,7 +380,8 @@ sub GetSubscription {
$debug and warn "query : $query\nsubsid :$subscriptionid";
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
- return $sth->fetchrow_hashref;
+ my $data= $sth->fetchrow_hashref;
+ return $data;
}
=head2 GetFullSubscription
@@ -987,7 +988,7 @@ sub GetSeq {
=head2 GetExpirationDate
-$sensddate = GetExpirationDate($subscriptionid)
+$enddate = GetExpirationDate($subscriptionid,$startdate)
this function return the next expiration date for a subscription given on input args.
@@ -1349,15 +1350,25 @@ sub NewSubscription {
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate
);
- #then create the 1st waited number
my $subscriptionid = $dbh->{'mysql_insertid'};
+ unless ($enddate){
+ $enddate=GetExpirationDate($subscriptionid,$startdate);
+ $query = qq|
+ UPDATE subscription
+ SET enddate=?
+ WHERE subscriptionid=?
+ |;
+ $sth = $dbh->prepare($query);
+ $sth->execute( $enddate, $subscriptionid );
+ }
+ #then create the 1st waited number
$query = qq(
INSERT INTO subscriptionhistory
(biblionumber, subscriptionid, histstartdate, opacnote, librariannote)
VALUES (?,?,?,?,?)
);
$sth = $dbh->prepare($query);
- $sth->execute( $biblionumber, $subscriptionid, $startdate, $notes, $internalnotes );
+ $sth->execute( $biblionumber, $subscriptionid, $startdate, $notes, $internalnotes );
# reread subscription to get a hash (for calculation of the 1st issue number)
$query = qq(
@@ -1719,7 +1730,7 @@ sub HasSubscriptionExpired {
my $dbh = C4::Context->dbh;
my $subscription = GetSubscription($subscriptionid);
if ( ( $subscription->{periodicity} % 16 ) > 0 ) {
- my $expirationdate = $subscription->{enddate};
+ my $expirationdate = $subscription->{enddate}||GetExpirationDate($subscriptionid);
my $query = qq|
SELECT max(planneddate)
FROM serial
--
1.6.3.3
More information about the Koha-patches
mailing list