| BREAKDOWN OF EMPLOYEES BY CATEGORY |
LOCAL / FILIPINO EMPLOYEES |
| DIRECT |
INDIRECT |
TOTAL |
| Security |
Janitorial |
Ground |
Construction |
Others |
@php
// Indirect categories
$indirectCategories = ['Security', 'Janitorial', 'Ground', 'Construction', 'Others'];
// Include Direct as the first category
$categories = array_merge(['Direct'], $indirectCategories);
// Genders
$genders = ['Male', 'Female'];
// Employment statuses
$statuses = ['Regular', 'Probationary', 'Casual'];
// Direct sub-categories
$directs = ['AVP and up', 'Managerial', 'Supervisory', 'Rank and File'];
// Residences (BY RESENDES)
$residences = [
'Angeles',
'Mabalacat',
'Porac',
'Other Pampanga',
'Bamban',
'Capas',
'Other Tarlac',
'Others',
];
// Count each direct sub-category
$directCounts = [];
foreach ($directs as $direct) {
$directCounts[$direct] = $records->where('category', $direct)->count();
}
// Count indirect categories for layout in Direct table
$directIndirectCounts = [];
foreach ($indirectCategories as $cat) {
$directIndirectCounts[$cat] = $records->where('category', $cat)->count();
}
$directGrandTotal = $records->count();
// --- BY GENDER ---
$genderCounts = [];
$genderDirectTotal = 0;
foreach ($genders as $gender) {
foreach ($categories as $cat) {
if ($cat === 'Direct') {
$genderCounts[$gender][$cat] = $records
->where('gender', $gender)
->whereNotIn('category', $indirectCategories)
->count();
} else {
$genderCounts[$gender][$cat] = $records
->where('gender', $gender)
->where('category', $cat)
->count();
}
}
// Total EXCLUDING Direct
$genderCounts[$gender]['Total'] = $records
->where('gender', $gender)
->whereIn('category', $categories)
->count();
$genderDirectTotal += $genderCounts[$gender]['Total'];
}
// --- BY EMPLOYMENT STATUS ---
$statusCounts = [];
$statusDirectTotal = 0;
foreach ($statuses as $status) {
foreach ($categories as $cat) {
if ($cat === 'Direct') {
$statusCounts[$status][$cat] = $records
->where('status', $status)
->whereNotIn('category', $indirectCategories)
->count();
} else {
$statusCounts[$status][$cat] = $records
->where('status', $status)
->where('category', $cat)
->count();
}
}
$statusCounts[$status]['Total'] = $records
->where('status', $status)
->whereIn('category', $categories)
->count();
$statusDirectTotal += $statusCounts[$status]['Total'];
}
// --- BY RESIDENCE ---
$residenceCounts = [];
$residenceDirectTotal = 0;
foreach ($residences as $res) {
foreach ($categories as $cat) {
if ($cat === 'Direct') {
$residenceCounts[$res][$cat] = $records
->where('domicile', $res)
->whereNotIn('category', $indirectCategories)
->count();
} else {
$residenceCounts[$res][$cat] = $records
->where('domicile', $res)
->where('category', $cat)
->count();
}
}
$residenceCounts[$res]['Total'] = $records
->where('domicile', $res)
->whereIn('category', $categories)
->count();
$residenceDirectTotal += $residenceCounts[$res]['Total'];
}
@endphp
{{-- ================== BY DIRECT CATEGORY ================== --}}
| BY DIRECT CATEGORY |
@foreach ($directs as $index => $direct)
@if ($index > 0)
@endif
| {{ $direct }} |
{{ $directCounts[$direct] }} |
@foreach ($indirectCategories as $cat)
|
@endforeach
|
@endforeach
| TOTAL |
{{ collect($directs)->sum(fn($d) => $directCounts[$d]) }}
|
@foreach ($indirectCategories as $cat)
|
@endforeach
|
{{-- ================== BY RESIDENCE ================== --}}
| BY RESIDENCE |
@foreach ($residences as $index => $res)
@if ($index > 0)
@endif
| {{ $res }} |
@foreach ($categories as $cat)
{{ $residenceCounts[$res][$cat] }} |
@endforeach
{{ $residenceCounts[$res]['Total'] }} |
@endforeach
| TOTAL |
@foreach ($categories as $cat)
@php
$total = 0;
foreach ($residences as $res) {
$total += $residenceCounts[$res][$cat];
}
@endphp
{{ $total }}
|
@endforeach
{{ $residenceDirectTotal }} |
{{-- ================== BY GENDER ================== --}}
| BY GENDER |
@foreach ($genders as $index => $gender)
@if ($index > 0)
@endif
| {{ $gender }} |
@foreach ($categories as $cat)
{{ $genderCounts[$gender][$cat] }} |
@endforeach
{{ $genderCounts[$gender]['Total'] }} |
@endforeach
| TOTAL |
@foreach ($categories as $cat)
{{ $genderCounts['Male'][$cat] + $genderCounts['Female'][$cat] }}
|
@endforeach
{{ $genderDirectTotal }} |
{{-- ================== BY EMPLOYMENT STATUS ================== --}}
| BY EMPLOYMENT STATUS |
@foreach ($statuses as $index => $status)
@if ($index > 0)
@endif
| {{ $status }} |
@foreach ($categories as $cat)
{{ $statusCounts[$status][$cat] }} |
@endforeach
{{ $statusCounts[$status]['Total'] }} |
@endforeach
| TOTAL |
@foreach ($categories as $cat)
@php
$total = 0;
foreach ($statuses as $status) {
$total += $statusCounts[$status][$cat];
}
@endphp
{{ $total }}
|
@endforeach
{{ $statusDirectTotal }} |