From 70e46edf73ab8c6279c9852646e8ee91dc0eeb84 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Mon, 27 Apr 2009 17:13:08 +0200 Subject: [PATCH] (bug #2961) change the workflow of the new issue 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 --- serials/serials-collection.pl | 54 +++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index 93aa00b596..baef9b9d7c 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -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); } -- 2.39.5