- SalesManagerController: User 시스템 기반으로 재구현 - SalesManagerService: 영업담당자 CRUD, 승인/반려 로직 - SalesManagerDocument: 멀티파일 업로드 모델 - User 모델에 parent, approval 관계 및 메서드 추가 - SalesRoleSeeder: 영업 역할 시더 (sales_operator, sales_admin, sales_manager) - 뷰 파일 전면 수정 (역할 체크박스, 멀티파일 업로드, 승인/반려 UI) - 라우트 추가 (approve, reject, documents) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
222 lines
12 KiB
PHP
222 lines
12 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">등록 후 본사 승인이 필요합니다.</p>
|
|
</div>
|
|
|
|
<!-- 폼 -->
|
|
<form action="{{ route('sales.managers.store') }}" method="POST" enctype="multipart/form-data" class="space-y-6">
|
|
@csrf
|
|
|
|
<!-- 기본 정보 -->
|
|
<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" name="user_id" value="{{ old('user_id') }}"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 @error('user_id') border-red-500 @enderror"
|
|
placeholder="미입력 시 이메일 사용">
|
|
@error('user_id')
|
|
<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="text" name="name" value="{{ old('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') }}" 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') }}"
|
|
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">비밀번호 <span class="text-red-500">*</span></label>
|
|
<input type="password" name="password" 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('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">비밀번호 확인 <span class="text-red-500">*</span></label>
|
|
<input type="password" name="password_confirmation" required
|
|
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', [])) ? '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>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">상위 관리자</label>
|
|
<select name="parent_id"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
<option value="">선택 안함 (최상위)</option>
|
|
@foreach($parents as $parent)
|
|
<option value="{{ $parent->id }}" {{ old('parent_id') == $parent->id ? 'selected' : '' }}>
|
|
{{ $parent->name }} ({{ $parent->email }})
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
<p class="mt-1 text-xs text-gray-500">영업 운영자, 영업 관리자만 상위 관리자로 지정 가능합니다.</p>
|
|
</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>
|
|
<p class="text-sm text-gray-500 mb-4">승인에 필요한 서류를 첨부해주세요. (신분증, 사업자등록증, 계약서 등)</p>
|
|
|
|
<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
|