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

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

Return to bug 15632