[Koha-patches] [PATCH] [followup](bug #2961) change the workflow of the new issue

Nahuel ANGELINETTI nahuel.angelinetti at biblibre.com
Tue Mar 17 15:28:59 CET 2009


This patch change the operations, it add a new expected if no one expected exists, else it create new excepted, and set the others as "late"
---
 serials/serials-collection.pl |   52 +++++++++++++++++++++++++---------------
 1 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl
index 93aa00b..7b31de5 100755
--- a/serials/serials-collection.pl
+++ b/serials/serials-collection.pl
@@ -54,28 +54,40 @@ if($op eq "gennext" && @subscriptionid){
     my $subscriptionid = @subscriptionid[0];
     my $subscription = GetSubscription($subscriptionid);
 
-    my $expected = GetNextExpected($subscriptionid);
-    
-    my (
-            $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
-            $newinnerloop1, $newinnerloop2, $newinnerloop3
-        ) = GetNextSeq($subscription);
-
-    ## We generate the next publication date    
-    my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription );
-
-    ## Creating the new issue
-    NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
-            1, $nextpublisheddate, $nextpublisheddate );
-            
-    ## Updating the subscription seq status
-    my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
-                WHERE  subscriptionid = ?";
-    $sth = $dbh->prepare($squery);
-    $sth->execute(
-        $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1,
-        $newinnerloop2, $newinnerloop3, $subscriptionid
-        );
+	my $sth = $dbh->prepare("SELECT publisheddate, serialid, serialseq, planneddate 
+							FROM serial WHERE status = 1 AND subscriptionid = ?");
+	$sth->execute($subscriptionid);
+
+	# modify actual expected issue, to generate the next
+	if ( my $issue = $sth->fetchrow_hashref ) {
+		warn "Modifying";
+		ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
+                $issue->{planneddate}, $issue->{publisheddate},
+                3, "Automatically set to late" );
+	}else{
+		my $expected = GetNextExpected($subscriptionid);
+	    my (
+	         $newserialseq,  $newlastvalue1, $newlastvalue2, $newlastvalue3,
+             $newinnerloop1, $newinnerloop2, $newinnerloop3
+            ) = GetNextSeq($subscription);
+	
+	     ## We generate the next publication date    
+	     my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription );
+		 warn "Creating new issue";
+	     ## Creating the new issue
+	     NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
+	             1, $nextpublisheddate, $nextpublisheddate );
+	             
+	     ## Updating the subscription seq status
+	     my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
+	                 WHERE  subscriptionid = ?";
+	     $sth = $dbh->prepare($squery);
+	     $sth->execute(
+	         $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1,
+	         $newinnerloop2, $newinnerloop3, $subscriptionid
+	         );
+
+	}
 
     print $query->redirect('/cgi-bin/koha/serials/serials-collection.pl?subscriptionid='.$subscriptionid);
 }
-- 
1.5.6.3





More information about the Koha-patches mailing list