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

85 lines
2.7 KiB
PHP

@extends('layouts.main')
@section('content')
<h2>
<i class="fa fa-folder">
<i class="fas fa-ticket-alt"></i>
</i>
{{ __('Campagnes') }}
<a href="{{ route('campagne.create') }}" class="add-button">
<i class="fas fa-plus-square"></i>
{{ __('Ajouter') }}
</a>
</h2>
<div class="content-list">
<table>
<thead>
<tr>
<th>{{__('Ref') }}</th>
<th>{{__('Nom') }}</th>
<th>{{__('Création') }}</th>
<th class="center">{{__('Publié ?')}}</th>
<th class="center">{{__('Démo')}}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($campagnes as $c)
<tr>
<td>{{ $c->camp_id }}</td>
<td><a href="{{ route('campagne.edit', $c) }}">{{ $c->camp_name }}</a></td>
<td>{{ date('d/m/Y H:i', strtotime($c->camp_createdate)) }}</td>
@if ( $c->camp_published === 1)
<td class="pub center"><i data-campid="{{ $c->camp_id }}" class="fas fa-check-circle green unpublishcamp"></i></td>
@else
<td class="pub center"><i data-campid="{{ $c->camp_id }}" class="fas fa-times-circle red publishcamp"></i></td>
@endif
<td class="center">
@if ( $c->camp_published === 1)
<i class="fas fa-eye showTemplate" data-campid="{{ $c->camp_id }}"></i>
@endif
</td>
<td>
@if ($c->camp_published === 0)
<a href="{{ route('campagne.destroy', $c) }}"><i class="fas fa-times delete-icon"></i></a>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<form method="POST" id="delete-hidden">
@csrf
@method('DELETE')
</form>
<input type="hidden" id="csrf" value="<?= csrf_token(); ?>">
@endsection
@section('scripts')
<script>
$('.content-list').on('click', '.showTemplate', function(event){
let campid = $(this).attr('data-campid');
event.preventDefault();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
});
$.ajax({
url: '/bo/campagne/'+ campid +'/showDemo',
type: 'POST',
data: {},
dataType: 'JSON',
success: function (response) {
window.open(response, '_blank');
},
error: function (e) {
console.log(e.responseText);
}
});
})
</script>
@endsection