first commit

This commit is contained in:
LAPTOP-V9RRD1TL\Michelle's Computer
2025-07-21 21:38:17 +08:00
commit f8f8fcaf96
2529 changed files with 227800 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$employment_id = $array['employment_id'] ;
$date_time = $array['date_time'] ;
$date_group_yest = date('Y-m-d', strtotime($date_time.'-1 days')) ;
$date_group = date('Y-m-d', strtotime($date_time)) ;
$temperature = $array['temperature'] ;
$sn = $array['sn'] ;
if ( $employment_id != '' && $date_time != '' ){
$status = '201' ;
// get staff
$staffs_q = $mysqli->query("SELECT staff_id FROM staff
WHERE deleted_at IS NULL AND staff_idno = '".$employment_id."' LIMIT 1") ;
if ( $staffs_q->num_rows == 0 ){
$mysqli->query("INSERT INTO staff
(staff_idno, staff_name, staff_email, gender_id, staff_icno, staff_passportno, religion_id, ethnic_id, created_at, updated_at) VALUES
('".$employment_id."', '', '', '0', '', '', '0', '0', '".TODAYDATE."', '".TODAYDATE."')") ;
$staff_id = $mysqli->insert_id ;
}else{
$staff = $staffs_q->fetch_assoc() ;
$staff_id = $staff['staff_id'] ;
}
$last_attendance_q = $mysqli->query("SELECT type FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND check_group = '".$date_group_yest."' ORDER BY attendance_id DESC LIMIT 1") ;
$check_type = 'in' ;
if ( $last_attendance_q->num_rows > 0 ){
// check if last attendance is in
$last_attendance = $last_attendance_q->fetch_assoc() ;
if ( $last_attendance['type'] == 'in' ){
$date_group = $date_group_yest ;
$check_type = 'out' ;
}
}
if ( $check_type != 'out' ){
$current_attendance_q = $mysqli->query("SELECT type FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' AND check_group = '".$date_group."' ORDER BY attendance_id DESC LIMIT 1") ;
if ( $current_attendance_q->num_rows > 0 ){
// check if last attendance is in
$current_attendance = $current_attendance_q->fetch_assoc() ;
if ( $current_attendance['type'] == 'in' ){
$check_type = 'out' ;
}
}
}
// check if staff and time exists
$check = $mysqli->query("SELECT * FROM staff_attendance
WHERE record_from = 'machine' AND staff_id = '".$staff_id."' AND created_at = '".$date_time."' LIMIT 1") ;
if ( $check->num_rows == 0 ){
// set information into staff_attendance
if ( $mysqli->query("INSERT INTO staff_attendance
(staff_id, check_group, type, code, record_from, mac_address, ip_address, latitude, longitude, check_area, temperature, created_at, updated_at) VALUES
('".$staff_id."', '".$date_group."', '".$check_type."', '".$sn."', 'machine', '', '', '', '', 'in', '".$temperature."', '".$date_time."', '".$date_time."')") ){
$status = '200' ;
}
}else{
$status = '200' ;
}
}
require( $require_sub.'footer.php' ) ;
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
$must_login = false ;
$require_path = '../../' ;
$require_sub = '../' ;
require( $require_sub.'header.php' ) ;
$status = '201' ;
$select_staff = $mysqli->query( "SELECT staff_id, staff_idno, staff_name, staff_shortname, staff_image, branch_id FROM staff
WHERE deleted_at IS NULL AND ( staff_date_resigned >= '".date( "Y-m-d", time() )."' OR staff_date_resigned = '0000-00-00' OR staff_date_resigned IS NULL ) AND updated_at >= '".date( "Y-m-d H:i:s", strtotime("-1 minutes") )."'" ) ;
if ( $select_staff->num_rows > 0 ){
$status = '200' ;
$array_branch = [] ;
$select_branch = $mysqli->query( "SELECT * FROM branch
WHERE deleted_at IS NULL" ) ;
if ( $select_branch->num_rows > 0 ){
while ( $row_branch = $select_branch->fetch_assoc() ){
$array_branch[$row_branch['branch_id']] = $row_branch ;
}
}
while ( $row_staff = $select_staff->fetch_assoc() ){
$staff_image = ( $row_staff['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_staff['staff_image']) : '' ) ;
$punch_companyid = PUNCHCOMPANYID ;
if ( $row_staff['branch_id'] > 0 ){
if ( arrayCheck( $array_branch[$row_staff['branch_id']] ) ){
if ( $array_branch[$row_staff['branch_id']]['branch_binding_id'] > 0 ){
$punch_companyid = $array_branch[$row_staff['branch_id']]['branch_binding_id'] ;
}
}
}
call( 'curl', PUNCHURL.'/api/user.php', 'POST', [], [
'company_id' => $punch_companyid,
'staff_idno' => $row_staff['staff_idno'],
'staff_name' => $row_staff['staff_name'],
'staff_shortname' => $row_staff['staff_shortname'],
'staff_image' => $staff_image
] ) ;
}
}
require( $require_sub.'footer.php' ) ;
?>