Merge pull request 'added csv download' (#9) from dev into main
Reviewed-on: #9
This commit was merged in pull request #9.
This commit is contained in:
@@ -217,6 +217,14 @@ div.headline h2{
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
#icon-download {
|
||||
position:absolute;
|
||||
top: 6px;
|
||||
left: 5px;
|
||||
pointer-events: none;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.input-table{
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
|
||||
35
app/public/download_table.php
Normal file
35
app/public/download_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include("../scripts/connection.php");
|
||||
include("../scripts/functions.php");
|
||||
$user_data = check_admin($con);
|
||||
|
||||
if(isset($_GET['table'])) {
|
||||
$table = $_GET['table'];
|
||||
}
|
||||
|
||||
header('Content-type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="table.csv" ');
|
||||
|
||||
function download_table($stmt) {
|
||||
$output = fopen('php://output', 'w');
|
||||
$header = true;
|
||||
while ($row = $stmt->fetch()) {
|
||||
if ($header) {
|
||||
fputcsv($output, array_keys($row));
|
||||
$header = false;
|
||||
}
|
||||
fputcsv($output, $row);
|
||||
}
|
||||
fclose($output);
|
||||
}
|
||||
|
||||
if($table == "total-score") {
|
||||
$total_score = get_total_score($con);
|
||||
download_table($total_score);
|
||||
} else {
|
||||
$station = get_station($con, $table);
|
||||
download_table($station);
|
||||
}
|
||||
?>
|
||||
@@ -74,6 +74,16 @@
|
||||
</form>
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
if($user_data['user_group'] == 'admin') {
|
||||
echo "<div class=\"btn-div\">
|
||||
<form action=\"download_table.php\" method=\"get\">
|
||||
<span class=\"gg-software-download icon\" id=\"icon-download\"></span>
|
||||
<input type=\"hidden\" name=\"table\" value=\"$session\">
|
||||
<input type=\"submit\" value=\"\">
|
||||
</form>
|
||||
</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="table-div">
|
||||
|
||||
Reference in New Issue
Block a user