445 lines
33 KiB
PHP
445 lines
33 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">
|
|
<h1 class="fw-bold">{{ __('Tickets') }}
|
|
@if (Session::get('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value)
|
|
(Archivés)
|
|
@endif
|
|
</h1>
|
|
@if (session('tickets.pr'))
|
|
@php
|
|
$site = \App\Models\Site::query()->find(session('tickets.pr'));
|
|
$projectManager = $site ? $site->projectManager : false;
|
|
@endphp
|
|
@if ($projectManager)
|
|
<h2>{{ __('Chef de projet') }} : {{ $projectManager->name }}</h2>
|
|
@endif
|
|
@endif
|
|
</div>
|
|
<div class="col">
|
|
<a class="btn btn-primary float-end" href="{{ route('bo.ticket.create') }}">
|
|
<i class="fa-solid fa-square-plus"></i> {{ __('ticket') }}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="row mt-3">
|
|
<div class="col">
|
|
<div class="row">
|
|
{{-- All sites --}}
|
|
<div class="col">
|
|
<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 les sites') }}</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>
|
|
{{-- All types --}}
|
|
<div class="col">
|
|
<div class="input-group">
|
|
<label class="input-group-text" for="selectType"><i class="fa-solid fa-ticket"></i></label>
|
|
<select class="form-select" id="selectType">
|
|
<option value="-1">{{ __('Tous les types') }}</option>
|
|
@foreach ($types as $type)
|
|
<option value="{{ $type->value }}"
|
|
@if (intval(session('tickets.ty')) == $type->value) selected="selected" @endif>
|
|
{{ $type->label() }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.getElementById('selectType').addEventListener('change', function(e) {
|
|
window.location = '{{ route('bo.ticket.index') }}?' + (this.value == -1 ? 'tys=-1' : 'ty=' + this
|
|
.value);
|
|
});
|
|
</script>
|
|
@endpush
|
|
</div>
|
|
</div>
|
|
{{-- All status --}}
|
|
<div class="col">
|
|
<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 les statuts') }}</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>
|
|
{{-- All assigned to --}}
|
|
@can('assignTickets', App\Models\Ticket::class)
|
|
<div class="col">
|
|
<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">{{ __("Sans filtre d'assignation") }}</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>
|
|
@endcan
|
|
{{-- Search form --}}
|
|
<div class="col">
|
|
<form 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="row">
|
|
<div class="col">
|
|
<div class="btn-group float-end">
|
|
@if (session('tickets.pr') && session('tickets.st') != \App\Enums\Tickets\TicketStatusEnum::archived->value)
|
|
@if (session('tickets.or'))
|
|
<a class="btn btn-info float-end" href="{{ route('bo.ticket.index', ['ord' => -1]) }}">
|
|
<i
|
|
class="fa-solid fa-equals"></i> {{ __('see_mode', ['mode' => __('validation.custom.default')]) }}
|
|
</a>
|
|
@else
|
|
<a class="btn btn-danger" href="{{ route('bo.ticket.index', ['or' => 1]) }}">
|
|
<i
|
|
class="fa-solid fa-triangle-exclamation"></i> {{ __('see_mode', ['mode' => __('validation.custom.priority')]) }}
|
|
</a>
|
|
@endif
|
|
@endif
|
|
@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="btn btn-secondary float-end"
|
|
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>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="w-100 overflow-scroll">
|
|
<table class="table-hover table">
|
|
<thead>
|
|
@php
|
|
$cols = [];
|
|
if (session('tickets.or')) {
|
|
$cols = array_merge($cols, [
|
|
'order' => Str::ucfirst(__('validation.custom.priority')),
|
|
]);
|
|
}
|
|
$cols = array_merge($cols, [
|
|
'id' => '#',
|
|
]);
|
|
if (!session()->has('tickets.pr') && !session('tickets.or')) {
|
|
$cols = array_merge($cols, [
|
|
'site' => Str::ucfirst(__('Website')),
|
|
]);
|
|
}
|
|
$cols = array_merge($cols, [
|
|
'type' => Str::ucfirst(__('validation.custom.type')),
|
|
'status' => Str::ucfirst(__('validation.attributes.status')),
|
|
'title' => Str::ucfirst(__('validation.attributes.name')),
|
|
]);
|
|
if (session()->has('tickets.ty') && intval(session('tickets.ty')) === \App\Enums\Tickets\TicketTypeEnum::evolution->value) {
|
|
$cols = array_merge($cols, [
|
|
'estimate' => Str::ucfirst(__('validation.custom.estimate')),
|
|
]);
|
|
}
|
|
if (Auth::user()->isAdmin()) {
|
|
$cols = array_merge($cols, [
|
|
'tickets' => Str::ucfirst(__('validation.custom.tickets')),
|
|
'assigned_to' => Str::ucfirst(__('validation.custom.assigned_to')),
|
|
]);
|
|
}
|
|
$cols = array_merge($cols, [
|
|
'date_mep' => Str::ucfirst(__('validation.custom.date_mep')),
|
|
'created_at' => Str::ucfirst(__('validation.attributes.created_at')),
|
|
]);
|
|
@endphp
|
|
@include('bo.modules.table-col-sorter', [
|
|
'cols' => $cols,
|
|
'ignore' => session('tickets.or') ? array_keys($cols) : ['id', 'site', 'status', 'tickets', 'estimate'],
|
|
])
|
|
</thead>
|
|
<tbody>
|
|
@if (!count($tickets))
|
|
<tr>
|
|
<td class="text-center" colspan="@if (Auth::user()->isAdmin()) 9 @else 6 @endif">
|
|
<h2>{{ __('Aucun ticket') }}</h2>
|
|
</td>
|
|
</tr>
|
|
@endif
|
|
@foreach ($tickets as $key => $ticket)
|
|
<tr class="position-relative">
|
|
{{-- order --}}
|
|
@if (session('tickets.or'))
|
|
@include('bo.modules.change-model-order-select', [
|
|
'model' => $ticket,
|
|
'value' => $key + 1 + ($tickets->currentPage() - 1) * $tickets->perPage(),
|
|
])
|
|
@endif
|
|
{{-- id --}}
|
|
<td scope="row">
|
|
<div class="d-flex justify-content-center">
|
|
<span>{{ $ticket->id }}
|
|
@if ($ticket->is_internal)
|
|
<i class="fa-solid fa-lock"></i>
|
|
@endif
|
|
</span>
|
|
</div>
|
|
</td>
|
|
@if (!session()->has('tickets.pr') && !session('tickets.or'))
|
|
{{-- site --}}
|
|
<td scope="row">
|
|
<div class="d-flex justify-content-center">
|
|
@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
|
|
</div>
|
|
</td>
|
|
@endif
|
|
{{-- type --}}
|
|
<td class="text-center">
|
|
<span class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
|
|
</td>
|
|
{{-- status --}}
|
|
<td scope="row">
|
|
<div class="d-flex justify-content-between">
|
|
<span class="d-flex flex-column">
|
|
<span class="{{ $ticket->status->class() }} rounded text-center">
|
|
{{ $ticket->status->label() }}
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
{{-- title --}}
|
|
<td>
|
|
<span class="me-1">{{ $ticket->title }}</span>
|
|
</td>
|
|
{{-- estimate --}}
|
|
@if (session()->has('tickets.ty') && intval(session('tickets.ty')) === \App\Enums\Tickets\TicketTypeEnum::evolution->value)
|
|
<td>
|
|
<span class="me-1">{{ $ticket->estimation?->amount ? sprintf('%sj', $ticket->estimation->amount) : 'En cours' }}</span>
|
|
</td>
|
|
@endif
|
|
{{-- tag --}}
|
|
@php
|
|
$routeName = request()->route()->getName();
|
|
@endphp
|
|
@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
|
|
{{-- assigned_to / date_mep --}}
|
|
@if (Auth::user()->isAdmin())
|
|
<td>{{ $ticket->assignedUser ? $ticket->assignedUser->name : __('Personne') }}
|
|
</td>
|
|
@endif
|
|
<td class="text-center">
|
|
{{ is_null($ticket->date_mep) ? '-' : $ticket->date_mep->format('d/m/Y') }}
|
|
</td>
|
|
<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">
|
|
@php
|
|
$ticket_files = $ticket->getFiles();
|
|
@endphp
|
|
@foreach ($ticket_files as $key => $file)
|
|
@if ($file !== null && (\App\Lib\Helpers\ToolboxHelper::isImageFile($file) || \App\Lib\Helpers\ToolboxHelper::isPdfFile($file)))
|
|
<a class="glightbox btn btn-outline-dark"
|
|
data-gallery="gallery{{ $ticket->id }}" href="{{ asset($file) }}"
|
|
target="_blank"><i class="fa-solid fa-file-image"></i>
|
|
</a>
|
|
@break
|
|
@endif
|
|
@endforeach
|
|
{{-- 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>
|
|
<!-- 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>
|
|
</div>
|
|
{{ $tickets->withQueryString()->links() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|