| Server IP : 172.67.187.206 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/work/ |
Upload File : |
<?php
/**
* ไฟล์ลงเวลาเข้างาน (CLI) [cite: 2025-07-09]
*/
require_once 'config.php';
require_once 'functions.php';
$target_u_id = 49;
$today = date('Y-m-d');
$time_now = date('H:i:s');
$location = 'office';
$detail = 'ปฏิบัติงานในสำนักงาน';
// ตรวจสอบว่าวันนี้ลงเวลาเข้าหรือยัง
$sql_check = "SELECT * FROM attendance WHERE u_id = '$target_u_id' AND att_date = '$today'";
$res_check = mysqli_query($conn, $sql_check);
if (mysqli_num_rows($res_check) == 0) {
// ยังไม่มีข้อมูล ให้บันทึกเข้างานใหม่ (เวลากลับเป็นค่าว่าง) [cite: 2025-07-09]
$sql_insert = "INSERT INTO attendance (u_id, att_date, time_in, time_out, work_location, work_detail)
VALUES ('$target_u_id', '$today', '$time_now', '00:00:00', '$location', '$detail')";
if (mysqli_query($conn, $sql_insert)) {
echo "[SUCCESS] Checked-in: ID $target_u_id at $time_now\n";
} else {
echo "[ERROR] " . mysqli_error($conn) . "\n";
}
} else {
echo "[INFO] Already checked-in for today.\n";
}
?>