(bug #2961) add a button to add manually the next issue
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Fri, 13 Feb 2009 16:15:31 +0000 (17:15 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 4 Mar 2009 11:47:22 +0000 (12:47 +0100)
This patch add a button in "Serial Collection" to add manually the next issue. And improve the function GetNextExpected
to retrieve at least something.

C4/Serials.pm
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tmpl
serials/serials-collection.pl

index 4d10615..f14a855 100644 (file)
@@ -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
 
index 10234c0..9647421 100644 (file)
@@ -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() {
             </tr>
       <!-- /TMPL_LOOP -->
         </table>
-      <p><input type="submit" value="Edit serials" /></p>
+      <p><input type="submit" value="Edit serials" />&nbsp;<input type="button" value="Generate Next" onClick="javascript:generateNext(<!-- TMPL_VAR NAME="subscriptionidlist" -->)" /></p>
     </div>
     <!--/TMPL_LOOP -->
   <input type="hidden" name="subscriptionid" value="<!--TMPL_VAR Name="subscriptionidlist"-->" />
index ca58f98..93aa00b 100755 (executable)
@@ -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){