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();
<link rel="stylesheet" type="text/css" href="css/dashboard.css"/>
<form method="post" action="dashboard.php">
<div id="basic_search">
<div style="min-height:25px;">
<!--<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(); ?>
<label>
<?php echo __( 'Report timeframe'); ?>:
......@@ -45,7 +45,6 @@ $plots = $report->getPlotData();
<?php echo __( 'Refresh');?>
</button>
<i class="help-tip icon-question-sign" href="#report_timeframe"></i>
</form>
</div>
</div>
<div class="clear"></div>
......@@ -109,10 +108,15 @@ foreach ($groups as $g=>$desc) {
}
$first = false; ?>
</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>
<?php
}
?>
</form>
<script>
$.drawPlots(<?php echo JsonDataEncoder::encode($report->getPlotData()); ?>);
</script>
......@@ -13,13 +13,14 @@ body, html {
padding:0;
}
.button.link,
a {
color:#184E81;
text-decoration:none;
display: inline-block;
}
a:hover {
a:hover, .button.link:hover {
text-decoration: underline;
}
......@@ -487,6 +488,7 @@ a {
}
table.dashboard-stats {
text-align:right;
border-bottom: 2px solid #ddd;
}
table.dashboard-stats tbody:first-child th {
border-bottom:1px dashed #ddd;
......@@ -1808,6 +1810,14 @@ select + .button {
box-shadow: 0 0 0 2px rgba(255,255,255,0.7) inset;
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,
.white.button {
......
......@@ -17,6 +17,31 @@ require('staff.inc.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');
$ost->addExtraHeader('<meta name="tip-namespace" content="dashboard.dashboard" />',
"$('#content').data('tipNamespace', 'dashboard.dashboard');");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment