@extends('seller.layouts.app') @section('panel_content') @php $total = $inquiries->count(); $newCount = $inquiries->where('IsRead',0)->count(); $quotedCount= $inquiries->whereNotNull('quoted_amount')->count(); $interested = $inquiries->where('lead_status','interested')->count(); $called = $inquiries->where('lead_status','called')->count(); $completed = $inquiries->where('lead_status','completed')->count(); $closed = $inquiries->where('is_closed',1)->count(); $convRate = $total > 0 ? round(($completed/$total)*100) : 0; @endphp {{-- Stats --}}
{{ $total }}
Total
{{ $newCount }}
Unread
{{ $called }}
Called
{{ $quotedCount }}
Quoted
{{ $interested }}
Interested
{{ $convRate }}%
Conv%
{{-- Header --}} {{-- Filter Tabs --}}
@if($inquiries->count() > 0) @php $sellerLat = Auth::user()->latitude ?? 0; $sellerLng = Auth::user()->longitude ?? 0; @endphp
@foreach($inquiries->sortByDesc('created_at') as $key => $inq) @php $isNew = $inq->IsRead == 0; $isClosed = $inq->is_closed ?? false; $status = $inq->lead_status ?? 'new'; $dist = null; if($inq->latitude && $inq->longitude && $sellerLat && $sellerLng) { $dLat = deg2rad($inq->latitude - $sellerLat); $dLon = deg2rad($inq->longitude - $sellerLng); $a = sin($dLat/2)*sin($dLat/2) + cos(deg2rad($sellerLat))*cos(deg2rad($inq->latitude))*sin($dLon/2)*sin($dLon/2); $dist = round(6371 * 2 * atan2(sqrt($a), sqrt(1-$a)), 1); } $phone = $inq->buyer_phone ?? ''; $cleanPhone = preg_replace('/\D/','',$phone); $mapsUrl = ($inq->latitude && $inq->longitude) ? 'https://www.google.com/maps/dir/?api=1&destination='.$inq->latitude.','.$inq->longitude : null; $hasQuote = !empty($inq->quoted_amount); $quoteAccepted = ($inq->quote_status ?? '') == 'accepted'; $note = \DB::table('inquiry_notes')->where('inquiry_id',$inq->id)->where('seller_id',Auth::id())->value('note') ?? ''; // Lead score $score = 10; if($status=='interested') $score=60; elseif($status=='quoted') $score=45; elseif($status=='called') $score=25; if($hasQuote) $score+=20; $score = min(100,$score); $scoreColor = $score>=70 ? '#27ae60' : ($score>=40 ? '#d97706' : '#6c757d'); // Nearby sellers $nearbySellers = collect(); if($inq->category_id) { $cid = $inq->category_id; $buyLat = $inq->latitude ?? 0; $buyLng = $inq->longitude ?? 0; $nearbySellers = \App\Models\Shop::with('user') ->where('user_id','!=',Auth::id()) ->where(function($q) use ($cid){ $q->where('sub_cat_ids',$cid) ->orWhere('sub_cat_ids','LIKE',$cid.',%') ->orWhere('sub_cat_ids','LIKE','%,'.$cid) ->orWhere('sub_cat_ids','LIKE','%,'.$cid.',%'); }) ->limit(8)->get() ->map(function($s) use ($buyLat,$buyLng){ $d = ($buyLat&&$buyLng&&$s->user&&$s->user->latitude) ? round((float)getDistance($s->user->latitude,$s->user->longitude,$buyLat,$buyLng),1) : null; $s->cd = $d; return $s; })->sortBy(fn($s)=>$s->cd??99999)->take(3); } @endphp
{{-- Header --}}
{{ strtoupper(substr($inq->buyer_name??'?',0,1)) }} @if($isNew&&!$isClosed)
@endif
{{ $inq->buyer_name ?: 'Guest' }} @if($isClosed) πŸŽ‰ Completed @elseif($status=='new') πŸ†• New @elseif($status=='called') πŸ“ž Called @elseif($status=='quoted') πŸ’° Quoted @elseif($status=='interested') βœ… Interested @elseif($status=='followup') πŸ”„ Follow Up @elseif($status=='not_interested') ❌ Not Int. @elseif($status=='completed') πŸŽ‰ Completed @else πŸ†• New @endif
@if($inq->category) {{ $inq->category->name }} @endif @if($inq->product_name) {{ Str::limit($inq->product_name,30) }} @endif
@if($phone)πŸ“ž {{ $phone }}@endif @if($inq->city)πŸ“ {{ $inq->city }}@endif @if($dist!==null){{ $dist }} km@endif {{ $inq->created_at->diffForHumans() }}
{{-- Note preview --}} @if($note)
πŸ“ {{ Str::limit($note,40) }}
@endif
{{-- Priority --}}
⬜
{{-- Quote Section --}} @if($hasQuote)
πŸ’° Quote Sent @if($inq->quote_note){{ Str::limit($inq->quote_note,30) }}@endif
β‚Ή{{ number_format($inq->quoted_amount) }} @if($quoteAccepted) βœ… Quote Accepted! @else ⏳ Awaiting @endif
@endif {{-- Closed Banner --}} @if($isClosed)
πŸŽ‰
Requirement Completed!
This enquiry has been closed by the customer
@endif {{-- Actions --}}
@if(!$isClosed) {{-- Status --}}
@if($phone) πŸ“ž Call πŸ’¬ WA @endif @if($inq->buyer_id) πŸ’¬ Chat @endif @if($mapsUrl) πŸ—ΊοΈ Dir @endif
@else πŸ”’ Enquiry Closed @endif
@endforeach
@else
πŸ“­
No inquiries yet

When customers send enquiries, they will appear here.

@endif {{-- Quote Modal --}}
πŸ’° Send Quotation
β‚Ή0
{{-- Note Modal --}}
πŸ“ Private Note

Only visible to you

{{-- Templates Modal --}}
⚑ Quick Reply Templates
{{-- Toast --}}
@endsection @section('script') @endsection