-
Notifications
You must be signed in to change notification settings - Fork 1
/
worklog.php
131 lines (82 loc) · 3.65 KB
/
worklog.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
<?php
session_start();
include("config/db.php");
if($_SESSION['user_name']==''){
header('Location: login.php');
}
$user_name = $_SESSION['user_name'];
if($_REQUEST['logtime']!=''){
$_SESSION['logtime'] = $_SESSION['logtime'] + 1;
if($_SESSION['checkin_time']==''){
$_SESSION['checkin_time'] = date("g:i a");
}
$selQry = "SELECT *FROM tbl_logs WHERE user_name='$user_name' AND log_date=CURDATE()";
$resLog = mysql_query($selQry);
if(mysql_num_rows($resLog)>0){
}else{
$insQry = "INSERT INTO tbl_logs(ID, user_name, user_login, user_logout, log_date) VALUES(null, '$user_name', NOW(), '00:00:00', CURDATE())";
mysql_query($insQry);
}
echo $_SESSION['checkin_time'];
die();
}
if($_REQUEST['checkout']=="checkout"){
$updQry = "UPDATE tbl_logs SET user_logout=NOW(), log_time=".$_SESSION['logtime']." WHERE user_logout='00:00:00' AND log_date=CURDATE() AND user_name='$user_name'";
mysql_query($updQry);
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
die();
}
?>
<?php include('template/header_work_log_page.php'); ?>
<div class="col-lg-6 col-lg-offset-3" id='timesheetarea'>
<div class="panel panel-primary">
<!-- Default panel contents -->
<div class="panel-heading"><span class="glyphicon glyphicon-time"></span> My Time Sheet</div>
<div class="panel-body">
<?php
echo "<div class='alert alert-danger'><h4>Current Week days</h4>";
echo "<div class='text-center'><ul class='pagination'>";
$startday=1;
$weekbeginning='';
$datevalue = ( date('d') - date('N') ) + 1 ;
$weekbeginning = date('Y') . "-" . date('m') ."-" . $datevalue ;
$date = $weekbeginning ;
for($day= 1; $day <= 7; $day++)
{
echo "<li><a href='#' onclick=\"loadtimesheetfordate('" . date( 'Y-m-d' , strtotime ($date) ) . "')\">" .
date( 'D' , strtotime ($date) ) . "<br/>" . date( 'd' , strtotime ($date) ) . "</a></li>";
$tdate = strtotime ( '1 day' , strtotime ( $date ) ) ;
$date = date('Y', $tdate) . "-" .date('m', $tdate) . "-" .date('d', $tdate);
}
echo "</ul>";
echo "<div class='week-navigation'>";
$date = $weekbeginning ;
$tdate = strtotime ( '-7 day' , strtotime ( $date ) ) ;
$date = date('Y', $tdate) . "-" .date('m', $tdate) . "-" .date('d', $tdate);
echo '<ul class="pager"><li class="previous"><a href="#" onclick="previousweek(\'' . date( 'Y-m-d' , strtotime ($date) ) .'\')">← Preview Week</a></li>';
$date = $weekbeginning ;
$tdate = strtotime ( '7 day' , strtotime ( $date ) ) ;
$date = date('Y', $tdate) . "-" .date('m', $tdate) . "-" .date('d', $tdate);
echo '<li class="next"><a href="#" onclick="nextweek(\'' . date( 'Y-m-d' , strtotime ($date) ) .'\')">Next Week →</a></li></ul>';
echo "</div>";
echo "</div>";
echo '</div>';
?>
</div>
<div class='grid'></div>
</div>
</div>
</div>
<?php include('template/footer.php'); ?>