|
Lines 24-34
use CGI;
Link Here
|
| 24 |
use C4::Auth; |
24 |
use C4::Auth; |
| 25 |
use C4::Context; |
25 |
use C4::Context; |
| 26 |
use C4::Debug; |
26 |
use C4::Debug; |
| 27 |
use C4::Branch; # GetBranches |
27 |
use C4::Branch; # GetBranchesLoop |
| 28 |
use C4::Output; |
28 |
use C4::Output; |
| 29 |
use C4::Koha; # GetItemTypes |
29 |
use C4::Koha; # GetItemTypes |
| 30 |
use C4::Reports; # GetDelimiterChoices |
|
|
| 31 |
use C4::Circulation; |
| 32 |
# use Date::Manip; # TODO: add not borrowed since date X criteria |
30 |
# use Date::Manip; # TODO: add not borrowed since date X criteria |
| 33 |
use Data::Dumper; |
31 |
use Data::Dumper; |
| 34 |
|
32 |
|
|
Lines 43-50
my $do_it = $input->param('do_it');
Link Here
|
| 43 |
my $limit = $input->param("Limit"); |
41 |
my $limit = $input->param("Limit"); |
| 44 |
my $column = $input->param("Criteria"); |
42 |
my $column = $input->param("Criteria"); |
| 45 |
my @filters = $input->param("Filter"); |
43 |
my @filters = $input->param("Filter"); |
| 46 |
my $output = $input->param("output"); |
44 |
|
| 47 |
my $basename = $input->param("basename") || 'catalogue_out'; |
|
|
| 48 |
my ($template, $borrowernumber, $cookie) = get_template_and_user({ |
45 |
my ($template, $borrowernumber, $cookie) = get_template_and_user({ |
| 49 |
template_name => "reports/catalogue_out.tmpl", |
46 |
template_name => "reports/catalogue_out.tmpl", |
| 50 |
query => $input, |
47 |
query => $input, |
|
Lines 54-110
my ($template, $borrowernumber, $cookie) = get_template_and_user({
Link Here
|
| 54 |
debug => 1, |
51 |
debug => 1, |
| 55 |
}); |
52 |
}); |
| 56 |
|
53 |
|
| 57 |
our $sep = $input->param("sep"); |
|
|
| 58 |
$sep = "\t" if ((! defined $sep) or $sep eq 'tabulation'); |
| 59 |
|
| 60 |
$template->param(do_it => $do_it); |
54 |
$template->param(do_it => $do_it); |
| 61 |
if ($do_it) { |
55 |
if ($do_it) { |
| 62 |
my $results = calculate($limit, $column, \@filters); |
56 |
my $results = calculate($limit, $column, \@filters); |
| 63 |
if ($output eq "screen") { |
57 |
$template->param(mainloop => $results); |
| 64 |
# Printing results to screen |
58 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 65 |
$template->param(mainloop => $results); |
|
|
| 66 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 67 |
} else { |
| 68 |
# Printing to a csv file FIXME: This is broken rather badly, if it ever worked at all here. |
| 69 |
print $input->header( |
| 70 |
-type => 'application/vnd.sun.xml.calc', |
| 71 |
-encoding => 'utf-8', |
| 72 |
-attachment=>"$basename.csv", |
| 73 |
-filename =>"$basename.csv" ); |
| 74 |
my $cols = @$results[0]->{loopcol}; |
| 75 |
my $lines = @$results[0]->{looprow}; |
| 76 |
# header |
| 77 |
print "num /". @$results[0]->{column} .$sep; |
| 78 |
# Other header |
| 79 |
foreach my $col ( @$cols ) { |
| 80 |
print $col->{coltitle}.$sep; |
| 81 |
} |
| 82 |
print "Total\n"; |
| 83 |
# Table |
| 84 |
foreach my $line ( @$lines ) { |
| 85 |
my $x = $line->{loopcell}; # FIXME: No Such thing. |
| 86 |
print $line->{rowtitle}.$sep; |
| 87 |
foreach my $cell (@$x) { |
| 88 |
print $cell->{value}.$sep; |
| 89 |
} |
| 90 |
print $line->{totalrow}, "\n"; |
| 91 |
} |
| 92 |
# footer |
| 93 |
print "TOTAL"; |
| 94 |
foreach my $col ( @$cols ) { |
| 95 |
print $sep.$col->{totalcol}; |
| 96 |
} |
| 97 |
print $sep.@$results[0]->{total}; |
| 98 |
} |
| 99 |
exit; # in either case, exit after do_it |
59 |
exit; # in either case, exit after do_it |
| 100 |
} |
60 |
} |
| 101 |
|
61 |
|
| 102 |
# Displaying choices (i.e., not do_it) |
62 |
# Displaying choices (i.e., not do_it) |
| 103 |
my @values; |
|
|
| 104 |
my %select; |
| 105 |
|
63 |
|
| 106 |
my @mime = ( map { +{type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation |
64 |
my $itemtypes = GetItemTypes(); |
| 107 |
my $itemtypes = GetItemTypes; |
|
|
| 108 |
my @itemtypeloop; |
65 |
my @itemtypeloop; |
| 109 |
foreach (sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys %$itemtypes) { |
66 |
foreach (sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys %$itemtypes) { |
| 110 |
push @itemtypeloop, { |
67 |
push @itemtypeloop, { |
|
Lines 114-121
foreach (sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{descriptio
Link Here
|
| 114 |
} |
71 |
} |
| 115 |
|
72 |
|
| 116 |
$template->param( |
73 |
$template->param( |
| 117 |
CGIextChoice => \@mime, |
|
|
| 118 |
CGIsepChoice => GetDelimiterChoices, |
| 119 |
itemtypeloop => \@itemtypeloop, |
74 |
itemtypeloop => \@itemtypeloop, |
| 120 |
branchloop => GetBranchesLoop($input->param("branch") || C4::Context->userenv->{branch}), |
75 |
branchloop => GetBranchesLoop($input->param("branch") || C4::Context->userenv->{branch}), |
| 121 |
); |
76 |
); |
| 122 |
- |
|
|