Files
sam-manage/resources/views/hr/employees/create.blade.php
김보곤 bb9193bcad feat: [hr] 인사관리 사원관리 Phase 1 구현
- Employee, Position 모델 생성 (tenant_user_profiles, positions 테이블)
- EmployeeService 생성 (CRUD, 통계, 필터/검색/페이지네이션)
- 뷰 컨트롤러(HR/EmployeeController) + API 컨트롤러 생성
- Blade 뷰: index(통계카드+HTMX테이블), create, edit, show, partials/table
- 라우트: web.php(/hr/employees/*), api.php(/admin/hr/employees/*)
2026-02-26 16:43:52 +09:00

186 lines
9.1 KiB
PHP

@extends('layouts.app')
@section('title', '사원 등록')
@section('content')
<div class="container mx-auto px-4 py-6 max-w-2xl">
{{-- 페이지 헤더 --}}
<div class="mb-6">
<a href="{{ route('hr.employees.index') }}" class="text-sm text-gray-500 hover:text-gray-700 inline-flex items-center gap-1 mb-2">
<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="M15 19l-7-7 7-7"/>
</svg>
사원 목록으로
</a>
<h1 class="text-2xl font-bold text-gray-800">사원 등록</h1>
</div>
{{-- 등록 --}}
<div class="bg-white rounded-lg shadow-sm p-6">
<form id="employeeForm"
hx-post="{{ route('api.admin.hr.employees.store') }}"
hx-headers='{"X-CSRF-TOKEN": "{{ csrf_token() }}", "Accept": "application/json"}'
hx-target="#form-message"
hx-swap="innerHTML"
class="space-y-6">
<div id="form-message"></div>
{{-- 기본 정보 --}}
<div class="border-b border-gray-200 pb-4 mb-4">
<h2 class="text-lg font-semibold text-gray-700">기본 정보</h2>
</div>
{{-- 이름 --}}
<div>
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">
이름 <span class="text-red-500">*</span>
</label>
<input type="text" name="name" id="name" required
placeholder="홍길동"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
{{-- 사번 --}}
<div>
<label for="employee_code" class="block text-sm font-medium text-gray-700 mb-1">
사번
</label>
<input type="text" name="employee_code" id="employee_code"
placeholder="EMP-001"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
{{-- 이메일 / 연락처 --}}
<div class="flex gap-4" style="flex-wrap: wrap;">
<div style="flex: 1 1 200px;">
<label for="email" class="block text-sm font-medium text-gray-700 mb-1">이메일</label>
<input type="email" name="email" id="email"
placeholder="user@example.com"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<div style="flex: 1 1 200px;">
<label for="phone" class="block text-sm font-medium text-gray-700 mb-1">연락처</label>
<input type="text" name="phone" id="phone"
placeholder="010-1234-5678"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
</div>
{{-- 비밀번호 --}}
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-1">
비밀번호
</label>
<input type="password" name="password" id="password"
placeholder="미입력 시 기본 비밀번호(sam1234!) 설정"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<p class="text-xs text-gray-400 mt-1">미입력 기본 비밀번호가 설정됩니다.</p>
</div>
{{-- 근무 정보 --}}
<div class="border-b border-gray-200 pb-4 mb-4 mt-8">
<h2 class="text-lg font-semibold text-gray-700">근무 정보</h2>
</div>
{{-- 부서 --}}
<div>
<label for="department_id" class="block text-sm font-medium text-gray-700 mb-1">부서</label>
<select name="department_id" id="department_id"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">선택하세요</option>
@foreach($departments as $dept)
<option value="{{ $dept->id }}">{{ $dept->name }}</option>
@endforeach
</select>
</div>
{{-- 직급 / 직책 --}}
<div class="flex gap-4" style="flex-wrap: wrap;">
<div style="flex: 1 1 200px;">
<label for="position_key" class="block text-sm font-medium text-gray-700 mb-1">직급</label>
<select name="position_key" id="position_key"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">선택하세요</option>
@foreach($ranks as $rank)
<option value="{{ $rank->key }}">{{ $rank->name }}</option>
@endforeach
</select>
</div>
<div style="flex: 1 1 200px;">
<label for="job_title_key" class="block text-sm font-medium text-gray-700 mb-1">직책</label>
<select name="job_title_key" id="job_title_key"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">선택하세요</option>
@foreach($titles as $title)
<option value="{{ $title->key }}">{{ $title->name }}</option>
@endforeach
</select>
</div>
</div>
{{-- 입사일 / 상태 --}}
<div class="flex gap-4" style="flex-wrap: wrap;">
<div style="flex: 1 1 200px;">
<label for="hire_date" class="block text-sm font-medium text-gray-700 mb-1">입사일</label>
<input type="date" name="hire_date" id="hire_date"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<div style="flex: 1 1 200px;">
<label for="employee_status" class="block text-sm font-medium text-gray-700 mb-1">재직상태</label>
<select name="employee_status" id="employee_status"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="active" selected>재직</option>
<option value="leave">휴직</option>
<option value="resigned">퇴직</option>
</select>
</div>
</div>
{{-- 주소 --}}
<div>
<label for="address" class="block text-sm font-medium text-gray-700 mb-1">주소</label>
<input type="text" name="address" id="address"
placeholder="주소를 입력하세요"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
{{-- 비상연락처 --}}
<div>
<label for="emergency_contact" class="block text-sm font-medium text-gray-700 mb-1">비상연락처</label>
<input type="text" name="emergency_contact" id="emergency_contact"
placeholder="긴급 시 연락할 전화번호"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
{{-- 버튼 --}}
<div class="flex justify-end gap-3 pt-4 border-t">
<a href="{{ route('hr.employees.index') }}"
class="px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors">
취소
</a>
<button type="submit"
class="px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors">
등록
</button>
</div>
</form>
</div>
</div>
@endsection
@push('scripts')
<script>
document.body.addEventListener('htmx:afterRequest', function(event) {
if (event.detail.successful) {
try {
const response = JSON.parse(event.detail.xhr.responseText);
if (response.success) {
window.location.href = '{{ route('hr.employees.index') }}';
}
} catch (e) {}
}
});
</script>
@endpush