-
Notifications
You must be signed in to change notification settings - Fork 1
/
display_today_only.php
123 lines (112 loc) · 3.05 KB
/
display_today_only.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
<?php
//Allow Access to DB
require 'db.php';
//Update status who are absent @9:00pm
require 'update_yasumi_status.php';
//Restrict Allowed Locations Only
require 'black_ip.php';
//refresh page every 3 seconds to update clockin list of today
$page = $_SERVER['PHP_SELF'];
$sec = "3600";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
<link rel="stylesheet" href="table.css">
<script src="js/time.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<style>
.div2 {
width: 800px;
height: 800px;
padding: 50px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="div2" align="center">
<center><h2><body onload=display_ct();>
<span id='ct' ></h2></span></center>
<br>
<table class="data-table">
<caption>TODAY</caption>
<thead>
<tr>
<th>date</th>
<th>id</th>
<th>Name</th>
<th>department</th>
<th>In</th>
<th>out</th>
<th>total</th>
</tr>
</thead>
<tbody>
<?
$report=("SELECT * FROM timecard WHERE date(clockin)=CURDATE() ORDER BY dept");
$result=mysqli_query($conn, $report) or die ("Error Retrieving Timesheet".mysqli_error($conn));
while($row = mysqli_fetch_array($result)){
$name = $row['full_name'];
$dept=$row['dept'];
$em_id = $row['employment_id'];
$aho = date('M-dS-Y', strtotime($row['clockin']));
//Display Today/Yesterday and day before
$current_day = date("M-dS-Y");
$yesderday = date('M-dS-Y',strtotime("-1 days"));
$daybefore = date('M-dS-Y',strtotime("-2 days"));
if($aho==$current_day){
$date="Today";
}elseif ($aho==$yesderday){
$date="Yesterday";
}elseif($aho==$daybefore){
$date=date('D dS, Y', strtotime($row['clockin']));
}else{
$date=$aho;
}
$clockin = date('G:ia',strtotime($row['clockin']));
$in = $row['clockin'];
$out = $row['clockout'];
$online = "../unix/img/online.png";
$offline = "../unix/img/offline.png";
$comment = $row['comment'];
if($comment==''){
$disp = "";
}else{
$disp = "<td style='background-color: #FFFF00'>$comment</td>";
}
if($out=="0000-00-00 00:00:00"){
$clockout = "<img src='$online' height=11 width=11> On Duty";
$total = "";
}elseif ($icon == 0){
$clockout = date('G:ia',strtotime($row['clockout']));
$start = new DateTime($in);
$finish = new DateTime($out);
$hour = $start->diff($finish);
$hrs = $hour->format("%H:%i:%s");
sscanf($hrs,"%d:%d:%d ", $h, $m, $s);
$d = ($h*3600) + ($m*60) + $s;
$total = gmdate('H:i:s', $d);
}
echo "<tr>";
echo "<td>$date</td>";
echo "<td>$em_id</td>";
echo "<td>$name</td>";
echo "<td>$dept</td>";
echo "<td>$clockin</td>";
echo "<td>$clockout</td>";
echo "<td>$total</td>";
echo "$disp";
echo "</tr>";
}
?>
</tbody>
<tfoot>
<tr>
</tr>
</tfoot>
</table><br><br>
</center>
</body>
</html>