MT 1717 : Opac descriptions for authorised values
[koha.git] / C4 / Serials.pm
index 96908bf..5077d83 100644 (file)
@@ -19,7 +19,7 @@ package C4::Serials;    #assumes C4/Serials.pm
 
 
 use strict;
-use C4::Dates qw(format_date format_date_in_iso);
+use C4::Dates qw(format_date);
 use Date::Calc qw(:all);
 use POSIX qw(strftime);
 use C4::Suggestions;
@@ -41,7 +41,7 @@ BEGIN {
     &NewSubscription    &ModSubscription    &DelSubscription    &GetSubscriptions
     &GetSubscription    &CountSubscriptionFromBiblionumber      &GetSubscriptionsFromBiblionumber
     &GetFullSubscriptionsFromBiblionumber   &GetFullSubscription &ModSubscriptionHistory
-    &HasSubscriptionExpired &GetExpirationDate &abouttoexpire
+    &HasSubscriptionStrictlyExpired &HasSubscriptionExpired &GetExpirationDate &abouttoexpire
     
     &GetNextSeq         &NewIssue           &ItemizeSerials    &GetSerials
     &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
@@ -55,8 +55,8 @@ BEGIN {
     &getroutinglist     &delroutingmember   &addroutingmember
     &reorder_members
     &check_routing &updateClaim &removeMissingIssue
-    
-    &old_newsubscription &old_modsubscription &old_getserials
+    &CountIssues
+
        );
 }
 
@@ -326,8 +326,7 @@ sub UpdateClaimdateIssues {
     $date = strftime("%Y-%m-%d",localtime) unless ($date);
     my $query = "
         UPDATE serial SET claimdate=$date,status=7
-        WHERE  serialid in ".join (",",@$serialids);
-    ;
+        WHERE  serialid in (".join (",",@$serialids) .")";
     my $rq = $dbh->prepare($query);
     $rq->execute;
     return $rq->rows;
@@ -353,8 +352,6 @@ sub GetSubscription {
     my $query            = qq(
         SELECT  subscription.*,
                 subscriptionhistory.*,
-                subscriptionhistory.enddate as histenddate,
-                aqbudget.bookfundid,
                 aqbooksellers.name AS aqbooksellername,
                 biblio.title AS bibliotitle,
                 subscription.biblionumber as bibnum);
@@ -367,7 +364,6 @@ sub GetSubscription {
             $query .= qq(             
        FROM subscription
        LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
-       LEFT JOIN aqbudget ON subscription.aqbudgetid=aqbudget.aqbudgetid
        LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
        LEFT JOIN biblio ON biblio.biblionumber=subscription.biblionumber
        WHERE subscription.subscriptionid = ?
@@ -406,7 +402,7 @@ sub GetFullSubscription {
             serial.status, 
             serial.notes as notes,
             year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
-            aqbudget.bookfundid,aqbooksellers.name as aqbooksellername,
+            aqbooksellers.name as aqbooksellername,
             biblio.title as bibliotitle,
             subscription.branchcode AS branchcode,
             subscription.subscriptionid AS subscriptionid |;
@@ -420,7 +416,6 @@ sub GetFullSubscription {
   FROM      serial 
   LEFT JOIN subscription ON 
           (serial.subscriptionid=subscription.subscriptionid )
-  LEFT JOIN aqbudget ON subscription.aqbudgetid=aqbudget.aqbudgetid 
   LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id 
   LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber 
   WHERE     serial.subscriptionid = ? 
@@ -517,13 +512,10 @@ sub GetSubscriptionsFromBiblionumber {
         SELECT subscription.*,
                branches.branchname,
                subscriptionhistory.*,
-               subscriptionhistory.enddate as histenddate, 
-               aqbudget.bookfundid,
                aqbooksellers.name AS aqbooksellername,
                biblio.title AS bibliotitle
        FROM subscription
        LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
-       LEFT JOIN aqbudget ON subscription.aqbudgetid=aqbudget.aqbudgetid
        LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
        LEFT JOIN biblio ON biblio.biblionumber=subscription.biblionumber
        LEFT JOIN branches ON branches.branchcode=subscription.branchcode
@@ -587,7 +579,6 @@ sub GetFullSubscriptionsFromBiblionumber {
             serial.status, 
             serial.notes as notes,
             year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
-            aqbudget.bookfundid,aqbooksellers.name as aqbooksellername,
             biblio.title as bibliotitle,
             subscription.branchcode AS branchcode,
             subscription.subscriptionid AS subscriptionid|;
@@ -602,7 +593,6 @@ sub GetFullSubscriptionsFromBiblionumber {
   FROM      serial 
   LEFT JOIN subscription ON 
           (serial.subscriptionid=subscription.subscriptionid)
-  LEFT JOIN aqbudget ON subscription.aqbudgetid=aqbudget.aqbudgetid 
   LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id 
   LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber 
   WHERE     subscription.biblionumber = ? 
@@ -1031,10 +1021,15 @@ sub GetExpirationDate {
     my ($subscriptionid) = @_;
     my $dbh              = C4::Context->dbh;
     my $subscription     = GetSubscription($subscriptionid);
-    my $enddate          = $subscription->{startdate};
-
-# we don't do the same test if the subscription is based on X numbers or on X weeks/months
-    if (($subscription->{periodicity} % 16) >0){
+    my $enddate          = $$subscription{enddate}||$$subscription{histenddate};
+
+    return $enddate if ($enddate && $enddate ne "0000-00-00");
+        
+         # we don't do the same test if the subscription is based on X numbers or on X weeks/months
+        $enddate=$$subscription{startdate};
+        my @date=split (/-/,$$subscription{startdate});
+        return if (scalar(@date)!=3 ||not check_date(@date));
+     if (($subscription->{periodicity} % 16) >0){
       if ( $subscription->{numberlength} ) {
           #calculate the date of the last issue.
           my $length = $subscription->{numberlength};
@@ -1043,17 +1038,20 @@ sub GetExpirationDate {
           }
       }
       elsif ( $subscription->{monthlength} ){
-          my @date=split (/-/,$subscription->{startdate});
-          my @enddate = Add_Delta_YM($date[0],$date[1],$date[2],0,$subscription->{monthlength});
-          $enddate=sprintf("%04d-%02d-%02d",$enddate[0],$enddate[1],$enddate[2]);
-      } elsif ( $subscription->{weeklength} ){
-          my @date=split (/-/,$subscription->{startdate});
-          my @enddate = Add_Delta_Days($date[0],$date[1],$date[2],$subscription->{weeklength}*7);
-          $enddate=sprintf("%04d-%02d-%02d",$enddate[0],$enddate[1],$enddate[2]);
-      }
-      return $enddate;
-    } else {
-      return 0;  
+                  if ($$subscription{startdate}){
+                      my @enddate = Add_Delta_YM($date[0],$date[1],$date[2],0,$subscription->{monthlength});
+                      $enddate=sprintf("%04d-%02d-%02d",$enddate[0],$enddate[1],$enddate[2]);
+                  }
+      } elsif   ( $subscription->{weeklength} ){
+                  if ($$subscription{startdate}){
+                       my @date=split (/-/,$subscription->{startdate});
+                       my @enddate = Add_Delta_Days($date[0],$date[1],$date[2],$subscription->{weeklength}*7);
+                       $enddate=sprintf("%04d-%02d-%02d",$enddate[0],$enddate[1],$enddate[2]);
+                       }
+         }
+         return $enddate;
+       } else {
+       return ;  
     }  
 }
 
@@ -1099,7 +1097,7 @@ sub ModSubscriptionHistory {
     ) = @_;
     my $dbh   = C4::Context->dbh;
     my $query = "UPDATE subscriptionhistory 
-                    SET histstartdate=?,enddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=?
+                    SET histstartdate=?,histenddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=?
                     WHERE subscriptionid=?
                 ";
     my $sth = $dbh->prepare($query);
@@ -1300,8 +1298,8 @@ sub ModSubscription {
         $whenmorethan3,   $setto3,       $lastvalue3,     $innerloop3,
         $numberingmethod, $status,       $biblionumber,   $callnumber,
         $notes,           $letter,       $hemisphere,     $manualhistory,
-        $internalnotes,   $serialsadditems,$subscriptionid,
-        $staffdisplaycount,$opacdisplaycount, $graceperiod, $location
+        $internalnotes,   $serialsadditems,
+        $staffdisplaycount,$opacdisplaycount, $graceperiod, $location,$enddate,$subscriptionid
     ) = @_;
 #     warn $irregularity;
     my $dbh   = C4::Context->dbh;
@@ -1311,7 +1309,10 @@ sub ModSubscription {
                         add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?,
                         add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?,
                         add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?,
-                        numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, letter=?, hemisphere=?,manualhistory=?,internalnotes=?,serialsadditems=?,staffdisplaycount = ?,opacdisplaycount = ?, graceperiod = ?, location = ?
+                        numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, 
+                                               letter=?, hemisphere=?,manualhistory=?,internalnotes=?,serialsadditems=?,
+                                               staffdisplaycount = ?,opacdisplaycount = ?, graceperiod = ?, location = ?
+                                               ,enddate=?
                     WHERE subscriptionid = ?";
      #warn "query :".$query;
     my $sth = $dbh->prepare($query);
@@ -1327,7 +1328,7 @@ sub ModSubscription {
         $numberingmethod, $status,       $biblionumber,   $callnumber,
         $notes,           $letter,       $hemisphere,     ($manualhistory?$manualhistory:0),
         $internalnotes,   $serialsadditems,
-        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location,
+        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location,$enddate,
         $subscriptionid
     );
     my $rows=$sth->rows;
@@ -1347,7 +1348,7 @@ $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu
     $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
     $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
     $numberingmethod, $status, $notes, $serialsadditems,
-    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location);
+    $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate);
 
 Create a new subscription with value given on input args.
 
@@ -1371,7 +1372,7 @@ sub NewSubscription {
         $notes,         $letter,       $firstacquidate,  $irregularity,
         $numberpattern, $callnumber,   $hemisphere,      $manualhistory,
         $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
-        $graceperiod, $location
+        $graceperiod, $location,$enddate
     ) = @_;
     my $dbh = C4::Context->dbh;
 
@@ -1385,15 +1386,15 @@ sub NewSubscription {
             add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3,
             numberingmethod, status, notes, letter,firstacquidate,irregularity,
             numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems,
-            staffdisplaycount,opacdisplaycount,graceperiod,location)
-        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+            staffdisplaycount,opacdisplaycount,graceperiod,location,enddate)
+        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
         |;
     my $sth = $dbh->prepare($query);
     $sth->execute(
         $auser,                         $branchcode,
         $aqbooksellerid,                $cost,
         $aqbudgetid,                    $biblionumber,
-        format_date_in_iso($startdate), $periodicity,
+        $startdate, $periodicity,
         $dow,                           $numberlength,
         $weeklength,                    $monthlength,
         $add1,                          $every1,
@@ -1407,12 +1408,13 @@ sub NewSubscription {
         $lastvalue3,                    $innerloop3,
         $numberingmethod,               "$status",
         $notes,                         $letter,
-        format_date_in_iso($firstacquidate),                $irregularity,
+        $firstacquidate,                $irregularity,
         $numberpattern,                 $callnumber,
         $hemisphere,                    $manualhistory,
         $internalnotes,                 $serialsadditems,
                $staffdisplaycount,                             $opacdisplaycount,
         $graceperiod,                   $location,
+               $enddate
     );
 
     #then create the 1st waited number
@@ -1424,7 +1426,7 @@ sub NewSubscription {
         );
     $sth = $dbh->prepare($query);
     $sth->execute( $biblionumber, $subscriptionid,
-        format_date_in_iso($startdate),
+        $startdate,
         $notes,$internalnotes );
 
    # reread subscription to get a hash (for calculation of the 1st issue number)
@@ -1447,8 +1449,8 @@ sub NewSubscription {
     $sth = $dbh->prepare($query);
     $sth->execute(
         "$serialseq", $subscriptionid, $biblionumber, 1,
-        format_date_in_iso($firstacquidate),
-        format_date_in_iso($firstacquidate)
+        $firstacquidate,
+        $firstacquidate
     );
     
     logaction("SERIAL", "ADD", $subscriptionid, "") if C4::Context->preference("SubscriptionLog");
@@ -1513,7 +1515,7 @@ sub ReNewSubscription {
         WHERE  subscriptionid=?
     |;
     $sth = $dbh->prepare($query);
-    $sth->execute( format_date_in_iso($startdate),
+    $sth->execute( $startdate,
         $numberlength, $weeklength, $monthlength, $subscriptionid );
         
     logaction("SERIAL", "RENEW", $subscriptionid, "") if C4::Context->preference("SubscriptionLog");
@@ -1631,7 +1633,7 @@ sub ItemizeSerials {
             $sth->execute( $data->{'biblionumber'} );
             my $biblioitem = $sth->fetchrow_hashref;
             $biblioitem->{'volumedate'} =
-              format_date_in_iso( $data->{planneddate} );
+               $data->{planneddate} ;
             $biblioitem->{'volumeddesc'} =
               $data->{serialseq} . ' ('
               . format_date( $data->{'planneddate'} ) . ')';
@@ -1779,6 +1781,49 @@ sub ItemizeSerials {
     }
 }
 
+=head2 HasSubscriptionStrictlyExpired
+
+=over 4
+
+1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid)
+
+the subscription has stricly expired when today > the end subscription date 
+
+return :
+1 if true, 0 if false, -1 if the expiration date is not set.
+
+=back
+
+=cut
+sub HasSubscriptionStrictlyExpired {
+    # Getting end of subscription date
+    my ($subscriptionid) = @_;
+    my $dbh              = C4::Context->dbh;
+    my $subscription     = GetSubscription($subscriptionid);
+    my $expirationdate   = GetExpirationDate($subscriptionid);
+   
+    # If the expiration date is set
+    if ($expirationdate != 0) {
+       my ($endyear, $endmonth, $endday) = split('-', $expirationdate);
+
+       # Getting today's date
+       my ($nowyear, $nowmonth, $nowday) = Today();
+
+       # if today's date > expiration date, then the subscription has stricly expired
+       if (Delta_Days($nowyear, $nowmonth, $nowday,
+                        $endyear, $endmonth, $endday) < 0) {
+           return 1;   
+       } else {
+           return 0;
+       }
+    } else {
+       # There are some cases where the expiration date is not set
+       # As we can't determine if the subscription has expired on a date-basis,
+       # we return -1;
+       return -1;
+    }
+}
+
 =head2 HasSubscriptionExpired
 
 =over 4
@@ -1974,7 +2019,7 @@ LEFT JOIN subscription  ON serial.subscriptionid=subscription.subscriptionid
 LEFT JOIN biblio        ON subscription.biblionumber=biblio.biblionumber
 LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
 WHERE subscription.subscriptionid = serial.subscriptionid 
-AND (serial.STATUS = 4 OR ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3))
+AND (serial.STATUS = 4 OR ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3 OR serial.STATUS = 7))
 AND subscription.aqbooksellerid=$supplierid
 $byserial
 ORDER BY $order"
@@ -2001,7 +2046,7 @@ LEFT JOIN aqbooksellers
 ON subscription.aqbooksellerid = aqbooksellers.id
 WHERE 
    subscription.subscriptionid = serial.subscriptionid 
-AND (serial.STATUS = 4 OR ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3))
+AND (serial.STATUS = 4 OR ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3 OR serial.STATUS = 7))
 $byserial
 ORDER BY $order"
         );
@@ -2345,6 +2390,31 @@ sub countissuesfrom {
     return $countreceived;  
 }
 
+=head2 CountIssues
+
+=over 4
+
+$result = &CountIssues($subscriptionid)
+
+
+=back
+
+=cut
+
+sub CountIssues {
+    my ($subscriptionid) = @_;
+    my $dbh              = C4::Context->dbh;
+    my $query = qq|
+            SELECT count(*)
+            FROM   serial
+            WHERE  subscriptionid=?
+        |;
+    my $sth=$dbh->prepare($query);
+    $sth->execute($subscriptionid);
+    my ($countreceived)=$sth->fetchrow;
+    return $countreceived;  
+}
+
 =head2 abouttoexpire
 
 =over 4
@@ -2403,231 +2473,6 @@ sub abouttoexpire {
    } else {return 0}
 }
 
-=head2 old_newsubscription
-
-=over 4
-
-($subscriptionid) = &old_newsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
-                        $startdate,$periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
-                        $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
-                        $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
-                        $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
-                        $numberingmethod, $status, $callnumber, $notes, $hemisphere)
-
-this function is similar to the NewSubscription subroutine but has a few different
-values passed in 
-$firstacquidate - date of first serial issue to arrive
-$irregularity - the issues not expected separated by a '|'
-- eg. monthly issue but not expecting issue for june and july would have $irregularity of '6|7'
-$numberpattern - the number for an array of labels to reconstruct the javascript correctly in the 
-   subscription-add.tmpl file
-$callnumber - display the callnumber of the serial
-$hemisphere - either 2 = southern hemisphere or 1 = northern hemisphere - used for quarterly serials
-
-return :
-the $subscriptionid number of the new subscription
-
-=back
-
-=cut
-
-sub old_newsubscription {
-    my (
-        $auser,         $aqbooksellerid,  $cost,          $aqbudgetid,
-        $biblionumber,  $startdate,       $periodicity,   $firstacquidate,
-        $dow,           $irregularity,    $numberpattern, $numberlength,
-        $weeklength,    $monthlength,     $add1,          $every1,
-        $whenmorethan1, $setto1,          $lastvalue1,    $add2,
-        $every2,        $whenmorethan2,   $setto2,        $lastvalue2,
-        $add3,          $every3,          $whenmorethan3, $setto3,
-        $lastvalue3,    $numberingmethod, $status,        $callnumber,
-        $notes,         $hemisphere
-    ) = @_;
-    my $dbh = C4::Context->dbh;
-
-    #save subscription
-    my $sth = $dbh->prepare(
-"insert into subscription (librarian,aqbooksellerid,cost,aqbudgetid,biblionumber,
-                                                        startdate,periodicity,firstacquidate,dow,irregularity,numberpattern,numberlength,weeklength,monthlength,
-                                                                add1,every1,whenmorethan1,setto1,lastvalue1,
-                                                                add2,every2,whenmorethan2,setto2,lastvalue2,
-                                                                add3,every3,whenmorethan3,setto3,lastvalue3,
-                                                                numberingmethod, status, callnumber, notes, hemisphere) values
-                                                          (?,?,?,?,?,?,?,?,?,?,?,
-                                                                                           ?,?,?,?,?,?,?,?,?,?,?,
-                                                                                           ?,?,?,?,?,?,?,?,?,?,?,?)"
-    );
-    $sth->execute(
-        $auser,         $aqbooksellerid,
-        $cost,          $aqbudgetid,
-        $biblionumber,  format_date_in_iso($startdate),
-        $periodicity,   format_date_in_iso($firstacquidate),
-        $dow,           $irregularity,
-        $numberpattern, $numberlength,
-        $weeklength,    $monthlength,
-        $add1,          $every1,
-        $whenmorethan1, $setto1,
-        $lastvalue1,    $add2,
-        $every2,        $whenmorethan2,
-        $setto2,        $lastvalue2,
-        $add3,          $every3,
-        $whenmorethan3, $setto3,
-        $lastvalue3,    $numberingmethod,
-        $status,        $callnumber,
-        $notes,         $hemisphere
-    );
-
-    #then create the 1st waited number
-    my $subscriptionid = $dbh->{'mysql_insertid'};
-    my $enddate        = GetExpirationDate($subscriptionid);
-
-    $sth =
-      $dbh->prepare(
-"insert into subscriptionhistory (biblionumber, subscriptionid, histstartdate, enddate, missinglist, recievedlist, opacnote, librariannote) values (?,?,?,?,?,?,?,?)"
-      );
-    $sth->execute(
-        $biblionumber, $subscriptionid,
-        format_date_in_iso($startdate),
-        format_date_in_iso($enddate),
-        "", "", "", $notes
-    );
-
-   # reread subscription to get a hash (for calculation of the 1st issue number)
-    $sth =
-      $dbh->prepare("select * from subscription where subscriptionid = ? ");
-    $sth->execute($subscriptionid);
-    my $val = $sth->fetchrow_hashref;
-
-    # calculate issue number
-    my $serialseq = GetSeq($val);
-    $sth =
-      $dbh->prepare(
-"insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"
-      );
-    $sth->execute( $serialseq, $subscriptionid, $val->{'biblionumber'},
-        1, format_date_in_iso($startdate) );
-    return $subscriptionid;
-}
-
-=head2 old_modsubscription
-
-=over 4
-
-($subscriptionid) = &old_modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
-                        $startdate,$periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
-                        $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
-                        $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
-                        $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
-                        $numberingmethod, $status, $callnumber, $notes, $hemisphere, $subscriptionid)
-
-this function is similar to the ModSubscription subroutine but has a few different
-values passed in 
-$firstacquidate - date of first serial issue to arrive
-$irregularity - the issues not expected separated by a '|'
-- eg. monthly issue but not expecting issue for june and july would have $irregularity of '6|7'
-$numberpattern - the number for an array of labels to reconstruct the javascript correctly in the 
-   subscription-add.tmpl file
-$callnumber - display the callnumber of the serial
-$hemisphere - either 2 = southern hemisphere or 1 = northern hemisphere - used for quarterly serials
-
-=back
-
-=cut
-
-sub old_modsubscription {
-    my (
-        $auser,        $aqbooksellerid, $cost,           $aqbudgetid,
-        $startdate,    $periodicity,    $firstacquidate, $dow,
-        $irregularity, $numberpattern,  $numberlength,   $weeklength,
-        $monthlength,  $add1,           $every1,         $whenmorethan1,
-        $setto1,       $lastvalue1,     $innerloop1,     $add2,
-        $every2,       $whenmorethan2,  $setto2,         $lastvalue2,
-        $innerloop2,   $add3,           $every3,         $whenmorethan3,
-        $setto3,       $lastvalue3,     $innerloop3,     $numberingmethod,
-        $status,       $biblionumber,   $callnumber,     $notes,
-        $hemisphere,   $subscriptionid
-    ) = @_;
-    my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare(
-"update subscription set librarian=?, aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?,
-                                                   periodicity=?,firstacquidate=?,dow=?,irregularity=?,numberpattern=?,numberlength=?,weeklength=?,monthlength=?,
-                                                  add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?,
-                                                  add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?,
-                                                  add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?,
-                                                  numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, hemisphere=? where subscriptionid = ?"
-    );
-    $sth->execute(
-        $auser,        $aqbooksellerid, $cost,           $aqbudgetid,
-        $startdate,    $periodicity,    $firstacquidate, $dow,
-        $irregularity, $numberpattern,  $numberlength,   $weeklength,
-        $monthlength,  $add1,           $every1,         $whenmorethan1,
-        $setto1,       $lastvalue1,     $innerloop1,     $add2,
-        $every2,       $whenmorethan2,  $setto2,         $lastvalue2,
-        $innerloop2,   $add3,           $every3,         $whenmorethan3,
-        $setto3,       $lastvalue3,     $innerloop3,     $numberingmethod,
-        $status,       $biblionumber,   $callnumber,     $notes,
-        $hemisphere,   $subscriptionid
-    );
-    $sth->finish;
-
-    $sth =
-      $dbh->prepare("select * from subscription where subscriptionid = ? ");
-    $sth->execute($subscriptionid);
-    my $val = $sth->fetchrow_hashref;
-
-    # calculate issue number
-    my $serialseq = Get_Seq($val);
-    $sth =
-      $dbh->prepare("UPDATE serial SET serialseq = ? WHERE subscriptionid = ?");
-    $sth->execute( $serialseq, $subscriptionid );
-
-    my $enddate = subscriptionexpirationdate($subscriptionid);
-    $sth = $dbh->prepare("update subscriptionhistory set enddate=?");
-    $sth->execute( format_date_in_iso($enddate) );
-}
-
-=head2 old_getserials
-
-=over 4
-
-($totalissues,@serials) = &old_getserials($subscriptionid)
-
-this function get a hashref of serials and the total count of them
-
-return :
-$totalissues - number of serial lines
-the serials into a table. Each line of this table containts a ref to a hash which it containts
-serialid, serialseq, status,planneddate,notes,routingnotes  from tables : serial where status is not 2, 4, or 5
-
-=back
-
-=cut
-
-sub old_getserials {
-    my ($subscriptionid) = @_;
-    my $dbh = C4::Context->dbh;
-
-    # status = 2 is "arrived"
-    my $sth =
-      $dbh->prepare(
-"select serialid,serialseq, status, planneddate,notes,routingnotes from serial where subscriptionid = ? and status <>2 and status <>4 and status <>5"
-      );
-    $sth->execute($subscriptionid);
-    my @serials;
-    my $num = 1;
-    while ( my $line = $sth->fetchrow_hashref ) {
-        $line->{ "status" . $line->{status} } =
-          1;    # fills a "statusX" value, used for template status select list
-        $line->{"planneddate"} = format_date( $line->{"planneddate"} );
-        $line->{"num"}         = $num;
-        $num++;
-        push @serials, $line;
-    }
-    $sth = $dbh->prepare("select count(*) from serial where subscriptionid=?");
-    $sth->execute($subscriptionid);
-    my ($totalissues) = $sth->fetchrow;
-    return ( $totalissues, @serials );
-}
 
 =head2 GetNextDate