-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.php
More file actions
40 lines (34 loc) · 1.31 KB
/
save.php
File metadata and controls
40 lines (34 loc) · 1.31 KB
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
40
<?php
function dtMili($data) {
return date('H:i:s', $data / 1000) . '.' . ($data % 1000);
}
$data = json_decode($_POST['bart']);
$subjid = $_POST['subjid'];
//$data = json_decode(file_get_contents('reports/test.csv'));
$filename = sprintf('reports/bart_report_%s_%s.csv', date('Ymd.His'), $subjid);
$report = '';
$report = "SUBJID:\t{$subjid}\n";
$report .= "Início:\t" . date('Y-m-d H:i:s', $data->start_time / 1000) . "\n";
$report .= "Término:\t" . date('Y-m-d H:i:s', $data->end_time / 1000) . "\n\n";
$report .= "Balões\n";
$report .= "Cor\tMax Pump\tGanho\tTotal Assopros\tInício\tTérmino\tTempos assopros (s)\n";
foreach ($data->balloons as $balao) {
$report .= $balao->color . "\t";
$report .= $balao->popprob . "\t";
$report .= $balao->earned . "\t";
$report .= $balao->pumps . "\t";
$report .= dtMili($balao->start_time) . "\t";
$report .= dtMili($balao->end_time) . "\t";
$last = 0;
foreach ($balao->time as $pumpTime) {
if ($last > 0) {
$diffTime = ($pumpTime - $last) / 1000;
$diffTime = str_replace('.', ',', sprintf('%.3f', $diffTime));
$report .= "$diffTime\t";
} else {
$last = $balao->start_time;
}
}
$report .= "\n";
}
file_put_contents($filename, $report);