324 lines
24 KiB
PHP
324 lines
24 KiB
PHP
@extends('layout.app')
|
|
|
|
@section('title', __('models.classes.tickets'))
|
|
@section('description', __('Liste de tous les :model', ['model' => __('models.classes.tickets')]))
|
|
@section('bodyClass', 'content ticketsIndex')
|
|
|
|
@section('content')
|
|
@php
|
|
$userPr = Auth::user()->sites ?? collect([]);
|
|
@endphp
|
|
<div class="container-xxl container">
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2 class="d-inline">{{ __('Gestion des tickets') }} @if (Session::get('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value)
|
|
(Archivés)
|
|
@endif
|
|
</h2>
|
|
<div class="float-end">
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="btn-group float-end">
|
|
@can('isAdmin')
|
|
<a class="btn btn-info" href="{{ route('bo.labels.index') }}"><i class="fa-solid fa-tags"></i></a>
|
|
@endcan
|
|
<a class="btn btn-primary" href="{{ route('bo.ticket.create') }}"><i
|
|
class="fa-solid fa-square-plus"></i> {{ __('ticket') }}</a>
|
|
@if (session('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value)
|
|
<a class="btn btn-success" href="{{ route('bo.ticket.index', ['sts' => -1]) }}"><i
|
|
class="fa-solid fa-inbox"></i></a>
|
|
@else
|
|
<a class="float-end btn btn-secondary"
|
|
href="{{ route('bo.ticket.index', ['st' => \App\Enums\Tickets\TicketStatusEnum::archived]) }}"><i
|
|
class="fa-solid fa-box-archive"></i></a>
|
|
@endif
|
|
<a class="btn btn-dark" href="{{ route('bo.ticket.index', ['rst' => 1]) }}"><i
|
|
class="fa-solid fa-eraser"></i> {{ __(' le tri') }}</a>
|
|
</div>
|
|
<div class="float-end me-2">
|
|
<div class="input-group">
|
|
<label class="input-group-text" for="selectProject"><i
|
|
class="fa-solid fa-diagram-project"></i></label>
|
|
<select class="form-select" id="selectProject">
|
|
<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>
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.getElementById('selectProject').addEventListener('change', function(e) {
|
|
window.location = '{{ route('bo.ticket.index') }}?' + (this.value == -1 ? 'prs=-1' : 'pr=' + this.value);
|
|
});
|
|
</script>
|
|
@endpush
|
|
</div>
|
|
</div>
|
|
<div class="float-end me-2">
|
|
<div class="input-group">
|
|
<label class="input-group-text" for="selectStatus"><i class="fa-solid fa-sign-hanging"></i></label>
|
|
<select class="form-select" id="selectStatus">
|
|
<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>
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.getElementById('selectStatus').addEventListener('change', function(e) {
|
|
window.location = '{{ route('bo.ticket.index') }}?' + (this.value == -1 ? 'sts=-1' : 'st=' + this.value);
|
|
});
|
|
</script>
|
|
@endpush
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
@can('assignTickets', App\Models\Ticket::class)
|
|
<div class="col">
|
|
<div class="float-end me-2 mt-3">
|
|
<div class="input-group">
|
|
<label class="input-group-text" for="selectAssign"><i class="fa-solid fa-hat-wizard"></i></label>
|
|
<select class="form-select" id="selectAssign">
|
|
<option value="-1">{{ __('Tous') }}</option>
|
|
@foreach (\App\Models\User::adminUsers() as $user)
|
|
<option value="{{ $user->id }}"
|
|
@if (intval(session('tickets.ass')) == $user->id) selected="selected" @endif>{{ $user->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.getElementById('selectAssign').addEventListener('change', function(e) {
|
|
window.location = '{{ route('bo.ticket.index') }}?' + (this.value == -1 ? 'assr=-1' : 'ass=' + this.value);
|
|
});
|
|
</script>
|
|
@endpush
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endcan
|
|
<div class="col">
|
|
<form class="float-end w-75 mt-3" id="searchTicketForm"
|
|
action="{{ request()->fullUrlWithQuery(['search' => '']) }}">
|
|
<div class="input-group mb-3">
|
|
<input class="form-control" id="searchTicket" name="search" type="text"
|
|
value="{{ session()->get('tickets.search') }}" aria-label="{{ __('Recherche de ticket..') }}"
|
|
aria-describedby="searchTicket" placeholder="{{ __('Recherche de ticket..') }}">
|
|
<button class="btn btn-outline-danger" id="searchDelete" type="button"><i
|
|
class="fa-solid fa-delete-left"></i></button>
|
|
<button class="btn btn-outline-primary" type="submit"><i
|
|
class="fa-solid fa-magnifying-glass"></i></button>
|
|
</div>
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.getElementById('searchDelete').addEventListener('click', function(e) {
|
|
document.getElementById('searchTicket').value = '';
|
|
document.getElementById('searchTicketForm').submit();
|
|
});
|
|
</script>
|
|
@endpush
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table-hover table">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">
|
|
<span># </span>
|
|
<span>@include('modules.sorter', ['colname' => 'id'])</span>
|
|
</th>
|
|
<th scope="col">
|
|
<span>{{ __('Titre') }} </span>
|
|
<span>@include('modules.sorter', ['colname' => 'title'])</span>
|
|
</th>
|
|
<th scope="col">
|
|
<span>{{ __('Type') }} </span>
|
|
<span>@include('modules.sorter', ['colname' => 'type'])</span>
|
|
</th>
|
|
@can('assignLabels', App\Models\Ticket::class)
|
|
<th scope="col">{{ __('Étiquettes') }}</th>
|
|
@endcan
|
|
@if (Auth::user()->isAdmin())
|
|
<th scope="col">
|
|
<span>{{ __('Assigné à') }} </span>
|
|
<span>@include('modules.sorter', ['colname' => 'assigned_to'])</span>
|
|
</th>
|
|
@endif
|
|
<th scope="col">
|
|
<span>{{ __('Le') }} </span>
|
|
<span>@include('modules.sorter', ['colname' => 'created_at'])</span>
|
|
</th>
|
|
<th scope="col"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@if (!count($tickets))
|
|
<tr>
|
|
<td class="text-center" colspan="@if (Auth::user()->isAdmin()) 6 @else 5 @endif">
|
|
<h2>{{ __('Aucun ticket') }}</h2>
|
|
</td>
|
|
</tr>
|
|
@endif
|
|
@foreach ($tickets as $ticket)
|
|
<tr class="position-relative">
|
|
<td scope="row">
|
|
<div class="d-flex justify-content-between">
|
|
<span class="me-1">{{ $ticket->id }} @if ($ticket->is_internal)
|
|
<i class="fa-solid fa-lock"></i>
|
|
@endif
|
|
</span>
|
|
<span class="d-flex flex-column text-end">
|
|
@if (Auth::user()->isAdmin())
|
|
<a href="{{ route('bo.sites.show', $ticket->site) }}"
|
|
title="{{ __('Voir le site :sitename', [
|
|
'sitename' => $ticket->site->name,
|
|
]) }}">{{ $ticket->site->name }}</a>
|
|
@else
|
|
<span class="text-decoration-underline">{{ $ticket->site->name }}</span>
|
|
@endif
|
|
<span
|
|
class="{{ $ticket->status->class() }} rounded text-center">{{ $ticket->status->label() }}</span>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="me-1">{{ $ticket->title }}</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
|
|
</td>
|
|
@can('assignLabels', App\Models\Ticket::class)
|
|
<td>
|
|
<span class="ticket-index-labels">
|
|
@foreach ($ticket->labels as $label)
|
|
<span class="badge label colorize"
|
|
data-color="{{ $label->color }}">{{ $label->name }}</span>
|
|
@endforeach
|
|
</span>
|
|
</td>
|
|
@endcan
|
|
@if (Auth::user()->isAdmin())
|
|
<td>{{ $ticket->assignedUser ? $ticket->assignedUser->name : __('Personne') }}</td>
|
|
@endif
|
|
<td>{{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }}</td>
|
|
<td>
|
|
<div class="d-flex flex-column">
|
|
<div>
|
|
<div class="btn-group" role="group">
|
|
@if ($ticket->file !== null)
|
|
<a class="glightbox btn btn-outline-dark"
|
|
data-gallery="gallery{{ $ticket->id }}" href="{{ asset($ticket->file) }}"
|
|
target="_blank"><i class="fa-solid fa-file-image"></i></a>
|
|
@endif
|
|
@if ($ticket->file2 !== null)
|
|
<a class="glightbox btn btn-outline-dark {{ $ticket->file !== null ? 'd-none' : '' }}"
|
|
data-gallery="gallery{{ $ticket->id }}" href="{{ asset($ticket->file2) }}"
|
|
target="_blank"></a>
|
|
@endif
|
|
{{-- Modal du ticket --}}
|
|
<!-- Button trigger modal -->
|
|
<button class="btn btn-outline-info" data-bs-toggle="modal"
|
|
data-bs-target="#ticket{{ $ticket->id }}Modal" type="button"><i
|
|
class="fa-solid fa-eye"></i></button>
|
|
<a class="btn btn-outline-success"
|
|
href="{{ route('bo.ticket.show', $ticket->id) }}"><i
|
|
class="fa-solid fa-comment"></i></a>
|
|
@if (auth()->user()->isAdmin())
|
|
<a class="btn btn-outline-primary"
|
|
href="{{ route('bo.ticket.edit', $ticket) }}"><i
|
|
class="fa-solid fa-pen"></i></a>
|
|
@endif
|
|
@can('changeStatus', $ticket)
|
|
@if (!$ticket->status->equals(\App\Enums\Tickets\TicketStatusEnum::archived))
|
|
<form class="confirmJS" method="POST"
|
|
action="{{ route('bo.ticket.archive', $ticket) }}">
|
|
@method('PUT')
|
|
@csrf
|
|
<button class="btn btn-outline-danger rounded-0 rounded-end" type="submit"><i
|
|
class="fa-solid fa-box-archive"></i></button>
|
|
</form>
|
|
@endif
|
|
@endcan
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Modal -->
|
|
<div class="modal fade" id="ticket{{ $ticket->id }}Modal"
|
|
aria-labelledby="ticket{{ $ticket->id }}ModalLabel" aria-hidden="true" tabindex="-1">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="ticket{{ $ticket->id }}ModalLabel">
|
|
@can('isAdmin')
|
|
<a href="{{ route('bo.sites.show', $ticket->site) }}"
|
|
title="{{ __('Voir le site :sitename', [
|
|
'sitename' => $ticket->site->name,
|
|
]) }}"><b>{{ $ticket->site->name }}</b></a>
|
|
@else
|
|
<b>{{ $ticket->site->name }}</b>
|
|
@endcan -
|
|
<u>
|
|
{{ __('Ticket n°') }} {{ $ticket->id }}
|
|
@if ($ticket->is_internal)
|
|
<i class="fa-solid fa-lock"></i>
|
|
@endif
|
|
</u> -
|
|
<span class="badge {{ $ticket->type->class() }}">
|
|
{{ $ticket->type->label() }}
|
|
</span>
|
|
</h5>
|
|
<button class="btn btn-sm btn-primary bg-primary" data-bs-dismiss="modal"
|
|
type="button" aria-label="Close">
|
|
<i class="fa-solid fa-xmark text-white"></i>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
@can('assignLabels', App\Models\Ticket::class)
|
|
<div class="mb-3 mt-1">
|
|
@foreach ($ticket->labels as $label)
|
|
<span class="badge label colorize"
|
|
data-color="{{ $label->color }}">{{ $label->name }}</span>
|
|
@endforeach
|
|
</div>
|
|
@endcan
|
|
<p>{!! clean(nl2br($ticket->text)) !!}</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-sm btn-primary" data-bs-dismiss="modal"
|
|
type="button">{{ __('Fermer') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
{{ $tickets->withQueryString()->links() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|