@php $canSubmit = true; $blockingReasons = []; if ($dailyControl->workforce_check_status !== 'Completed') { $canSubmit = false; $blockingReasons[] = "Morning workforce check-in is not complete."; } $stillPresent = $dailyControl->workerAttendances->where('status', 'Present')->count(); if ($stillPresent > 0) { $canSubmit = false; $blockingReasons[] = "There are still $stillPresent workers checked in. All workers must be checked out."; } $incompleteOps = $dailyControl->workActivities->whereIn('status', ['Pending', 'Started'])->count(); if ($incompleteOps > 0) { $canSubmit = false; $blockingReasons[] = "There are $incompleteOps operations still In Progress or Planned. They must be Completed, Incomplete, or Cancelled."; } $incompleteSgr = $dailyControl->sgrTrainOperations->where('status', 'Draft')->count(); if ($incompleteSgr > 0) { $canSubmit = false; $blockingReasons[] = "There are $incompleteSgr SGR train operations still in Draft. They must be finalized and submitted."; } $unreconciledMaterials = $dailyControl->materials->whereIn('status', ['Issued', 'Acknowledged'])->count(); if ($unreconciledMaterials > 0) { $canSubmit = false; $blockingReasons[] = "There are $unreconciledMaterials materials that have not been fully reconciled (must record usage)."; } @endphp

Shift End Report

Auto-generated summary for today's operations.

Workforce

{{ $dailyControl->workerAttendances->count() }}
Assigned
{{ $dailyControl->workerAttendances->where('status', 'CheckedOut')->count() }}
Checked Out
{{ $dailyControl->workerAttendances->where('status', 'Absent')->count() }}
Absent
{{ $stillPresent }}
Still Present

Operations

@if($dailyControl->workActivities->isEmpty())

No operations recorded.

@else
@foreach($dailyControl->workActivities->groupBy('cleaning_service_type_id') as $typeId => $activities) @php $type = $activities->first()->serviceType; @endphp
{{ $type ? $type->name : 'Unknown Service' }}
@foreach($activities as $activity) @endforeach
{{ $activity->activity_name }} @if($activity->status === 'Completed') Completed @elseif($activity->status === 'Incomplete') Incomplete @else {{ $activity->status }} @endif
@endforeach
@endif

SGR Trains

@if($dailyControl->sgrTrainOperations->isEmpty())

No trains inspected.

@else
{{ $dailyControl->sgrTrainOperations->count() }} Total
{{ $dailyControl->sgrTrainOperations->where('status', 'Submitted')->count() }} Completed
@endif

Materials

@if($dailyControl->materials->isEmpty())

No materials tracked.

@else
{{ $dailyControl->materials->count() }} Tracked
{{ $dailyControl->materials->where('status', 'Consumed')->count() }} Reconciled
@endif

Issues

@if($dailyControl->operationalIssues->isEmpty())

No issues reported.

@else
{{ $dailyControl->operationalIssues->where('status', 'Open')->count() }} Open
{{ $dailyControl->operationalIssues->where('status', 'Resolved')->count() }} Resolved
@endif

Submission

Finalize and lock the shift record.

@if($dailyControl->status === 'Submitted')

Shift Submitted

This record is locked and pending coordinator review.

@else
@if(!$canSubmit)

Cannot Submit Yet

    @foreach($blockingReasons as $reason)
  • {{ $reason }}
  • @endforeach
@else

Ready to Submit

@endif
@csrf
@endif