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/*)
This commit is contained in:
188
resources/views/hr/employees/edit.blade.php
Normal file
188
resources/views/hr/employees/edit.blade.php
Normal file
@@ -0,0 +1,188 @@
|
||||
@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-put="{{ route('api.admin.hr.employees.update', $employee->id) }}"
|
||||
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
|
||||
value="{{ $employee->user?->name }}"
|
||||
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="display_name" class="block text-sm font-medium text-gray-700 mb-1">표시 이름</label>
|
||||
<input type="text" name="display_name" id="display_name"
|
||||
value="{{ $employee->display_name }}"
|
||||
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"
|
||||
value="{{ $employee->employee_code }}"
|
||||
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"
|
||||
value="{{ $employee->user?->email }}"
|
||||
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"
|
||||
value="{{ $employee->user?->phone }}"
|
||||
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 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 }}" {{ $employee->department_id == $dept->id ? 'selected' : '' }}>
|
||||
{{ $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 }}" {{ $employee->position_key === $rank->key ? 'selected' : '' }}>
|
||||
{{ $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 }}" {{ $employee->job_title_key === $title->key ? 'selected' : '' }}>
|
||||
{{ $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"
|
||||
value="{{ $employee->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" {{ $employee->employee_status === 'active' ? 'selected' : '' }}>재직</option>
|
||||
<option value="leave" {{ $employee->employee_status === 'leave' ? 'selected' : '' }}>휴직</option>
|
||||
<option value="resigned" {{ $employee->employee_status === 'resigned' ? 'selected' : '' }}>퇴직</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"
|
||||
value="{{ $employee->address }}"
|
||||
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"
|
||||
value="{{ $employee->emergency_contact }}"
|
||||
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.show', $employee->id) }}"
|
||||
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.show', $employee->id) }}';
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user