Bug 6790: Remove unnecessary variable from getroutinglist return
[koha_fer] / C4 / Serials.pm
index 8aa6ebc..9cda52e 100644 (file)
@@ -588,7 +588,7 @@ sub GetSubscriptions {
             $tmpstring =~ s/^AND //;
             push @sqlstrings, $tmpstring;
         }
-        $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")";
+        $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))";
     }
     if ($issn) {
         my @sqlstrings;
@@ -601,7 +601,7 @@ sub GetSubscriptions {
             $tmpstring =~ s/^OR //;
             push @sqlstrings, $tmpstring;
         }
-        $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")";
+        $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))";
     }
     $sql .= "$sqlwhere ORDER BY title";
     $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params );
@@ -612,14 +612,6 @@ sub GetSubscriptions {
     my $odd           = 1;
 
     while ( my $line = $sth->fetchrow_hashref ) {
-        if ( $previousbiblio eq $line->{biblionumber} ) {
-            $line->{title} = "";
-            $line->{issn}  = "";
-        } else {
-            $previousbiblio = $line->{biblionumber};
-            $odd           = -$odd;
-        }
-        $line->{toggle} = 1 if $odd == 1;
         $line->{'cannotedit'} =
           (      C4::Context->preference('IndependantBranches')
               && C4::Context->userenv
@@ -2027,12 +2019,11 @@ sub delroutingmember {
 
 =head2 getroutinglist
 
-($count,@routinglist) = getroutinglist($subscriptionid)
+@routinglist = getroutinglist($subscriptionid)
 
 this gets the info from the subscriptionroutinglist for $subscriptionid
 
 return :
-a count of the number of members on routinglist
 the routinglist as an array. Each element of the array contains a hash_ref containing
 routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription
 
@@ -2042,20 +2033,14 @@ sub getroutinglist {
     my ($subscriptionid) = @_;
     my $dbh              = C4::Context->dbh;
     my $sth              = $dbh->prepare(
-        "SELECT routingid, borrowernumber, ranking, biblionumber 
+        'SELECT routingid, borrowernumber, ranking, biblionumber
             FROM subscription 
             JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
-            WHERE subscription.subscriptionid = ? ORDER BY ranking ASC
-                              "
+            WHERE subscription.subscriptionid = ? ORDER BY ranking ASC'
     );
     $sth->execute($subscriptionid);
-    my @routinglist;
-    my $count = 0;
-    while ( my $line = $sth->fetchrow_hashref ) {
-        $count++;
-        push( @routinglist, $line );
-    }
-    return ( $count, @routinglist );
+    my $routinglist = $sth->fetchall_arrayref({});
+    return @{$routinglist};
 }
 
 =head2 countissuesfrom
@@ -2154,7 +2139,7 @@ sub abouttoexpire {
             @res=Date::Calc::Today;
         }
         my @endofsubscriptiondate=split(/-/,$expirationdate);
-        my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 0, 0, 0);
+        my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 124, 0, 0);
         my @datebeforeend;
         @datebeforeend = Add_Delta_Days(  $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2],
             - (3 * $per_list[$per])) if (@endofsubscriptiondate && $endofsubscriptiondate[0]*$endofsubscriptiondate[1]*$endofsubscriptiondate[2]);
@@ -2317,6 +2302,15 @@ sub GetNextDate(@) {
             }
             @resultdate = Add_Delta_YMD( $year, $month, $day, 0, 3, 0 );
         }
+        if ( $subscription->{periodicity} == 13 ) {
+            for ( my $i = 0 ; $i < @irreg ; $i++ ) {
+                if ( $irreg[$i] == ( ( $tmpmonth != 8 ) ? ( $tmpmonth + 4 ) % 12 : 12 ) ) {
+                    ( $year, $month, $day ) = Add_Delta_YMD( $year, $month, $day, 0, 4, 0 );
+                    $tmpmonth = ( ( $tmpmonth != 8 ) ? ( $tmpmonth + 4 ) % 12 : 12 );
+                }
+            }
+            @resultdate = Add_Delta_YMD( $year, $month, $day, 0, 4, 0 );
+        }
         if ( $subscription->{periodicity} == 9 ) {
             for ( my $i = 0 ; $i < @irreg ; $i++ ) {
                 if ( $irreg[$i] == ( ( $tmpmonth != 9 ) ? ( $tmpmonth + 3 ) % 12 : 12 ) ) {