diff --git a/app/Http/Controllers/Api/Admin/HR/EmployeeController.php b/app/Http/Controllers/Api/Admin/HR/EmployeeController.php index 06804c44..c25db9b7 100644 --- a/app/Http/Controllers/Api/Admin/HR/EmployeeController.php +++ b/app/Http/Controllers/Api/Admin/HR/EmployeeController.php @@ -300,6 +300,38 @@ public function forceDestroy(Request $request, int $id): JsonResponse|Response } } + /** + * 사원 제외/복원 토글 + */ + public function toggleExclude(Request $request, int $id): JsonResponse|Response + { + $employee = $this->employeeService->toggleExclude($id); + + if (! $employee) { + return response()->json([ + 'success' => false, + 'message' => '사원 정보를 찾을 수 없습니다.', + ], 404); + } + + $isExcluded = $employee->getJsonExtraValue('is_excluded', false); + + if ($request->header('HX-Request')) { + $employees = $this->employeeService->getEmployees( + $request->all(), + $request->integer('per_page', 20) + ); + + return response(view('hr.employees.partials.table', compact('employees'))); + } + + return response()->json([ + 'success' => true, + 'message' => $isExcluded ? '사원이 목록에서 제외되었습니다.' : '사원이 목록에 복원되었습니다.', + 'is_excluded' => $isExcluded, + ]); + } + /** * 사원 첨부파일 업로드 (로컬 + GCS 듀얼 저장) */ diff --git a/app/Http/Controllers/HR/EmployeeController.php b/app/Http/Controllers/HR/EmployeeController.php index 50a35108..635c3346 100644 --- a/app/Http/Controllers/HR/EmployeeController.php +++ b/app/Http/Controllers/HR/EmployeeController.php @@ -18,7 +18,8 @@ public function __construct( */ public function index(): View { - $stats = $this->employeeService->getStats(); + $showExcluded = request()->boolean('show_excluded'); + $stats = $this->employeeService->getStats($showExcluded); $departments = $this->employeeService->getDepartments(); return view('hr.employees.index', [ diff --git a/app/Services/HR/EmployeeService.php b/app/Services/HR/EmployeeService.php index 18153b19..01f7b0f0 100644 --- a/app/Services/HR/EmployeeService.php +++ b/app/Services/HR/EmployeeService.php @@ -26,6 +26,21 @@ public function getEmployees(array $filters = [], int $perPage = 20): LengthAwar ->with(['user', 'department']) ->forTenant($tenantId); + // 제외 사원 필터 (기본: 숨김) + if (empty($filters['show_excluded'])) { + // "영업팀" 포함 부서 사원 제외 + $query->where(function ($q) { + $q->whereDoesntHave('department', function ($dq) { + $dq->where('name', 'like', '%영업팀%'); + })->orWhereNull('department_id'); + }); + // 강제 제외된 사원 제외 + $query->where(function ($q) { + $q->whereNull('json_extra->is_excluded') + ->orWhere('json_extra->is_excluded', false); + }); + } + // 검색 필터 (이름, 이메일, 연락처) if (! empty($filters['q'])) { $search = $filters['q']; @@ -89,12 +104,23 @@ public function getEmployeeById(int $id): ?Employee /** * 사원 통계 */ - public function getStats(): array + public function getStats(bool $showExcluded = false): array { $tenantId = session('selected_tenant_id'); $baseQuery = Employee::query()->forTenant($tenantId); + if (! $showExcluded) { + $baseQuery->where(function ($q) { + $q->whereDoesntHave('department', function ($dq) { + $dq->where('name', 'like', '%영업팀%'); + })->orWhereNull('department_id'); + })->where(function ($q) { + $q->whereNull('json_extra->is_excluded') + ->orWhere('json_extra->is_excluded', false); + }); + } + return [ 'total' => (clone $baseQuery)->count(), 'active' => (clone $baseQuery)->where('employee_status', 'active')->count(), @@ -394,6 +420,23 @@ public function forceDeleteEmployee(int $id): array return ['success' => true, 'message' => "사원 '{$name}'이(가) 영구삭제되었습니다."]; } + /** + * 사원 제외/복원 토글 + */ + public function toggleExclude(int $id): ?Employee + { + $employee = $this->getEmployeeById($id); + if (! $employee) { + return null; + } + + $isExcluded = $employee->getJsonExtraValue('is_excluded', false); + $employee->setJsonExtraValue('is_excluded', ! $isExcluded); + $employee->save(); + + return $employee; + } + /** * 부서 목록 (드롭다운용) */ diff --git a/resources/views/hr/employees/index.blade.php b/resources/views/hr/employees/index.blade.php index ba511749..3ad2baf9 100644 --- a/resources/views/hr/employees/index.blade.php +++ b/resources/views/hr/employees/index.blade.php @@ -86,7 +86,13 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 f -
+
+
-
+
{{ $employee->display_name ?? $employee->user?->name ?? '-' }} + @if($isExcludedRow) + 제외 + @endif
@@ -129,6 +133,28 @@ class="text-blue-600 hover:text-blue-800" title="수정"> + {{-- 제외/복원 --}} + @php $isExcluded = $employee->getJsonExtraValue('is_excluded', false); @endphp + + {{-- 퇴직 처리 --}} @if($employee->employee_status !== 'resigned')