Lines 125-139
sub get_opac_new {
Link Here
|
125 |
my ($idnew) = @_; |
125 |
my ($idnew) = @_; |
126 |
my $dbh = C4::Context->dbh; |
126 |
my $dbh = C4::Context->dbh; |
127 |
my $query = q{ |
127 |
my $query = q{ |
128 |
SELECT opac_news.*,branches.branchname |
128 |
SELECT opac_news.*,branches.branchname, |
|
|
129 |
timestamp AS newdate, |
130 |
borrowers.title AS author_title, |
131 |
borrowers.firstname AS author_firstname, |
132 |
borrowers.surname AS author_surname |
129 |
FROM opac_news LEFT JOIN branches |
133 |
FROM opac_news LEFT JOIN branches |
130 |
ON opac_news.branchcode=branches.branchcode |
134 |
ON opac_news.branchcode=branches.branchcode |
|
|
135 |
LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber |
131 |
WHERE opac_news.idnew = ?; |
136 |
WHERE opac_news.idnew = ?; |
132 |
}; |
137 |
}; |
133 |
my $sth = $dbh->prepare($query); |
138 |
my $sth = $dbh->prepare($query); |
134 |
$sth->execute($idnew); |
139 |
$sth->execute($idnew); |
135 |
my $data = $sth->fetchrow_hashref; |
140 |
my $data = $sth->fetchrow_hashref; |
136 |
$data->{$data->{'lang'}} = 1 if defined $data->{lang}; |
141 |
$data->{$data->{'lang'}} = 1 if defined $data->{lang}; |
|
|
142 |
$data->{newdate} = output_pref({ dt => dt_from_string( $data->{newdate} ), dateonly => 1 }); |
137 |
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }); |
143 |
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }); |
138 |
$data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ; |
144 |
$data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ; |
139 |
return $data; |
145 |
return $data; |
Lines 189-209
sub get_opac_news {
Link Here
|
189 |
=cut |
195 |
=cut |
190 |
|
196 |
|
191 |
sub GetNewsToDisplay { |
197 |
sub GetNewsToDisplay { |
192 |
my ($lang,$branch) = @_; |
198 |
my ($lang,$branch,$time,$id) = @_; |
193 |
my $dbh = C4::Context->dbh; |
199 |
my $dbh = C4::Context->dbh; |
194 |
# SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate |
200 |
# SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate |
|
|
201 |
my @values; |
195 |
my $query = q{ |
202 |
my $query = q{ |
196 |
SELECT opac_news.*,timestamp AS newdate, |
203 |
SELECT opac_news.*,timestamp AS newdate, |
197 |
borrowers.title AS author_title, |
204 |
borrowers.title AS author_title, |
198 |
borrowers.firstname AS author_firstname, |
205 |
borrowers.firstname AS author_firstname, |
199 |
borrowers.surname AS author_surname |
206 |
borrowers.surname AS author_surname |
200 |
FROM opac_news |
207 |
FROM opac_news |
201 |
LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber |
208 |
LEFT JOIN borrowers on borrowers.borrowernumber = |
202 |
WHERE ( |
209 |
opac_news.borrowernumber |
203 |
expirationdate >= CURRENT_DATE() |
210 |
WHERE (}; |
204 |
OR expirationdate IS NULL |
211 |
|
205 |
OR expirationdate = '00-00-0000' |
212 |
if ( defined $id ) { |
206 |
) |
213 |
$query .= q{ opac_news.idnew = ? } if defined $id; |
|
|
214 |
push( @values, $id ); |
215 |
} |
216 |
|
217 |
unless ( defined $time ) { |
218 |
$query .= q{ AND } if defined $id; |
219 |
$query .= q{ |
220 |
expirationdate >= CURRENT_DATE() |
221 |
OR expirationdate IS NULL |
222 |
OR expirationdate = '00-00-0000' |
223 |
} unless( defined $time and $time eq 'all' ); |
224 |
} |
225 |
|
226 |
$query .= q{ ) |
207 |
AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) |
227 |
AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) |
208 |
AND (lang = '' OR lang = ?) |
228 |
AND (lang = '' OR lang = ?) |
209 |
AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) |
229 |
AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) |
Lines 213-219
sub GetNewsToDisplay {
Link Here
|
213 |
# by adding 1, that captures today correctly. |
233 |
# by adding 1, that captures today correctly. |
214 |
my $sth = $dbh->prepare($query); |
234 |
my $sth = $dbh->prepare($query); |
215 |
$lang = $lang // q{}; |
235 |
$lang = $lang // q{}; |
216 |
$sth->execute($lang,$branch); |
236 |
push( @values, $lang ); |
|
|
237 |
push( @values, $branch ); |
238 |
$sth->execute(@values); |
217 |
my @results; |
239 |
my @results; |
218 |
while ( my $row = $sth->fetchrow_hashref ){ |
240 |
while ( my $row = $sth->fetchrow_hashref ){ |
219 |
$row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 }); |
241 |
$row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 }); |
220 |
- |
|
|