ldc-mesbr-app/resources/views/campagnes/edit.blade.php
2025-11-07 11:08:02 +01:00

147 lines
5.5 KiB
PHP

@extends('layouts.main')
@section('content')
<h2>
<i class="fa fa-folder">
<i class="fas fa-ticket-alt"></i>
</i>
{{ __('Editer la campagne') }}
</h2>
<div class="form-wrapper">
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('campagne.update', ['campagne' => $campagne]) }}" method="POST">
@csrf
@method('PUT')
<div class="form-split">
<div class="form-field">
<label>{{ __('Nom') }}</label>
<input type="text" name="camp_name" value="{{ $campagne->camp_name }}" required>
</div>
<div class="form-field">
<label>{{ __('Type') }}</label>
<select name="camp_type" id="camp_type">
@foreach (CampaignTypes::toArray() as $type)
<option value="{{ $type->value }}" @if ($campagne->camp_type->equals($type)) selected @endif>{{ $type->label }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-split">
<div class="form-field">
<label>{{ __('Publier') }}</label>
<select name="camp_published">
<option value="0" @if ($campagne->camp_published === 0) selected @endif>{{ __('Non') }}</option>
<option value="1" @if ($campagne->camp_published === 1) selected @endif>{{ __('Oui') }}</option>
</select>
</div>
<div class="form-field limitPrinting">
<label for="camp_limitedPrinting">{{ __('Limiter les impressions à 1 BR à la fois') }}</label>
<input id="camp_limitedPrinting" {{ $campagne->camp_limitedPrinting === 1 ? 'checked="checked"' : '' }} name="camp_limitedPrinting" type="checkbox" value="{{ $campagne->camp_limitedPrinting }}">
<label for="camp_limitedPrinting"></label>
</div>
</div>
<div class="form-field submit">
<input type="submit" value="{{ __('Mettre à jour') }}">
</div>
</form>
</div>
<div class="coupons-wrapper">
<h2>
<i class="fas fa-ticket-alt"></i>
{{ __('Coupons de la campagne') }}
</h2>
<table>
<thead>
<th>{{ __('Code') }}</th>
<th>{{ __('Nom') }}</th>
<th></th>
</thead>
@foreach($campagne->coupons as $coupon)
<tr class="@if($coupon->coupon_published == 0) notPublished @endif">
<td>{{ $coupon->coupon_code }}</td>
<td>{{ $coupon->coupon_name }}</td>
<td><i class="fas fa-times delete-coupon" data-campid={{$campagne->camp_id}} data-couponid={{$coupon->coupon_id}}></i></td>
</tr>
@endforeach
</table>
@if(count($campagne->coupons) === 0)
<p class="no-result">{{ __('Pas de coupons liés') }}</p>
@endif
<input type="hidden" name="csrf" id="csrf" value="<?= csrf_token(); ?>">
<button data-fancybox data-src="#coupons-list" href="javascript:;">
{{ __('Ajouter des coupons a cette campagne') }}
</button>
</div>
<div class="notifs-wrapper">
<h2><i class="fas fa-bell"></i> {{ __('Notifications par mail') }}</h2>
<div class="form-wrapper">
<form action="{{ route('campaign.new-notif', ['campaign' => $campagne]) }}" method="POST">
@csrf
<div class="form-split">
<div class="form-field">
<label>{{ __('Nom') }}</label>
<input type="text" name="notif_name" required>
</div>
<div class="form-field"></div>
<div class="form-field">
<label>{{ __('Email') }}</label>
<input type="email" name="notif_email" required>
</div>
<div class="form-field">
<span></span>
<input type="submit" value="{{ __('Ajouter') }}">
</div>
</div>
</form>
</div>
<table>
<thead>
<tr>
<th>{{__('No') }}</th>
<th>{{__('Nom') }}</th>
<th>{{__('Email') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($campagne->notifications as $n)
<tr>
<td>{{ $n->notif_id }}</td>
<td>{{ $n->notif_name }}</td>
<td>{{ $n->notif_email }}</td>
<td><a href="{{ route('campaign.delete-notif', $n->notif_id) }}"><i class="fas fa-times delete-icon"></i></a></td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div id="coupons-list" style="display:none;">
<h2>
<i class="fas fa-ticket-alt"></i>
{{ __('Ajouter des Coupons') }}
</h2>
@foreach($coupons as $coupon)
<div class="inputGroup @if($coupon->coupon_published == 0) notPublished @endif">
<input id="coupon[{{$coupon->coupon_id}}]" name="coupon[{{$coupon->coupon_id}}]" type="checkbox" value="{{$coupon->coupon_id}}"/>
<label for="coupon[{{$coupon->coupon_id}}]">{{$coupon->coupon_name}}</label>
</div>
@endforeach
<input type="hidden" name="camp_id" id="camp_id" value="{{ $campagne->camp_id }}">
<input type="hidden" name="csrf" id="csrf" value="<?= csrf_token(); ?>">
<input type="submit" id="addCoupons" value="Ajouter">
</div>
<form method="POST" id="delete-hidden">
@csrf
@method('DELETE')
</form>
@endsection