View | Details | Raw Unified | Return to bug 12167
Collapse All | Expand All

(-)a/C4/NewsChannels.pm (-6 / +5 lines)
Lines 188-214 sub get_opac_news { Link Here
188
sub GetNewsToDisplay {
188
sub GetNewsToDisplay {
189
    my ($lang,$branch) = @_;
189
    my ($lang,$branch) = @_;
190
    my $dbh = C4::Context->dbh;
190
    my $dbh = C4::Context->dbh;
191
    # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
192
    my $query = q{
191
    my $query = q{
193
     SELECT *,timestamp AS newdate
192
     SELECT *,opac_news.timestamp AS newdate
194
     FROM   opac_news
193
     FROM   opac_news
195
     WHERE   (
194
     WHERE   (
196
        expirationdate >= CURRENT_DATE()
195
        expirationdate >= CURRENT_DATE()
197
        OR    expirationdate IS NULL
196
        OR    expirationdate IS NULL
198
        OR    expirationdate = '00-00-0000'
197
        OR    expirationdate = '00-00-0000'
199
     )
198
     )
200
     AND   `timestamp` < CURRENT_DATE()+1
199
     AND   CAST( opac_news.timestamp AS DATE ) <= CURRENT_DATE()
201
     AND   (lang = '' OR lang = ?)
200
     AND   (lang = '' OR lang = ?)
202
     AND   (branchcode IS NULL OR branchcode = ?)
201
     AND   (branchcode IS NULL OR branchcode = ?)
203
     ORDER BY number
202
     ORDER BY number
204
    }; # expirationdate field is NOT in ISO format?
203
    }; # expirationdate field is NOT in ISO format?
205
       # timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00
204
       # casting timestamp to date truncates HH:mm:ss
206
       #           by adding 1, that captures today correctly.
205
       # changing to <= CURRENT_DATE() today is captured.
207
    my $sth = $dbh->prepare($query);
206
    my $sth = $dbh->prepare($query);
208
    $lang = $lang // q{};
207
    $lang = $lang // q{};
209
    $sth->execute($lang,$branch);
208
    $sth->execute($lang,$branch);
210
    my @results;
209
    my @results;
211
    while ( my $row = $sth->fetchrow_hashref ){
210
    while ( my $row = $sth->fetchrow_hashref ){
211
        # this will type cast and respect system preferences.
212
        $row->{newdate} = format_date($row->{newdate});
212
        $row->{newdate} = format_date($row->{newdate});
213
        push @results, $row;
213
        push @results, $row;
214
    }
214
    }
215
- 

Return to bug 12167