@php $lotEmbedding = (array) ($lot->embedding_input ?? []); $companyEmbedding = (array) ($primaryCompany->embedding_input ?? []); $lotNeedTokens = collect(array_merge( $lotEmbedding['need_summary'] ?? [], $lotEmbedding['services_deliverables'] ?? [], $lotEmbedding['skills_capabilities'] ?? [], $lotEmbedding['constraints_compliance'] ?? [] ))->filter()->map(fn ($t) => \Illuminate\Support\Str::lower($t))->unique(); $companyTokens = collect(array_merge( $companyEmbedding['core_activities'] ?? [], $companyEmbedding['services_deliverables'] ?? [], $companyEmbedding['skills_capabilities'] ?? [], $companyEmbedding['constraints_compliance'] ?? [], $companyEmbedding['company_profile'] ?? [] ))->filter()->map(fn ($t) => \Illuminate\Support\Str::lower($t))->unique(); $overlap = $lotNeedTokens->intersect($companyTokens)->take(3)->values()->all(); $expectations = array_filter(array_merge( data_get($lot->meta, 'expectations.service_scope', []), data_get($lot->meta, 'expectations.deliverables', []), data_get($lot->meta, 'expectations.operational_requirements', []) )); $needLines = $lotEmbedding['need_summary'] ?? []; $servicesLines = $lotEmbedding['services_deliverables'] ?? []; $skillsLines = $lotEmbedding['skills_capabilities'] ?? []; $constraintLines = $lotEmbedding['constraints_compliance'] ?? []; $companyKeywords = collect(array_merge( $companyEmbedding['core_activities'] ?? [], $companyEmbedding['services_deliverables'] ?? [], $companyEmbedding['skills_capabilities'] ?? [], $companyEmbedding['constraints_compliance'] ?? [], $primaryCompany->certifications ?? [] ))->filter()->unique()->take(10)->values()->all(); $deadlineText = $tender->deadline_at?->format('d/m') ?? '?'; $callScript = [ 'accroche' => sprintf('Bonjour %s, ici %s. Je vous appelle pour le lot %s de %s.', $primaryCompany->name ?? 'entreprise', config('app.name', 'FlowTender'), $lot->number ?? $lot->title, $tender->buyer_name ?? 'un acheteur public' ), 'pitch' => [ sprintf('Besoin : %s.', $needLines ? implode(', ', array_slice($needLines, 0, 3)) : ($lot->title ?? 'prestations spécialisées')), sprintf('Livrables attendus : %s.', $servicesLines ? implode(', ', array_slice($servicesLines, 0, 3)) : 'analyses et reporting'), sprintf('Contrainte principale : %s.', $constraintLines ? implode(', ', array_slice($constraintLines, 0, 2)) : 'respect des délais et normes en vigueur'), ], 'questions' => array_filter([ 'Êtes-vous disponibles sur la période annoncée ? (deadline '.$deadlineText.')', $skillsLines ? 'Disposez-vous en interne des compétences clés : '.implode(', ', array_slice($skillsLines, 0, 3)).' ?' : null, 'Souhaitez-vous recevoir le DCE complet par email ?' ]), 'next' => [ 'Partager le lien du lot et la date limite par email.', 'Confirmer l’interlocuteur et coordonner un envoi de documents.', 'Planifier un rappel si besoin pour vérifier la décision.', ], ]; @endphp
← Retour à la liste #{{ $lot->id }}
@if($flashMessage)
{{ $flashMessage }}
@endif

Lot / AO

Lot {{ $lot->number ?? '—' }} — {{ $lot->title }}

{{ $tender->title }}

{{ $tender->buyer_name ?? 'Acheteur inconnu' }} · {{ $tender->region ?? 'Région ?' }}

Date limite {{ $tender->deadline_at?->format('d/m/Y H:i') ?? '—' }}
Estimation {{ $lot->estimated_value ? number_format((float) $lot->estimated_value, 0, ',', ' ').' '.$lot->currency : '—' }}

Ce qui est attendu

    @forelse(array_slice($expectations, 0, 4) as $exp)
  • {{ $exp }}
  • @empty
  • {{ $lot->ai_brief ?? 'Voir dossier AO' }}
  • @endforelse

Embedding – besoin

{{ $needLines ? implode(', ', array_slice($needLines, 0, 5)) : '—' }}

Services

{{ $servicesLines ? implode(', ', array_slice($servicesLines, 0, 5)) : '—' }}

Compétences

{{ $skillsLines ? implode(', ', array_slice($skillsLines, 0, 5)) : '—' }}

Contraintes

{{ $constraintLines ? implode(', ', array_slice($constraintLines, 0, 5)) : '—' }}

Entreprise cible

{{ $primaryCompany->name ?? 'Aucune' }}

{{ $primaryCompany->city ?? 'Ville ?' }} · {{ $primaryCompany->regions[0] ?? $primaryCompany->country ?? '—' }}

@if($primaryScore) {{ number_format($primaryScore->proximity_score, 1) }} / 100 @endif
@php $phone = is_array($primaryCompany?->contact_phones ?? null) ? ($primaryCompany->contact_phones[0] ?? null) : null; $email = is_array($primaryCompany?->contact_emails ?? null) ? ($primaryCompany->contact_emails[0] ?? null) : null; @endphp @if($phone)
Téléphone {{ $phone }}
@endif @if($email)
Email {{ $email }}
@endif

Ce qu’ils font

@forelse($companyKeywords as $keyword) {{ $keyword }} @empty Informations manquantes @endforelse

Pourquoi eux ?

@if(!empty($overlap)) Points communs : {{ implode(', ', $overlap) }}. @else Alignement sur les compétences clés et la zone géographique. @endif

Script d’appel

Accroche

{{ $callScript['accroche'] }}

Pitch

    @foreach($callScript['pitch'] as $line)
  • {{ $line }}
  • @endforeach

Questions

    @foreach($callScript['questions'] as $line)
  • {{ $line }}
  • @endforeach

Next step

    @foreach($callScript['next'] as $line)
  • {{ $line }}
  • @endforeach

Statut call center

{{ \App\Support\CallCenter::label($callStatus) }}

Dernier call {{ $lot->last_call_at?->diffForHumans() ?? 'jamais' }}
@foreach($statusOptions as $value => $label) @endforeach

Changer d’entreprise

Top 5

@foreach($topScores as $score) @php $company = $score->company; $companyPhones = is_array($company?->contact_phones ?? null) ? $company->contact_phones : []; $companyEmails = is_array($company?->contact_emails ?? null) ? $company->contact_emails : []; @endphp

{{ $company->name }}

{{ number_format($score->proximity_score, 1) }} / 100

@if(!empty($companyPhones))

📞 {{ $companyPhones[0] }}

@elseif(!empty($companyEmails))

✉️ {{ $companyEmails[0] }}

@endif
@endforeach