Integration Baniere dans le backend
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
@extends('layouts.app')
|
||||
@section('title', 'Campagnes — Signatures CABM')
|
||||
@section('content')
|
||||
@php
|
||||
$isAdmin = auth()->user()->hasRole('admin');
|
||||
$tz = config('signature.timezone');
|
||||
$badge = ['running' => 'ok', 'scheduled' => '', 'inactive' => 'warn', 'ended' => ''];
|
||||
$variable = '{'.'{'.'{banniere}'.'}'.'}';
|
||||
$period = fn ($d) => $d->timezone($tz)->format('d/m/Y H:i');
|
||||
@endphp
|
||||
<div class="row" style="margin-bottom:8px">
|
||||
<h1 style="margin:0">Campagnes</h1>
|
||||
<span class="spacer"></span>
|
||||
<a class="btn" href="{{ route('admin.campaigns.create') }}">Nouvelle campagne</a>
|
||||
</div>
|
||||
<p class="muted">
|
||||
Une campagne ajoute une bannière sous la signature pendant une période, pour tous les agents ou pour certains groupes AD.
|
||||
<strong>Une seule bannière par signature</strong> : si plusieurs campagnes en cours concernent un agent, celle dont la priorité
|
||||
est la plus haute l'emporte (à égalité : la plus ancienne). La bannière n'apparaît que dans la signature complète,
|
||||
pas dans la signature courte des réponses, et seulement si le template contient <code>{{ $variable }}</code>.
|
||||
@unless ($isAdmin) Vous préparez les campagnes ; un administrateur les active. @endunless
|
||||
</p>
|
||||
|
||||
@if ($withoutBanner->isNotEmpty())
|
||||
<div class="notice" role="note">
|
||||
Ces templates publiés ne contiennent pas <code>{{ $variable }}</code> : leurs agents ne verront aucune bannière —
|
||||
{{ $withoutBanner->join(', ') }}.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card" style="overflow-x:auto">
|
||||
<table class="list">
|
||||
<thead><tr><th style="width:130px">Bannière</th><th>Campagne</th><th>Période</th><th>Destinataires</th><th>Priorité</th><th>État</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
@forelse ($campaigns as $c)
|
||||
@php
|
||||
$status = $c->status();
|
||||
$locked = $c->active && ! $isAdmin;
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
@if (in_array($c->id, $missing, true))
|
||||
<span class="badge warn">image manquante</span>
|
||||
<div class="muted">{{ $c->image_path }}</div>
|
||||
@else
|
||||
<img src="{{ asset('img/'.$c->image_path) }}" alt="{{ $c->alt_text }}" style="max-width:120px;max-height:60px;border:1px solid var(--line);background:#fff">
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.campaigns.edit', $c) }}"><strong>{{ $c->name }}</strong></a>
|
||||
<div class="muted">
|
||||
@if ($c->link_url)
|
||||
Lien : <a href="{{ $c->link_url }}" target="_blank" rel="noopener">{{ \Illuminate\Support\Str::limit($c->link_url, 50) }}</a>
|
||||
@else
|
||||
Sans lien
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
<td style="white-space:nowrap">{{ $period($c->starts_at) }}<br>→ {{ $period($c->ends_at) }}</td>
|
||||
<td style="overflow-wrap:anywhere">{{ $c->groups->isEmpty() ? 'Tous les agents' : $c->groups->pluck('display_name')->join(', ') }}</td>
|
||||
<td>{{ $c->priority }}</td>
|
||||
<td>
|
||||
<span class="badge {{ $badge[$status] }}">{{ \App\Models\Campaign::STATUSES[$status] }}</span>
|
||||
@if ($status === 'running')
|
||||
<div class="muted">
|
||||
@if (($reach[$c->id] ?? 0) > 0)
|
||||
vue par {{ $reach[$c->id] }} agent{{ $reach[$c->id] > 1 ? 's' : '' }}
|
||||
@else
|
||||
aucun agent : masquée par une campagne plus prioritaire, ou groupes vides
|
||||
@endif
|
||||
</div>
|
||||
@elseif ($status === 'inactive')
|
||||
<div class="muted">{{ $isAdmin ? 'à activer' : 'en attente d\'un administrateur' }}</div>
|
||||
@endif
|
||||
</td>
|
||||
<td style="text-align:right">
|
||||
<a class="btn secondary small" style="margin:2px 0" href="{{ route('admin.campaigns.edit', $c) }}">{{ $locked ? 'Voir' : 'Modifier' }}</a>
|
||||
@if ($isAdmin)
|
||||
@if ($status !== 'ended')
|
||||
<form class="inline" method="post" action="{{ route('admin.campaigns.toggle', $c) }}">
|
||||
@csrf
|
||||
<button class="btn secondary small" style="margin:2px 0" type="submit">{{ $c->active ? 'Désactiver' : 'Activer' }}</button>
|
||||
</form>
|
||||
@endif
|
||||
<form class="inline" method="post" action="{{ route('admin.campaigns.destroy', $c) }}"
|
||||
onsubmit="return confirm('Supprimer cette campagne ? Les messages déjà envoyés conservent la bannière.')">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn danger small" style="margin:2px 0" type="submit">Supprimer</button>
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="7" class="muted">Aucune campagne. Les signatures sont envoyées sans bannière.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="muted">Vérifiez la bannière reçue par un agent précis dans l'onglet <a href="{{ route('admin.agents.index') }}">Agents</a>.</p>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user