(bug #2961) change the workflow of the new issue
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Mon, 27 Apr 2009 15:13:08 +0000 (17:13 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Tue, 26 May 2009 19:15:19 +0000 (21:15 +0200)
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"

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
serials/serials-collection.pl

index 93aa00b..baef9b9 100755 (executable)
@@ -54,28 +54,38 @@ 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 ) {
+               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 );
+            ## 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);
 }