Merge branch 'fix-ticket-show' into 'develop'

fix ticket show blade

See merge request ldc-web/projets/support-web!76
This commit is contained in:
Vincent BRIDIER 2024-02-05 11:09:10 +00:00
commit af97d31fc3

View file

@ -5,253 +5,167 @@
@section('bodyClass', 'content ticketsShow')
@section('content')
<div class="form-row row">
<h2 class="col">
<a class="text-decoration-none btn btn-sm btn-primary" href="{{ route('bo.ticket.index') }}" role="button"
aria-roledescription="{{ _('Revenir en arrière') }}"><i class="fa-solid fa-arrow-left-long"></i></a>
{{ $ticket->full_name }}
@if ($ticket->is_internal)<i class="fa-solid fa-lock"></i>@endif
<span class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
</h2>
<div class="col d-flex flex-row text-end">
@can('suscribeToTicket', $ticket)
<form class="col" id="form_abonnement" action="{{ route('bo.ticket.subscribe', $ticket->id) }}" method="POST">
@csrf
<div class="custom-control custom-checkbox p-2 text-right">
<input class="custom-control-input" id="subscription" name="subscription" type="checkbox"
@if ($isSubscribed) checked @endif>
<label class="custom-control-label" for="subscription">{{ __('Suivre le ticket') }}</label>
</div>
@push('scripts')
<script nonce="{{ $nonce }}">
document.getElementById('subscription').addEventListener('change', function(e) {
document.getElementById('form_abonnement').submit();
});
</script>
@endpush
</form>
@endcan
@can('assignTo', $ticket)
<form class="col me-2" id="form_assign" action="{{ route('bo.ticket.assignTo', ['ticket' => $ticket]) }}" method="POST">
@csrf
<div class="input-group">
<label class="input-group-text" for="assign"><i class="fa-solid fa-hat-wizard"></i></label>
<select class="form-select" id="assign" name="assign">
<option value="" @if (!$ticket->assignedUser) selected @endif>{{ __('Personne n\'est assigné') }}</option>
@foreach (\App\Models\User::adminUsers() as $user)
<option value="{{ $user->id }}" @if (optional($ticket->assignedUser)->id == $user->id) selected @endif>{{ $user->name }}</option>
@endforeach
</select>
@push('scripts')
<script nonce="{{ $nonce }}">
document.getElementById('assign').addEventListener('change', function(e) {
document.getElementById('form_assign').submit();
});
</script>
@endpush
</div>
</form>
@endcan
@can('changeStatus', $ticket)
<form class="col" id="form_status" action="{{ route('bo.ticket.changeStatus', $ticket->id) }}" method="POST">
@csrf
<div class="input-group">
<label class="input-group-text" for="status"><i class="fa-solid fa-sign-hanging"></i></label>
<select class="form-select" id="status" name="status">
@foreach (\App\Enums\Tickets\TicketStatusEnum::cases() as $ticketStatus)
<option value="{{ $ticketStatus->value }}" @if ($ticketStatus === $ticket->status) selected @endif>
{{ $ticketStatus->label() }}</option>
@endforeach
</select>
@push('scripts')
<script nonce="{{ $nonce }}">
document.getElementById('status').addEventListener('change', function(e) {
document.getElementById('form_status').submit();
});
</script>
@endpush
</div>
</form>
@endcan
@if ($ticket->status->equals(\App\Enums\Tickets\TicketStatusEnum::archived))
@can('reopen', $ticket)
<form class="col" id="form_status" action="{{ route('bo.ticket.reopen', $ticket) }}" method="POST">
@csrf
<button class="btn btn-danger" type="submit">{{ __('Réouvrir le ticket') }}</button>
</form>
@endcan
@endif
</div>
<div class="form-row row">
<h2 class="col">
<a href="{{ route('bo.ticket.index') }}" class="text-decoration-none btn btn-sm btn-primary" role="button" aria-roledescription="{{ _('Revenir en arrière') }}"><i class="fa-solid fa-arrow-left-long"></i></a>
{{ $ticket->full_name }}
@if ($ticket->is_internal)<i class="fa-solid fa-lock"></i>@endif
<span class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
</h2>
<div class="col d-flex flex-row text-end">
@can('suscribeToTicket', $ticket)
<form action="{{ route('bo.ticket.subscribe', $ticket->id) }}" method="POST" id="form_abonnement" class="col">
@csrf
<div class="custom-control custom-checkbox text-right p-2">
<input type="checkbox" name="subscription" class="custom-control-input" id="subscription" @if ($isSubscribed)checked @endif>
<label class="custom-control-label" for="subscription">{{ __('Suivre le ticket') }}</label>
</div>
@push('scripts')
<script nonce="{{ $nonce }}">document.getElementById('subscription').addEventListener('change', function (e) {
document.getElementById('form_abonnement').submit();
});</script>
@endpush
</form>
@endcan
@can('assignTo', $ticket)
<form action="{{ route('bo.ticket.assignTo', ['ticket' => $ticket]) }}" method="POST" id="form_assign" class="col me-2">
@csrf
<div class="input-group">
<label class="input-group-text" for="assign"><i class="fa-solid fa-hat-wizard"></i></label>
<select class="form-select" name="assign" id="assign">
<option value="" @if(!$ticket->assignedUser)selected @endif>{{ __('Personne n\'est assigné') }}</option>
@foreach(\App\Models\User::adminUsers() as $user)
<option value="{{ $user->id }}" @if(optional($ticket->assignedUser)->id == $user->id)selected @endif>{{ $user->name }}</option>
@endforeach
</select>
@push('scripts')
<script nonce="{{ $nonce }}">document.getElementById('assign').addEventListener('change', function (e) {
document.getElementById('form_assign').submit();
});</script>
@endpush
</div>
</form>
@endcan
@can('changeStatus', $ticket)
<form action="{{ route('bo.ticket.changeStatus', $ticket->id) }}" method="POST" id="form_status" class="col">
@csrf
<div class="input-group">
<label class="input-group-text" for="status"><i class="fa-solid fa-sign-hanging"></i></label>
<select class="form-select" name="status" id="status">
@foreach(\App\Enums\Tickets\TicketStatusEnum::cases() as $ticketStatus)
<option value="{{ $ticketStatus->value }}" @if($ticketStatus === $ticket->status)selected @endif>{{ $ticketStatus->label() }}</option>
@endforeach
</select>
@push('scripts')
<script nonce="{{ $nonce }}">document.getElementById('status').addEventListener('change', function (e) {
document.getElementById('form_status').submit();
});</script>
@endpush
</div>
</form>
@endcan
@if($ticket->status->equals(\App\Enums\Tickets\TicketStatusEnum::archived))
@can('reopen', $ticket)
<form action="{{ route('bo.ticket.reopen', $ticket) }}" method="POST" id="form_status" class="col">
@csrf
<button class="btn btn-danger" type="submit">{{ __('Réouvrir le ticket') }}</button>
</form>
@endcan
@endif
</div>
@can('assignLabels', App\Models\Ticket::class)
<div class="row">
<p class="col-12 fs-5">
{{ $ticket->title }}
</p>
<div class="col-12">
@foreach ($ticket->labels as $label)
<span class="badge label colorize" data-color="{{ $label->color }}">{{ $label->name }}</span>
@endforeach
</div>
@can('assignLabels', App\Models\Ticket::class)
<div class="row">
<div class="col">
@foreach ($ticket->labels as $label)
<span class="badge label colorize" data-color="{{ $label->color }}">{{ $label->name }}</span>
@endforeach
</div>
</div>
@endcan
<hr>
@if($ticket->estimation)
@include('estimations.pendingCard', ['ticket' => $ticket, 'estimation' => $ticket->estimation])
<hr>
@endif
<div>
<h4>
{{ __('Suivi') }}
@can('createMessage', $ticket)
<button type="button" class="btn btn-sm btn-primary mx-1 float-end" data-bs-toggle="modal" data-bs-target="#messageModal">
{{ __('Répondre') }}
</button>
<div class="modal fade" id="messageModal" tabindex="-1" aria-labelledby="messageModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.create', $ticket) }}" method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input type="hidden" name="ticket_id" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Répondre au ticket n°:ticketId', ['ticketId' => $ticket->id]) }} <span class="badge {{ $ticket->type->class() }}">{{ $ticket->type->label() }}</span>
</h5>
<button type="button"
class="btn btn-sm btn-primary bg-primary"
data-bs-dismiss="modal"
aria-label="Close">
<i class="text-white fa-solid fa-xmark"></i>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<textarea name="message" class="form-control" rows="10"></textarea>
</div>
</div>
<div class="row mt-4">
<div class="col">
<label for="formFile" class="form-label">{{ __('Joindre un fichier (jpg, png, pdf) 2Mo max') }}</label>
<input class="form-control" type="file" id="formFile" name="file_message" accept="image/jpeg, image/png, image/jpg, .pdf">
</div>
</div>
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input name="subscribe" type="checkbox" class="form-check-input" id="subscribeResponse" autocomplete="off" @if ($isSubscribed)checked @endif value="1">
<label class="form-check-label" for="subscribeResponse">{{ __('Suivre le ticket') }}</label>
</div>
</div>
</div>
@can('createPrivateMessage', $ticket)
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input name="is_private" type="checkbox" class="form-check-input" id="setPrivate" autocomplete="off" value="{{ \App\Enums\MessageTypeEnum::private }}">
<label class="form-check-label" for="setPrivate">{{ __('Rendre le message privé') }}</label>
</div>
</div>
</div>
@endif
</div>
<div class="modal-footer">
<button type="reset" class="btn btn-sm btn-danger" data-bs-dismiss="modal">{{ __('Fermer') }}</button>
<button type="submit" class="btn btn-sm btn-success">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
</div>
</div>
@endcan
<hr>
@if ($ticket->estimation)
@include('estimations.pendingCard', ['ticket' => $ticket, 'estimation' => $ticket->estimation])
<hr>
@endif
<div>
<h4>
{{ __('Suivi') }}
@can('createMessage', $ticket)
<button class="btn btn-sm btn-primary float-end mx-1" data-bs-toggle="modal" data-bs-target="#messageModal" type="button">
{{ __('Répondre') }}
</button>
<div class="modal fade" id="messageModal" aria-labelledby="messageModalLabel" aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.create', $ticket) }}" method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input name="ticket_id" type="hidden" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Répondre au ticket n°:ticketId', ['ticketId' => $ticket->id]) }} <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">
<div class="row">
<div class="col">
<textarea class="form-control" name="message" rows="10"></textarea>
</div>
</div>
<div class="row mt-4">
<div class="col">
<label class="form-label" for="formFile">{{ __('Joindre un fichier (jpg, png, pdf) 2Mo max') }}</label>
<input class="form-control" id="formFile" name="file_message" type="file"
accept="image/jpeg, image/png, image/jpg, .pdf">
</div>
</div>
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" id="subscribeResponse" name="subscribe" type="checkbox"
value="1" autocomplete="off" @if ($isSubscribed) checked @endif>
<label class="form-check-label" for="subscribeResponse">{{ __('Suivre le ticket') }}</label>
</div>
</div>
</div>
@can('createPrivateMessage', $ticket)
<div class="row mt-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" id="setPrivate" name="is_private" type="checkbox"
value="{{ \App\Enums\MessageTypeEnum::private }}" autocomplete="off">
<label class="form-check-label" for="setPrivate">{{ __('Rendre le message privé') }}</label>
</div>
</div>
</div>
@endif
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger" data-bs-dismiss="modal" type="reset">{{ __('Fermer') }}</button>
<button class="btn btn-sm btn-success" type="submit">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
</div>
</div>
@endcan
@can('estimate', $ticket)
<a class="btn btn-sm btn-info float-end mx-1"
href="{{ route('bo.ticket.estimation.estimate', $ticket) }}">{{ __('Estimation') }}</a>
@endcan
</h4>
@foreach ($messages as $message)
@if ($message->type->equals(\App\Enums\MessageTypeEnum::public) || Auth::user()->can('createPrivateMessage', $ticket))
@if ($message->user_id === null)
<div class="offset-md-3 col-md-6 alert alert-info text-dark text-center">
{!! nl2br(clean($message->message)) !!} - <span class="fw-bold text-light">Le
{{ \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i') }}</span>
<small class="fw-bold">({{ __('Message système') }})</small>
</div>
@else
<div
class="@if ($message->user_id === Auth::user()->id) offset-md-4 alert-dark @else alert-light @endif @if ($message->type->equals(\App\Enums\MessageTypeEnum::private)) border border-danger border-2 @endif col-md-8 alert">
@if ($message->type->equals(\App\Enums\MessageTypeEnum::private))
<i class="fa-solid fa-lock"></i>&nbsp;&nbsp;
@endif
{!! \App\Lib\Helpers\ToolboxHelper::plainToHtml($message->message) !!}
@if ($message->file !== null)
<br><a href="{{ asset($message->file) }}" @if (\App\Lib\Helpers\ToolboxHelper::isImageFile($message->file)) data-fslightbox="gallery" @endif
target="_blank">Ouvrir la pièce jointe</a><br>
@endif
<br><br>
<small class="text-bg-dark fw-bold">
{!! __('Créé le :date par <b>:userName</b>', [
'date' => \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i'),
'userName' => $message->user ? $message->user->name : __('Utilisateur supprimé'),
]) !!}
</small>
@if ($message->user_id === Auth::user()->id)
@can('updateMessage', $ticket, $message)
<button class="btn btn-sm btn-primary float-end" data-bs-toggle="modal"
data-bs-target="#updateMessageModal{{ $message->id }}" type="button">
{{ __('Modifier le message') }}
</button>
<div class="modal fade" id="updateMessageModal{{ $message->id }}" aria-labelledby="updateMessageModalLabel"
aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{ route('bo.ticket.message.update', ['ticket' => $ticket, 'message' => $message]) }}"
method="POST" enctype="multipart/form-data">
@method('PUT')
@csrf
<input name="ticket_id" type="hidden" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Modification du message n°:messageid', ['messageid' => $message->id]) }}
</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">
<div class="row">
<div class="col">
<textarea class="form-control" name="message" rows="10">{{ $message->message }}</textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger" data-bs-dismiss="modal"
type="reset">{{ __('Fermer') }}</button>
<button class="btn btn-sm btn-success" type="submit">{{ __('Envoyer') }}</button>
</div>
</form>
</div>
</div>
</div>
@endcan
@endif
</div>
@endif
@endif
@endforeach
</div>
<hr>
<div>
<h4>{{ __('Description') }}</h4>
<p>{!! clean(\App\Lib\Helpers\ToolboxHelper::plainToHtml($ticket->text)) !!}</p>
<small class="text-body-secondary">{!! __('Créé le :date par <b>:userName</b>', [
'date' => \Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i'),
'userName' => $ticket->user ? $ticket->user->name : __('Utilisateur supprimé'),
]) !!}</small>
@endcan
@can('estimate', $ticket)
<a href="{{ route('bo.ticket.estimation.estimate', $ticket) }}" class="btn btn-sm btn-info mx-1 float-end">{{ __('Estimation') }}</a>
@endcan
</h4>
@foreach ($messages as $message)
@if (
$message->type->equals(\App\Enums\MessageTypeEnum::public) ||
(Auth::user()->can('createPrivateMessage', $ticket))
)
@if ($message->user_id === null)
<div class="offset-md-3 col-md-6 alert alert-info text-center text-dark">
{!! nl2br(clean($message->message)) !!} - <span class="fw-bold text-light">Le {{ \Carbon\Carbon::parse($message->created_at)->format('d/m/Y à H:i')}}</span>
<small class="fw-bold">({{ __('Message système') }})</small>
</div>
@else
<div class="@if($message->user_id === Auth::user()->id)offset-md-4 alert-dark @else alert-light @endif @if($message->type->equals(\App\Enums\MessageTypeEnum::private)) border border-danger border-2 @endif col-md-8 alert">
@ -306,21 +220,56 @@
</div>
</div>
</div>
@endif
@can('createGitlabIssue', $ticket)
<form class="col d-flex justify-content-end" id="form_issue" action="{{ route('bo.ticket.create-issue', $ticket) }}" method="POST">
@csrf
<button class="btn btn-warning align-end" type="submit">{{ __("Créer l'issue Gitlab") }}</button>
</form>
@else
@can('isAdmin')
@if (!\is_null($ticket->gitlab_issue))
<br>
<p>
{{ __("Lien vers l'issue Gitlab : ") }}
<a href="{{ $ticket->gitlab_issue }}" target="_blank">{{ __('Ouvrir') }}</a>
</p>
@endif
@endcan
@endcan
@endsection
@endif
</div>
@endif
@endif
@endforeach
</div>
<hr>
<div>
<h4>{{__('Description') }}</h4>
<p>{!! clean(\App\Lib\Helpers\ToolboxHelper::plainToHtml($ticket->text)) !!}</p>
<small class="text-body-secondary">{!! __('Créé le :date par <b>:userName</b>', [
'date' => \Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i'),
'userName' => $ticket->user ? $ticket->user->name : __('Utilisateur supprimé')
]) !!}</small>
</div>
@if (!is_null($ticket->file) or !is_null($ticket->file2))
<hr>
<div>
<h4>{{ __('Pièces jointes') }}</h4>
<ul>
@if (!is_null($ticket->file))
<li>
{{ __('Pièce jointe n°1') }} :
<a @if(\App\Lib\Helpers\ToolboxHelper::isImageFile($ticket->file)) class="glightbox" data-gallery="ticket" @endif href="{{ asset($ticket->file) }}" target="_blank">{{ __('Ouvrir la pièce jointe') }}</a>
</li>
@endif
@if (!is_null($ticket->file2))
<li>
{{ __('Pièce jointe n°2') }} :
<a @if(\App\Lib\Helpers\ToolboxHelper::isImageFile($ticket->file2)) class="glightbox" data-gallery="ticket" @endif href="{{ asset($ticket->file2) }}" target="_blank">{{ __('Ouvrir la pièce jointe') }}</a>
</li>
@endif
</ul>
</div>
@endif
@can('createGitlabIssue', $ticket)
<form action="{{ route('bo.ticket.create-issue', $ticket) }}" method="POST" id="form_issue" class="col d-flex justify-content-end">
@csrf
<button class="btn btn-warning align-end" type="submit">{{ __("Créer l'issue Gitlab") }}</button>
</form>
@else
@can('isAdmin')
@if (!\is_null($ticket->gitlab_issue))
<br>
<p>
{{ __("Lien vers l'issue Gitlab : ")}}
<a href="{{ $ticket->gitlab_issue}}" target="_blank">{{ __("Ouvrir") }}</a>
</p>
@endif
@endcan
@endcan
@endsection