114 lines
3.5 KiB
PHP
114 lines
3.5 KiB
PHP
<?php
|
|
include_once('./_common.php');
|
|
|
|
// 관리자 권한 확인
|
|
if (!$is_admin) {
|
|
die(json_encode(['success' => false, 'message' => '관리자 권한이 필요합니다.']));
|
|
}
|
|
|
|
// EstimateManager 로드
|
|
require_once G5_PATH . '/adm/order_manage/classes/EstimateManager.class.php';
|
|
$estimate_manager = new EstimateManager();
|
|
|
|
$action = isset($_REQUEST['action']) ? clean_xss_tags($_REQUEST['action']) : '';
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
try {
|
|
switch ($action) {
|
|
case 'confirm_payment':
|
|
$wr_id = (int) ($_POST['wr_id'] ?? 0);
|
|
if (!$wr_id) {
|
|
throw new Exception('견적 ID가 필요합니다.');
|
|
}
|
|
|
|
$result = $estimate_manager->confirmExpertVisitPayment($wr_id, 'admin');
|
|
|
|
if (!$result['success']) {
|
|
throw new Exception($result['message']);
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'message' => '전문가 방문 비용 결제가 확인되었습니다.',
|
|
'data' => $result['data']
|
|
]);
|
|
break;
|
|
|
|
case 'schedule_visit':
|
|
$wr_id = (int) ($_POST['wr_id'] ?? 0);
|
|
$visit_datetime = clean_xss_tags($_POST['visit_datetime'] ?? '');
|
|
$expert_id = clean_xss_tags($_POST['expert_id'] ?? '');
|
|
|
|
if (!$wr_id || !$visit_datetime) {
|
|
throw new Exception('필수 정보가 누락되었습니다.');
|
|
}
|
|
|
|
// 날짜 형식 변환 (datetime-local -> Y-m-d H:i)
|
|
$visit_datetime = date('Y-m-d H:i', strtotime($visit_datetime));
|
|
|
|
$result = $estimate_manager->scheduleExpertVisit($wr_id, $visit_datetime, $expert_id, 'admin');
|
|
|
|
if (!$result['success']) {
|
|
throw new Exception($result['message']);
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'message' => '전문가 방문 일정이 설정되었습니다.',
|
|
'data' => $result['data']
|
|
]);
|
|
break;
|
|
|
|
case 'complete_visit':
|
|
$wr_id = (int) ($_POST['wr_id'] ?? 0);
|
|
$visit_notes = clean_xss_tags($_POST['visit_notes'] ?? '');
|
|
|
|
if (!$wr_id) {
|
|
throw new Exception('견적 ID가 필요합니다.');
|
|
}
|
|
|
|
$result = $estimate_manager->completeExpertVisit($wr_id, $visit_notes, 'admin');
|
|
|
|
if (!$result['success']) {
|
|
throw new Exception($result['message']);
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'message' => '전문가 방문이 완료 처리되었습니다.',
|
|
'data' => $result['data']
|
|
]);
|
|
break;
|
|
|
|
case 'get_visit_info':
|
|
$wr_id = (int) ($_GET['wr_id'] ?? 0);
|
|
if (!$wr_id) {
|
|
throw new Exception('견적 ID가 필요합니다.');
|
|
}
|
|
|
|
$visit_info = $estimate_manager->getExpertVisitInfo($wr_id);
|
|
|
|
if (!$visit_info) {
|
|
throw new Exception('전문가 방문 정보를 찾을 수 없습니다.');
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'data' => $visit_info
|
|
]);
|
|
break;
|
|
|
|
default:
|
|
throw new Exception('유효하지 않은 액션입니다.');
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
error_log("expert_visits_ajax.php Error: " . $e->getMessage());
|
|
|
|
echo json_encode([
|
|
'success' => false,
|
|
'message' => $e->getMessage()
|
|
]);
|
|
}
|
|
?>
|