@extends('front.layouts.main') @section('title', 'Leads') @push('pageCss') @endpush @section('content')
{{-- Header --}} {{-- Search and Pagination Form --}}
Total {{ $leads->total() }}
@if ( $leads->total() > 0 )
@php $currentSort = request('sort_by'); $currentOrder = request('order') === 'asc' ? 'desc' : 'asc'; // Get all current query parameters except sort_by and order $sortQueryParams = request()->query(); unset($sortQueryParams['sort_by']); unset($sortQueryParams['order']); unset($sortQueryParams['page']); // Reset to page 1 when sorting @endphp @foreach ($leads as $lead) @php $expectedDate = \Carbon\Carbon::parse($lead->expected_closure_date); $today = \Carbon\Carbon::today(); $daysUntilClosure = $today->diffInDays($expectedDate, false); $isWonOrLost = in_array($lead->lead_status, ['won', 'lost']); $rowClass = ''; if (!$isWonOrLost) { if ($expectedDate < $today && $lead->lead_status != 'won') { $rowClass = 'table-danger'; // Red - past due } elseif ($daysUntilClosure <= 7 && $lead->lead_status != 'won') { $rowClass = 'table-warning'; // Orange - within 7 days } else { $rowClass = 'table-success'; // Green - more than 7 days } } @endphp @if ($lead->lead_type == 'individual') @else @endif @endforeach
@php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'lead_name', // <-- was agent_name 'order' => $currentSort == 'lead_name' ? $currentOrder : 'asc', ]); @endphp Lead Name @if ($currentSort === 'lead_name') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'lead_type', 'order' => $currentSort == 'lead_type' ? $currentOrder : 'asc', ]); @endphp Lead Type @if ($currentSort === 'lead_type') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'client', 'order' => $currentSort == 'client' ? $currentOrder : 'asc', ]); @endphp Client @if ($currentSort === 'client') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'product_name', 'order' => $currentSort == 'product_name' ? $currentOrder : 'asc', ]); @endphp Product @if ($currentSort === 'product_name') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'added_on', 'order' => $currentSort == 'added_on' ? $currentOrder : 'asc', ]); @endphp Added on @if ($currentSort === 'added_on') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'expected_closure_date', 'order' => $currentSort == 'expected_closure_date' ? $currentOrder : 'asc', ]); @endphp Expected Closure Date @if ($currentSort === 'expected_closure_date') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'stage', 'order' => $currentSort == 'stage' ? $currentOrder : 'asc', ]); @endphp Stage @if ($currentSort === 'stage') @else @endif @php $sortParams = array_merge($sortQueryParams, [ 'sort_by' => 'action', 'order' => $currentSort == 'action' ? $currentOrder : 'asc', ]); @endphp Action @if ($currentSort === 'action') @else @endif
{{ $lead->customer_name ?? 'N/A' }}{{ $lead->business_name ?? 'N/A' }}{{ ucfirst($lead->lead_type) ?? 'N/A' }} {{ $lead->kuaCompany? $lead->kuaCompany->name: 'N/A' }} {{ $lead->kuaProduct ? $lead->kuaProduct->product_name : 'N/A' }} {{ \Carbon\Carbon::parse($lead->created_at)->format('d M Y') ?? 'N/A' }} {{ \Carbon\Carbon::parse($lead->expected_closure_date)->format('d M Y') ?? 'N/A' }} {{ ucfirst($lead->lead_status ?? 'N/A') }} @if (!$isWonOrLost) @if($lead->company_id != 0 && $lead->product_id != 0) @endif @endif visibility @if ($lead->lead_status == 'new') edit @endif
Color Legend:
Green: More than 7 days until closure
Orange: Within 7 days of closure
Red: Past closure date
@else
@endif
{{-- Modal for customer TIN number --}} {{-- Modal for lost lead --}}
{{-- Modal for lost lead --}}
@endsection @if (session('success')) @endif @if (session('error')) @endif @push('pageJs') @endpush