diff --git a/PHPExcel_1.8.0/Classes/PHPExcel/Shared/PDF/fonts/utils/pfm2afm.exe b/PHPExcel_1.8.0/Classes/PHPExcel/Shared/PDF/fonts/utils/pfm2afm.exe deleted file mode 100644 index 25c21fa1..00000000 Binary files a/PHPExcel_1.8.0/Classes/PHPExcel/Shared/PDF/fonts/utils/pfm2afm.exe and /dev/null differ diff --git a/geoattendance/fix_geo_db.php b/geoattendance/fix_geo_db.php new file mode 100644 index 00000000..97f5c1cf --- /dev/null +++ b/geoattendance/fix_geo_db.php @@ -0,0 +1,37 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // 1. Check for ID 0 and move it if exists + // We use a subquery to find a safe new ID + echo "Checking for ID 0...\n"; + $stmt = $pdo->query("SELECT count(*) FROM geo_attendance WHERE id = 0"); + if ($stmt->fetchColumn() > 0) { + echo " - Found row with ID 0. Moving it to a new ID...\n"; + // Calculate max id + 1 + $stmt = $pdo->query("SELECT MAX(id) FROM geo_attendance"); + $maxId = $stmt->fetchColumn(); + $newId = ($maxId > 0 ? $maxId : 0) + 1; + + $pdo->exec("UPDATE geo_attendance SET id = $newId WHERE id = 0"); + echo " - ID 0 moved to $newId.\n"; + } + + // 2. Apply AUTO_INCREMENT + echo "Applying AUTO_INCREMENT to 'id' column...\n"; + $sql = "ALTER TABLE geo_attendance MODIFY id INT NOT NULL AUTO_INCREMENT"; + $pdo->exec($sql); + echo " - Success! 'geo_attendance.id' is now AUTO_INCREMENT.\n"; + +} catch (Exception $e) { + echo "Error: " . $e->getMessage() . "\n"; +} +?> diff --git a/geoattendance/index.php b/geoattendance/index.php index ada992fb..8d9bc59c 100644 --- a/geoattendance/index.php +++ b/geoattendance/index.php @@ -3,7 +3,7 @@ - SAM GeoWork - GPS 기반 출퇴근 시스템 + SAM GPS 기반 출퇴근 시스템 @@ -161,6 +161,9 @@ const [distance, setDistance] = useState(null); const [activeTab, setActiveTab] = useState('home'); + const [permissionStatus, setPermissionStatus] = useState('unknown'); + const [isSecure, setIsSecure] = useState(window.isSecureContext); + useEffect(() => { lucide.createIcons(); }, [activeTab, records]); @@ -169,31 +172,79 @@ useEffect(() => { loadRecords(); loadOfficeConfig(); + checkPermission(); }, []); - // Start watching location - useEffect(() => { - if ('geolocation' in navigator) { - const watchId = navigator.geolocation.watchPosition( - (position) => { - const newLoc = { - latitude: position.coords.latitude, - longitude: position.coords.longitude, - accuracy: position.coords.accuracy - }; - setCurrentLocation(newLoc); - setErrorMsg(null); - }, - (err) => { - console.error(err); - setErrorMsg("Unable to retrieve location. Please enable GPS."); - }, - { enableHighAccuracy: true, maximumAge: 10000, timeout: 5000 } - ); - return () => navigator.geolocation.clearWatch(watchId); - } else { - setErrorMsg("Geolocation is not supported by your browser."); + const checkPermission = async () => { + if (navigator.permissions && navigator.permissions.query) { + try { + const result = await navigator.permissions.query({ name: 'geolocation' }); + setPermissionStatus(result.state); + result.onchange = () => { + setPermissionStatus(result.state); + }; + } catch (error) { + console.error("Permission query failed", error); + } } + }; + + // Start watching location with fallback logic + useEffect(() => { + let watchId = null; + + const startWatch = (highAccuracy = true) => { + if (watchId) navigator.geolocation.clearWatch(watchId); + + if ('geolocation' in navigator) { + watchId = navigator.geolocation.watchPosition( + (position) => { + const newLoc = { + latitude: position.coords.latitude, + longitude: position.coords.longitude, + accuracy: position.coords.accuracy + }; + setCurrentLocation(newLoc); + setErrorMsg(null); + }, + (err) => { + console.error(err); + + // On Timeout (code 3) and currently using High Accuracy, try fallback + if (err.code === 3 && highAccuracy) { + console.warn("High accuracy timed out. Falling back to low accuracy."); + startWatch(false); + return; + } + + let msg = "위치를 가져올 수 없습니다."; + switch(err.code) { + case 1: msg = "위치 정보 권한이 거부되었습니다. 브라우저 설정에서 권한을 허용해주세요."; break; + case 2: msg = "위치 정보를 사용할 수 없습니다. GPS 신호를 확인해주세요."; break; + case 3: msg = "위치 정보 요청 시간이 초과되었습니다. (Low Accuracy 시도 실패)"; break; + default: msg = "알 수 없는 오류가 발생했습니다. (" + err.message + ")"; break; + } + if (window.location.protocol !== 'https:' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') { + msg += " (주의: 보안 연결(HTTPS)이 아니면 위치 정보가 차단될 수 있습니다)"; + } + setErrorMsg(msg); + }, + { + enableHighAccuracy: highAccuracy, + maximumAge: 10000, + timeout: 15000 // 15 seconds timeout + } + ); + } else { + setErrorMsg("Geolocation is not supported by your browser."); + } + }; + + startWatch(true); // Start with High Accuracy + + return () => { + if (watchId) navigator.geolocation.clearWatch(watchId); + }; }, []); // Recalculate distance when location or office changes @@ -437,8 +488,25 @@
-

디버그 정보

-
+

시스템 상태 확인

+
+
+ GPS 권한: + + {permissionStatus === 'granted' ? '허용됨' : permissionStatus === 'prompt' ? '대기중(물어봄)' : '거부됨'} + +
+
+ 보안 연결(HTTPS): + + {isSecure ? '안전함' : '불안전(HTTP)'} + +
+ {!isSecure && ( +

+ 주의: HTTPS가 아니면 최신 브라우저에서 GPS가 차단됩니다. +

+ )}

거리: {distance ? distance.toFixed(1) : '알 수 없음'} 미터

반경 제한: {office.allowedRadiusMeters} 미터

GPS 정확도: {currentLocation?.accuracy ? currentLocation.accuracy.toFixed(1) + 'm' : '알 수 없음'}

diff --git a/holiday/list.php b/holiday/list.php index 09a4916d..d1bfec65 100644 --- a/holiday/list.php +++ b/holiday/list.php @@ -41,13 +41,14 @@ function checkNull($strtmp) { $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; $mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : ''; +$sort_order = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : 'DESC'; $tablename = 'holiday'; require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php"); $pdo = db_connect(); -$order = " ORDER BY registedate DESC, num desc "; +$order = " ORDER BY startdate " . ($sort_order === 'ASC' ? 'ASC' : 'DESC') . ", num desc "; if (checkNull($search)) { $sql = "SELECT * FROM ".$DB.".".$tablename." @@ -65,7 +66,8 @@ try { - + +
@@ -112,7 +114,9 @@ try { - + @@ -179,6 +183,15 @@ $(document).ready(function() { $("#searchBtn").on("click", function() { $("#board_form").submit(); }); + + // 휴일시작 헤더 클릭 시 정렬 토글 + $("#sortStartDate").on("click", function(e) { + e.stopPropagation(); + var currentOrder = $("#sort_order").val(); + var newOrder = (currentOrder === 'DESC') ? 'ASC' : 'DESC'; + $("#sort_order").val(newOrder); + $("#board_form").submit(); + }); }); function loadForm(mode, num = null) { diff --git a/img/uploads/2019_11_15_15_31_48_.JPG b/img/uploads/2019_11_15_15_31_48_.JPG new file mode 100644 index 00000000..c95ae672 Binary files /dev/null and b/img/uploads/2019_11_15_15_31_48_.JPG differ diff --git a/img/uploads/2019_11_15_15_38_20_.JPG b/img/uploads/2019_11_15_15_38_20_.JPG new file mode 100644 index 00000000..3b1d3728 Binary files /dev/null and b/img/uploads/2019_11_15_15_38_20_.JPG differ diff --git a/img/uploads/2019_11_15_15_42_26_.JPG b/img/uploads/2019_11_15_15_42_26_.JPG new file mode 100644 index 00000000..9ad0d29c Binary files /dev/null and b/img/uploads/2019_11_15_15_42_26_.JPG differ diff --git a/img/uploads/2019_11_15_15_43_33_.JPG b/img/uploads/2019_11_15_15_43_33_.JPG new file mode 100644 index 00000000..d3f945e6 Binary files /dev/null and b/img/uploads/2019_11_15_15_43_33_.JPG differ diff --git a/img/uploads/2019_11_15_15_48_30_.JPG b/img/uploads/2019_11_15_15_48_30_.JPG new file mode 100644 index 00000000..1655ee95 Binary files /dev/null and b/img/uploads/2019_11_15_15_48_30_.JPG differ diff --git a/img/uploads/2019_11_15_15_50_51_.JPG b/img/uploads/2019_11_15_15_50_51_.JPG new file mode 100644 index 00000000..61aa82ce Binary files /dev/null and b/img/uploads/2019_11_15_15_50_51_.JPG differ diff --git a/output/debug_schema.php b/output/debug_schema.php new file mode 100644 index 00000000..e6e9c19e --- /dev/null +++ b/output/debug_schema.php @@ -0,0 +1,12 @@ +query("SHOW COLUMNS FROM output LIKE 'num'"); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + print_r($row); +} catch (Exception $e) { + echo "Error: " . $e->getMessage(); +} +?> diff --git a/output/fix_db_autoincrement.php b/output/fix_db_autoincrement.php new file mode 100644 index 00000000..c17ccf12 --- /dev/null +++ b/output/fix_db_autoincrement.php @@ -0,0 +1,54 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $DB = 'chandj'; + + // 1. Fix output table + echo "Fixing 'output' table...\n"; + // Check if auto_increment exists or just try to apply it + // Usually 'MODIFY num INT AUTO_INCREMENT' works. Assuming 'num' is int. + // We also need to make sure we don't break existing keys. + // Safest is "MODIFY num INT NOT NULL AUTO_INCREMENT" + $sql = "ALTER TABLE {$DB}.output MODIFY num INT NOT NULL AUTO_INCREMENT"; + $pdo->exec($sql); + echo " - 'output.num' set to AUTO_INCREMENT successfully.\n"; + +} catch (Exception $e) { + echo " - Error fixing 'output': " . $e->getMessage() . "\n"; +} + +try { + // 2. Fix geo_attendance table + // First, find the primary key column name + echo "Fixing 'geo_attendance' table...\n"; + $stmt = $pdo->query("SHOW KEYS FROM {$DB}.geo_attendance WHERE Key_name = 'PRIMARY'"); + $pk = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($pk) { + $pkColumn = $pk['Column_name']; + echo " - Found Primary Key column: $pkColumn\n"; + + $sql = "ALTER TABLE {$DB}.geo_attendance MODIFY $pkColumn INT NOT NULL AUTO_INCREMENT"; + $pdo->exec($sql); + echo " - 'geo_attendance.$pkColumn' set to AUTO_INCREMENT successfully.\n"; + } else { + echo " - Could not find Primary Key for geo_attendance.\n"; + } + +} catch (Exception $e) { + echo " - Error fixing 'geo_attendance': " . $e->getMessage() . "\n"; +} + +echo "Done.\n"; +?> diff --git a/output/insert.php b/output/insert.php index e5ad42b1..dcbfc304 100644 --- a/output/insert.php +++ b/output/insert.php @@ -1,12 +1,12 @@ - beginTransaction(); @@ -178,6 +181,7 @@ try { ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmh = $pdo->prepare($sql); + $stmh->execute([ $outdate, $indate, $orderman, $outworkplace, $outputplace, $receiver, $phone, $comment, $con_num, $root, @@ -291,7 +295,8 @@ try { $pdo->commit(); } catch (Exception $ex) { $pdo->rollBack(); - print "오류: ".$Exception->getMessage(); + // print "오류: ".$Exception->getMessage(); + throw new Exception($ex->getMessage()); } } @@ -317,7 +322,8 @@ try { $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); - print "오류: ".$Exception->getMessage(); + // print "오류: ".$Exception->getMessage(); + throw new Exception($Exception->getMessage()); } } diff --git a/output/lotnum.txt b/output/lotnum.txt index 961636ae..d3c36ef4 100644 --- a/output/lotnum.txt +++ b/output/lotnum.txt @@ -1 +1 @@ -250717-02 \ No newline at end of file +251214-03 \ No newline at end of file diff --git a/session.php b/session.php index db8fc068..96935153 100644 --- a/session.php +++ b/session.php @@ -31,6 +31,9 @@ $first_approval_id = $_SESSION["first_approval_id"] ?? ''; $first_approval_name = $_SESSION["first_approval_name"] ?? ''; // APP_URL 기반 동적 URL 설정 -$root_dir = rtrim($_ENV['APP_URL'] ?? 'https://5130.co.kr', '/'); +// APP_URL 기반 동적 URL 설정 +// $root_dir = rtrim($_ENV['APP_URL'] ?? 'https://5130.co.kr', '/'); +$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? "https://" : "http://"; +$root_dir = $protocol . $_SERVER['HTTP_HOST']; $WebSite = $root_dir . '/'; ?> \ No newline at end of file
번호휴일시작휴일시작 + + 휴일종료 기간체크 내용