241 lines
13 KiB
PHP
241 lines
13 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', '영업담당자 수정')
|
|
|
|
@section('content')
|
|
<div class="max-w-3xl mx-auto">
|
|
<!-- 페이지 헤더 -->
|
|
<div class="mb-6">
|
|
<a href="{{ route('sales.managers.index') }}" class="text-gray-500 hover:text-gray-700 text-sm mb-2 inline-flex items-center">
|
|
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
|
</svg>
|
|
목록으로
|
|
</a>
|
|
<h1 class="text-2xl font-bold text-gray-800">영업담당자 수정</h1>
|
|
<p class="text-sm text-gray-500 mt-1">{{ $partner->name }} ({{ $partner->email }})</p>
|
|
</div>
|
|
|
|
<!-- 폼 -->
|
|
<form action="{{ route('sales.managers.update', $partner->id) }}" method="POST" enctype="multipart/form-data" class="space-y-6">
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
<!-- 기본 정보 -->
|
|
<div class="bg-white rounded-lg shadow-sm p-6">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4">기본 정보</h2>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">로그인 ID</label>
|
|
<input type="text" value="{{ $partner->user_id ?? $partner->email }}" disabled
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg bg-gray-100 text-gray-500">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">이름 <span class="text-red-500">*</span></label>
|
|
<input type="text" name="name" value="{{ old('name', $partner->name) }}" required
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 @error('name') border-red-500 @enderror">
|
|
@error('name')
|
|
<p class="mt-1 text-sm text-red-500">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">이메일 <span class="text-red-500">*</span></label>
|
|
<input type="email" name="email" value="{{ old('email', $partner->email) }}" required
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 @error('email') border-red-500 @enderror">
|
|
@error('email')
|
|
<p class="mt-1 text-sm text-red-500">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">전화번호</label>
|
|
<input type="text" name="phone" value="{{ old('phone', $partner->phone) }}"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">비밀번호</label>
|
|
<input type="password" name="password" placeholder="변경 시에만 입력"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 @error('password') border-red-500 @enderror">
|
|
@error('password')
|
|
<p class="mt-1 text-sm text-red-500">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">비밀번호 확인</label>
|
|
<input type="password" name="password_confirmation" placeholder="변경 시에만 입력"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 역할 및 조직 -->
|
|
<div class="bg-white rounded-lg shadow-sm p-6">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4">역할 및 조직</h2>
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">역할 <span class="text-red-500">*</span></label>
|
|
<div class="space-y-2">
|
|
@foreach($roles as $role)
|
|
<label class="flex items-center">
|
|
<input type="checkbox" name="role_ids[]" value="{{ $role->id }}"
|
|
{{ in_array($role->id, old('role_ids', $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 class="text-gray-400">({{ $role->name }})</span>
|
|
</span>
|
|
</label>
|
|
@endforeach
|
|
</div>
|
|
@error('role_ids')
|
|
<p class="mt-1 text-sm text-red-500">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
@if($partner->parent)
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">추천인(유치자)</label>
|
|
<div class="px-4 py-2 bg-gray-50 border border-gray-200 rounded-lg text-gray-700">
|
|
{{ $partner->parent->name }} ({{ $partner->parent->email }})
|
|
</div>
|
|
<p class="mt-1 text-xs text-gray-500">추천인은 변경할 수 없습니다.</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 기존 첨부 서류 -->
|
|
@if($partner->salesDocuments->isNotEmpty())
|
|
<div class="bg-white rounded-lg shadow-sm p-6">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4">기존 첨부 서류</h2>
|
|
<div class="space-y-3">
|
|
@foreach($partner->salesDocuments as $document)
|
|
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
|
|
<div class="flex items-center gap-3">
|
|
<span class="px-2 py-0.5 text-xs bg-gray-200 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>
|
|
<form action="{{ route('sales.managers.documents.delete', [$partner->id, $document->id]) }}" method="POST"
|
|
onsubmit="return confirm('이 서류를 삭제하시겠습니까?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="text-red-500 hover:text-red-700">
|
|
<svg class="w-5 h-5" 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>
|
|
</form>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<!-- 새 첨부 서류 -->
|
|
<div class="bg-white rounded-lg shadow-sm p-6">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4">새 서류 추가</h2>
|
|
|
|
<div id="document-list" class="space-y-4">
|
|
<div class="document-item border border-gray-200 rounded-lg p-4">
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">문서 유형</label>
|
|
<select name="documents[0][document_type]"
|
|
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">
|
|
@foreach($documentTypes as $value => $label)
|
|
<option value="{{ $value }}">{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">파일</label>
|
|
<input type="file" name="documents[0][file]"
|
|
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"
|
|
accept="image/*,.pdf,.doc,.docx">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">설명</label>
|
|
<input type="text" name="documents[0][description]"
|
|
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"
|
|
placeholder="선택사항">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="button" id="add-document-btn"
|
|
class="mt-4 inline-flex items-center px-4 py-2 border border-gray-300 rounded-lg text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
|
|
<svg class="w-4 h-4 mr-2" 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">
|
|
<a href="{{ route('sales.managers.index') }}"
|
|
class="px-6 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition">
|
|
취소
|
|
</a>
|
|
<button type="submit"
|
|
class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition">
|
|
수정
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
let documentIndex = 1;
|
|
|
|
document.getElementById('add-document-btn').addEventListener('click', function() {
|
|
const container = document.getElementById('document-list');
|
|
const template = `
|
|
<div class="document-item border border-gray-200 rounded-lg p-4 relative">
|
|
<button type="button" onclick="this.parentElement.remove()"
|
|
class="absolute top-2 right-2 text-gray-400 hover:text-red-500">
|
|
<svg class="w-5 h-5" 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 class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">문서 유형</label>
|
|
<select name="documents[${documentIndex}][document_type]"
|
|
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">
|
|
@foreach($documentTypes as $value => $label)
|
|
<option value="{{ $value }}">{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">파일</label>
|
|
<input type="file" name="documents[${documentIndex}][file]"
|
|
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"
|
|
accept="image/*,.pdf,.doc,.docx">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">설명</label>
|
|
<input type="text" name="documents[${documentIndex}][description]"
|
|
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"
|
|
placeholder="선택사항">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
container.insertAdjacentHTML('beforeend', template);
|
|
documentIndex++;
|
|
});
|
|
</script>
|
|
@endpush
|