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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt (-9 / +12 lines)
Lines 133-149 Link Here
133
                    [% IF ( total ) %]
133
                    [% IF ( total ) %]
134
                        <h4>[% total %] lines found.</h4>
134
                        <h4>[% total %] lines found.</h4>
135
                        <table>
135
                        <table>
136
                            <tr>
136
                            <thead>
137
                                <th>Date</th>
137
                                <tr>
138
                                <th>Librarian</th>
138
                                    <th>Date</th>
139
                                <th>Module</th>
139
                                    <th>Librarian</th>
140
                                <th>Action</th>
140
                                    <th>Module</th>
141
                                <th>Object</th>
141
                                    <th>Action</th>
142
                                <th>Info</th>
142
                                    <th>Object</th>
143
                            </tr>
143
                                    <th>Info</th>
144
                                </tr>
145
                            </thead>
146
                            <tbody>
144
                            [% FOREACH loopro IN looprow %]
147
                            [% FOREACH loopro IN looprow %]
145
                                [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
148
                                [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
146
                                <tr>
147
                                    <td>[% loopro.timestamp %]</td>
149
                                    <td>[% loopro.timestamp %]</td>
148
                                    <td>
150
                                    <td>
149
                                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopro.user %]" title="display detail for this librarian."> [% IF ( loopro.userfirstname ) || ( loopro.usersurname ) %][% loopro.userfirstname %] [% loopro.usersurname %] ([% loopro.user %]) [% ELSE %][% loopro.user %][% END %]</a>
151
                                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopro.user %]" title="display detail for this librarian."> [% IF ( loopro.userfirstname ) || ( loopro.usersurname ) %][% loopro.userfirstname %] [% loopro.usersurname %] ([% loopro.user %]) [% ELSE %][% loopro.user %][% END %]</a>
Lines 184-189 Link Here
184
                                    </td>
186
                                    </td>
185
                                </tr>
187
                                </tr>
186
                            [% END %]
188
                            [% END %]
189
                            </tbody>
187
                        </table>
190
                        </table>
188
                    [% ELSE %]
191
                    [% ELSE %]
189
                        <div class="dialog alert">
192
                        <div class="dialog alert">
(-)a/tools/viewlog.pl (-102 / +105 lines)
Lines 31-38 use C4::Log; Link Here
31
use C4::Items;
31
use C4::Items;
32
use C4::Branch;
32
use C4::Branch;
33
use C4::Debug;
33
use C4::Debug;
34
# use Data::Dumper;
34
use C4::Search;    # enabled_staff_search_views
35
use C4::Search;		# enabled_staff_search_views
36
35
37
use vars qw($debug $cgi_debug);
36
use vars qw($debug $cgi_debug);
38
37
Lines 42-52 plugin that shows stats Link Here
42
41
43
=cut
42
=cut
44
43
45
my $input    = new CGI;
44
my $input = new CGI;
46
45
47
$debug or $debug = $cgi_debug;
46
$debug or $debug = $cgi_debug;
48
my $do_it    = $input->param('do_it');
47
my $do_it    = $input->param('do_it');
49
my @modules   = $input->param("modules");
48
my @modules  = $input->param("modules");
50
my $user     = $input->param("user");
49
my $user     = $input->param("user");
51
my @action   = $input->param("action");
50
my @action   = $input->param("action");
52
my $object   = $input->param("object");
51
my $object   = $input->param("object");
Lines 54-62 my $info = $input->param("info"); Link Here
54
my $datefrom = $input->param("from");
53
my $datefrom = $input->param("from");
55
my $dateto   = $input->param("to");
54
my $dateto   = $input->param("to");
56
my $basename = $input->param("basename");
55
my $basename = $input->param("basename");
57
#my $del      = $input->param("sep");
58
my $output   = $input->param("output") || "screen";
56
my $output   = $input->param("output") || "screen";
59
my $src      = $input->param("src");    # this param allows us to be told where we were called from -fbcit
57
my $src      = $input->param("src"); # this param allows us to be told where we were called from -fbcit
60
58
61
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
59
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
62
    {
60
    {
Lines 69-87 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
69
    }
67
    }
70
);
68
);
71
69
72
if ($src eq 'circ') {   # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
70
if ( $src eq 'circ' ) {
71
72
    # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
73
    use C4::Members;
73
    use C4::Members;
74
    use C4::Members::Attributes qw(GetBorrowerAttributes);
74
    use C4::Members::Attributes qw(GetBorrowerAttributes);
75
    my $borrowernumber = $object;
75
    my $borrowernumber = $object;
76
    my $data = GetMember('borrowernumber'=>$borrowernumber);
76
    my $data = GetMember( 'borrowernumber' => $borrowernumber );
77
    my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'});
77
    my ( $picture, $dberror ) = GetPatronImage( $data->{'borrowernumber'} );
78
    $template->param( picture => 1 ) if $picture;
78
    $template->param( picture => 1 ) if $picture;
79
79
80
    if (C4::Context->preference('ExtendedPatronAttributes')) {
80
    if ( C4::Context->preference('ExtendedPatronAttributes') ) {
81
        my $attributes = GetBorrowerAttributes($data->{'borrowernumber'});
81
        my $attributes = GetBorrowerAttributes( $data->{'borrowernumber'} );
82
        $template->param(
82
        $template->param(
83
            ExtendedPatronAttributes => 1,
83
            ExtendedPatronAttributes => 1,
84
            extendedattributes => $attributes
84
            extendedattributes       => $attributes
85
        );
85
        );
86
    }
86
    }
87
87
Lines 89-119 if ($src eq 'circ') { # if we were called from circulation, use the circulatio Link Here
89
    my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $data->{streettype} );
89
    my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $data->{streettype} );
90
    my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
90
    my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
91
91
92
    $template->param(   menu            => 1,
92
    $template->param(
93
                        title           => $data->{'title'},
93
        menu           => 1,
94
                        initials        => $data->{'initials'},
94
        title          => $data->{'title'},
95
                        surname         => $data->{'surname'},
95
        initials       => $data->{'initials'},
96
                        othernames      => $data->{'othernames'},
96
        surname        => $data->{'surname'},
97
                        borrowernumber  => $borrowernumber,
97
        othernames     => $data->{'othernames'},
98
                        firstname       => $data->{'firstname'},
98
        borrowernumber => $borrowernumber,
99
                        cardnumber      => $data->{'cardnumber'},
99
        firstname      => $data->{'firstname'},
100
                        categorycode    => $data->{'categorycode'},
100
        cardnumber     => $data->{'cardnumber'},
101
                        category_type   => $data->{'category_type'},
101
        categorycode   => $data->{'categorycode'},
102
                        categoryname	=> $data->{'description'},
102
        category_type  => $data->{'category_type'},
103
                        address         => $address,
103
        categoryname   => $data->{'description'},
104
                        address2        => $data->{'address2'},
104
        address        => $address,
105
                        city            => $data->{'city'},
105
        address2       => $data->{'address2'},
106
                        state           => $data->{'state'},
106
        city           => $data->{'city'},
107
                        zipcode         => $data->{'zipcode'},
107
        state          => $data->{'state'},
108
                        country         => $data->{'country'},
108
        zipcode        => $data->{'zipcode'},
109
                        phone           => $data->{'phone'},
109
        country        => $data->{'country'},
110
                        phonepro        => $data->{'phonepro'},
110
        phone          => $data->{'phone'},
111
                        mobile          => $data->{'mobile'},
111
        phonepro       => $data->{'phonepro'},
112
                        email           => $data->{'email'},
112
        mobile         => $data->{'mobile'},
113
                        emailpro        => $data->{'emailpro'},
113
        email          => $data->{'email'},
114
                        branchcode      => $data->{'branchcode'},
114
        emailpro       => $data->{'emailpro'},
115
                        branchname		=> GetBranchName($data->{'branchcode'}),
115
        branchcode     => $data->{'branchcode'},
116
                        RoutingSerials => C4::Context->preference('RoutingSerials'),
116
        branchname     => GetBranchName( $data->{'branchcode'} ),
117
        RoutingSerials => C4::Context->preference('RoutingSerials'),
117
    );
118
    );
118
}
119
}
119
120
Lines 125-182 $template->param( Link Here
125
if ($do_it) {
126
if ($do_it) {
126
127
127
    my @data;
128
    my @data;
128
    my ($results,$modules,$action);
129
    my ( $results, $modules, $action );
129
    if ($action[0] ne '') { $action = \@action; } # match All means no limit
130
    if ( $action[0]  ne '' ) { $action  = \@action; }     # match All means no limit
130
    if ($modules[0] ne '') { $modules = \@modules; } # match All means no limit
131
    if ( $modules[0] ne '' ) { $modules = \@modules; }    # match All means no limit
131
    $results = GetLogs($datefrom,$dateto,$user,$modules,$action,$object,$info);
132
    $results = GetLogs( $datefrom, $dateto, $user, $modules, $action, $object, $info );
132
    @data=@$results;
133
    @data = @$results;
133
    my $total = scalar @data;
134
    foreach my $result (@data) {
134
    foreach my $result (@data){
135
135
    # Init additional columns for CSV export
136
        # Init additional columns for CSV export
136
    $result->{'biblionumber'} = q{};
137
        $result->{'biblionumber'}      = q{};
137
    $result->{'biblioitemnumber'} = q{};
138
        $result->{'biblioitemnumber'}  = q{};
138
    $result->{'barcode'} = q{};
139
        $result->{'barcode'}           = q{};
139
    $result->{'userfirstname'} = q{};
140
        $result->{'userfirstname'}     = q{};
140
    $result->{'usersurname'} = q{};
141
        $result->{'usersurname'}       = q{};
141
    $result->{'borrowerfirstname'} = q{};
142
        $result->{'borrowerfirstname'} = q{};
142
    $result->{'borrowersurname'} = q{};
143
        $result->{'borrowersurname'}   = q{};
143
144
144
	if (substr($result->{'info'}, 0, 4) eq 'item' || $result->{module} eq "CIRCULATION"){
145
        if ( substr( $result->{'info'}, 0, 4 ) eq 'item' || $result->{module} eq "CIRCULATION" ) {
145
	    # get item information so we can create a working link
146
146
        my $itemnumber=$result->{'object'};
147
            # get item information so we can create a working link
147
        $itemnumber=$result->{'info'} if ($result->{module} eq "CIRCULATION");
148
            my $itemnumber = $result->{'object'};
148
	    my $item=GetItem($itemnumber);
149
            $itemnumber = $result->{'info'} if ( $result->{module} eq "CIRCULATION" );
149
        if ($item) {
150
            my $item = GetItem($itemnumber);
150
            $result->{'biblionumber'}=$item->{'biblionumber'};
151
            if ($item) {
151
            $result->{'biblioitemnumber'}=$item->{'biblionumber'};
152
                $result->{'biblionumber'}     = $item->{'biblionumber'};
152
            $result->{'barcode'}=$item->{'barcode'};
153
                $result->{'biblioitemnumber'} = $item->{'biblionumber'};
154
                $result->{'barcode'}          = $item->{'barcode'};
155
            }
153
        }
156
        }
154
	}
157
155
    #always add firstname and surname for librarian/user
158
        #always add firstname and surname for librarian/user
156
    if ($result->{'user'}){
159
        if ( $result->{'user'} ) {
157
        my $userdetails = C4::Members::GetMemberDetails($result->{'user'});
160
            my $userdetails = C4::Members::GetMemberDetails( $result->{'user'} );
158
        if ($userdetails){
161
            if ($userdetails) {
159
            $result->{'userfirstname'} = $userdetails->{'firstname'};
162
                $result->{'userfirstname'} = $userdetails->{'firstname'};
160
            $result->{'usersurname'} = $userdetails->{'surname'};
163
                $result->{'usersurname'}   = $userdetails->{'surname'};
164
            }
161
        }
165
        }
162
    }
166
163
    #add firstname and surname for borrower, when using the CIRCULATION, MEMBERS, FINES
167
        #add firstname and surname for borrower, when using the CIRCULATION, MEMBERS, FINES
164
    if ($result->{module} eq "CIRCULATION" || $result->{module} eq "MEMBERS" || $result->{module} eq "FINES"){
168
        if ( $result->{module} eq "CIRCULATION" || $result->{module} eq "MEMBERS" || $result->{module} eq "FINES" ) {
165
        if($result->{'object'}){
169
            if ( $result->{'object'} ) {
166
            my $borrowerdetails = C4::Members::GetMemberDetails($result->{'object'});
170
                my $borrowerdetails = C4::Members::GetMemberDetails( $result->{'object'} );
167
            if ($borrowerdetails){
171
                if ($borrowerdetails) {
168
                $result->{'borrowerfirstname'} = $borrowerdetails->{'firstname'};
172
                    $result->{'borrowerfirstname'} = $borrowerdetails->{'firstname'};
169
                $result->{'borrowersurname'} = $borrowerdetails->{'surname'};
173
                    $result->{'borrowersurname'}   = $borrowerdetails->{'surname'};
174
                }
170
            }
175
            }
171
        }
176
        }
172
    }
177
    }
173
    }
178
174
    
175
    if ( $output eq "screen" ) {
179
    if ( $output eq "screen" ) {
180
176
        # Printing results to screen
181
        # Printing results to screen
177
        $template->param (
182
        $template->param(
178
			logview => 1,
183
            logview  => 1,
179
            total    => $total,
184
            total    => scalar @data,
180
            looprow  => \@data,
185
            looprow  => \@data,
181
            do_it    => 1,
186
            do_it    => 1,
182
            datefrom => $datefrom,
187
            datefrom => $datefrom,
Lines 187-235 if ($do_it) { Link Here
187
            info     => $info,
192
            info     => $info,
188
            src      => $src,
193
            src      => $src,
189
        );
194
        );
190
	    #module   => 'fix this', #this seems unused in actual code
195
191
	foreach my $module (@modules) {
196
        # Used modules
192
		$template->param($module  => 1);
197
        foreach my $module (@modules) {
193
	}
198
            $template->param( $module => 1 );
199
        }
194
200
195
        output_html_with_http_headers $input, $cookie, $template->output;
201
        output_html_with_http_headers $input, $cookie, $template->output;
196
    } else {
202
    }
203
    else {
204
197
        # Printing to a csv file
205
        # Printing to a csv file
198
        my $content = q{};
206
        my $content = q{};
199
        my $delimiter = C4::Context->preference('delimiter') || ',';
207
        my $delimiter = C4::Context->preference('delimiter') || ',';
200
        if (@data) {
208
        if (@data) {
201
            my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter } );
209
            my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter } );
202
            $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag();
210
            $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag();
211
203
            # First line with heading
212
            # First line with heading
204
            # Exporting bd id seems useless
213
            # Exporting bd id seems useless
205
            my @headings = grep { $_ ne 'action_id' } sort keys $data[0];
214
            my @headings = grep { $_ ne 'action_id' } sort keys $data[0];
206
            if ( $csv->combine( @headings ) ) {
215
            if ( $csv->combine(@headings) ) {
207
                $content .= $csv->string() . "\n";
216
                $content .= $csv->string() . "\n";
208
            }
217
            }
218
209
            # Lines of logs
219
            # Lines of logs
210
            foreach my $line (@data) {
220
            foreach my $line (@data) {
211
                my @cells = map { $line->{$_} } @headings;
221
                my @cells = map { $line->{$_} } @headings;
212
                if ( $csv->combine( @cells ) ) {
222
                if ( $csv->combine(@cells) ) {
213
                    $content .= $csv->string() . "\n";
223
                    $content .= $csv->string() . "\n";
214
                }
224
                }
215
            }
225
            }
216
        }
226
        }
227
228
        # Output
217
        print $input->header(
229
        print $input->header(
218
            -type       => 'text/csv',
230
            -type       => 'text/csv',
219
            -attachment => $basename . '.csv',
231
            -attachment => $basename . '.csv',
220
        );
232
        );
221
        print $content;
233
        print $content;
222
    }
234
    }
223
	exit;
235
    exit;
224
} else {
236
}
225
    #my @values;
237
else {
226
    #my %labels;
238
    output_html_with_http_headers $input, $cookie, $template->output;
227
    #my %select;
228
	#initialize some paramaters that might not be used in the template - it seems to evaluate EXPR even if a false TMPL_IF
229
	$template->param(
230
        	total => 0,
231
		module => "",
232
		info => ""
233
	);
234
	output_html_with_http_headers $input, $cookie, $template->output;
235
}
239
}
236
- 

Return to bug 11331