Skip to content
Snippets Groups Projects
Commit 4302d1d8 authored by Jared Hancock's avatar Jared Hancock
Browse files

dashboard: Reimplement export support

parent c03279de
No related branches found
No related tags found
No related merge requests found
...@@ -11,10 +11,10 @@ $plots = $report->getPlotData(); ...@@ -11,10 +11,10 @@ $plots = $report->getPlotData();
<link rel="stylesheet" type="text/css" href="css/dashboard.css"/> <link rel="stylesheet" type="text/css" href="css/dashboard.css"/>
<form method="post" action="dashboard.php">
<div id="basic_search"> <div id="basic_search">
<div style="min-height:25px;"> <div style="min-height:25px;">
<!--<p><?php //echo __('Select the starting time and period for the system activity graph');?></p>--> <!--<p><?php //echo __('Select the starting time and period for the system activity graph');?></p>-->
<form method="post" action="dashboard.php">
<?php echo csrf_token(); ?> <?php echo csrf_token(); ?>
<label> <label>
<?php echo __( 'Report timeframe'); ?>: <?php echo __( 'Report timeframe'); ?>:
...@@ -45,7 +45,6 @@ $plots = $report->getPlotData(); ...@@ -45,7 +45,6 @@ $plots = $report->getPlotData();
<?php echo __( 'Refresh');?> <?php echo __( 'Refresh');?>
</button> </button>
<i class="help-tip icon-question-sign" href="#report_timeframe"></i> <i class="help-tip icon-question-sign" href="#report_timeframe"></i>
</form>
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
...@@ -109,10 +108,15 @@ foreach ($groups as $g=>$desc) { ...@@ -109,10 +108,15 @@ foreach ($groups as $g=>$desc) {
} }
$first = false; ?> $first = false; ?>
</tbody></table> </tbody></table>
<div style="margin-top: 5px"><button type="submit" class="link button" name="export"
value="<?php echo Format::htmlchars($g); ?>">
<i class="icon-download"></i>
<?php echo __('Export'); ?></a></div>
</div> </div>
<?php <?php
} }
?> ?>
</form>
<script> <script>
$.drawPlots(<?php echo JsonDataEncoder::encode($report->getPlotData()); ?>); $.drawPlots(<?php echo JsonDataEncoder::encode($report->getPlotData()); ?>);
</script> </script>
...@@ -13,13 +13,14 @@ body, html { ...@@ -13,13 +13,14 @@ body, html {
padding:0; padding:0;
} }
.button.link,
a { a {
color:#184E81; color:#184E81;
text-decoration:none; text-decoration:none;
display: inline-block; display: inline-block;
} }
a:hover { a:hover, .button.link:hover {
text-decoration: underline; text-decoration: underline;
} }
...@@ -487,6 +488,7 @@ a { ...@@ -487,6 +488,7 @@ a {
} }
table.dashboard-stats { table.dashboard-stats {
text-align:right; text-align:right;
border-bottom: 2px solid #ddd;
} }
table.dashboard-stats tbody:first-child th { table.dashboard-stats tbody:first-child th {
border-bottom:1px dashed #ddd; border-bottom:1px dashed #ddd;
...@@ -1808,6 +1810,14 @@ select + .button { ...@@ -1808,6 +1810,14 @@ select + .button {
box-shadow: 0 0 0 2px rgba(255,255,255,0.7) inset; box-shadow: 0 0 0 2px rgba(255,255,255,0.7) inset;
color: white; color: white;
} }
.link.button, .link.button:hover, .link.button:active {
border: none;
box-shadow: none;
background-color: transparent;
color:#184E81;
padding: 0;
font-size: inherit;
}
.light .button:hover, .light .button:hover,
.white.button { .white.button {
......
...@@ -17,6 +17,31 @@ require('staff.inc.php'); ...@@ -17,6 +17,31 @@ require('staff.inc.php');
require_once INCLUDE_DIR . 'class.report.php'; require_once INCLUDE_DIR . 'class.report.php';
if ($_POST['export']) {
$report = new OverviewReport($_POST['start'], $_POST['period']);
switch (true) {
case ($data = $report->getTabularData($_POST['export'])):
$ts = strftime('%Y%m%d');
$group = Format::slugify($_POST['export']);
$delimiter = ',';
if (class_exists('NumberFormatter')) {
$nf = NumberFormatter::create(Internationalization::getCurrentLocale(),
NumberFormatter::DECIMAL);
$s = $nf->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
if ($s == ',')
$delimiter = ';';
}
Http::download("stats-$group-$ts.csv", 'text/csv');
$output = fopen('php://output', 'w');
fputs($output, chr(0xEF) . chr(0xBB) . chr(0xBF));
fputcsv($output, $data['columns'], $delimeter);
foreach ($data['data'] as $row)
fputcsv($output, $row, $delimeter);
exit;
}
}
$nav->setTabActive('dashboard'); $nav->setTabActive('dashboard');
$ost->addExtraHeader('<meta name="tip-namespace" content="dashboard.dashboard" />', $ost->addExtraHeader('<meta name="tip-namespace" content="dashboard.dashboard" />',
"$('#content').data('tipNamespace', 'dashboard.dashboard');"); "$('#content').data('tipNamespace', 'dashboard.dashboard');");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment