@extends('admin.layouts.app') @php $locale = app()->getLocale(); $nameField = $locale === 'ar' ? 'name_ar' : 'name_en'; $dash = __('application_detail.not_available'); $optionName = static fn ($option): string => (string) ($option?->{$nameField} ?: $option?->name_en ?: $option?->name_ar ?: $option?->value ?: $dash); $value = static fn ($value): string => filled($value) ? (string) $value : $dash; $money = static fn ($value): string => $value === null || $value === '' ? $dash : number_format((float) $value, 2).' '.__('application_detail.sar'); $isCurrent = (int) $investor->current_investor_application_id === (int) $application->id; $displayName = (string) $investor->display_name; $title = $displayName; $initials = collect(preg_split('/\s+/', trim($displayName)) ?: [])->filter()->take(2)->map(fn ($part) => mb_strtoupper(mb_substr($part, 0, 1)))->implode('') ?: '—'; $legacyImage = $investor->files->firstWhere('file_type', \App\Models\File::TYPE_IMAGE); $profilePhotoUrl = static function ($path): ?string { if (blank($path)) { return null; } $path = (string) $path; if (preg_match('~^https?://~i', $path)) { return $path; } $path = ltrim($path, '/'); return str_starts_with($path, 'storage/') ? '/'.$path : '/storage/'.$path; }; $avatarUrl = $profilePhotoUrl($investor->avatar_path) ?: ($legacyImage ? route('admin.files.show', $legacyImage) : null); $country = $investor->country?->{$nameField} ?: $investor->country?->name_en ?: $investor->country?->name_ar; $city = $investor->city?->{$nameField} ?: $investor->city?->name_en ?: $investor->city?->name_ar; $location = collect([$city, $country])->filter()->join(' · ') ?: $dash; $externalUrl = static function ($url): ?string { if (blank($url)) { return null; } return preg_match('~^https?://~i', (string) $url) ? (string) $url : 'https://'.ltrim((string) $url, '/'); }; $linkedinUrl = $externalUrl($investor->linkedin_profile); $whatsappNumber = preg_replace('/\D+/', '', (string) $investor->phone_number); if (str_starts_with($whatsappNumber, '00')) { $whatsappNumber = substr($whatsappNumber, 2); } $whatsappUrl = filled($whatsappNumber) ? 'https://wa.me/'.$whatsappNumber : null; $fieldLabel = static fn (string $field): string => (string) __('admin.investors_admin.fields.'.$field); $catalogValue = static function (string $field) use ($applicationOptionCatalogs, $dataValues, $optionName, $dash): string { $id = $dataValues[$field] ?? null; return $id === null ? $dash : $optionName($applicationOptionCatalogs->get($field, collect())->firstWhere('id', (int)$id)); }; $companies = old('fields.previous_investments_companies', $dataValues['previous_investments_companies'] ?? []); $companies = is_array($companies) && $companies !== [] ? $companies : ['']; $investmentOptionFields = [ 'average_ticket_option_id', 'expected_annual_investments_option_id', 'investment_experience_level_option_id', 'has_angel_invested_option_id', 'exit_experience_option_id', 'investment_method_option_id', ]; $classificationFields = [ 'category_option_id', 'background_option_id', 'investment_experience_option_id', 'activity_in_numu_option_id', 'is_in_other_angel_group_option_id', 'referral_source_option_id', 'template_name_option_id', ]; $selectedPivotOptions = static function (string $field) use ($applicationPivotCatalogs, $dataValues) { $selected = collect($dataValues[$field] ?? [])->map(static fn ($id) => (int)$id); return $applicationPivotCatalogs->get($field, collect())->whereIn('id', $selected)->values(); }; $privacyAccepted = old('fields.accepted_privacy_policy', $dataValues['accepted_privacy_policy'] ?? null); $activityItems = $activity->getCollection(); @endphp @section('title', __('application_detail.investor_title').' · '.$title) @section('page_title', __('application_detail.investor_title')) @push('styles') @endpush @section('content')
@include('admin.partials.application-detail-icons')
{{ $initials }}@if($avatarUrl){{ $displayName }}@endif

{{ __('application_detail.hero.investor_application_type') }}

{{ $displayName }}

{{ __('application_detail.application_number', ['number' => $application->application_number]) }} · {{ $application->submitted_at ? __('application_detail.submitted', ['date' => $application->submitted_at->translatedFormat('j M Y, H:i')]) : __('application_detail.not_submitted') }}@if($application->source) · {{ __('application_detail.source') }}: {{ $application->source }}@endif

{{ $isCurrent ? __('application_detail.current') : __('application_detail.historical') }} {{ __('application_detail.workflow.status') }}: {{ $optionName($application->statusOption) }} {{ __('application_detail.workflow.group') }}: {{ $application->group?->name ?: $dash }}
@foreach([ ['url' => $investor->phone_number ? 'tel:'.$investor->phone_number : null, 'icon' => 'phone', 'class' => 'phone', 'label' => __('admin.investors_admin.fields.phone_number'), 'external' => false], ['url' => $whatsappUrl, 'icon' => 'whatsapp', 'class' => 'whatsapp', 'label' => __('application_detail.actions.whatsapp'), 'external' => true], ['url' => $investor->email ? 'mailto:'.$investor->email : null, 'icon' => 'mail', 'class' => 'mail', 'label' => __('admin.investors_admin.fields.email'), 'external' => false], ['url' => $linkedinUrl, 'icon' => 'linkedin', 'class' => 'linkedin', 'label' => __('admin.investors_admin.fields.linkedin_profile'), 'external' => true], ] as $contactAction) @if($contactAction['url']) @else @endif @endforeach
{{ __('application_detail.actions.view_profile') }} {{ __('application_detail.actions.view_timeline') }} @if(auth('admin')->user()?->can('investments.manage'))
{{ __('admin.investments_index.add') }}@endif
@foreach([ ['annual_investments', $catalogValue('expected_annual_investments_option_id'), 'activity'], ['investments_count', $value($dataValues['investments_count'] ?? null), 'workflow'], ['average_ticket', $catalogValue('average_ticket_option_id'), 'cash'], ['background', $catalogValue('background_option_id'), 'business'], ['experience', $catalogValue('investment_experience_level_option_id'), 'business'], ['activity_numu', $catalogValue('activity_in_numu_option_id'), 'activity'], ] as [$metric, $metricValue, $icon])
{{ __('application_detail.metrics.'.$metric) }}
{{ $metricValue }}
@endforeach
@if(session('success'))
{{ session('success') }}
@endif @if($errors->any())@endif
@foreach([ [__('admin.investors_admin.fields.name'), $displayName, 'profile', null, false, null, false], [__('admin.investors_admin.fields.full_name_en'), $investor->full_name_en, 'profile', null, false, null, false], [__('admin.investors_admin.fields.full_name_ar'), $investor->full_name_ar, 'profile', null, false, null, false], [__('admin.investors_admin.fields.email'), $investor->email, 'mail', $investor->email ? 'mailto:'.$investor->email : null, false, $investor->email, false], [__('admin.investors_admin.fields.phone_number'), $investor->phone_number, 'phone', $investor->phone_number ? 'tel:'.$investor->phone_number : null, false, $investor->phone_number, true], [__('admin.investors_admin.fields.country_id'), $location, 'location', null, false, null, false], [__('admin.investors_admin.fields.linkedin_profile'), $linkedinUrl ? 'LinkedIn' : null, 'linkedin', $linkedinUrl, true, $linkedinUrl, false], [__('application_detail.source'), $investor->source, 'file', null, false, null, false], ] as [$label, $identityValue, $icon, $href, $opensNewTab, $copyValue, $showWhatsapp]) @php($hasIdentityValue = filled($identityValue) && $identityValue !== $dash)
{{ $label }}@if($href && $hasIdentityValue){{ $value($identityValue) }}@else{{ $value($identityValue) }}@endif @if(filled($copyValue) || ($showWhatsapp && $whatsappUrl)) @if(filled($copyValue))@endif @if($showWhatsapp && $whatsappUrl)@endif @endif
@endforeach

{{ __('application_detail.account_context_help') }}

{{ __('application_detail.actions.view_timeline') }}

{{ __('application_detail.workflow_history.current_state') }}

{{ __('application_detail.workflow.group') }}{{ $application->group?->name ?: $dash }}
{{ __('application_detail.workflow.status') }}{{ $optionName($application->statusOption) }}
{{ __('application_detail.workflow.action') }}{{ $optionName($application->action) }}
@if(filled($application->rejection_reason))
{{ __('admin.rejection_modal.reason_label') }}{{ $application->rejection_reason }}
@endif

{{ $isCurrent ? __('application_detail.current_projection_help') : __('application_detail.historical_projection_help') }}

@include('admin.partials.application-workflow-history', ['items' => $activityItems])
@foreach([ 'group_id' => [__('application_detail.workflow.group'), $workflowOptions['groups'], 'name'], 'status_option_id' => [__('application_detail.workflow.status'), $workflowOptions['statuses'], $nameField], 'action_option_id' => [__('application_detail.workflow.action'), $workflowOptions['actions'], $nameField], ] as $field => [$label, $options, $display])
@csrf @method('PATCH')@if($field === 'action_option_id')@endif
@endforeach
{{ $fieldLabel('investor_bio') }}{{ $value($dataValues['investor_bio'] ?? null) }}
{{ $fieldLabel('previous_investments_companies') }}
@forelse($dataValues['previous_investments_companies'] ?? [] as $company){{ $company }}@empty{{ $dash }}@endforelse
@csrf @method('PATCH')
{{ $fieldLabel('previous_investments_companies') }}
@foreach($companies as $company)
@endforeach
{{ __('application_detail.companies_help') }}
@include('admin.partials.application-form-actions')
@foreach($investmentOptionFields as $field)
{{ $fieldLabel($field) }}{{ $catalogValue($field) }}
@endforeach @foreach(['investments_count','investment_cap_sar','number','investment_value','wishlist_value','formula_result','demo_date','joining_date'] as $field)
{{ $fieldLabel($field) }}{{ $field === 'investment_cap_sar' ? $money($dataValues[$field] ?? null) : $value($dataValues[$field] ?? null) }}
@endforeach
@csrf @method('PATCH')
@foreach($investmentOptionFields as $field)@endforeach @foreach(['investment_value','wishlist_value','formula_result'] as $field)@endforeach @foreach(['demo_date','joining_date'] as $field)@endforeach
@include('admin.partials.application-form-actions')
@foreach($classificationFields as $field)
{{ $fieldLabel($field) }}{{ $catalogValue($field) }}
@endforeach
@csrf @method('PATCH')
@foreach($classificationFields as $field)@endforeach
@include('admin.partials.application-form-actions')
@foreach(['sectors' => __('application_detail.metrics.sectors'), 'stages' => __('application_detail.metrics.stages'), 'payment_methods' => $fieldLabel('investment_method_option_id')] as $field => $label)
{{ $label }}
@forelse($selectedPivotOptions($field) as $selected)@if($field === 'sectors'){{ $optionName($selected) }}@else{{ $optionName($selected) }}@endif @empty{{ __('application_detail.empty.chips') }}@endforelse
@endforeach
@csrf @method('PATCH')
@foreach(['sectors' => __('application_detail.metrics.sectors'), 'stages' => __('application_detail.metrics.stages'), 'payment_methods' => $fieldLabel('investment_method_option_id')] as $field => $label)@php($selectedValues = collect(old('fields.'.$field, $dataValues[$field] ?? []))->map(static fn($id) => (int)$id)->all())@endforeach
@include('admin.partials.application-form-actions')
{{ __('application_detail.sections.privacy') }}{{ $privacyAccepted === null || $privacyAccepted === '' ? __('application_detail.privacy.not_recorded') : ((bool)$privacyAccepted ? __('application_detail.privacy.accepted') : __('application_detail.privacy.not_accepted')) }}
{{ __('application_detail.privacy.accepted_at') }}{{ $value($dataValues['accepted_privacy_policy_at'] ?? null) }}
{{ __('application_detail.privacy.ip') }}{{ $value($dataValues['accepted_privacy_policy_ip'] ?? null) }}
{{ __('application_detail.privacy.version') }}{{ $value($dataValues['accepted_privacy_policy_version'] ?? null) }}
@csrf @method('PATCH')
@include('admin.partials.application-form-actions')
@forelse($application->meetings as $meeting)
{{ $meeting->title ?: '#'.$meeting->id }}
{{ $meeting->meeting_date?->translatedFormat('j M Y') ?: $dash }} · {{ $meeting->status ?: $dash }}
{{ __('application_detail.actions.open') }}
@empty
{{ __('application_detail.empty.meetings') }}
@endforelse
@include('admin.partials.application-notes', [ 'applicationNotes' => $application->notes, 'noteStoreAction' => route('admin.investors.applications.notes.store', [$investor, $application]), 'noteUpdateAction' => fn ($note) => route('admin.investors.applications.notes.update', [$investor, $application, $note]), 'noteDestroyAction' => fn ($note) => route('admin.investors.applications.notes.destroy', [$investor, $application, $note]), ])
@forelse($activityItems as $event)
{{ $event['event_label'] }}{{ $event['source_label'] }}

{{ $event['summary'] }}

{{ $event['actor'] }}

@if($event['reason'])

{{ __('application_detail.activity.reason') }}: {{ $event['reason'] }}

@endif @if($event['changes'])
@foreach($event['changes'] as $change)
{{ $change['label'] }}{{ $change['before'] }}→{{ $change['after'] }}
@endforeach
@endif
@empty
{{ __('application_detail.empty.activity') }}
@endforelse
@include('admin.partials.rejection-modal') @endsection @push('scripts') @endpush