58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', 1);
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
/* =========================
|
|
로그인 / 권한 가드
|
|
========================= */
|
|
require_once __DIR__ . '/adm_guard.php';
|
|
require_once __DIR__ . '/db_conn.php';
|
|
|
|
/* =========================
|
|
세션 기준 값
|
|
========================= */
|
|
$login = $_SESSION['login'];
|
|
$auth_bc = $login['auth_bc']; // 권한코드
|
|
$member_id = $login['member_id']; // 회사ID
|
|
$user_id = $login['user_id'] ?? 'SYSTEM';
|
|
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', 1);
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
// JSON 데이터 읽기
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
|
|
try {
|
|
// 2. $pdo 변수가 있는지 확인 (DB 연결 확인)
|
|
if (!isset($pdo)) {
|
|
throw new Exception('데이터베이스 연결 설정($pdo)을 찾을 수 없습니다.');
|
|
}
|
|
|
|
$ids = $input['ids'] ?? [];
|
|
if (empty($ids)) {
|
|
throw new Exception('삭제 대상이 없습니다.');
|
|
}
|
|
|
|
$pdo->beginTransaction();
|
|
|
|
// 3. 삭제 실행
|
|
$stmt = $pdo->prepare("SELECT kngil.sp_item_d(:itm_cd)");
|
|
|
|
foreach ($ids as $code) {
|
|
$stmt->execute([':itm_cd' => $code]);
|
|
}
|
|
|
|
$pdo->commit();
|
|
echo json_encode(['status' => 'success']);
|
|
|
|
} catch (Exception $e) {
|
|
if (isset($pdo) && $pdo->inTransaction()) {
|
|
$pdo->rollBack();
|
|
}
|
|
// 기존 출력물 제거 후 깨끗한 JSON만 출력
|
|
if (ob_get_length()) ob_clean();
|
|
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
|
|
}
|
|
?>
|