version 1.30, 2003/11/17 19:55:41
|
version 1.31, 2003/11/21 21:51:28
|
Line 1190 sub calcerror {
|
Line 1190 sub calcerror {
|
sub display { |
sub display { |
my $self = shift; |
my $self = shift; |
my ($r) = @_; |
my ($r) = @_; |
$self->compute($r); |
|
my $outputmode = 'html'; |
my $outputmode = 'html'; |
if ($ENV{'form.output_format'} =~ /^(html|excel|csv)$/) { |
foreach ($self->output_options()) { |
$outputmode = $ENV{'form.output_format'}; |
if ($ENV{'form.output_format'} eq $_->{'value'}) { |
|
$outputmode = $_->{'value'}; |
|
last; |
|
} |
} |
} |
if ($outputmode eq 'html') { |
if ($outputmode eq 'html') { |
|
$self->compute($r); |
$self->outsheet_html($r); |
$self->outsheet_html($r); |
|
} elsif ($outputmode eq 'htmlclasslist') { |
|
# No computation neccessary... This is kludgy |
|
$self->outsheet_htmlclasslist($r); |
} elsif ($outputmode eq 'excel') { |
} elsif ($outputmode eq 'excel') { |
|
$self->compute($r); |
$self->outsheet_excel($r); |
$self->outsheet_excel($r); |
} elsif ($outputmode eq 'csv') { |
} elsif ($outputmode eq 'csv') { |
|
$self->compute($r); |
$self->outsheet_csv($r); |
$self->outsheet_csv($r); |
} |
} |
$self->cleanup(); |
$self->cleanup(); |
Line 1336 sub html_header {
|
Line 1344 sub html_header {
|
return '' if (! $ENV{'request.role.adv'}); |
return '' if (! $ENV{'request.role.adv'}); |
return "<table>\n". |
return "<table>\n". |
'<tr><th align="center">'.&mt('Output Format').'</th></tr>'."\n". |
'<tr><th align="center">'.&mt('Output Format').'</th></tr>'."\n". |
'<tr><td>'.&output_selector()."</td></tr>\n". |
'<tr><td>'.$self->output_selector()."</td></tr>\n". |
"</table>\n"; |
"</table>\n"; |
} |
} |
|
|
|
## |
|
## Default output types are HTML, Excel, and CSV |
|
sub output_options { |
|
my $self = shift(); |
|
return ({value => 'html', |
|
description => 'HTML'}, |
|
{value => 'excel', |
|
description => 'Excel'}, |
|
{value => 'csv', |
|
description => 'Comma Separated Values'},); |
|
} |
|
|
sub output_selector { |
sub output_selector { |
|
my $self = shift(); |
my $output_selector = '<select name="output_format" size="3">'."\n"; |
my $output_selector = '<select name="output_format" size="3">'."\n"; |
my $default = 'html'; |
my $default = 'html'; |
if (exists($ENV{'form.output_format'})) { |
if (exists($ENV{'form.output_format'})) { |
Line 1348 sub output_selector {
|
Line 1369 sub output_selector {
|
} else { |
} else { |
$ENV{'form.output_format'} = $default; |
$ENV{'form.output_format'} = $default; |
} |
} |
foreach (['html','HTML'], |
foreach ($self->output_options()) { |
['excel','Excel'], |
$output_selector.='<option value="'.$_->{'value'}.'"'; |
['csv','Comma Separated Values']) { |
if ($_->{'value'} eq $default) { |
my ($name,$description) = @{$_}; |
|
$output_selector.=qq{<option value="$name"}; |
|
if ($name eq $default) { |
|
$output_selector .= ' selected'; |
$output_selector .= ' selected'; |
} |
} |
$output_selector .= ">".&mt($description)."</option>\n"; |
$output_selector .= ">".&mt($_->{'description'})."</option>\n"; |
} |
} |
$output_selector .= "</select>\n"; |
$output_selector .= "</select>\n"; |
return $output_selector; |
return $output_selector; |
Line 1405 sub create_excel_spreadsheet {
|
Line 1423 sub create_excel_spreadsheet {
|
return ($workbook,$filename); |
return ($workbook,$filename); |
} |
} |
|
|
|
# |
|
# This routine is just a stub |
|
sub outsheet_htmlclasslist { |
|
my $self = shift; |
|
my ($r) = @_; |
|
$r->print('<h2>'.&mt("This output is not supported").'</h2>'); |
|
$r->rflush(); |
|
return; |
|
} |
|
|
sub outsheet_excel { |
sub outsheet_excel { |
my $self = shift; |
my $self = shift; |
my ($r) = @_; |
my ($r) = @_; |