- my ($results,$modules,$action);
- if ($action[0] ne '') { $action = \@action; } # match All means no limit
- if ($modules[0] ne '') { $modules = \@modules; } # match All means no limit
- $results = GetLogs($datefrom,$dateto,$user,$modules,$action,$object,$info);
- @data=@$results;
- my $total = scalar @data;
- foreach my $result (@data){
- if ($result->{'info'} eq 'item'||$result->{module} eq "CIRCULATION"){
- # get item information so we can create a working link
- my $itemnumber=$result->{'object'};
- $itemnumber=$result->{'info'} if ($result->{module} eq "CIRCULATION");
- my $item=GetItem($itemnumber);
- $result->{'biblionumber'}=$item->{'biblionumber'};
- $result->{'biblioitemnumber'}=$item->{'biblionumber'};
- $result->{'barcode'}=$item->{'barcode'};
- }
+ my ( $results, $modules, $actions, $interfaces );
+ if ( defined $actions[0] && $actions[0] ne '' ) { $actions = \@actions; } # match All means no limit
+ if ( $modules[0] ne '' ) { $modules = \@modules; } # match All means no limit
+ if ( defined $interfaces[0] && $interfaces[0] ne '' ) { $interfaces = \@interfaces; } # match All means no limit
+ $results = GetLogs( $datefrom, $dateto, $user, $modules, $actions, $object, $info, $interfaces );
+ @data = @$results;
+ foreach my $result (@data) {
+
+ # Init additional columns for CSV export
+ $result->{'biblionumber'} = q{};
+ $result->{'biblioitemnumber'} = q{};
+ $result->{'barcode'} = q{};
+ $result->{'userfirstname'} = q{};
+ $result->{'usersurname'} = q{};
+ $result->{'borrowerfirstname'} = q{};
+ $result->{'borrowersurname'} = q{};
+
+ if ( substr( $result->{'info'}, 0, 4 ) eq 'item' || $result->{module} eq "CIRCULATION" ) {
+
+ # get item information so we can create a working link
+ my $itemnumber = $result->{'object'};
+ $itemnumber = $result->{'info'} if ( $result->{module} eq "CIRCULATION" );
+ my $item = GetItem($itemnumber);
+ if ($item) {
+ $result->{'biblionumber'} = $item->{'biblionumber'};
+ $result->{'biblioitemnumber'} = $item->{'biblionumber'};
+ $result->{'barcode'} = $item->{'barcode'};
+ }
+ }
+
+ #always add firstname and surname for librarian/user
+ if ( $result->{'user'} ) {
+ my $userdetails = C4::Members::GetMemberDetails( $result->{'user'} );
+ if ($userdetails) {
+ $result->{'userfirstname'} = $userdetails->{'firstname'};
+ $result->{'usersurname'} = $userdetails->{'surname'};
+ }
+ }
+
+ #add firstname and surname for borrower, when using the CIRCULATION, MEMBERS, FINES
+ if ( $result->{module} eq "CIRCULATION" || $result->{module} eq "MEMBERS" || $result->{module} eq "FINES" ) {
+ if ( $result->{'object'} ) {
+ my $borrowerdetails = C4::Members::GetMemberDetails( $result->{'object'} );
+ if ($borrowerdetails) {
+ $result->{'borrowerfirstname'} = $borrowerdetails->{'firstname'};
+ $result->{'borrowersurname'} = $borrowerdetails->{'surname'};
+ }
+ }
+ }