Bug 7356 - Fix various typos and mis-spellings
[koha.git] / C4 / Serials.pm
index 32c9bcb..1471184 100644 (file)
@@ -441,7 +441,6 @@ sub PrepareSerialsData {
     foreach my $key ( sort { $b cmp $a } keys %tmpresults ) {
         push @res, $tmpresults{$key};
     }
-    $res[0]->{'first'} = 1;
     return \@res;
 }
 
@@ -582,27 +581,27 @@ sub GetSubscriptions {
         my @sqlstrings;
         my @strings_to_search;
         @strings_to_search = map { "%$_%" } split( / /, $string );
-        foreach my $index qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes) {
+        foreach my $index (qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes)) {
             push @bind_params, @strings_to_search;
             my $tmpstring = "AND $index LIKE ? " x scalar(@strings_to_search);
             $debug && warn "$tmpstring";
             $tmpstring =~ s/^AND //;
             push @sqlstrings, $tmpstring;
         }
-        $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")";
+        $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))";
     }
     if ($issn) {
         my @sqlstrings;
         my @strings_to_search;
         @strings_to_search = map { "%$_%" } split( / /, $issn );
-        foreach my $index qw(biblioitems.issn subscription.callnumber) {
+        foreach my $index ( qw(biblioitems.issn subscription.callnumber)) {
             push @bind_params, @strings_to_search;
             my $tmpstring = "OR $index LIKE ? " x scalar(@strings_to_search);
             $debug && warn "$tmpstring";
             $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 );
@@ -1635,7 +1634,9 @@ sub HasSubscriptionExpired {
         my $sth = $dbh->prepare($query);
         $sth->execute($subscriptionid);
         my ($res) = $sth->fetchrow;
-        return 0 unless $res;
+        if (!$res || $res=~m/^0000/) {
+            return 0;
+        }
         my @res                   = split( /-/, $res );
         my @endofsubscriptiondate = split( /-/, $expirationdate );
         return 2 if ( scalar(@res) != 3 || scalar(@endofsubscriptiondate) != 3 || not check_date(@res) || not check_date(@endofsubscriptiondate) );
@@ -2153,7 +2154,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]);
@@ -2316,6 +2317,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 ) ) {