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

(-)a/Koha/Illrequest/Logger.pm (-36 / +11 lines)
Lines 24-30 use Time::Local; Link Here
24
use C4::Koha;
24
use C4::Koha;
25
use C4::Context;
25
use C4::Context;
26
use C4::Templates;
26
use C4::Templates;
27
use C4::Log qw( logaction GetLogs );
27
use C4::Log qw( logaction );
28
use Koha::ActionLogs;
28
29
29
=head1 NAME
30
=head1 NAME
30
31
Lines 198-223 sub get_log_template { Link Here
198
    }
199
    }
199
}
200
}
200
201
201
=head3 get_epoch
202
203
    $epoch = Koha::Illrequest::Logger->get_epoch($timestamp);
204
205
Given a timestamp string returned from GetLogs, get the epoch
206
207
=cut
208
209
sub get_epoch {
210
    my $timestamp = shift;
211
212
    return if !$timestamp=~/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}/;
213
214
    my ($date, $time) = split(/\s/, $timestamp);
215
    my ($y, $mon, $d) = split(/-/, $date);
216
    my ($h, $min, $s) = split(/:/, $time);
217
218
    return timelocal($s, $min, $h, $d, $mon-1, $y);
219
}
220
221
=head3 get_request_logs
202
=head3 get_request_logs
222
203
223
    $requestlogs = Koha::IllRequest::Logger->get_request_logs($request_id);
204
    $requestlogs = Koha::IllRequest::Logger->get_request_logs($request_id);
Lines 229-244 Get all logged actions for a given request Link Here
229
sub get_request_logs {
210
sub get_request_logs {
230
    my ( $self, $request ) = @_;
211
    my ( $self, $request ) = @_;
231
212
232
    my $logs = GetLogs(
213
    my $logs = Koha::ActionLogs->search(
233
        undef,
214
        {
234
        undef,
215
            module => 'ILL',
235
        undef,
216
            object => $request->id
236
        ['ILL'],
217
        },
237
        undef,
218
        { order_by => { -desc => "timestamp" } }
238
        $request->id,
219
    )->unblessed;
239
        undef,
220
240
        undef
241
    );
242
    # Populate a lookup table for status aliases
221
    # Populate a lookup table for status aliases
243
    my $aliases = GetAuthorisedValues('ILLSTATUS');
222
    my $aliases = GetAuthorisedValues('ILLSTATUS');
244
    my $alias_hash;
223
    my $alias_hash;
Lines 257-266 sub get_request_logs { Link Here
257
        );
236
        );
258
    }
237
    }
259
238
260
    my $format = '%Y-%m-%d %H:%M:%S';
239
    return $logs;
261
    my @sorted = sort { get_epoch($$b{'timestamp'}) <=> get_epoch($$a{'timestamp'}) } @{$logs};
262
263
    return \@sorted;
264
}
240
}
265
241
266
=head1 AUTHOR
242
=head1 AUTHOR
267
- 

Return to bug 20750