초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
40
acigroup/save_groupcode.php
Normal file
40
acigroup/save_groupcode.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// 필수 파라미터 체크
|
||||
if (!isset($_POST['groupCode']) || !isset($_POST['groupName']) || !isset($_POST['orders'])) {
|
||||
echo json_encode(['error' => '필수 데이터가 누락되었습니다.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$groupCode = $_POST['groupCode'];
|
||||
$groupName = $_POST['groupName'];
|
||||
$orders = $_POST['orders']; // 체크박스로 선택한 수주번호 배열
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// 각 수주번호에 대해 update 쿼리 실행
|
||||
$sql = "UPDATE {$DB}.output SET ACIgroupCode = ?, ACIgroupName = ? WHERE num = ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
foreach ($orders as $orderNum) {
|
||||
$stmt->execute([$groupCode, $groupName, $orderNum]);
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
echo json_encode(['status' => 'success']);
|
||||
} catch (PDOException $e) {
|
||||
$pdo->rollBack();
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user