|
Lines 135-141
sub get_opac_new {
Link Here
|
| 135 |
my $data = $sth->fetchrow_hashref; |
135 |
my $data = $sth->fetchrow_hashref; |
| 136 |
$data->{$data->{'lang'}} = 1 if defined $data->{lang}; |
136 |
$data->{$data->{'lang'}} = 1 if defined $data->{lang}; |
| 137 |
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }) if ( $data->{expirationdate} ); |
137 |
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }) if ( $data->{expirationdate} ); |
| 138 |
$data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ; |
138 |
$data->{publicationdate} = output_pref({ dt => dt_from_string( $data->{publicationdate} ), dateonly => 1 }); |
| 139 |
return $data; |
139 |
return $data; |
| 140 |
} |
140 |
} |
| 141 |
|
141 |
|
|
Lines 145-151
sub get_opac_news {
Link Here
|
| 145 |
my $dbh = C4::Context->dbh; |
145 |
my $dbh = C4::Context->dbh; |
| 146 |
my $query = q{ |
146 |
my $query = q{ |
| 147 |
SELECT opac_news.*, branches.branchname, |
147 |
SELECT opac_news.*, branches.branchname, |
| 148 |
timestamp AS newdate, |
148 |
publicationdate AS newdate, |
| 149 |
borrowers.title AS author_title, |
149 |
borrowers.title AS author_title, |
| 150 |
borrowers.firstname AS author_firstname, |
150 |
borrowers.firstname AS author_firstname, |
| 151 |
borrowers.surname AS author_surname |
151 |
borrowers.surname AS author_surname |
|
Lines 162-168
sub get_opac_news {
Link Here
|
| 162 |
$query .= ' AND (opac_news.branchcode IS NULL OR opac_news.branchcode=?)'; |
162 |
$query .= ' AND (opac_news.branchcode IS NULL OR opac_news.branchcode=?)'; |
| 163 |
push @values,$branchcode; |
163 |
push @values,$branchcode; |
| 164 |
} |
164 |
} |
| 165 |
$query.= ' ORDER BY timestamp DESC '; |
165 |
$query.= ' ORDER BY publicationdate DESC '; |
| 166 |
#if ($limit) { |
166 |
#if ($limit) { |
| 167 |
# $query.= 'LIMIT 0, ' . $limit; |
167 |
# $query.= 'LIMIT 0, ' . $limit; |
| 168 |
#} |
168 |
#} |
|
Lines 191-199
sub get_opac_news {
Link Here
|
| 191 |
sub GetNewsToDisplay { |
191 |
sub GetNewsToDisplay { |
| 192 |
my ($lang,$branch) = @_; |
192 |
my ($lang,$branch) = @_; |
| 193 |
my $dbh = C4::Context->dbh; |
193 |
my $dbh = C4::Context->dbh; |
| 194 |
# SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate |
|
|
| 195 |
my $query = q{ |
194 |
my $query = q{ |
| 196 |
SELECT opac_news.*,timestamp AS newdate, |
195 |
SELECT opac_news.*,publicationdate AS newdate, |
| 197 |
borrowers.title AS author_title, |
196 |
borrowers.title AS author_title, |
| 198 |
borrowers.firstname AS author_firstname, |
197 |
borrowers.firstname AS author_firstname, |
| 199 |
borrowers.surname AS author_surname |
198 |
borrowers.surname AS author_surname |
|
Lines 203-215
sub GetNewsToDisplay {
Link Here
|
| 203 |
expirationdate >= CURRENT_DATE() |
202 |
expirationdate >= CURRENT_DATE() |
| 204 |
OR expirationdate IS NULL |
203 |
OR expirationdate IS NULL |
| 205 |
) |
204 |
) |
| 206 |
AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) |
205 |
AND publicationdate <= CURDATE() |
| 207 |
AND (opac_news.lang = '' OR opac_news.lang = ?) |
206 |
AND (opac_news.lang = '' OR opac_news.lang = ?) |
| 208 |
AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) |
207 |
AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) |
| 209 |
ORDER BY number |
208 |
ORDER BY number |
| 210 |
}; # expirationdate field is NOT in ISO format? |
209 |
}; |
| 211 |
# timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00 |
|
|
| 212 |
# by adding 1, that captures today correctly. |
| 213 |
my $sth = $dbh->prepare($query); |
210 |
my $sth = $dbh->prepare($query); |
| 214 |
$lang = $lang // q{}; |
211 |
$lang = $lang // q{}; |
| 215 |
$sth->execute($lang,$branch); |
212 |
$sth->execute($lang,$branch); |