-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.php
More file actions
78 lines (64 loc) · 1.79 KB
/
service.php
File metadata and controls
78 lines (64 loc) · 1.79 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
function getTeams()
{
$vTeams = array();
for ($i=1; $i<7;$i++) {
$vTeams['team_' . $i] = array(
'id' => 'team_' . $i,
'name' => 'Team ' . $i,
'checked' => true,
);
}
ksort($vTeams);
return $vTeams;
}
function getTeamdata()
{
$vTeams = getTeams();
$vTypes = array('Type 1', 'Type 2', 'Type 3');
$vHours = array(4, 8);
$teamData = array();
foreach ($vTeams as $team) {
$users = array();
for ($x = 0; $x < rand(4,18); $x++) {
$absence_records = array();
for ($j = rand(1,15); $j < rand(16,29); $j++) {
$typeKey = array_rand($vTypes, 1);
$hoursKey = array_rand($vHours, 1);
$absence_records[] = array(
'date' => '2013-' . str_pad(rand(1,12), 2, 0, STR_PAD_LEFT) . '-' . str_pad($j, 2, 0, STR_PAD_LEFT),
'type' => $vTypes[$typeKey],
'hours' => $vHours[$hoursKey]
);
}
$users[] = array(
'name' => "Person $x",
'role' => 'Developer',
'absence_records' => $absence_records
);
}
$teamData[] = array(
'id' => $team['id'],
'name' => $team['name'],
'data' => $users
);
}
return $teamData;
}
$m = @ $_REQUEST['m'];
$data = array();
switch ($m) {
case 'teams':
$data = getTeams();
break;
case 'data':
$data = getTeamdata();
break;
}
header('Content-Type: application/json');
$response = array(
'success' => 1,
'data' => $data
);
$prefix = ")]}',\n";
echo $prefix . json_encode($response);