@extends('admin.admin_dashboard') @section('customcss') @endsection @section('admin')
{{-- Page Header --}}

Employee Work Rules & Shifts

Configure and manage shift schedules for all staff members

{{-- Statistics Overview Cards --}}
TOTAL RULES

{{ $stats['total'] ?? 0 }}

ACTIVE RULES

{{ $stats['active'] ?? 0 }}

MORNING SHIFT

{{ $stats['morning'] ?? 0 }}

DAY SHIFT

{{ $stats['day'] ?? 0 }}

{{-- Filters Card --}}
{{-- Search Text --}}
{{-- Employee Select --}}
{{-- Shift Select --}}
{{-- Status Select --}}
{{-- Submit Buttons --}}
{{-- Work Rules Table --}}
@forelse($workRules as $rule) @php $emp = $rule->employee; $primaryId = (!empty($emp->primary_id) && $emp->primary_id !== '0' && $emp->primary_id !== 0) ? $emp->primary_id : '-'; $secondaryId = (!empty($emp->e_id) && $emp->e_id !== '0' && $emp->e_id !== 0) ? $emp->e_id : '-'; $post = $emp->postDetails->name ?? ($emp->post ?? '-'); $shiftName = $rule->shift->name ?? 'N/A'; $isMorning = str_contains(strtolower($shiftName), 'morning'); $shiftBadgeClass = $isMorning ? 'badge-shift-morning' : 'badge-shift-day'; $totalMins = $rule->weeklySchedules->sum('work_minutes'); $hoursStr = intdiv($totalMins, 60) . 'h ' . ($totalMins % 60) . 'm'; @endphp {{-- Primary ID --}} {{-- Secondary ID --}} {{-- Employee Details --}} {{-- Shift with High-Contrast Solid Badge --}} {{-- Weekly Schedule --}} {{-- Weekly Hours --}} {{-- Grace Time --}} {{-- Status Toggle --}} {{-- Actions --}} @empty @endforelse
Primary ID Secondary ID Employee Details Shift Weekly Schedule & Timings Weekly Hours Grace Status Actions
{{ $primaryId }}{{ $secondaryId }}
{{ $emp->name ?? 'Unknown' }}
{{ $post }}
{{ $shiftName }}
@php $dayNames = [6 => 'Sat', 0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri']; $schedules = $rule->weeklySchedules->keyBy('day_of_week'); @endphp @foreach($dayNames as $dayNum => $dayLabel) @php $sch = $schedules[$dayNum] ?? null; @endphp @if($sch && $sch->is_off) {{ $dayLabel }}: Off @elseif($sch && $sch->start_time && $sch->end_time) {{ $dayLabel }}: {{ \Carbon\Carbon::parse($sch->start_time)->format('H:i') }}-{{ \Carbon\Carbon::parse($sch->end_time)->format('H:i') }} @endif @endforeach
{{ $hoursStr }} {{ $rule->grace_minutes }}m
@csrf @method('PATCH')
@csrf @method('DELETE')
No employee work rules found matching the criteria.
{{-- Pagination --}} @if($workRules->hasPages()) @endif
@endsection