Lines 215-229
sub GetLogs {
Link Here
|
215 |
my $datefrom = shift; |
215 |
my $datefrom = shift; |
216 |
my $dateto = shift; |
216 |
my $dateto = shift; |
217 |
my $user = shift; |
217 |
my $user = shift; |
218 |
my $modules = shift; |
218 |
my $modules = shift; |
219 |
my $action = shift; |
219 |
my $action = shift; |
220 |
my $object = shift; |
220 |
my $object = shift; |
221 |
my $info = shift; |
221 |
my $info = shift; |
222 |
|
222 |
|
223 |
my $iso_datefrom = $datefrom ? output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 }) : undef; |
223 |
my $iso_datefrom = $datefrom ? output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 }) : undef; |
224 |
my $iso_dateto = $dateto ? output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 }) : undef; |
224 |
my $iso_dateto = $dateto ? output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 }) : undef; |
225 |
|
225 |
|
226 |
my $dbh = C4::Context->dbh; |
226 |
$user ||= q{}; |
|
|
227 |
|
228 |
my $dbh = C4::Context->dbh; |
227 |
my $query = " |
229 |
my $query = " |
228 |
SELECT * |
230 |
SELECT * |
229 |
FROM action_logs |
231 |
FROM action_logs |
Lines 231-265
sub GetLogs {
Link Here
|
231 |
"; |
233 |
"; |
232 |
|
234 |
|
233 |
my @parameters; |
235 |
my @parameters; |
234 |
$query .= " AND DATE_FORMAT(timestamp, '%Y-%m-%d') >= \"".$iso_datefrom."\" " if $iso_datefrom; #fix me - mysql specific |
236 |
$query .= |
235 |
$query .= " AND DATE_FORMAT(timestamp, '%Y-%m-%d') <= \"".$iso_dateto."\" " if $iso_dateto; |
237 |
" AND DATE_FORMAT(timestamp, '%Y-%m-%d') >= \"" . $iso_datefrom . "\" " |
236 |
if($user ne "") { |
238 |
if $iso_datefrom; #fix me - mysql specific |
237 |
$query .= " AND user = ? "; |
239 |
$query .= |
238 |
push(@parameters,$user); |
240 |
" AND DATE_FORMAT(timestamp, '%Y-%m-%d') <= \"" . $iso_dateto . "\" " |
|
|
241 |
if $iso_dateto; |
242 |
if ( $user ne q{} ) { |
243 |
$query .= " AND user = ? "; |
244 |
push( @parameters, $user ); |
239 |
} |
245 |
} |
240 |
if($modules && scalar(@$modules)) { |
246 |
if ( $modules && scalar(@$modules) ) { |
241 |
$query .= " AND module IN (".join(",",map {"?"} @$modules).") "; |
247 |
$query .= |
242 |
push(@parameters,@$modules); |
248 |
" AND module IN (" . join( ",", map { "?" } @$modules ) . ") "; |
|
|
249 |
push( @parameters, @$modules ); |
243 |
} |
250 |
} |
244 |
if($action && scalar(@$action)) { |
251 |
if ( $action && scalar(@$action) ) { |
245 |
$query .= " AND action IN (".join(",",map {"?"} @$action).") "; |
252 |
$query .= " AND action IN (" . join( ",", map { "?" } @$action ) . ") "; |
246 |
push(@parameters,@$action); |
253 |
push( @parameters, @$action ); |
247 |
} |
254 |
} |
248 |
if($object) { |
255 |
if ($object) { |
249 |
$query .= " AND object = ? "; |
256 |
$query .= " AND object = ? "; |
250 |
push(@parameters,$object); |
257 |
push( @parameters, $object ); |
251 |
} |
258 |
} |
252 |
if($info) { |
259 |
if ($info) { |
253 |
$query .= " AND info LIKE ? "; |
260 |
$query .= " AND info LIKE ? "; |
254 |
push(@parameters,"%".$info."%"); |
261 |
push( @parameters, "%" . $info . "%" ); |
255 |
} |
262 |
} |
256 |
|
263 |
|
257 |
my $sth = $dbh->prepare($query); |
264 |
my $sth = $dbh->prepare($query); |
258 |
$sth->execute(@parameters); |
265 |
$sth->execute(@parameters); |
259 |
|
266 |
|
260 |
my @logs; |
267 |
my @logs; |
261 |
while( my $row = $sth->fetchrow_hashref ) { |
268 |
while ( my $row = $sth->fetchrow_hashref ) { |
262 |
push @logs , $row; |
269 |
push @logs, $row; |
263 |
} |
270 |
} |
264 |
return \@logs; |
271 |
return \@logs; |
265 |
} |
272 |
} |
266 |
- |
|
|