@extends('template.layouts.template-base') @section('title') Attendance | {{ config('setting.website_name') ?: config('app.name') }} @endsection @section('content')

Attendance

@error('staff_type')
{{ $message }}
@enderror
@error('clients')
{{ $message }}
@enderror
@error('projects')
{{ $message }}
@enderror
{{-- Today by default; the date searched stays in the field --}} @error('date')
{{ $message }}
@enderror
{{-- Errors of the attendance submitted below (future date, attendance status) --}} @php $saveErrors = collect($errors->getMessages()) ->filter(fn ($messages, $field) => $field === 'attendance_date' || str_starts_with($field, 'staff')) ->flatten()->unique(); @endphp @if ($saveErrors->isNotEmpty())
Attendance was not saved:
@endif @if(isset($staffList))
@csrf
Date: {{ date('d-m-Y',strtotime($requestDate)) }}
@if(isset($selectedClient) && $selectedClient->company_name)
Client: {{ $selectedClient->company_name }}
@endif @if(isset($selectedProject) && $selectedProject->project_name)
Project: {{ $selectedProject->project_name }}
@endif
{{-- Active staff of the chosen client / project (Staff Creation); none: a message instead of an empty list --}} @if($staffList->isEmpty())
No active staff found for {{ $selectedClient->company_name ?? ($selectedProject->project_name ?? 'the selected client / project') }}. Add staff for it in Staff Management > Staff Creation, then search again.
@else @if ($errors->has('staff.*.attendance'))
Attendance was not saved: {{ count($errors->get('staff.*.attendance')) }} staff already used the allowed Casual Leave for this month. Choose another status for the highlighted rows and submit again.
@endif
@foreach($staffList as $index => $staff) {{-- @php $attendance = optional($staff->attendance->first()?->dayRecord->first()); @endphp --}} @php $monthlyAttendance = $staff->attendance->first(); $dayAttendance = optional($monthlyAttendance?->dayRecord->first()); // The status chosen before a save that was stopped (e.g. a second CL), else the saved one $chosenStatus = old('staff') !== null ? old("staff.$index.attendance") : $dayAttendance?->attendance_type; $clError = $errors->first("staff.$index.attendance"); @endphp @endforeach
S.no Staff ID Name Attendance LOP Hours Total OT Hours Shift Meal Days Comments
{{ $loop->iteration }} {{ $staff->staff_id }} {{ $staff->staff_name }}
attendance_type == 'P' ? 'checked' : '' }}> --}} {{ $chosenStatus == 'P' ? 'checked' : '' }}>

{{-- One CL per staff per month: shown when CL is chosen for a staff who already took the month's CL on another day (also when the save was stopped for it) --}}
{{ \App\Services\AttendanceRules::CL_LIMIT_MESSAGE }} @if (!empty($clTaken[$staff->id])) (CL taken on {{ $clTaken[$staff->id] }}) @endif
{{-- The shift saved for this staff on this exact date is shown chosen, like an Edit page; a staff without attendance on the date has no shift chosen (another day's shift is never shown). One click chooses a shift, a click on the chosen shift clears it; shift is optional. shift_clear tells the server a shift saved for the date was cleared. --}} @php $dayShift = $dayAttendance?->shift; @endphp
@foreach (\App\Services\AttendanceRules::SHIFT_LETTERS as $shiftValue => $shiftLetter)
@endforeach
{{-- Meal of this staff on this date (optional, one per day = 1 Meal Day): the meal saved for this exact date is shown chosen; one click chooses a meal, a click on the chosen meal clears it --}} @php $dayMeal = $dayAttendance?->meal; @endphp @foreach (\App\Services\AttendanceRules::MEALS as $meal)
@endforeach
@endif
@endif @section('scripts') @include('template.attendance.partials.date-guard') @endsection @endsection