@php $steps = [ 1 => ['label' => __('Upload'), 'icon' => 'arrow-up-tray'], 2 => ['label' => __('Map columns'), 'icon' => 'table-cells'], 3 => ['label' => __('Assign'), 'icon' => 'user-group'], 4 => ['label' => __('Review'), 'icon' => 'check-circle'], 5 => ['label' => __('Result'), 'icon' => 'flag'], ]; $classColors = ['new' => 'emerald', 'match' => 'sky', 'possible' => 'amber', 'error' => 'rose']; $classCounts = $batch?->options['classes'] ?? []; $select = 'mt-1 block w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500'; @endphp
{{ __('Imports and Exports') }}

{{ __('Import client profiles') }}

{{ __('Load organisations and their contacts from a spreadsheet into a portfolio. Nothing enters the pipeline until someone pulls it from the work queue.') }}

{{-- Progress --}}
@foreach ($steps as $n => $s) @php $state = $step > $n ? 'done' : ($step === $n ? 'current' : 'todo'); @endphp @if (! $loop->last)
@endif @endforeach
@if ($step >= 3 && $errors->any())
    @foreach ($errors->all() as $message)
  • {{ $message }}
  • @endforeach
@endif {{-- ===================== STEP 1 · UPLOAD ===================== --}} @if ($step === 1)

{{ __('Where is the list?') }}

@foreach (['upload' => ['label' => __('Excel or CSV file'), 'icon' => 'document-text'], 'google_sheet' => ['label' => __('Google Sheet link'), 'icon' => 'link']] as $key => $meta) @endforeach
@if ($sourceType === 'upload')
{{ __('Reading the file…') }}
@else
{{ __('Load') }} {{ __('Loading…') }}

{{ __('The sheet must be shared as "Anyone with the link can view".') }}

@endif

{{ __('Starting from scratch? The template has every column the import understands, with example rows. One row can hold an organisation and one of its contacts; repeat the organisation for more contacts.') }}

{{ __('Template') }}
@endif {{-- ===================== STEP 2 · MAP ===================== --}} @if ($step === 2 && $batch) @if ($previous)

{{ __('This file was imported on :date by :name. Rows already on record will show as matches, so nothing is created twice.', [ 'date' => $previous->created_at->timezone(config('app.display_timezone'))->format('j M Y'), 'name' => $previous->user?->name ?? __('someone'), ]) }} {{ __('See that import') }}

@endif

{{ $batch->file_name }}

@if (count($sheetNames) > 1)
@endif
@foreach (array_slice($previewGrid, $headerRow, 5, true) as $index => $cells) @foreach ($cells as $cell) @endforeach @endforeach
{{ $cell }}
@foreach (['organisation' => __('Organisation columns'), 'contact' => __('Contact columns, from the same row')] as $group => $title)

{{ $title }}

@foreach ($fields as $field => [$label, $fieldGroup]) @if ($fieldGroup === $group)
@endif @endforeach
@endforeach @endif {{-- ===================== STEP 3 · ASSIGN ===================== --}} @if ($step === 3 && $batch)

{{ __('Which portfolio') }}

@foreach (['new' => [__('A new list'), __('Start a portfolio for these organisations.'), 'plus'], 'existing' => [__('An existing list'), __('Top up a portfolio already being worked.'), 'folder']] as $key => [$title, $hint, $icon]) @endforeach
@if ($target === 'existing')
@if ($portfolios->isEmpty())

{{ __('There is no open list you may add to.') }}

@endif
@else
@endif

{{ __('Who works it') }}

@foreach ($teamUsers as $person) @endforeach

{{ __('By sector and by tier keep each group with one person. The number beside each name is how many organisations they would receive.') }}

@endif {{-- ===================== STEP 4 · REVIEW ===================== --}} @if ($step === 4 && $batch) @php $reviewMeta = ['' => __('All rows')] + array_map(fn ($label) => __($label), \App\Services\Crm\Import\ProfileStager::CLASSES); $pages = (int) ceil($review['total'] / 25); @endphp
@foreach (\App\Services\Crm\Import\ProfileStager::CLASSES as $class => $label) @endforeach

{{ $reviewMeta[$reviewClass] ?? __('All rows') }}

{{ __('Nothing is merged. For each match, link the existing record, fill in what it is missing, or skip the row.') }}

@if (($classCounts['match'] ?? 0) > 0) @endif @if (($classCounts['possible'] ?? 0) > 0) @endif
@forelse ($review['rows'] as $row) @php $choice = $decisions[$row['i']] ?? []; $decidable = in_array($row['class'], ['match', 'possible'], true) && $row['same_as'] === null; @endphp @empty @endforelse
{{ __('Row') }} {{ __('Organisation') }} {{ __('Contact') }} {{ __('Class') }} {{ __('What to do') }}
{{ $row['row'] }} {{ $row['org']['name'] ?? __('No name') }}

{{ collect([$row['org']['website'] ?? null, $row['org']['email'] ?? null, $row['org']['phone'] ?? null])->filter()->join(' · ') }}

{{ $row['contact']['name'] ?? '-' }} @if (! empty($row['contact']['email']))

{{ $row['contact']['email'] }}

@endif
{{ __(\App\Services\Crm\Import\ProfileStager::CLASSES[$row['class']]) }} @if ($row['class'] === 'error') {{ implode(' ', $row['errors']) }} @elseif ($row['same_as'] !== null) {{ __('Same organisation as an earlier row: its contact is added there.') }} @elseif ($row['class'] === 'new') {{ __('Create a new prospect') }} @elseif ($decidable)
@if (in_array($choice['action'] ?? '', ['link', 'update'], true) && count($row['matches']) > 1) @endif
    @foreach ($row['matches'] as $match) @php $existing = $customers[$match['customer_id']] ?? null; @endphp
  • {{ $existing?->name ?? __('Organisation #:id', ['id' => $match['customer_id']]) }}: {{ __('same :fields', ['fields' => implode(', ', $match['matched_on'])]) }}. {{ $existing?->relationshipOwner ? __('Owned by :name.', ['name' => $existing->relationshipOwner->name]) : __('No relationship owner.') }}
  • @endforeach
@endif
@if ($pages > 1)
{{ __('Page :page of :pages', ['page' => $reviewPage, 'pages' => $pages]) }}
@if ($reviewPage > 1) {{ __('Previous') }} @endif @if ($reviewPage < $pages) {{ __('Next') }} @endif
@endif
@endif {{-- Sticky footer --}} @if ($step > 1)
{{ __('Back') }}
@if ($step === 2) {{ __('Check the rows') }} {{ __('Checking every row…') }} @elseif ($step === 3) {{ __('Review') }} @elseif ($step === 4) @if ($undecided > 0) {{ trans_choice(':count possible duplicate needs a decision|:count possible duplicates need a decision', $undecided, ['count' => $undecided]) }} @endif {{ __('Import :count rows', ['count' => number_format($batch?->total_rows ?? 0)]) }} {{ __('Starting…') }} @endif
@endif