-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclockin.php
More file actions
166 lines (124 loc) · 7.75 KB
/
Copy pathclockin.php
File metadata and controls
166 lines (124 loc) · 7.75 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
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
<?php
require 'db.php';
$id = $_GET['id'];
$full_name = $_GET['name'];
$dept = $_GET['dept'];
$rate = $_GET['vahe'];
$office = $_GET['area'];
$clock_in_time = date_default_timezone_get();
$now = date('Y-m-d H:i:s',strtotime($clock_in_time));
//Update users to On Duty after clock-in
$in = ("UPDATE users SET in_or_out=1, punchin='".$now."' where id=$id ");
$clockin = mysqli_query($conn, $in) or die ("Error Clocking In Insert into user status :".mysqli_error($conn));
//IP address Restriction
include 'black_ip.php';
// If clockin from Hanoi IP address
if($add1_ip){
//Determine location base on IP address
$location = "Office 2 Location";
// $date = new DateTime("now", new DateTimeZone('Asia/Ho_Chi_Minh') );
// echo $date->format('Y-m-d H:i:s');
//Convert server time (JST) to Hanoi time JST-2
$time = date('H:i:s', strtotime($now));
$today = date('Y-m-d', strtotime($now));
sscanf($time,"%d:%d:%d ", $h, $m, $s);
$time_in_secs = ($h*3600) + ($m*60) + $s;
$time_offset = $time_in_secs - 7200;
$hanoi_time = gmdate('H:i:s', $time_offset);
$hanoi_time_clock_in = $today.' '.$hanoi_time; //Date and Time now in Hanoi
//Hanoi date and time determined
$hanoi_current_time = date('H:i:s', strtotime($hanoi_time_clock_in)); // today in Hanoi
$hanoi_current_day = date('Y-m-d', strtotime($hanoi_time_clock_in)); // current time in Hanoi
// Please update the following to the usuall time slot clock in.
$am_5_50 = '05:50:00';
$am_6_20 = '06:20:00';
$am_6_50 = '06:50:00';
$am_7_30 = '07:30:00';
$am_8_00 = '08:00:00';
$am_8_30 = '08:30:00';
$am_9_00 = '09:00:00';
$am_10_00 = '10:00:00';
$noon = '13:00:00';
if ($hanoi_current_time <= '06:50:59' && $hanoi_current_time > '06:20:59'){ // If clockin between 6:21 am - 6:50 am
$hanoi_right_time_clockin = $today.' '.$am_6_50; // Time will be recorded as 6:50 am
}elseif($hanoi_current_time <= '07:30:59' && $hanoi_current_time > '06:50:59'){ // Late clockin after 6:50 am
$hanoi_right_time_clockin = $today.' '.$am_7_30; // Time will be recorded as 7:30 am
}elseif ($hanoi_current_time <= '08:00:59' && $hanoi_current_time > '07:30:59'){ // If clockin between 7:30 - 8:00 am
$hanoi_right_time_clockin = $today.' '.$am_8_00; // Time will be recorded as 8:00 am
}elseif ($hanoi_current_time <= '08:30:59' && $hanoi_current_time > '08:00:59'){ // Late clockin after 8:00 am
$hanoi_right_time_clockin = $today.' '.$am_8_30; // Time will be recorded as 8:30 am
}elseif ($hanoi_current_time <= '09:00:59' && $hanoi_current_time >= '08:30:59'){ // If clockin between 8:30 am - 9:00 am
$hanoi_right_time_clockin = $today.' '.$am_9_00; // Time will be recorded as 9:00 am
}elseif ($hanoi_current_time <= '10:00:59' && $hanoi_current_time >= '09:30:59'){ // If clockin between 9:30 am - 10:00 am
$hanoi_right_time_clockin = $today.' '.$am_10_00; // Time will be recorded as 10:00 am
}else{
}
/*if ($hanoi_current_time <= $am_9_00 && $hanoi_current_time >= '08:30:00'){
$hanoi_right_time_clockin = $today.' '.$am_8_30;
}*/
$hanoi_clock_in=("Insert into timecard (`employment_id`,`full_name`,`clockin`,`actual_time_in`,`dept`,`rank_rate`, `location`)
Values ('$id', '$full_name', '$hanoi_right_time_clockin', '$hanoi_time_clock_in', '$dept', '$rate', '$office')");
$hanoi_clock_input = mysqli_query($conn, $hanoi_clock_in) or die ("Error Clocking In Into timesheet from Hanoi :".mysqli_error($conn));
// Clocking in from Kumamoto Office
}elseif ($add2_ip || $myip){
$location = "Office Location 1";
//Japan time and date
$jp_time = date('H:i:s', strtotime($now));
$jp_today = date('Y-m-d', strtotime($now));
$am_5_50 = '05:50:00';
$am_6_20 = '06:20:00'; // Late clockin
$am_6_50 = '06:50:00';
$am_7_30 = '07:30:00';
$am_8_00 = '08:00:00';
$am_8_30 = '08:30:00';
$am_9_00 = '09:00:00';
$am_10_00 = '10:00:00';
$am_11_00 = '11:00:00';
$pm_13_00 = '13:00:00';
$pm_15_00 = '15:00:00';
$noon = '15:00:00';
if ($jp_time <= '05:50:59' && $jp_time >= '05:20:00'){ // if clockin between 5:30 am - 5:50 am
$jp_right_time_clockin = $jp_today.' '.$am_5_50; // time will be recorded as 5:50 am
}elseif($jp_time <= '06:20:59' && $jp_time > '05:50:59'){ // Late clockin after 5:50 am
$jp_right_time_clockin = $jp_today.' '.$am_6_20; // Time will be recorded as 6:20 am
}elseif ($jp_time <= '06:50:59' && $jp_time > '06:20:59'){ // If clockin between 6:21 am - 6:50 am
$jp_right_time_clockin = $jp_today.' '.$am_6_50; // Time will be recorded as 6:50 am
}elseif($jp_time <= '07:30:59' && $jp_time > '06:50:59'){ // Late clockin after 6:50 am
$jp_right_time_clockin = $jp_today.' '.$am_7_30; // Time will be recorded as 7:30 am
}elseif ($jp_time <= '08:00:59' && $jp_time > '07:30:59'){ // If clockin between 7:30 - 8:00 am
$jp_right_time_clockin = $jp_today.' '.$am_8_00; // Time will be recorded as 8:00 am
}elseif ($jp_time <= '08:30:59' && $jp_time > '08:00:59'){ // Late clockin after 8:00 am
$jp_right_time_clockin = $jp_today.' '.$am_8_30; // Time will be recorded as 8:30 am
}elseif ($jp_time <= '09:00:59' && $jp_time >= '08:30:59'){ // If clockin between 8:30 am - 9:00 am
$jp_right_time_clockin = $jp_today.' '.$am_9_00; // Time will be recorded as 9:00 am
}elseif ($jp_time <= '09:30:59' && $jp_time >= '08:31:00'){ // If clockin between 8:30 am - 9:00 am
$jp_right_time_clockin = $jp_today.' 09:30:00'; // Time will be recorded as 9:00 am
}elseif ($jp_time <= '10:00:59' && $jp_time >= '09:30:59'){ // If clockin between 8:30 am - 9:00 am
$jp_right_time_clockin = $jp_today.' '.$am_10_00;
}elseif ($jp_time <= '11:00:59' && $jp_time >= '10:30:59'){ // If clockin between 8:30 am - 9:00 am
$jp_right_time_clockin = $jp_today.' '.$am_11_00;
}elseif ($jp_time <= '13:00:59' && $jp_time >= '11:00:59'){ // If clockin between 8:30 am - 9:00 am
$jp_right_time_clockin = $jp_today.' '.$pm_13_00;
}elseif ($jp_time <= '15:00:59' && $jp_time >= '14:30:59'){ // If clockin between 8:30 am - 9:00 am
$jp_right_time_clockin = $jp_today.' '.$pm_13_00;
}else{ // Testing.............
$jp_right_time_clockin = $jp_today.' '.$noon;
}
//check if the person already clockin
$sql_chk = ("SELECT clockin, actual_time_in FROM timecard WHERE employment_id ='".$id."' AND date(clockin)=CURDATE()");
$result_chk = mysqli_query($conn, $sql_chk) or die ("Error Checking Clocking :".mysqli_error($sql_chk));
$num_of_row_affected = mysqli_num_rows($result_chk);
if($num_of_row_affected == 1){
echo '<br><br><b><center><font color="red">You are already Logged In. Please try again after this message.</font> <br>The system will reset your status</b></center>';
$in = ("UPDATE users SET in_or_out=1, punchin='".$now."' where id=$id ");
$clockin = mysqli_query($conn, $in) or die ("Error Clocking In Insert into user status :".mysqli_error($conn));
echo '<META HTTP-EQUIV=REFRESH CONTENT="3; '.$_SERVER["HTTP_REFERER"].'">';
}else{
$clock_in=("Insert into timecard (`employment_id`,`full_name`,`clockin`,`actual_time_in`,`dept`,`rank_rate`, `location`)
Values ('$id','$full_name','$jp_right_time_clockin','$now','$dept','$rate', '$office')");
$clock_input = mysqli_query($conn, $clock_in) or die ("Error Clocking In Into timesheet:".mysqli_error($conn));
echo "<br><br><br><br><center><img src='/unix/img/clok1.gif' height=50 width=50> <h3> $full_name Clocking In from <font color='red'>$location</font> </h3></center>";
echo '<META HTTP-EQUIV=REFRESH CONTENT="2; '.$_SERVER["HTTP_REFERER"].'">';
}
}
?>