@include('new_layouts.header') @php $profile = \App\Models\Utility::get_file('uploads/avatar/'); @endphp

{{ __('#') }} {{ __('Ongoing Tenders') }} {{ __('Submission Date') }} {{ __('Remaining Days') }}
@forelse ($tenders as $tender) @php $mainTenderIds = $tender['main_tender_ids']; $subTenderIds = $tender['sub_division_ids']; $categories = DB::table('trade_category') ->whereIn('id', $mainTenderIds) ->get(); $divisions = DB::table('tender_divisions') ->whereIn('trade_id', $mainTenderIds) ->whereIn('id', $subTenderIds) ->get(); // Get RFQ counts $rfqCounts = DB::table('tender_subcon_allocated AS t') ->select([ DB::raw('TRIM(BOTH \'"\' FROM j.trade_id) as main_trade_id'), DB::raw('COUNT(DISTINCT t.subcon_id) as number_of_subcontractors') ]) ->where('tender_id', $tender['id']) ->where('t.subcon_id', '!=', 0) ->crossJoin(DB::raw('JSON_TABLE( CONCAT(\'[\', REPLACE(SUBSTRING(main_trade, 2, LENGTH(main_trade) - 2), \',\', \',\'), \']\'), \'$[*]\' COLUMNS (trade_id VARCHAR(10) PATH \'$\') ) as j')) ->groupBy('j.trade_id') ->orderBy('j.trade_id') ->get() ->keyBy('main_trade_id'); // Get received quotation counts $receivedCounts = DB::table('tender_subcon_allocated AS t') ->select([ DB::raw('TRIM(BOTH \'"\' FROM j.trade_id) as main_trade_id'), DB::raw('COUNT(DISTINCT CASE WHEN t.subcon_file_id IS NOT NULL THEN t.subcon_id END) as received_count') ]) ->where('tender_id', $tender['id']) ->where('t.subcon_id', '!=', 0) ->crossJoin(DB::raw('JSON_TABLE( CONCAT(\'[\', REPLACE(SUBSTRING(main_trade, 2, LENGTH(main_trade) - 2), \',\', \',\'), \']\'), \'$[*]\' COLUMNS (trade_id VARCHAR(10) PATH \'$\') ) as j')) ->groupBy('j.trade_id') ->orderBy('j.trade_id') ->get() ->keyBy('main_trade_id'); // Calculate project totals $project_total_rfq = $rfqCounts->sum('number_of_subcontractors'); $project_total_received = $receivedCounts->sum('received_count'); $project_total_pending = $project_total_rfq - $project_total_received; @endphp @if ($categories->count() > 0 || $divisions->count() > 0) @foreach ($categories as $cat) @php $count_total = isset($rfqCounts[$cat->id]) ? $rfqCounts[$cat->id]->number_of_subcontractors : 0; $count_total_received = isset($receivedCounts[$cat->id]) ? $receivedCounts[$cat->id]->received_count : 0; $count_pending = $count_total - $count_total_received; @endphp @endforeach @endif @empty @endforelse
Project Name Cut-off Date Subcontractor RFQ Trade RFQ Issued Quotation Received Quotation Pending
{{ $tender['project_name'] }} {{ Utility::site_date_format($tender['dead_line'], \Auth::user()->id) }} @foreach ($tender['sub_con_details'] as $sub_con) {{ DB::table('users')->where('id', $sub_con)->value('name') }} @endforeach
All Trade 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
{{ $cat->trade_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
No data available
@include('new_layouts.footer')