-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
216 lines (198 loc) · 10.9 KB
/
index.php
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
include $_SERVER['DOCUMENT_ROOT'].'/lib/header.php';
?>
<main class="mdl-layout__content">
<div class="mdl-grid mdl-grid--no-spacing">
<div class="mdl-grid mdl-cell mdl-cell--9-col-desktop mdl-cell--12-col-tablet mdl-cell--4-col-phone mdl-cell--top">
<!-- Pie chart-->
<div class="mdl-cell mdl-cell--4-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
<div class="mdl-card mdl-shadow--2dp pie-chart">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">My Day</h2>
</div>
<div class="mdl-card__supporting-text">
<div class="pie-chart__container">
</div>
</div>
</div>
</div>
<!-- Weather widget-->
<div class="mdl-cell mdl-cell--4-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
<div class="mdl-card mdl-shadow--2dp weather">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Weather</h2>
<div class="mdl-layout-spacer"></div>
<div class="mdl-card__subtitle-text">
<i class="material-icons">room</i>
<span class="weather-city"></span>
</div>
</div>
<div class="mdl-card__supporting-text mdl-card--expand">
<p class="weather-temperature"></p>
<p class="weather-description"></p>
<p class="weather-update"></p>
</div>
</div>
</div>
<!-- Trending widget-->
<div class="mdl-cell mdl-cell--4-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
<div class="mdl-card mdl-shadow--2dp trending">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Trending</h2>
</div>
<div class="mdl-card__supporting-text">
<ul class="mdl-list">
<li class="mdl-list__item">
<span class="mdl-list__item-primary-content list__item-text">UX</span>
<span class="mdl-list__item-secondary-content">
<i class="material-icons trending__arrow-up" role="presentation"></i>
</span>
<span class="mdl-list__item-secondary-content trending__percent">1 %</span>
</li>
<li class="mdl-list__item list__item--border-top">
<span class="mdl-list__item-primary-content list__item-text">PHP</span>
<span class="mdl-list__item-secondary-content">
<i class="material-icons trending__arrow-down" role="presentation"></i>
</span>
<span class="mdl-list__item-secondary-content trending__percent">2 %</span>
</li>
<li class="mdl-list__item list__item--border-top">
<span class="mdl-list__item-primary-content list__item-text ">Big Data</span>
<span class="mdl-list__item-secondary-content">
<i class="material-icons trending__arrow-up" role="presentation"></i>
</span>
<span class="mdl-list__item-secondary-content trending__percent">5 %</span>
</li>
<li class="mdl-list__item list__item--border-top">
<span class="mdl-list__item-primary-content list__item-text">Material Design</span>
<span class="mdl-list__item-secondary-content">
<i class="material-icons trending__arrow-up" role="presentation"></i>
</span>
<span class="mdl-list__item-secondary-content trending__percent">18 %</span>
</li>
<li class="mdl-list__item list__item--border-top">
<span class="mdl-list__item-primary-content">JavaScript</span>
<span class="mdl-list__item-secondary-content">
<i class="material-icons trending__arrow-up" role="presentation"></i>
</span>
<span class="mdl-list__item-secondary-content trending__percent">17 %</span>
</li>
</ul>
</div>
</div>
</div>
<!-- Table-->
<div class="mdl-cell mdl-cell--12-col-desktop mdl-cell--12-col-tablet mdl-cell--4-col-phone overflow-x-auto">
<div class="mdl-card mdl-shadow--2dp projects">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Projects</h2>
</div>
<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp projects-table">
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">Name</th>
<th class="mdl-data-table__cell--non-numeric">Members</th>
<th class="mdl-data-table__cell--non-numeric">Deadline</th>
<th class="mdl-data-table__cell--non-numeric">Your Time Used</th>
</tr>
</thead>
<tbody>
<?php
foreach ($Projects->getUserProjects($user_id) as $project) {
$Project = $Projects->getProjects($project->project_id);
$totalTime = $Projects->getProjectTotalTime($Project->id, $user_id);
if(empty($totalTime->totaltime)){
$totalTime = "Nothing recorded";
}else{
$totalTime = Basics::secondsToTime($totalTime->totaltime);
}
$userList = "";
$Users = $Projects->getProjectUsers($Project->id);
$users=0;
foreach ($Users as $user) {
$users++;
$getUser = $Account->get($user->user_id);
if(count($Users)==$users){
$userList .= $getUser->name;
}else{
$userList .= $getUser->name.", ";
}
}
if($Project->deadline==NULL OR $Project->deadline=="None" OR $Project->deadline=="0000-00-00 00:00:00"){
$deadline = "None";
}else{
$deadlineTime = time() - strtotime($Project->deadline);
$deadline = Basics::secondsToTime($deadlineTime);
}
?>
<tr class="is-selected">
<td class="mdl-data-table__cell--non-numeric"><a href="project/<?php echo $Project->id; ?>"><?php echo $Project->name; ?></a></td>
<td class="mdl-data-table__cell--non-numeric"><?php echo $userList; ?></td>
<td class="mdl-data-table__cell--non-numeric"><?php echo $deadline; ?></td>
<td class="mdl-data-table__cell--non-numeric"><?php echo $totalTime; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div class="mdl-cell mdl-cell--12-col-desktop mdl-cell--12-col-tablet mdl-cell--4-col-phone overflow-x-auto">
<!-- ToDo_widget-->
<div class="mdl-card mdl-shadow--2dp todo">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">To-do list</h2>
</div>
<div class="mdl-card__supporting-text">
<ul class="mdl-list">
</ul>
</div>
<div class="mdl-card__actions">
<button class="mdl-button mdl-js-button mdl-js-ripple-effect">remove selected</button>
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--fab mdl-shadow--8dp mdl-button--colored ">
<i class="material-icons mdl-js-ripple-effect">add</i>
</button>
</div>
</div>
</div>
</div>
</div>
</main>
<script>
function getMinutesBetweenDates(startDate, endDate) {
var diff = endDate.getTime() - startDate.getTime();
return (diff / 60000);
}
function weather(lat, lng){
$.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=' + lat + '&lon=' + lng + '&appid=5342396fae3e79c95bce218695ccdd33&units=metric', function(data){
var update = Math.floor(getMinutesBetweenDates(new Date(data['dt']*1000), new Date()));
var city = data['name'] + ', ' + data['sys']['country'];
var temp = Math.round( data['main']['temp'] * 10 ) / 10;
var wind = "Wind " + data['wind']['speed'] + " m/s";
$('.weather-city').html(city);
$('.weather-temperature').html(temp + "<sup>°</sup>");
$('.weather-description').html(wind);
$('.weather-update').html("Last updated " + update + " minutes ago");
});
}
if(localStorage.location==undefined){
weather(localStorage.lat, localStorage.lng);
console.log("TESTe");
}else{
console.log("TEST");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert('Your browser doesn\'t support this feature!');
}
}
function showPosition(position) {
weather(position.coords.latitude, position.coords.longitude);
}
getLocation();
}
</script>
<?php
include $_SERVER['DOCUMENT_ROOT'].'/lib/footer.php';