-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.php
More file actions
39 lines (28 loc) · 958 Bytes
/
export.php
File metadata and controls
39 lines (28 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once('php/config.php');
require_once('php/Teams.php');
require_once('php/Team.php');
require_once('php/Score.php');
pg_connect('host=' . Config::$HOST . ' dbname=' . Config::$DATABASE . ' user=' . Config::$USER . ' password=' . Config::$PASSWORD . '');
$teams = Teams::findAllByRank(Config::$ENDSCOREORDER);
$filename = 'puntentelling_' . str_replace(' ', '_', strtolower(Config::$ORGANISATION));
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $filename . '.csv');
$output = fopen('php://output', 'w');
$header = array('#', 'Naam');
foreach(Config::$ROUNDS as $num => $round) {
$header[] = $round;
}
fputcsv($output, $header, ';');
$rank = 1;
foreach($teams as $team) {
$data = array(
$rank++,
$team->getName()
);
foreach(Config::$ROUNDS as $num => $round) {
$data[] = $team->getScore($num);
}
fputcsv($output, $data, ';');
}
?>