|
{{ $tender['project_name'] }}
|
{{ $tender['dead_line'] ? Utility::site_date_format($tender['dead_line'], \Auth::user()->id) : '-' }}
|
@foreach ($tender['sub_con_details'] as $sub_con)
@php
$subconName = DB::table('users')
->where('id', $sub_con)
->value('name');
@endphp
@if ($subconName)
{{ $subconName }}
@endif
@endforeach
|
All
Subdivision RFQ Total |
@if ($project_total_rfq > 0)
{{ $project_total_rfq }}
@else
-
@endif
|
@if ($project_total_received > 0)
{{ $project_total_received }}
@else
-
@endif
|
@if ($project_total_pending > 0)
{{ $project_total_pending }}
@else
-
@endif
|
{{-- Individual Subdivision Rows --}}
@foreach ($subdivision as $cat)
@php
// Initialize counts
$count_total = 0;
$count_total_received = 0;
// Create possible lookup keys based on the data structure
$possibleKeys = [
'[' .
$cat->tra_id .
']|[' .
$cat->subdiv_id .
']|' .
$cat->id,
'[' .
$cat->tra_id .
']|[' .
$cat->subdiv_id .
']|' .
$cat->tra_id,
'[' .
$cat->tra_id .
']|[' .
$cat->subdiv_id .
']|' .
$cat->subdiv_id,
$cat->tra_id .
'|' .
$cat->subdiv_id .
'|' .
$cat->id,
$cat->tra_id .
'|' .
$cat->subdiv_id .
'|' .
$cat->tra_id,
$cat->tra_id .
'|' .
$cat->subdiv_id .
'|' .
$cat->subdiv_id,
];
// Try to find matching counts using the lookup keys
foreach ($possibleKeys as $key) {
if (isset($rfqLookup[$key])) {
$count_total = $rfqLookup[$key];
$count_total_received =
$receivedLookup[$key] ?? 0;
break;
}
}
// Fallback: Use direct database query if lookup fails
if ($count_total == 0) {
$directRfqCount = DB::table(
'tender_subcon_allocated',
)
->where(
'tender_id',
$tender['id'],
)
->where('subcon_id', '!=', 0)
->where(function ($query) use (
$cat,
) {
$query
->where(
'main_trade',
'LIKE',
'%' .
$cat->tra_id .
'%',
)
->where(
'sub_division',
'LIKE',
'%' .
$cat->subdiv_id .
'%',
)
->where(
'cat_id',
$cat->id,
);
})
->distinct('subcon_id')
->count();
$directReceivedCount = DB::table(
'tender_subcon_allocated',
)
->where(
'tender_id',
$tender['id'],
)
->where('subcon_id', '!=', 0)
->where(function ($query) use (
$cat,
) {
$query
->where(
'main_trade',
'LIKE',
'%' .
$cat->tra_id .
'%',
)
->where(
'sub_division',
'LIKE',
'%' .
$cat->subdiv_id .
'%',
)
->where(
'cat_id',
$cat->id,
);
})
->where(function ($query) {
$query
->where(function ($q) {
$q->where(
'method_type',
1,
)->whereNotNull(
'subcon_file_id',
);
})
->orWhere(function (
$q,
) {
$q->where(
'method_type',
0,
)->whereNotNull(
'subcon_file_id',
);
});
})
->distinct('subcon_id')
->count();
$count_total = $directRfqCount;
$count_total_received = $directReceivedCount;
}
$count_pending =
$count_total -
$count_total_received;
@endphp
|
{{ $cat->category_name }} |
@if ($count_total > 0)
{{ $count_total }}
@else
-
@endif
|
@if ($count_total_received > 0)
{{ $count_total_received }}
@else
-
@endif
|
@if ($count_pending > 0)
{{ $count_pending }}
@else
-
@endif
|
@endforeach
@endif
@empty