line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::OptimalQuery::PrinterFriendly; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1135
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
4
|
no warnings qw( uninitialized ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'CGI::OptimalQuery::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
7
|
1
|
|
|
1
|
|
5
|
use POSIX qw( strftime ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub output { |
10
|
0
|
|
|
0
|
0
|
|
my $o = shift; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $buf; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $fn = $o->{schema}->{title}; |
15
|
0
|
|
|
|
|
|
{ my @t = localtime; |
|
0
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
$fn .= '_'.($t[5] + 1900).($t[4] + 1).$t[3].'.html'; |
17
|
0
|
|
|
|
|
|
$fn =~ s/\s+/\_/g; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $title = ($o->{schema}->{title}); |
21
|
0
|
0
|
|
|
|
|
if ($$o{queryDescr}) { |
22
|
0
|
|
|
|
|
|
$title .= " - $$o{queryDescr}"; |
23
|
|
|
|
|
|
|
} |
24
|
0
|
|
|
|
|
|
my $v = $o->escape_html($o->get_filter()); |
25
|
0
|
0
|
|
|
|
|
if ($v) { |
26
|
0
|
|
|
|
|
|
$title .= " - $v"; |
27
|
|
|
|
|
|
|
} |
28
|
0
|
0
|
|
|
|
|
if ($o->get_hi_rec < $o->get_count) { |
29
|
0
|
|
|
|
|
|
$title .= ' results: '.$o->commify($o->get_lo_rec)." - ".$o->commify($o->get_hi_rec); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$buf .= $$o{q}->header(-type => 'text/html', -attachment => $fn); |
33
|
0
|
|
|
|
|
|
$buf .= ' |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
'.$o->escape_html($title).' |
37
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
| ';
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my @userselcols = @{ $o->get_usersel_cols }; |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
foreach my $i (0 .. $#userselcols) { |
81
|
0
|
|
|
|
|
|
my $colAlias = $o->get_usersel_cols->[$i]; |
82
|
0
|
|
0
|
|
|
|
my $nice = $o->get_nice_name($colAlias) || $colAlias; |
83
|
0
|
|
|
|
|
|
$buf .= " | ".$o->escape_html($nice)." | ";
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
|
|
|
$buf .= " |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
| |
88
|
|
|
|
|
|
|
| ";
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $i = 0; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
while (my $r = $o->fetch()) { |
93
|
0
|
|
|
|
|
|
$buf .= " | ";
94
|
0
|
|
|
|
|
|
foreach my $col (@userselcols) { |
95
|
0
|
|
|
|
|
|
$buf .= " | ".$o->get_val($col)." | ";
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
$buf .= " | \n";
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# flush |
100
|
0
|
0
|
|
|
|
|
if (++$i == 10000) { |
101
|
0
|
|
|
|
|
|
$$o{output_handler}->($buf); |
102
|
0
|
|
|
|
|
|
$buf = ''; |
103
|
0
|
|
|
|
|
|
$i=0; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
|
$o->finish(); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$$o{output_handler}->($buf); |
109
|
0
|
|
|
|
|
|
$buf .= " |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
| |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
"; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return undef; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |