This repository was archived by the owner on Aug 13, 2020. It is now read-only.
forked from tohirsolomons/loadshedding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogteam.php
More file actions
87 lines (64 loc) · 1.85 KB
/
logteam.php
File metadata and controls
87 lines (64 loc) · 1.85 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
79
80
81
82
83
84
85
86
87
<?php
date_default_timezone_set('Africa/Johannesburg');
define('LOADSHEDDING_STAGE', 2);
$today=date('d');
$teamZones = [
'5' => ['Nadeem'],
'10' => ['Justin'],
'11' => ['Kamil'],
'12' => ['Tohir'],
'15' => ['Mel', 'Elvis', 'Mncedi'],
];
require_once 'vendor/autoload.php';
$csv = new parseCSV('stage'.LOADSHEDDING_STAGE.'.csv');
$data = $csv->data;
// Create an Array of Date Columns
$datesColumn = [];
for ($i=2; $i<=17; $i++)
{
$datesColumn[$i] = [$data[0][$i]];
if (!empty($data[1][$i])) {
$datesColumn[$i][] = $data[1][$i];
}
}
// Find Load Shedding
$loadShedding = [];
for ($i=2; $i<=count($data)-1; $i++)
{
$startTime = $data[$i][0];
$endTime = $data[$i][1];
for ($j=2; $j<=17; $j++)
{
// Ignore if not today
if (!in_array($today, $datesColumn[$j])) {
continue;
}
// Get Zones
$zones = explode(',', $data[$i][$j]);
foreach ($zones as $zone)
{
$zone = (int)$zone;
// Check whether it affects someone in team
if (isset($teamZones[$zone])) {
$loadShedding[$j][] = [
'date'=>$datesColumn[$j],
'zone'=>$zone,
'starttime'=>$startTime,
'endtime'=>$endTime,
'affects'=>$teamZones[$zone]
];
}
}
}
}
echo 'Loadshedding in LogTeam for '.date('l, j F Y').' - Stage '.LOADSHEDDING_STAGE.PHP_EOL.PHP_EOL;
foreach ($loadShedding as $result)
{
foreach ($result as $time)
{
echo sprintf('Zone %s', str_pad($time['zone'],2));
echo sprintf(' - %s till %s for: ', $time['starttime'], $time['endtime']);
echo implode(', ', $time['affects']);
echo PHP_EOL;
}
}