first commit 2
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
$sub_menu = '800800';
|
||||
include_once('./_common.php');
|
||||
|
||||
if ($is_admin != 'super') {
|
||||
alert('최고관리자만 접근 가능합니다.');
|
||||
}
|
||||
|
||||
// 결제 상태 업데이트 처리
|
||||
if ($_POST['mode'] == 'update_payment') {
|
||||
$wr_id = (int) $_POST['wr_id'];
|
||||
$payment_status = sql_real_escape_string($_POST['payment_status']);
|
||||
$payment_memo = sql_real_escape_string($_POST['payment_memo']);
|
||||
|
||||
// 결제 상태에 따른 견적 상태 결정
|
||||
$estimate_status_map = [
|
||||
'pending' => '견적채택',
|
||||
'deposit_paid' => '입금확인',
|
||||
'interim_pending' => '중도금입금예정',
|
||||
'interim_paid' => '중도금입금완료',
|
||||
'final_pending' => '잔금입금예정',
|
||||
'final_paid' => '시공완료'
|
||||
];
|
||||
|
||||
$new_estimate_status = $estimate_status_map[$payment_status] ?? '견적채택';
|
||||
|
||||
sql_query("UPDATE estimate SET
|
||||
status = '{$new_estimate_status}',
|
||||
extra_2 = '{$payment_status}',
|
||||
extra_4 = '{$payment_memo}',
|
||||
updated_at = NOW()
|
||||
WHERE wr_id = '{$wr_id}'");
|
||||
|
||||
// 게시판 상태도 업데이트
|
||||
sql_query("UPDATE g5_write_order SET wr_1 = '{$new_estimate_status}' WHERE wr_id = '{$wr_id}'");
|
||||
|
||||
alert('결제 상태가 업데이트되었습니다.', './payment_manager.php');
|
||||
}
|
||||
|
||||
// 결제 대기 중인 견적 목록 조회
|
||||
$sql = "SELECT e.*, w.wr_subject, w.wr_name, w.wr_datetime,
|
||||
(SELECT mb_name FROM g5_member WHERE mb_id = e.extra_4) as selected_dealer_name
|
||||
FROM estimate e
|
||||
JOIN g5_write_order w ON e.wr_id = w.wr_id
|
||||
WHERE e.status IN ('견적채택', '입금확인', '중도금입금예정', '중도금입금완료', '잔금입금예정')
|
||||
AND e.is_deleted = 0
|
||||
ORDER BY
|
||||
CASE e.status
|
||||
WHEN '견적채택' THEN 1
|
||||
WHEN '중도금입금예정' THEN 2
|
||||
WHEN '잔금입금예정' THEN 3
|
||||
ELSE 4
|
||||
END,
|
||||
e.updated_at DESC";
|
||||
$result = sql_query($sql);
|
||||
|
||||
$g5['title'] = '결제 관리';
|
||||
include_once(G5_ADMIN_PATH . '/admin.head.php');
|
||||
?>
|
||||
|
||||
<div class="local_desc01 local_desc">
|
||||
<p>견적 선택 후 결제 진행 상황을 관리합니다.</p>
|
||||
</div>
|
||||
|
||||
<section id="anc_payment_manager">
|
||||
<h2>결제 관리 목록</h2>
|
||||
<div class="tbl_head01 tbl_wrap">
|
||||
<table>
|
||||
<caption>결제 진행 현황</caption>
|
||||
<colgroup>
|
||||
<col style="width:80px">
|
||||
<col>
|
||||
<col style="width:100px">
|
||||
<col style="width:100px">
|
||||
<col style="width:120px">
|
||||
<col style="width:100px">
|
||||
<col style="width:100px">
|
||||
<col style="width:80px">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">번호</th>
|
||||
<th scope="col">제목</th>
|
||||
<th scope="col">고객명</th>
|
||||
<th scope="col">선택된 대리점</th>
|
||||
<th scope="col">견적 상태</th>
|
||||
<th scope="col">결제 상태</th>
|
||||
<th scope="col">결제 금액</th>
|
||||
<th scope="col">관리</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$num = 1;
|
||||
while ($row = sql_fetch_array($result)) {
|
||||
$payment_status = $row['extra_2'] ?: 'pending';
|
||||
$deposit_amount = $row['extra_3'] ?: 0;
|
||||
|
||||
$payment_status_text = [
|
||||
'pending' => '계약금 대기',
|
||||
'deposit_paid' => '계약금 완료',
|
||||
'interim_pending' => '중도금 대기',
|
||||
'interim_paid' => '중도금 완료',
|
||||
'final_pending' => '잔금 대기',
|
||||
'final_paid' => '잔금 완료'
|
||||
];
|
||||
|
||||
$status_class = [
|
||||
'pending' => 'status-pending',
|
||||
'deposit_paid' => 'status-paid',
|
||||
'interim_pending' => 'status-pending',
|
||||
'interim_paid' => 'status-paid',
|
||||
'final_pending' => 'status-pending',
|
||||
'final_paid' => 'status-completed'
|
||||
];
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $num++; ?></td>
|
||||
<td>
|
||||
<a href="<?php echo G5_BBS_URL; ?>/board.php?bo_table=order&wr_id=<?php echo $row['wr_id']; ?>">
|
||||
<?php echo htmlspecialchars($row['wr_subject']); ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo $row['wr_name']; ?></td>
|
||||
<td><?php echo $row['selected_dealer_name'] ?: '-'; ?></td>
|
||||
<td>
|
||||
<span class="estimate-status">
|
||||
<?php echo get_status_display_name($row['status']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="payment-status <?php echo $status_class[$payment_status] ?? ''; ?>">
|
||||
<?php echo $payment_status_text[$payment_status] ?? $payment_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo $deposit_amount ? number_format($deposit_amount) . '원' : '-'; ?></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn_03"
|
||||
onclick="editPayment(<?php echo $row['wr_id']; ?>, '<?php echo $payment_status; ?>')">관리</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if (sql_num_rows($result) == 0) { ?>
|
||||
<tr>
|
||||
<td colspan="8" class="empty_table">결제 대기 중인 견적이 없습니다.</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 결제 관리 모달 -->
|
||||
<div id="paymentModal"
|
||||
style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); background:white; border:2px solid #ccc; padding:20px; z-index:1000; width:500px;">
|
||||
<h3>결제 상태 관리</h3>
|
||||
<form name="paymentForm" method="post" action="./payment_manager.php">
|
||||
<input type="hidden" name="mode" value="update_payment">
|
||||
<input type="hidden" name="wr_id" id="modal_wr_id">
|
||||
|
||||
<table class="tbl_frm01">
|
||||
<tr>
|
||||
<th>결제 상태</th>
|
||||
<td>
|
||||
<select name="payment_status" id="modal_payment_status">
|
||||
<option value="pending">계약금 대기</option>
|
||||
<option value="deposit_paid">계약금 완료</option>
|
||||
<option value="interim_pending">중도금 대기</option>
|
||||
<option value="interim_paid">중도금 완료</option>
|
||||
<option value="final_pending">잔금 대기</option>
|
||||
<option value="final_paid">잔금 완료 (시공완료)</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>관리자 메모</th>
|
||||
<td>
|
||||
<textarea name="payment_memo" id="modal_payment_memo" rows="3" cols="50"
|
||||
placeholder="입금 확인일, 특이사항 등"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div style="text-align:center; margin-top:20px;">
|
||||
<input type="submit" value="저장" class="btn btn_02">
|
||||
<button type="button" onclick="closePaymentModal()" class="btn btn_03">취소</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="paymentModalOverlay"
|
||||
style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:999;"
|
||||
onclick="closePaymentModal()"></div>
|
||||
|
||||
<style>
|
||||
.status-pending {
|
||||
color: #ff6600;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.status-paid {
|
||||
color: #0066cc;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.status-completed {
|
||||
color: #009900;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.estimate-status {
|
||||
background: #f0f0f0;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.payment-status {
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.empty_table {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function editPayment(wr_id, current_status) {
|
||||
document.getElementById('modal_wr_id').value = wr_id;
|
||||
document.getElementById('modal_payment_status').value = current_status;
|
||||
document.getElementById('paymentModal').style.display = 'block';
|
||||
document.getElementById('paymentModalOverlay').style.display = 'block';
|
||||
}
|
||||
|
||||
function closePaymentModal() {
|
||||
document.getElementById('paymentModal').style.display = 'none';
|
||||
document.getElementById('paymentModalOverlay').style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
include_once(G5_ADMIN_PATH . '/admin.tail.php');
|
||||
?>
|
||||
Reference in New Issue
Block a user