Files
sam-manage/resources/views/sales/managers/partials/edit-modal.blade.php
pro d4a6b042ef fix:모달 닫기 버튼에 이벤트 델리게이션 적용
- data-close-modal 속성으로 닫기 버튼 식별
- 부모 요소에서 클릭 이벤트 감지하여 모달 닫기

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 21:38:54 +09:00

194 lines
10 KiB
PHP

{{-- 영업파트너 수정 모달 내용 --}}
<div class="p-6 max-h-[80vh] overflow-y-auto">
<!-- 헤더 -->
<div class="flex justify-between items-start mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">영업파트너 수정</h2>
<p class="text-sm text-gray-500 mt-1">{{ $partner->name }} ({{ $partner->email }})</p>
</div>
<button type="button" data-close-modal class="text-gray-400 hover:text-gray-600">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<!-- -->
<form action="{{ route('sales.managers.update', $partner->id) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<!-- 기본 정보 -->
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h3 class="text-sm font-semibold text-gray-800 mb-3">기본 정보</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">로그인 ID</label>
<input type="text" value="{{ $partner->user_id ?? $partner->email }}" disabled
class="w-full px-3 py-2 border border-gray-300 rounded-lg bg-gray-100 text-gray-500 text-sm">
</div>
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">이름 <span class="text-red-500">*</span></label>
<input type="text" name="name" value="{{ $partner->name }}" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
</div>
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">이메일 <span class="text-red-500">*</span></label>
<input type="email" name="email" value="{{ $partner->email }}" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
</div>
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">전화번호</label>
<input type="text" name="phone" value="{{ $partner->phone }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
</div>
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">비밀번호</label>
<input type="password" name="password" placeholder="변경 시에만 입력"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
</div>
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">비밀번호 확인</label>
<input type="password" name="password_confirmation" placeholder="변경 시에만 입력"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
</div>
</div>
</div>
<!-- 역할 -->
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h3 class="text-sm font-semibold text-gray-800 mb-3">역할 <span class="text-red-500">*</span></h3>
<div class="flex flex-wrap gap-4">
@foreach($roles as $role)
<label class="flex items-center">
<input type="checkbox" name="role_ids[]" value="{{ $role->id }}"
{{ in_array($role->id, $currentRoleIds) ? 'checked' : '' }}
class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
<span class="ml-2 text-sm text-gray-700">
{{ $role->description ?? $role->name }}
</span>
</label>
@endforeach
</div>
</div>
<!-- 추천인 정보 -->
@if($partner->parent)
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h3 class="text-sm font-semibold text-gray-800 mb-2">추천인(유치자)</h3>
<div class="px-3 py-2 bg-white border border-gray-200 rounded-lg text-sm text-gray-700">
{{ $partner->parent->name }} ({{ $partner->parent->email }})
</div>
<p class="mt-1 text-xs text-gray-500">추천인은 변경할 없습니다.</p>
</div>
@endif
<!-- 기존 첨부 서류 -->
@if($partner->salesDocuments->isNotEmpty())
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h3 class="text-sm font-semibold text-gray-800 mb-3">기존 첨부 서류</h3>
<div class="space-y-2">
@foreach($partner->salesDocuments as $document)
<div class="flex items-center justify-between p-2 bg-white rounded border">
<div class="flex items-center gap-2">
<span class="px-2 py-0.5 text-xs bg-gray-100 text-gray-600 rounded">{{ $document->document_type_label }}</span>
<span class="text-sm text-gray-700">{{ $document->original_name }}</span>
<span class="text-xs text-gray-400">{{ $document->formatted_size }}</span>
</div>
<button type="button" onclick="deleteDocument({{ $partner->id }}, {{ $document->id }})"
class="text-red-500 hover:text-red-700">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</button>
</div>
@endforeach
</div>
</div>
@endif
<!-- 첨부 서류 -->
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h3 class="text-sm font-semibold text-gray-800 mb-3"> 서류 추가</h3>
<div id="modal-document-list" class="space-y-3">
<div class="flex items-center gap-3">
<select name="documents[0][document_type]"
class="w-32 px-2 py-1.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
@foreach($documentTypes as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</select>
<input type="file" name="documents[0][file]" accept="image/*,.pdf,.doc,.docx"
class="flex-1 text-sm text-gray-500 file:mr-2 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-sm file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
<input type="text" name="documents[0][description]" placeholder="설명(선택)"
class="w-32 px-2 py-1.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
<button type="button" onclick="addDocumentRow()"
class="mt-3 text-sm text-blue-600 hover:text-blue-800 flex items-center gap-1">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
서류 추가
</button>
</div>
<!-- 푸터 버튼 -->
<div class="flex justify-end gap-3">
<button type="button" data-close-modal
class="px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition text-sm">
취소
</button>
<button type="submit"
class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition text-sm">
수정
</button>
</div>
</form>
</div>
<script>
let modalDocIndex = 1;
function addDocumentRow() {
const container = document.getElementById('modal-document-list');
const html = `
<div class="flex items-center gap-3">
<select name="documents[${modalDocIndex}][document_type]"
class="w-32 px-2 py-1.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
@foreach($documentTypes as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</select>
<input type="file" name="documents[${modalDocIndex}][file]" accept="image/*,.pdf,.doc,.docx"
class="flex-1 text-sm text-gray-500 file:mr-2 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-sm file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
<input type="text" name="documents[${modalDocIndex}][description]" placeholder="설명(선택)"
class="w-32 px-2 py-1.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
<button type="button" onclick="this.parentElement.remove()" class="text-red-500 hover:text-red-700">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
`;
container.insertAdjacentHTML('beforeend', html);
modalDocIndex++;
}
function deleteDocument(partnerId, documentId) {
if (!confirm('이 서류를 삭제하시겠습니까?')) return;
fetch(`/sales/managers/${partnerId}/documents/${documentId}`, {
method: 'DELETE',
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
'Accept': 'application/json'
}
}).then(response => {
if (response.ok) {
openEditModal(partnerId); // 모달 새로고침
}
});
}
</script>