@extends('layouts.dashboard') @section('content') @php use App\Models\AdCampaign; /** * Vendor → Sponsored ads → one placement. The owner's full view of their campaign: * creative at real size, buy facts, and the moderation trail — including the reason a * rejected one was rejected. While the placement is still pending and unpaid its content * can be corrected here (the one window where nothing has been decided or charged); * after that the page is read-only. Saving never moves status: the state machine * (pending → approved → active once paid) belongs to moderation and payment. * * @var array $c campaign row (+ dish_*) * @var array $history moderation events, newest first * @var bool $editable pending + unpaid * @var array $menuItems this restaurant's dishes (only when editable) */ $status = (string) $c['status']; $statusPill = static function (string $s): string { return match ($s) { 'active', 'approved' => 'qm-pill-green', 'pending' => 'qm-pill-amber', 'rejected', 'expired' => 'qm-pill-red', default => 'qm-pill-grey', }; }; $decidedVerb = static function (string $action): string { return match ($action) { 'approve' => t('admin.campaigns.decided_approved'), 'reject' => t('admin.campaigns.decided_rejected'), 'mark_paid' => t('admin.campaigns.decided_marked_paid'), 'edit' => t('admin.campaigns.decided_edited'), default => ucfirst(str_replace('_', ' ', $action)), }; }; $placement = (string) $c['placement']; $creative = (string) ($c['image'] ?? ''); $isVideo = $creative !== '' && str_ends_with(strtolower($creative), '.mp4'); $coverSrc = !$isVideo && $creative !== '' ? $creative : (string) ($c['dish_image'] ?? ''); @endphp @php /* .qm-d2: the dashboard density standard (app.css §35) */ @endphp
{{ t_raw('admin.campaigndetail.back') }}
{{ status_label('campaign', $status) }} {{ status_label('payment', (string) $c['payment_status']) }}

{{ $c['headline'] }}

{{ status_label('ad_placement', $placement) }}

@php /* Same cancel the list row offers, same handler; nothing new to learn. */ @endphp @if ($status === 'pending')
@csrf
@endif
{{ t_raw('admin.campaigns.col_placement') }}
{{ status_label('ad_placement', $placement) }} @if (($c['target_type'] ?? 'none') !== 'none' && !empty($c['target_slug'])) {{ status_label('ad_target_type', (string) $c['target_type']) }}: {{ (string) $c['target_slug'] }} @endif
{{ t_raw('common.period') }}
@if (!empty($c['starts_at'])) {!! fmt_day($c['starts_at']) !!} – {!! fmt_day($c['ends_at'] ?? null) !!} @else {{ t_raw('admin.campaigns.months_suffix', [':n' => (int) $c['months']]) }} @endif {{ t_raw('admin.campaigndetail.submitted') }}: {!! fmt_day($c['created_at']) !!}
{{ t_raw('common.price') }}
{{ money((float) $c['price']) }} {{ t_raw('admin.campaigns.months_suffix', [':n' => (int) $c['months']]) }}
{{ t_raw('admin.campaigns.col_payment') }}
{{ status_label('payment', (string) $c['payment_status']) }} @if (!empty($c['payment_ref'])){{ (string) $c['payment_ref'] }}@endif
{{ t_raw('admin.campaigndetail.dish') }}
{!! !empty($c['dish_name']) ? e((string) $c['dish_name']) : t('admin.campaigndetail.whole_restaurant') !!}

{{ t_raw('admin.campaigndetail.sec_creative') }}

@if ($isVideo) @elseif ($coverSrc !== '') @endif @if ($editable)
@csrf @if (AdCampaign::placementUses($placement, 'headline'))
@endif @if (AdCampaign::placementUses($placement, 'body'))
@endif
{!! media_field_html('image', $c['image'] ?? null, ['accept' => 'both']) !!}
@else @php /* Decided or paid: the creative is the record of what was bought/reviewed. */ @endphp @if (AdCampaign::placementUses($placement, 'body') && !empty($c['body']))

{{ (string) $c['body'] }}

@endif @endif

{{ t_raw('admin.campaigndetail.sec_history') }}

@if ($history) @foreach ($history as $h) @endforeach @else @partial('table-empty', ['colspan' => 3, 'icon' => 'fa-history', 'msg' => t('admin.campaigndetail.no_history')]) @endif
{{ t_raw('admin.reservationdetail.col_change') }}{{ t_raw('common.description') }}{{ t_raw('common.when') }}
@if (!empty($h['from_status']) && !empty($h['to_status']) && $h['from_status'] !== $h['to_status']) {{ status_label('campaign', (string) $h['from_status']) }} {{ status_label('campaign', (string) $h['to_status']) }} @else {!! $decidedVerb((string) $h['action']) !!} @endif
{!! or_dash($h['admin_note'] ?? null) !!}
{{ time_ago($h['created_at']) }}
@php /* /.qm-d2 */ @endphp @endsection