초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
43
instock/fetch_code.php
Normal file
43
instock/fetch_code.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
header('Content-Type: application/json'); // JSON 반환 헤더 추가
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$mode = $_POST['mode'] ?? '';
|
||||
$item_name = $_POST['item_name'] ?? '';
|
||||
|
||||
if ($mode === 'fetch_specifications' && $item_name) {
|
||||
$sql = "SELECT specification FROM {$DB}.instock WHERE item_name = ? AND is_deleted IS NULL";
|
||||
try {
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute([$item_name]);
|
||||
$result = $stmh->fetchAll(PDO::FETCH_COLUMN); // 컬럼 값만 배열로 가져옴
|
||||
|
||||
// '전동개폐기'인 경우 '2000KG380V(유선)' 등 추가
|
||||
if ($item_name === '전동개폐기') {
|
||||
$result[] = '2000KG380V(유선)';
|
||||
$result[] = '2000KG380V(무선)';
|
||||
$result[] = '400KG380V(무선)';
|
||||
$result[] = '500KG380V(유선)';
|
||||
$result[] = '1000KG380V(유선)';
|
||||
$result[] = '1500KG380V(유선)';
|
||||
}
|
||||
|
||||
// 'GI0.5T'인 경우 '1219*1219' 추가
|
||||
if ($item_name === 'GI0.5T') {
|
||||
$result[] = '1219*1219';
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
echo json_encode(['success' => true, 'data' => $result]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'No matching data found']);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid request parameters']);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user