feat:수당지급일 입력 시 개발상태 인계 여부 검증 안전장치 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -292,9 +292,18 @@ public function updateCommissionDate(int $id, Request $request)
|
||||
$field = $request->input('field');
|
||||
$date = $request->input('date') ?: now()->format('Y-m-d');
|
||||
|
||||
// 수당지급일 필드는 개발상태가 '인계'일 때만 저장 가능
|
||||
$paidFields = ['first_partner_paid_at', 'second_partner_paid_at', 'manager_paid_at'];
|
||||
if (in_array($field, $paidFields) && $management->hq_status !== 'handover') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '개발상태가 인계일 때만 수당이 지급됩니다.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$updateData = [$field => $date];
|
||||
|
||||
// 납입일 입력 시 수당지급일 자동 계산 (익월 10일)
|
||||
// 납입일 입력 시 수당지급일 자동 계산 (익월 10일) - 인계 상태일 때만
|
||||
$autoFields = [
|
||||
'first_payment_at' => 'first_partner_paid_at',
|
||||
'second_payment_at' => 'second_partner_paid_at',
|
||||
@@ -302,7 +311,7 @@ public function updateCommissionDate(int $id, Request $request)
|
||||
|
||||
$autoField = null;
|
||||
$autoDate = null;
|
||||
if (isset($autoFields[$field])) {
|
||||
if (isset($autoFields[$field]) && $management->hq_status === 'handover') {
|
||||
$autoField = $autoFields[$field];
|
||||
$autoDate = \Carbon\Carbon::parse($date)->addMonth()->day(10)->format('Y-m-d');
|
||||
$updateData[$autoField] = $autoDate;
|
||||
|
||||
@@ -52,6 +52,27 @@ class="refresh-btn inline-flex items-center gap-1.5 px-4 py-2 text-sm text-gray-
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 인계 상태 경고 모달 -->
|
||||
<div id="handoverWarningModal" class="hidden fixed inset-0 z-50 overflow-y-auto">
|
||||
<div class="fixed inset-0 bg-black bg-opacity-50 transition-opacity" onclick="closeHandoverWarningModal()"></div>
|
||||
<div class="flex min-h-full items-center justify-center p-4">
|
||||
<div class="relative bg-white rounded-xl shadow-2xl w-full max-w-sm p-6">
|
||||
<div class="text-center">
|
||||
<div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-amber-100 mb-4">
|
||||
<svg class="h-6 w-6 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-lg font-bold text-gray-900 mb-3">수당 지급 불가</h3>
|
||||
<p class="text-sm text-gray-600 mb-6">개발상태가 <span class="font-semibold text-emerald-600">인계</span>일 때만<br>수당이 지급됩니다.</p>
|
||||
</div>
|
||||
<button type="button" onclick="closeHandoverWarningModal()" class="w-full px-4 py-2.5 text-sm font-medium text-white bg-gray-700 hover:bg-gray-800 rounded-lg transition">
|
||||
확인
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 삭제 확인 모달 -->
|
||||
@if(auth()->user()->isSuperAdmin())
|
||||
<div id="deleteModal" class="hidden fixed inset-0 z-50 overflow-y-auto">
|
||||
@@ -244,6 +265,30 @@ function confirmDelete() {
|
||||
});
|
||||
}
|
||||
|
||||
// 인계 상태 체크 (수당지급 필드만)
|
||||
const commissionPaidFields = ['first_partner_paid_at', 'second_partner_paid_at', 'manager_paid_at'];
|
||||
|
||||
function checkHandoverStatus(prospectId, field) {
|
||||
if (!commissionPaidFields.includes(field)) return true;
|
||||
|
||||
const hqSelect = document.querySelector(`select[data-hq-status="${prospectId}"]`);
|
||||
if (hqSelect && hqSelect.value !== 'handover') {
|
||||
openHandoverWarningModal();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function openHandoverWarningModal() {
|
||||
document.getElementById('handoverWarningModal').classList.remove('hidden');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function closeHandoverWarningModal() {
|
||||
document.getElementById('handoverWarningModal').classList.add('hidden');
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
// 수당 날짜 저장 (date input에서 호출)
|
||||
function saveCommissionDate(prospectId, field, date) {
|
||||
const input = document.querySelector(`input[data-prospect-id="${prospectId}"][data-field="${field}"]`);
|
||||
@@ -254,6 +299,12 @@ function saveCommissionDate(prospectId, field, date) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 수당지급일 입력 시 인계 상태 체크
|
||||
if (!checkHandoverStatus(prospectId, field)) {
|
||||
input.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/sales/admin-prospects/${prospectId}/commission-date`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -192,6 +192,7 @@ class="w-28 h-7 text-xs px-1 border-2 border-gray-300 rounded {{ $commissionDisa
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-center">
|
||||
<select
|
||||
data-hq-status="{{ $prospect->id }}"
|
||||
onchange="updateHqStatus({{ $prospect->id }}, this.value)"
|
||||
class="text-xs font-medium rounded-lg px-2 py-1 border cursor-pointer
|
||||
@if($prospect->hq_status === 'handover') bg-emerald-100 text-emerald-700 border-emerald-300
|
||||
|
||||
Reference in New Issue
Block a user