Files
sam-kd/eworks/saveRefLine.php
hskwon aca1767eb9 초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경
- DB 연결 하드코딩 → .env 기반으로 변경
- MySQL strict mode DATE 오류 수정
2025-12-10 20:14:31 +09:00

32 lines
1022 B
PHP

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
// JSON 데이터 수신
$data = json_decode(file_get_contents('php://input'), true);
// 파일 경로 설정
$filePath = './RefLine/RefLine_' . $data['userId'] . '.json';
// 파일이 이미 존재하면 기존 데이터를 로드하고, 존재하지 않으면 새 배열을 생성
if(file_exists($filePath)) {
$existingData = json_decode(file_get_contents($filePath), true);
if (!is_array($existingData)) { // 기존 데이터가 배열이 아니면 새 배열 생성
$existingData = array();
}
} else {
$existingData = array();
}
// 새로운 결재라인 정보를 기존 데이터에 추가
$existingData[] = array(
'userId' => $data['userId'],
'savedName' => $data['savedName'],
'RefOrder' => $data['RefOrder']
);
// 파일에 수정된 데이터 저장
file_put_contents($filePath, json_encode($existingData));
echo json_encode(array('status' => 'success', 'message' => 'Ref line saved successfully.'));
?>