-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdashboard.php
305 lines (255 loc) · 12 KB
/
sdashboard.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?php
$GLOBALS['title'] = "Dashboard-Hostel-Management-System";
$page_name = "DashBoard";
require('include/sessionManager.php');
$ses = new \sessionManager\sessionManager();
require('include/dbplayer.php');
$ses->start();
if ($ses->isExpired()) {
header('Location: login.php');
} elseif ($ses->Get("userGroupId") == "UG003") {
header('Location: edashboard.php');
} elseif ($ses->Get("userGroupId") == "UG002" || $ses->Get("userGroupId") == "UG001") {
header('Location:dashboard.php');
} else {
$name = $ses->Get("name");
$userIdf = $ses->Get("userIdLoged");
$db = new \dbplayer\dbplayer();
$msg = $db->open();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST["btnAttend"])) {
if ($msg = "true") {
$result = $db->getData("SELECT * FROM attendence WHERE userId='" . $userIdf . "' and date=CURDATE()");
if (mysql_num_rows($result) < 1) {
$data = array(
'userId' => $userIdf,
'date' => date("Y-m-d"),
'isAbsence' => 'No',
'isLeave' => 'No',
'remark' => 'Self',
);
$result = $db->insertData("attendence", $data);
//var_dump($result);
if (is_numeric($result)) {
// $db->close();
echo '<script type="text/javascript"> alert("Attendence Added Successfully.");</script>';
} elseif (strpos($result, 'Duplicate') !== false) {
echo '<script type="text/javascript"> alert("Attendence Already Exits for today!"); </script>';
} else {
echo '<script type="text/javascript"> alert("' . $result . '");</script>';
}
} else {
echo '<script type="text/javascript"> alert("Attendence Already Exits for today!"); </script>';
}
} else {
echo '<script type="text/javascript"> alert("' . $msg . '");</script>';
}
}
}
if ($msg = "true") {
$data = array();
$qery = "select case when sum(amount) is NULL THEN 0 ELSE sum(amount) END as totals from deposit where depositDate >= DATE_FORMAT(CURDATE(), '%Y-%m-%d')-interval 1 MONTH and userId='" . $userIdf . "' UNION ALL SELECT case when sum(noOfMeal) is null THEN 0 ELSE sum(noOfMeal) END as toMeal from meal WHERE DATE(date)=DATE(NOW()) and userId='" . $userIdf . "' UNION ALL select case when sum(noOfMeal) is null THEN 0 ELSE sum(noOfMeal) end from meal where date >= DATE_FORMAT(CURDATE(), '%Y-%m-%d')-interval 1 MONTH and userId='" . $userIdf . "'UNION ALL select case when rate is null THEN 0 ELSE rate END from mealrate";
// var_dump($qery);
$result = $db->getData($qery);
$GLOBALS['totals'] = array();
// $data = array();
if (false === strpos((string)$result, "Can't")) {
while ($row = mysql_fetch_array($result)) {
// array_push($data,$row['totals']);
array_push($GLOBALS['totals'], $row['totals']);
}
} else {
echo '<script type="text/javascript"> alert("' . $result . '");</script>';
}
//var_dump( $GLOBALS['totals']);
$GLOBALS['data'] = '';
$result = $db->getData("SELECT serial,title,description,DATE_FORMAT(createdDate,'%D %M,%Y %h:%i:%s %p') as date FROM notice ORDER BY serial DESC LIMIT 4");
if (false === strpos((string)$result, "Can't")) {
$GLOBALS['data'] = $result;
//var_dump($GLOBALS['data']);
} else {
echo '<script type="text/javascript"> alert("' . $result . '");</script>';
}
} else {
echo '<script type="text/javascript"> alert("' . $msg . '");</script>';
}
}
?>
<?php include('./smater.php'); ?>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="col-lg-6">
<h1 class="page-header titlehms"><i class="fa fa-hand-o-right"></i>Dashboard<i class="fa fa-hand-o-left"></i></h1>
</div>
<div class="col-lg-6">
<form action="sdashboard.php" accept-charset="utf-8" method="post" enctype="multipart/form-data">
<button class="btn btn-success pull-right margin-to-5" type="submit" name="btnAttend"><i class="fa fa-2x fa-check"></i>Attendence</button>
</form>
</div>
</div>
<!-- /.col-lg-12 -->
</div>
<div class="row">
<div class="col-lg-3 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-money fa-4x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo $GLOBALS['totals'][0]; ?></div>
<div>Current Deposit</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-maxcdn fa-4x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo intval($GLOBALS['totals'][1]); ?></div>
<div>Today's Meal</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-red">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-maxcdn fa-4x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo intval($GLOBALS['totals'][2]); ?></div>
<div>Total Meal</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-yellow">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-money fa-4x"></i>
<div>Rate:<?php echo $GLOBALS['totals'][3]; ?></div>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo floatval($GLOBALS['totals'][3] * $GLOBALS['totals'][2]); ?></div>
<div>Total Meal Cost</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="panel panel-info">
<div class="panel-heading">
<i class="fa fa-list-alt fa-fw"></i>Notice Board
</div>
<div class="panel-body">
<div id="accordion" class="panel-group">
<?php while ($row = mysql_fetch_array($GLOBALS['data'])) {
echo '<div class="panel panel-success">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#' . $row['serial'] . '" data-parent="#accordion" data-toggle="collapse" aria-expanded="false" class="collapsed">' . $row['title'] . ' [' . $row['date'] . ']</a>';
echo '</h4>
</div>
<div class="panel-collapse collapse" id="' . $row['serial'] . '" aria-expanded="false" style="height: 0px;">
<div class="panel-body">';
echo $row['description'];
echo '</div></div></div>';
}
?>
</div>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-lg-6">
<div class="custom-calendar-wrap">
<div id="custom-inner" class="custom-inner">
<div class="custom-header clearfix">
<nav>
<span id="custom-prev" class="custom-prev"></span>
<span id="custom-next" class="custom-next"></span>
</nav>
<h2 id="custom-month" class="custom-month"></h2>
<h2 id="custom-year" class="custom-year"></h2>
</div>
<div id="calendar" class="fc-calendar-container"></div>
</div>
</div>
</div>
</div>
</div>
<!-- /#page-wrapper -->
<?php include('./footer.php'); ?>
<script type="text/javascript">
$(function() {
var transEndEventNames = {
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'oTransitionEnd',
'msTransition': 'MSTransitionEnd',
'transition': 'transitionend'
},
transEndEventName = transEndEventNames[Modernizr.prefixed('transition')],
$wrapper = $('#custom-inner'),
$calendar = $('#calendar'),
cal = $calendar.calendario({
onDayClick: function($el, $contentEl, dateProperties) {
if ($contentEl.length > 0) {
showEvents($contentEl, dateProperties);
}
},
caldata: codropsEvents,
displayWeekAbbr: true
}),
$month = $('#custom-month').html(cal.getMonthName()),
$year = $('#custom-year').html(cal.getYear());
$('#custom-next').on('click', function() {
cal.gotoNextMonth(updateMonthYear);
});
$('#custom-prev').on('click', function() {
cal.gotoPreviousMonth(updateMonthYear);
});
function updateMonthYear() {
$month.html(cal.getMonthName());
$year.html(cal.getYear());
}
// just an example..
function showEvents($contentEl, dateProperties) {
hideEvents();
var $events = $('<div id="custom-content-reveal" class="custom-content-reveal"><h4>Events for ' + dateProperties.monthname + ' ' + dateProperties.day + ', ' + dateProperties.year + '</h4></div>'),
$close = $('<span class="custom-content-close"></span>').on('click', hideEvents);
$events.append($contentEl.html(), $close).insertAfter($wrapper);
setTimeout(function() {
$events.css('top', '0%');
}, 25);
}
function hideEvents() {
var $events = $('#custom-content-reveal');
if ($events.length > 0) {
$events.css('top', '100%');
Modernizr.csstransitions ? $events.on(transEndEventName, function() {
$(this).remove();
}) : $events.remove();
}
}
});
</script>