From 5397ab31dce0e836647e5d6976cc3a1b1e929e09 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Fri, 13 Feb 2009 17:15:31 +0100 Subject: [PATCH] (bug #2961) add a button to add manually the next issue This patch add a button in "Serial Collection" to add manually the next issue. And improve the function GetNextExpected to retrieve at least something. Signed-off-by: Galen Charlton --- C4/Serials.pm | 6 ++++ .../modules/serials/serials-collection.tmpl | 8 ++++- serials/serials-collection.pl | 31 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 4ca031299e..b78453ef83 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1245,8 +1245,14 @@ sub GetNextExpected($) { # Each subscription has only one 'expected' issue, with serial.status==1. $sth->execute( $subscriptionid, 1 ); my ( $nextissue ) = $sth->fetchrow_hashref; + if(not $nextissue){ + $sth = $dbh->prepare('SELECT serialid,planneddate FROM serial WHERE subscriptionid = ? ORDER BY planneddate DESC LIMIT 1'); + $sth->execute( $subscriptionid ); + $nextissue = $sth->fetchrow_hashref; + } $nextissue->{planneddate} = C4::Dates->new($nextissue->{planneddate},'iso'); return $nextissue; + } =head2 ModNextExpected diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tmpl index 10234c0e07..96474217f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tmpl @@ -30,6 +30,12 @@ function popup(subscriptionid) { newin=window.open('subscription-renew.pl?mode=popup&subscriptionid='+subscriptionid,'popup','width=500,height=400,toolbar=false,scrollbars=yes'); } +function generateNext(subscriptionid) { + if(confirm("Do you really want to generate next serial?")){ + document.location = 'serials-collection.pl?op=gennext&subscriptionid='+subscriptionid; + } +} + $(document).ready(function() { $('#subscription_years > ul').tabs(); }); @@ -239,7 +245,7 @@ $(document).ready(function() { -

+

 )" />

" /> diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index ca58f98290..93aa00b596 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -49,6 +49,37 @@ my @subscriptionid = $query->param('subscriptionid'); my $subscriptiondescs ; my $subscriptions; + +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 + ); + + print $query->redirect('/cgi-bin/koha/serials/serials-collection.pl?subscriptionid='.$subscriptionid); +} + if (@subscriptionid){ my @subscriptioninformation=(); foreach my $subscriptionid (@subscriptionid){ -- 2.39.5