171 lines
6.7 KiB
PHP
171 lines
6.7 KiB
PHP
<?php
|
|
$sub_menu = "800700";
|
|
include_once('./_common.php');
|
|
|
|
auth_check_menu($auth, $sub_menu, 'r');
|
|
|
|
$g5['title'] = 'StatusManager 테스트';
|
|
|
|
// StatusManager 클래스 로드
|
|
require_once G5_PATH . '/adm/order_manage/classes/StatusManager.class.php';
|
|
|
|
$status_manager = new StatusManager();
|
|
$test_results = [];
|
|
|
|
// 테스트 실행
|
|
if ($_POST['action'] === 'test') {
|
|
$wr_id = (int) $_POST['wr_id'];
|
|
$new_status = trim($_POST['new_status']);
|
|
$user_role = trim($_POST['user_role']);
|
|
$user_id = $member['mb_id'];
|
|
|
|
if ($wr_id && $new_status && $user_role) {
|
|
$result = $status_manager->changeStatus($wr_id, $new_status, $user_id, $user_role, 'StatusManager 테스트');
|
|
$test_results[] = $result;
|
|
}
|
|
}
|
|
|
|
// 최근 견적 목록 조회 (테스트용)
|
|
$recent_estimates = [];
|
|
$sql = "
|
|
SELECT w.wr_id, w.wr_subject, w.mb_id, e.status, e.updated_at
|
|
FROM {$g5['write_prefix']}order w
|
|
LEFT JOIN estimate e ON w.wr_id = e.wr_id
|
|
WHERE w.wr_parent = 0
|
|
ORDER BY w.wr_datetime DESC
|
|
LIMIT 10
|
|
";
|
|
$result = sql_query($sql);
|
|
while ($row = sql_fetch_array($result)) {
|
|
$recent_estimates[] = $row;
|
|
}
|
|
|
|
include_once(G5_ADMIN_PATH . '/admin.head.php');
|
|
?>
|
|
|
|
<div class="local_desc01 local_desc">
|
|
<p>
|
|
StatusManager 클래스의 상태 변경 기능을 테스트합니다.<br>
|
|
실제 데이터가 변경되므로 주의해서 사용하세요.
|
|
</p>
|
|
</div>
|
|
|
|
<?php if (!empty($test_results)): ?>
|
|
<div class="local_desc02 local_desc">
|
|
<h3>테스트 결과</h3>
|
|
<?php foreach ($test_results as $result): ?>
|
|
<div
|
|
style="padding: 10px; margin: 10px 0; border: 1px solid <?php echo $result['success'] ? '#28a745' : '#dc3545'; ?>; background: <?php echo $result['success'] ? '#d4edda' : '#f8d7da'; ?>;">
|
|
<strong><?php echo $result['success'] ? '성공' : '실패'; ?>:</strong>
|
|
<?php echo htmlspecialchars($result['message']); ?>
|
|
<?php if (isset($result['data'])): ?>
|
|
<br><small>변경 내용: <?php echo htmlspecialchars(json_encode($result['data'], JSON_UNESCAPED_UNICODE)); ?></small>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form name="ftest" method="post" action="./status_test.php">
|
|
<input type="hidden" name="action" value="test">
|
|
|
|
<div class="tbl_frm01 tbl_wrap">
|
|
<table>
|
|
<caption>StatusManager 테스트</caption>
|
|
<colgroup>
|
|
<col class="grid_4">
|
|
<col>
|
|
</colgroup>
|
|
<tbody>
|
|
<tr>
|
|
<th scope="row"><label for="wr_id">게시물 ID</label></th>
|
|
<td>
|
|
<select name="wr_id" id="wr_id" class="frm_input">
|
|
<option value="">선택하세요</option>
|
|
<?php foreach ($recent_estimates as $estimate): ?>
|
|
<option value="<?php echo $estimate['wr_id']; ?>">
|
|
<?php echo $estimate['wr_id']; ?> -
|
|
<?php echo htmlspecialchars($estimate['wr_subject']); ?>
|
|
(현재: <?php echo $estimate['status'] ?: '견적신청중'; ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><label for="new_status">새 상태</label></th>
|
|
<td>
|
|
<select name="new_status" id="new_status" class="frm_input">
|
|
<option value="">선택하세요</option>
|
|
<option value="견적신청중">견적신청중</option>
|
|
<option value="작성완료">작성완료</option>
|
|
<option value="견적채택">견적채택</option>
|
|
<option value="입금예정">입금예정</option>
|
|
<option value="입금확인">입금확인</option>
|
|
<option value="다운로드">다운로드</option>
|
|
<option value="견적제안">견적제안</option>
|
|
<option value="견적취소">견적취소</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><label for="user_role">사용자 역할</label></th>
|
|
<td>
|
|
<select name="user_role" id="user_role" class="frm_input">
|
|
<option value="">선택하세요</option>
|
|
<option value="admin">관리자</option>
|
|
<option value="customer">고객</option>
|
|
<option value="agent">대리점</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="btn_confirm01 btn_confirm">
|
|
<input type="submit" value="상태 변경 테스트" class="btn_submit">
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div class="local_desc02 local_desc">
|
|
<h3>최근 견적 목록</h3>
|
|
<table class="tbl_head01 tbl_wrap">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>제목</th>
|
|
<th>작성자</th>
|
|
<th>현재 상태</th>
|
|
<th>수정일</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($recent_estimates as $estimate): ?>
|
|
<tr>
|
|
<td><?php echo $estimate['wr_id']; ?></td>
|
|
<td><?php echo htmlspecialchars($estimate['wr_subject']); ?></td>
|
|
<td><?php echo htmlspecialchars($estimate['mb_id']); ?></td>
|
|
<td><?php echo $estimate['status'] ?: '견적신청중'; ?></td>
|
|
<td><?php echo $estimate['updated_at'] ?: '-'; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="local_desc02 local_desc">
|
|
<h3>StatusManager 주요 기능</h3>
|
|
<ul>
|
|
<li><strong>상태 전환 검증:</strong> 사용자 권한별 허용된 상태 변경만 가능</li>
|
|
<li><strong>비즈니스 규칙 검증:</strong> 24시간 제한, 중복 선택 방지 등</li>
|
|
<li><strong>자동 이력 기록:</strong> 모든 상태 변경이 estimate_history에 기록</li>
|
|
<li><strong>후속 처리:</strong> 알림 발송, 자동 상태 전환, 다른 견적 취소 등</li>
|
|
<li><strong>트랜잭션 처리:</strong> 오류 발생 시 자동 롤백</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<?php
|
|
include_once(G5_ADMIN_PATH . '/admin.tail.php');
|
|
?>
|