fix: some elements crashed since the inscrease of files in tickets and messages

This commit is contained in:
Noah Lancien 2024-11-12 12:52:21 +01:00
parent c770d5d80e
commit 5e459a6571
6 changed files with 432 additions and 375 deletions

View file

@ -178,8 +178,8 @@ class TicketController extends Controller
$ticket = new Ticket($request->validated());
/** @var null|array<\Illuminate\Http\UploadedFile> */
$fileTickets = $request->file_tickets;
/** @var array<\Illuminate\Http\UploadedFile> */
$fileTickets = $request->file_tickets ?? [];
if (count($fileTickets) > 0) {
foreach ($fileTickets as $key => $file) {
if ($key === 0) {
@ -544,8 +544,13 @@ class TicketController extends Controller
Session::has('tickets.sort_col') and
Session::has('tickets.sort_way') and
in_array(Session::get('tickets.sort_col'), [
'id', 'site_id', 'created_at', 'created_by',
'type', 'status', 'assigned_to'
'id',
'site_id',
'created_at',
'created_by',
'type',
'status',
'assigned_to'
])
) {
$tickets->orderBy(
@ -653,30 +658,32 @@ class TicketController extends Controller
};
try {
if (!\is_null($ticket->file)) {
$uploadedFile = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile, 1);
foreach ($ticket->getFiles() as $key => $file) {
if (!\is_null($file)) {
$uploadedFile = GitLab::projects()->uploadFile($gitlabRepoId, $file);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile, $key + 1);
}
}
if (!\is_null($ticket->file2)) {
$uploadedFile2 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file2);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile2, 2);
}
// if (!\is_null($ticket->file2)) {
// $uploadedFile2 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file2);
// $description .= $this->formatGitlabFiles($ticket, $uploadedFile2, 2);
// }
if (!\is_null($ticket->file3)) {
$uploadedFile3 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file3);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile3, 3);
}
// if (!\is_null($ticket->file3)) {
// $uploadedFile3 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file3);
// $description .= $this->formatGitlabFiles($ticket, $uploadedFile3, 3);
// }
if (!\is_null($ticket->file4)) {
$uploadedFile4 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file4);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile4, 4);
}
// if (!\is_null($ticket->file4)) {
// $uploadedFile4 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file4);
// $description .= $this->formatGitlabFiles($ticket, $uploadedFile4, 4);
// }
if (!\is_null($ticket->file5)) {
$uploadedFile5 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file5);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile5, 5);
}
// if (!\is_null($ticket->file5)) {
// $uploadedFile5 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file5);
// $description .= $this->formatGitlabFiles($ticket, $uploadedFile5, 5);
// }
$issue = GitLab::issues()->create($gitlabRepoId, [
'title' => 'ts-' . $ticket->id,

View file

@ -33,14 +33,18 @@ class CreateEstimateRequest extends FormRequest
$ticket = $this->ticket;
return [
'amount' => [
'required', 'numeric', 'gt:0', function ($attribute, $value, $fail) {
if ((\floatval($value) * 1000) % 62.5 !== 0) {
'required',
'numeric',
'gt:0',
function ($attribute, $value, $fail) {
if (fmod((\floatval($value) * 1000), 62.5) !== 0.0) {
$fail("$attribute doit être un multiple de 62.5 (soit 0.0625)");
}
}
],
'credit_account_id' => [
'required', 'exists:credit_accounts,id',
'required',
'exists:credit_accounts,id',
function ($attribute, $value, $fail) use ($ticket) {
/** @var \App\Models\Credit\Account|null */
$account = Account::whereId($value)->first();
@ -57,11 +61,11 @@ class CreateEstimateRequest extends FormRequest
*
* @return array
*/
public function messages(): array
public function attributes(): array
{
return [
'amount' => 'Montant',
'credit_account_id' => 'Compte'
'credit_account_id' => 'Compte à débiter'
];
}
}

View file

@ -68,6 +68,18 @@ class ToolboxHelper
return \preg_match('/(\.png|\.jpg|\.jpeg|\.gif)$/', $url, $m) === 1;
}
/**
* Check uri points to pdf file
*
* @param string $url
* @return boolean
*/
public static function isPdfFile(string $url): bool
{
$m = [];
return \preg_match('/(\.pdf)$/', $url, $m) === 1;
}
/**
* Strip scheme (https) on oembed urls
* Only embed allowed are for MP4 self hosted videos right now
@ -339,7 +351,7 @@ class ToolboxHelper
): Builder {
$currentLocale = app()->currentLocale();
$locales = collect(config('app.locales'))
->mapWithKeys(fn (string $locale) => [$locale => $locale]);
->mapWithKeys(fn(string $locale) => [$locale => $locale]);
if (!$locales->has($defaultLocale)) {
// * Remove default locale.
$locales->pull($defaultLocale);
@ -357,7 +369,7 @@ class ToolboxHelper
$q->whereRaw("JSON_EXTRACT({$column}, '$.{$currentLocale}') = '{$value}'");
}
// * Query any other locale
$locales->each(fn ($locale) => $q->orWhereRaw(
$locales->each(fn($locale) => $q->orWhereRaw(
"JSON_EXTRACT({$column}, '$.{$locale}') = '{$value}'"
));
});
@ -449,7 +461,10 @@ class ToolboxHelper
$fileFullPath = self::getUploadedFileFullPath($value, $useStorage);
if (
!\in_array(self::getUploadedFileMimeType($value, $useStorage), [
'image/jpeg', 'image/jpg', 'image/png', 'image/gif'
'image/jpeg',
'image/jpg',
'image/png',
'image/gif'
])
) {
$fail(trans(':attribute doit être une image de type \'image/jpeg,image/jpg,image/png,image/gif\'', [

View file

@ -275,4 +275,20 @@ class Ticket extends Model
Str::limit(\preg_replace('/[[:cntrl:]]+/', '', $ticket->text), 35),
);
}
/**
* Get an array of all files columns of the ticket.
*
* @return array
*/
public function getFiles(): array
{
return [
$this->file,
$this->file2,
$this->file3,
$this->file4,
$this->file5,
];
}
}

View file

@ -226,101 +226,101 @@
<div>
<div class="btn-group" role="group">
@php
$ticket_files = [$ticket->file, $ticket->file2, $ticket->file3, $ticket->file4, $ticket->file5]
$ticket_files = $ticket->getFiles();
@endphp
@foreach($ticket_files as $key => $file)
@if ($file !== null)
@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>
@break
@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
@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>
</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>&nbsp;-&nbsp;
<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>
<!-- 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>&nbsp;-&nbsp;
<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>
</td>
</tr>
@endforeach
</tbody>
</table>
{{ $tickets->withQueryString()->links() }}
</div>
</div>
</div>
</div>
</div>
@endsection

View file

@ -5,273 +5,288 @@
@section('bodyClass', 'content ticketsShow')
@section('content')
<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>
</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')
<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
<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>
<button class="btn btn-danger" type="submit">{{ __('Réouvrir le ticket') }}</button>
</form>
@endcan
@endif
</div>
</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 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>
@for ($i = 1; $i < 4; $i++)
<div class="row mt-4">
<div class="col">
<h4>Fichier joint {{ $i }}</h4>
<input class="form-control" name="file_messages[]" type="file"
accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
</div>
</div>
@endfor
<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 class="modal-body">
<div class="row">
<div class="col">
<textarea name="message" class="form-control" rows="10"></textarea>
</div>
</div>
@for($i = 1; $i < 4; $i++)
<div class="row mt-4">
<div class="col">
<h4>Fichier joint {{ $i }}</h4>
<input name="file_messages[]" class="form-control" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
</div>
</div>
@endfor
<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>
@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) !!}
@foreach ([$message->file, $message->file2, $message->file3] as $file)
@if ($file !== null)
<br><a href="{{ asset($file) }}" target="_blank">Ouvrir la pièce jointe</a>
@endif
@endforeach
<br><br>
<small class="@if ($message->user_id === Auth::user()->id) text-bg-dark @else text-body-secondary @endif 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>
</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>
@endcan
@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
@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">
@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) !!}
@foreach ([$message->file, $message->file2, $message->file3] as $file)
@if ($file !== null)
<br><a href="{{ asset($file) }}" target="_blank">Ouvrir la pièce jointe</a>
@endif
@endif
@endforeach
<br><br>
<small class="@if($message->user_id === Auth::user()->id)text-bg-dark @else text-body-secondary @endif 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 type="button" class="btn btn-sm btn-primary float-end" data-bs-toggle="modal" data-bs-target="#updateMessageModal{{$message->id}}">
{{ __('Modifier le message') }}
</button>
<div class="modal fade" id="updateMessageModal{{$message->id}}" tabindex="-1" aria-labelledby="updateMessageModalLabel" aria-hidden="true">
<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 type="hidden" name="ticket_id" value="{{ $ticket->id }}">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">
{{ __('Modification du message n°:messageid', ['messageid' => $message->id]) }}
</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">{{ $message->message }}</textarea>
</div>
</div>
</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
@endif
</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>
@php
$ticket_files = $ticket->getFiles();
@endphp
@if (!empty(Arr::whereNotNull($ticket_files)))
<div>
<h4>{{ __('Pièces jointes') }}</h4>
@foreach ($ticket_files as $key => $file)
@if (!is_null($file))
<ul>
<li>
{{ __('Pièce jointe ') }}{{ $key + 1 }} :
<a href="{{ asset($file) }}" @if (\App\Lib\Helpers\ToolboxHelper::isImageFile($file)) class="glightbox" data-gallery="ticket" @endif
target="_blank">{{ __('Ouvrir la pièce jointe') }}</a>
</li>
</ul>
@endif
@endforeach
</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>
@php
$ticket_files = [$ticket->file, $ticket->file2, $ticket->file3, $ticket->file4, $ticket->file5]
@endphp
<div>
<h4>{{ __('Pièces jointes') }}</h4>
@foreach($ticket_files as $key => $file)
@if (!is_null($file))
<ul>
<li>
{{ __('Pièce jointe ') }}{{ $key + 1 }} :
<a @if(\App\Lib\Helpers\ToolboxHelper::isImageFile($file)) class="glightbox" data-gallery="ticket" @endif href="{{ asset($file) }}" target="_blank">{{ __('Ouvrir la pièce jointe') }}</a>
</li>
</ul>
</div>
@endif
@endforeach
<hr>
@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
<hr>
@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