CSR AND PLACEMENT DIVISION
REPORT ON EMPLOYMENT

@php // Nationalities based on your labels $nationalities = [ 'AM' => 'American', 'AUS' => 'Australian', 'CAN' => 'Canadian', 'BRIT' => 'British', 'IND' => 'Indian', 'ISR' => 'Israeli', 'JAP' => 'Japanese', 'KOR' => 'Korean', 'MAL' => 'Malaysian', 'RUS' => 'Russian', 'SING' => 'Singaporean', 'TAI' => 'Taiwanese', 'UKR' => 'Ukrainian', 'OTHERS' => 'Others', ]; // Create reverse lookup (label → code) $nationalityLabels = array_flip($nationalities); // Normalize nationalities (if not found, assign "Others") $normalizedRecords = $records->map(function ($item) use ($nationalityLabels) { if (!isset($nationalityLabels[$item->nationality])) { $item->nationality = 'Others'; } return $item; }); // Direct categories $directs = ['AVP and up', 'Managerial', 'Supervisory', 'Rank and File']; // Genders $genders = ['Male', 'Female']; // Residences $residences = [ 'Angeles', 'Mabalacat', 'Porac', 'Other Pampanga', 'Bamban', 'Capas', 'Other Tarlac', 'Others', ]; // Initialize counts arrays $directCountsByNationality = []; $genderCountsByNationality = []; $residenceCountsByNationality = []; $totalByNationality = []; foreach ($nationalities as $code => $label) { // --- BY NATURE OF WORK --- foreach ($directs as $direct) { $directCountsByNationality[$code][$direct] = $normalizedRecords ->where('nationality', $label) ->where('category', $direct) ->count(); } // --- BY GENDER --- foreach ($genders as $gender) { $genderCountsByNationality[$code][$gender] = $normalizedRecords ->where('nationality', $label) ->where('gender', $gender) ->count(); } // --- BY RESIDENCE --- foreach ($residences as $residence) { $residenceCountsByNationality[$code][$residence] = $normalizedRecords ->where('nationality', $label) ->where('domicile', $residence) ->count(); } // --- TOTAL BY NATIONALITY --- $totalByNationality[$code] = $normalizedRecords->where('nationality', $label)->count(); } @endphp @foreach ($nationalities as $code => $label) @endforeach {{-- ================== BY NATURE OF WORK ================== --}} @foreach ($directs as $index => $direct) @if ($index > 0) @endif @foreach ($nationalities as $code => $label) @endforeach @endforeach @foreach ($nationalities as $code => $label) @endforeach {{-- ================== BY RESIDENCE ================== --}} @foreach ($residences as $index => $residence) @if ($index > 0) @endif @foreach ($nationalities as $code => $label) @endforeach @endforeach @foreach ($nationalities as $code => $label) @endforeach {{-- ================== BY GENDER ================== --}} @foreach ($genders as $index => $gender) @if ($index > 0) @endif @foreach ($nationalities as $code => $label) @endforeach @endforeach @foreach ($nationalities as $code => $label) @endforeach
BREAKDOWN OF EMPLOYEES BY CATEGORY EXPAT / FOREIGN EMPLOYEES
{{ $code }}
BY NATURE OF WORK
{{ $direct }}{{ $directCountsByNationality[$code][$direct] }}
TOTAL{{ $totalByNationality[$code] }}
BY RESIDENCE
{{ $residence }}{{ $residenceCountsByNationality[$code][$residence] }}
TOTAL{{ $totalByNationality[$code] }}
BY GENDER
{{ $gender }}{{ $genderCountsByNationality[$code][$gender] }}
TOTAL{{ $totalByNationality[$code] }}

Prepared by:
{{ auth()->user()->name }} {{ ucwords(str_replace('_', ' ', auth()->user()->user_type)) }} {{ auth()->user()->telephone }} {{ now()->format('M d, Y') }}
Authorized Representative Position / Designation Contact Nos. Date Accomplished
Notes:
  1. Please specify the nationality for the "OTHERS" column.
Legend: @php // Nationalities list $nationalities = [ 'AM' => 'American', 'AUS' => 'Australian', 'CAN' => 'Canadian', 'BRIT' => 'British', 'IND' => 'Indian', 'ISR' => 'Israeli', 'JAP' => 'Japanese', 'KOR' => 'Korean', 'MAL' => 'Malaysian', 'RUS' => 'Russian', 'SING' => 'Singaporean', 'TAI' => 'Taiwanese', 'UKR' => 'Ukrainian', 'OTHERS' => 'Others', ]; $chunks = array_chunk($nationalities, 4, true); @endphp @foreach ($chunks as $chunk) @foreach ($chunk as $code => $label) @endforeach @endforeach
{{ $code }} - {{ $label }}
Instructions: This report should be submitted together with the attached detailed list of employees.