ldc-supportweb/resources/views/ticket/index.blade.php

201 lines
11 KiB
PHP

@extends('layout.app')
@section('content')
@php
$userPr = Auth::user()->sites ?? collect([]);
@endphp
<div class="container container-xxl">
<h2>
Gestion des tickets @if(request()->status) (Archivés) @endif
<div class="float-end">
<div class="row">
<div class="col">
<div class="btn-group float-end">
<a href="{{ route('ticket.create') }}" class="btn btn-primary">{{ __('Créer un ticket') }}</a>
@if(session('tickets.st') == TicketStatus::archived())
<a href="{{ route('ticket.index', ['sts' => -1 ]) }}" class="btn btn-success">{{ __('Tickets Actifs') }}</a>
@else
<a href="{{ route('ticket.index', ['st' => TicketStatus::archived()]) }}" class="float-end btn btn-secondary">{{ __('Tickets Archivés') }}</a>
@endif
<a href="{{ route('ticket.index', ['rst' => 1]) }}" class="btn btn-dark">{{ __('Réinitialiser le tri') }}</a>
</div>
<div class="float-end me-2">
<select class="form-select" onchange="window.location='{{ route('ticket.index') }}?'+(this.value == -1 ? 'prs=-1' : 'pr='+this.value);">
<option value="-1">{{ __('Tous') }}</option>
@foreach($sites as $site)
@if (Auth::user()->isAdmin())
<option value="{{ $site->id }}" @if(intval(session('tickets.pr'))==$site->id)selected="selected" @endif>{{ $site->name }}</option>
@elseif ($userPr->filter(function($pr) use($site) { return $pr->id === $site->id; })->count())
<option value="{{ $site->id }}" @if(intval(session('tickets.pr'))==$site->id)selected="selected" @endif>{{ $site->name }}</option>
@endif
@endforeach
</select>
</div>
<div class="float-end me-2">
<select class="form-select" onchange="window.location='{{ route('ticket.index') }}?'+(this.value == -1 ? 'sts=-1' : 'st='+this.value);">
<option value="-1">{{ __('Tous') }}</option>
@foreach($status as $statut)
<option value="{{ $statut->value }}" @if(intval(session('tickets.st'))==$statut->value)selected="selected" @endif>{{ $statut->label }}</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="row">
<div class="col">
<form id="searchTicketForm" class="float-end mt-3 w-75" action="{{ request()->fullUrlWithQuery(['search' => '']) }}">
<div class="input-group mb-3">
<input id="searchTicket" type="text" name="search" class="form-control" placeholder="{{ __('Recherche de ticket..') }}" aria-label="{{ __('Recherche de ticket..') }}" aria-describedby="searchTicket" value="{{ session()->get('tickets.search') }}">
<button class="btn btn-outline-danger" type="button" onclick="document.getElementById('searchTicket').value = '';document.getElementById('searchTicketForm').submit();">&#9003;</button>
<button class="btn btn-outline-primary" type="submit">&#128269;</button>
</div>
</form>
</div>
</div>
</div>
</h2>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
#&nbsp;
@include('modules.sorter', ['colname' => 'id'])
</th>
<th scope="col">
{{__('Projet') }}&nbsp;
@include('modules.sorter', ['colname' => 'site_id'])
</th>
<th scope="col">
{{__('Type') }}&nbsp;
@include('modules.sorter', ['colname' => 'type'])
</th>
<th scope="col">{{__('Fichier') }}</th>
<th scope="col">{{__('Fichier 2') }}</th>
<th scope="col">
{{__('Date de création') }}&nbsp;
@include('modules.sorter', ['colname' => 'created_at'])
</th>
<th scope="col">
{{__('Créé par') }}&nbsp;
@include('modules.sorter', ['colname' => 'created_by'])
</th>
<th scope="col">
{{__('Statut') }}&nbsp;
@include('modules.sorter', ['colname' => 'status'])
</th>
<th scope="col">{{__('Contenu') }}</th>
<th>{{__('Actions') }}</th>
</tr>
</thead>
<tbody>
@if(!count($tickets))
<tr>
<td colspan="10" class="text-center">
<h2>{{ __('Aucun ticket') }}</h2>
</td>
</tr>
@endif
@foreach ($tickets as $ticket)
@php
$cls = $ticket->status == TicketStatus::archived() ? 'text-secondary' : null;
$cls = (!$cls && $ticket->status == TicketStatus::new()) ? 'text-danger' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::processed()) ? 'text-info' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::recette()) ? 'text-primary' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::production()) ? 'text-success' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::inprogress()) ? 'text-dark' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::waiting()) ? 'text-white bg-danger' : $cls;
$ticketClass = 'bg-primary';
switch($ticket->type) {
case TicketType::bug():
$ticketClass = 'bg-danger';
break;
case TicketType::evolution():
$ticketClass = 'bg-success';
break;
case TicketType::newsletter():
$ticketClass = 'bg-warning';
break;
}
@endphp
<tr>
<td scope="row">
{{ $ticket->id }}
@if ($ticket->is_internal)
🔒
@endif
</td>
<td>{{ $ticket->site->name }}</td>
<td>
<span class="badge {{ $ticketClass }}">{{ $ticket->type->label }}</span>
</td>
<td>
@if ($ticket->file !== null)
<a data-fslightbox="gallery" href="{{ asset($ticket->file) }}" class="btn btn-sm btn-outline-primary" target="_blank">Fichier</a>
@endif
</td>
<td>
@if ($ticket->file2 !== null)
<a data-fslightbox="gallery" href="{{ asset($ticket->file2) }}" class="btn btn-sm btn-outline-primary" target="_blank">Fichier 2</a>
@endif
</td>
<td>{{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }}</td>
<td>{{ $ticket->user ? $ticket->user->name : __('Utilisateur supprimé') }}</td>
<td><span class="rounded {{ $cls }}">{{ $ticket->status->label }}</span></td>
<td>
{{-- Modal du ticket --}}
<!-- Button trigger modal -->
<button type="button" class="btn btn-sm btn-outline-primary" data-bs-toggle="modal" data-bs-target="#ticket{{ $ticket->id }}Modal">
{{ __('Aperçu') }}
</button>
<!-- Modal -->
<div class="modal fade" id="ticket{{ $ticket->id }}Modal" tabindex="-1" aria-labelledby="ticket{{ $ticket->id }}ModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ticket{{ $ticket->id }}ModalLabel">
<b>{{ $ticket->site->name }}</b> -
<u>
{{__('Ticket n°') }} {{ $ticket->id }}
@if ($ticket->is_internal)
🔒
@endif
</u>&nbsp;-&nbsp;
<span class="badge {{ $ticketClass }}">
{{$ticket->type->label}}
</span>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ __('Fermer') }}"></button>
</div>
<div class="modal-body">
<p>{!! clean(nl2br($ticket->text)) !!}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-primary" data-bs-dismiss="modal">{{ __('Fermer') }}</button>
</div>
</div>
</div>
</div>
</td>
<td>
<a href="{{ route('ticket.show', $ticket->id) }}" class="btn btn-sm btn-outline-success">{{ __('Messages') }}</a>
@if(auth()->user()->isAdmin())
<a href="{{ route('ticket.edit', $ticket) }}" class="btn btn-sm btn-outline-primary">{{ __('Modifier') }}</a>
@endif
@can('delete', $ticket)
@if(!$ticket->status->equals(TicketStatus::archived()))
<form method="POST" action="{{ route('ticket.archive', $ticket) }}">
@method('PUT')
@csrf
<button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('Êtes-vous sûr(e) ?')">{{ __('Archiver') }}</button>
</form>
@endif
@endcan
</td>
</tr>
@endforeach
</tbody>
</table>
{{ $tickets->withQueryString()->links() }}
</div>
@endsection