$_POST['steel'] ?? '0', 'motor' => $_POST['motor'] ?? '0', 'warranty' => $_POST['warranty'] ?? '', 'slatcheck' => $_POST['slatcheck'] ?? '0', 'partscheck' => $_POST['partscheck'] ?? '0' ]; if ($type === '스크린') { // 스크린 계산 로직 require_once $_SERVER['DOCUMENT_ROOT'].'/estimate/get_screen_amount.php'; if (empty($estimateList)) { throw new Exception('스크린 견적 데이터(estimateList)가 없습니다.'); } $details = json_decode((string)$estimateList, true); if (!is_array($details)) { throw new Exception('스크린 JSON 파싱 오류: ' . json_last_error_msg()); } $result = calculateScreenAmount($details, $inspectionFee, $pdo, $checkboxOptions); } elseif ($type === '철재') { // 슬랫 계산 로직 require_once $_SERVER['DOCUMENT_ROOT'].'/estimate/get_slat_amount.php'; if (empty($estimateSlatList)) { throw new Exception('철재 견적 데이터(estimateSlatList)가 없습니다.'); } $details = json_decode((string)$estimateSlatList, true); if (!is_array($details)) { throw new Exception('철재 JSON 파싱 오류: ' . json_last_error_msg()); } $result = calculateSlatAmount($details, $inspectionFee, $pdo, $checkboxOptions); } else { throw new Exception("알 수 없는 type 값: {$type}"); } // error_log("계산 결과: " . print_r($result, true)); // JSON 응답 전송 전에 출력 버퍼 정리 if (ob_get_length()) ob_clean(); echo json_encode([ 'success' => true, 'data' => $result, ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } catch (Exception $e) { error_log("get_estimate_amount ERROR: " . $e->getMessage()); // JSON 응답 전송 전에 출력 버퍼 정리 if (ob_get_length()) ob_clean(); echo json_encode([ 'success' => false, 'error' => $e->getMessage(), ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); }