diff --git a/include/staff/dashboard.inc.php b/include/staff/dashboard.inc.php index 95421e155aff7c5267fc48fca00b60d459bfa770..d75ee3ef97621897d87f86439b1b82c465764de3 100644 --- a/include/staff/dashboard.inc.php +++ b/include/staff/dashboard.inc.php @@ -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> diff --git a/scp/css/scp.css b/scp/css/scp.css index 127dd00d5068f67b600ee05beb72dc6cc12e4f68..26369e0ec14b20d279cb2a51dc3df00cfa73aea5 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -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 { diff --git a/scp/dashboard.php b/scp/dashboard.php index 4a0cd3eef5fead042ee955acb288e6d21a1c5553..d5a5b60b563ef7c385d16f2aac93f0f7c40c4bbc 100644 --- a/scp/dashboard.php +++ b/scp/dashboard.php @@ -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');");