Lines 26-37
use Text::CSV::Encoded;
Link Here
|
26 |
use C4::Context; |
26 |
use C4::Context; |
27 |
use C4::Koha; |
27 |
use C4::Koha; |
28 |
use C4::Output; |
28 |
use C4::Output; |
29 |
use C4::Log; |
|
|
30 |
use C4::Items; |
29 |
use C4::Items; |
31 |
use C4::Serials; |
30 |
use C4::Serials; |
32 |
use C4::Debug; |
31 |
use C4::Debug; |
33 |
use C4::Search; # enabled_staff_search_views |
32 |
use C4::Search; # enabled_staff_search_views |
34 |
|
33 |
|
|
|
34 |
use Koha::ActionLogs; |
35 |
use Koha::Database; |
36 |
use Koha::DateUtils; |
35 |
use Koha::Items; |
37 |
use Koha::Items; |
36 |
use Koha::Patrons; |
38 |
use Koha::Patrons; |
37 |
|
39 |
|
Lines 102-127
$template->param(
Link Here
|
102 |
); |
104 |
); |
103 |
|
105 |
|
104 |
if ($do_it) { |
106 |
if ($do_it) { |
|
|
107 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
108 |
my %search_params; |
109 |
|
110 |
if ($datefrom and $dateto ) { |
111 |
my $dateto_endday = dt_from_string($dateto); |
112 |
$dateto_endday->set( # We set last second of day to see all log from that day |
113 |
hour => 23, |
114 |
minute => 59, |
115 |
second => 59 |
116 |
); |
117 |
$search_params{'timestamp'} = { |
118 |
-between => [ |
119 |
$dtf->format_datetime( dt_from_string($datefrom) ), |
120 |
$dtf->format_datetime( $dateto_endday ), |
121 |
] |
122 |
}; |
123 |
} elsif ($datefrom) { |
124 |
$search_params{'timestamp'} = { |
125 |
'>=' => $dtf->format_datetime( dt_from_string($datefrom) ) |
126 |
}; |
127 |
} elsif ($dateto) { |
128 |
my $dateto_endday = dt_from_string($dateto); |
129 |
$dateto_endday->set( # We set last second of day to see all log from that day |
130 |
hour => 23, |
131 |
minute => 59, |
132 |
second => 59 |
133 |
); |
134 |
$search_params{'timestamp'} = { |
135 |
'<=' => $dtf->format_datetime( $dateto_endday ) |
136 |
}; |
137 |
} |
138 |
$search_params{user} = $user if $user; |
139 |
$search_params{module} = { -in => [ @modules ] } if ( defined $modules[0] and $modules[0] ne '' ) ; |
140 |
$search_params{action} = { -in => [ @actions ] } if ( defined $actions[0] && $actions[0] ne '' ); |
141 |
$search_params{object} = $object if $object; |
142 |
$search_params{info} = $info if $info; |
143 |
$search_params{interface} = { -in => [ @interfaces ] } if ( defined $interfaces[0] && $interfaces[0] ne '' ); |
105 |
|
144 |
|
106 |
my @data; |
145 |
my @logs = Koha::ActionLogs->search(\%search_params); |
107 |
my ( $results, $modules, $actions, $interfaces ); |
|
|
108 |
if ( defined $actions[0] && $actions[0] ne '' ) { $actions = \@actions; } # match All means no limit |
109 |
if ( $modules[0] ne '' ) { $modules = \@modules; } # match All means no limit |
110 |
if ( defined $interfaces[0] && $interfaces[0] ne '' ) { $interfaces = \@interfaces; } # match All means no limit |
111 |
$results = GetLogs( $datefrom, $dateto, $user, $modules, $actions, $object, $info, $interfaces ); |
112 |
@data = @$results; |
113 |
foreach my $result (@data) { |
114 |
|
146 |
|
|
|
147 |
my @data; |
148 |
foreach my $log (@logs) { |
149 |
my $result = $log->unblessed; |
115 |
# Init additional columns for CSV export |
150 |
# Init additional columns for CSV export |
116 |
$result->{'biblionumber'} = q{}; |
151 |
$result->{'biblionumber'} = q{}; |
117 |
$result->{'biblioitemnumber'} = q{}; |
152 |
$result->{'biblioitemnumber'} = q{}; |
118 |
$result->{'barcode'} = q{}; |
153 |
$result->{'barcode'} = q{}; |
119 |
|
154 |
|
120 |
if ( substr( $result->{'info'}, 0, 4 ) eq 'item' || $result->{module} eq "CIRCULATION" ) { |
155 |
if ( substr( $log->info, 0, 4 ) eq 'item' || $log->module eq "CIRCULATION" ) { |
121 |
|
156 |
|
122 |
# get item information so we can create a working link |
157 |
# get item information so we can create a working link |
123 |
my $itemnumber = $result->{'object'}; |
158 |
my $itemnumber = $log->object; |
124 |
$itemnumber = $result->{'info'} if ( $result->{module} eq "CIRCULATION" ); |
159 |
$itemnumber = $log->info if ( $log->module eq "CIRCULATION" ); |
125 |
my $item = Koha::Items->find($itemnumber); |
160 |
my $item = Koha::Items->find($itemnumber); |
126 |
if ($item) { |
161 |
if ($item) { |
127 |
$result->{'biblionumber'} = $item->biblionumber; |
162 |
$result->{'biblionumber'} = $item->biblionumber; |
Lines 131-154
if ($do_it) {
Link Here
|
131 |
} |
166 |
} |
132 |
|
167 |
|
133 |
#always add firstname and surname for librarian/user |
168 |
#always add firstname and surname for librarian/user |
134 |
if ( $result->{'user'} ) { |
169 |
if ( $log->user ) { |
135 |
my $patron = Koha::Patrons->find( $result->{'user'} ); |
170 |
my $patron = Koha::Patrons->find( $log->user ); |
136 |
if ($patron) { |
171 |
if ($patron) { |
137 |
$result->{librarian} = $patron; |
172 |
$result->{librarian} = $patron; |
138 |
} |
173 |
} |
139 |
} |
174 |
} |
140 |
|
175 |
|
141 |
#add firstname and surname for borrower, when using the CIRCULATION, MEMBERS, FINES |
176 |
#add firstname and surname for borrower, when using the CIRCULATION, MEMBERS, FINES |
142 |
if ( $result->{module} eq "CIRCULATION" || $result->{module} eq "MEMBERS" || $result->{module} eq "FINES" ) { |
177 |
if ( $log->module eq "CIRCULATION" || $log->module eq "MEMBERS" || $log->module eq "FINES" ) { |
143 |
if ( $result->{'object'} ) { |
178 |
if ( $log->object ) { |
144 |
my $patron = Koha::Patrons->find( $result->{'object'} ); |
179 |
my $patron = Koha::Patrons->find( $log->object ); |
145 |
if ($patron) { |
180 |
if ($patron) { |
146 |
$result->{patron} = $patron; |
181 |
$result->{patron} = $patron; |
147 |
} |
182 |
} |
148 |
} |
183 |
} |
149 |
} |
184 |
} |
|
|
185 |
push @data, $result; |
150 |
} |
186 |
} |
151 |
|
|
|
152 |
if ( $output eq "screen" ) { |
187 |
if ( $output eq "screen" ) { |
153 |
|
188 |
|
154 |
# Printing results to screen |
189 |
# Printing results to screen |
Lines 171-177
if ($do_it) {
Link Here
|
171 |
foreach my $module (@modules) { |
206 |
foreach my $module (@modules) { |
172 |
$template->param( $module => 1 ); |
207 |
$template->param( $module => 1 ); |
173 |
} |
208 |
} |
174 |
|
|
|
175 |
output_html_with_http_headers $input, $cookie, $template->output; |
209 |
output_html_with_http_headers $input, $cookie, $template->output; |
176 |
} |
210 |
} |
177 |
else { |
211 |
else { |
178 |
- |
|
|