Merge remote branch 'kc/master' into new/enh/bug_5917
[koha.git] / C4 / Serials.pm
index 40ff3b6..da0f4bd 100644 (file)
@@ -1,6 +1,7 @@
 package C4::Serials;
 
 # Copyright 2000-2002 Katipo Communications
+# Parts Copyright 2010 Biblibre
 #
 # This file is part of Koha.
 #
@@ -124,10 +125,11 @@ sub GetLateIssues {
             LEFT JOIN  biblio ON biblio.biblionumber = subscription.biblionumber
             LEFT JOIN  aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
             WHERE      ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3)
-            AND        subscription.aqbooksellerid=$supplierid
+            AND        subscription.aqbooksellerid=?
             ORDER BY   title
         |;
         $sth = $dbh->prepare($query);
+        $sth->execute($supplierid);
     } else {
         my $query = qq|
             SELECT     name,title,planneddate,serialseq,serial.subscriptionid
@@ -139,8 +141,8 @@ sub GetLateIssues {
             ORDER BY   title
         |;
         $sth = $dbh->prepare($query);
+        $sth->execute;
     }
-    $sth->execute;
     my @issuelist;
     my $last_title;
     my $odd   = 0;
@@ -723,9 +725,16 @@ sub GetSerials2 {
     my @serials;
 
     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->{"publisheddate"}              = format_date( $line->{"publisheddate"} );
+        $line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list
+        # Format dates for display
+        for my $datefield ( qw( planneddate publisheddate ) ) {
+            if ($line->{$datefield} =~m/^00/) {
+                $line->{$datefield} = q{};
+            }
+            else {
+                $line->{$datefield} = format_date( $line->{$datefield} );
+            }
+        }
         push @serials, $line;
     }
     return @serials;