ldc-supportweb/resources/views/ticket/index.blade.php
2021-07-05 18:35:59 +02:00

168 lines
9.1 KiB
PHP

@extends('layout.app')
@section('content')
@php
$userPr = Auth::user()->projects ?? 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(request()->status)
<a href="{{ route('ticket.index') }}" class="btn btn-success">{{ __('Tickets en cours') }}</a>
@else
<a href="{{ route('ticket.index', ['status' => 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($projects as $project)
@if (Auth::user()->role->equals(Role::admin()))
<option value="{{ $project->id }}" @if(intval(session('tickets.pr')) == $project->id)selected="selected" @endif>{{ $project->name }}</option>
@elseif ($userPr->filter(function($pr) use($project) { return $pr->id === $project->id; })->count())
<option value="{{ $project->id }}" @if(intval(session('tickets.pr')) == $project->id)selected="selected" @endif>{{ $project->name }}</option>
@endif
@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="{{ request()->search }}">
<button class="btn btn-outline-danger" type="button" onclick="$('#searchTicket').val('');$('#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' => 'project_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)
<tr>
<td scope="row">
{{ $ticket->id }}
</td>
<td>{{ $ticket->project->name }}</td>
<td>
@if ($ticket->type->equals(TicketType::bug()))
<span class="badge bg-danger">{{ $ticket->type->label }}</span>
@else
<span class="badge bg-success">{{ $ticket->type->label }}</span>
@endif
</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->name }}</td>
@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;
@endphp
<td><span class="{{ $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">
{{ $ticket->project->name }} - {{__('Ticket N°') }}{{ $ticket->id }} - {{ $ticket->type === 0 ? "Bug" : "Évolution" }}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>{!! nl2br(e($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()->role->equals(Role::admin()))
<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