add field for the title of a ticket, make the migration and the request

This commit is contained in:
nicolas.demangeat 2024-02-02 10:34:06 +00:00 • committed by Vincent BRIDIER
parent 4cd2980227
commit 9675c1bb3a
9 changed files with 726 additions and 562 deletions

View file

@ -595,7 +595,7 @@ class TicketController extends Controller
});
} //end foreach
} //end if
}, 'text', 'file', 'file2');
}, 'text', 'title', 'file', 'file2');
}
/**

View file

@ -97,6 +97,7 @@ class StoreTicket extends FormRequest
}
],
'text' => 'required|string|min:40',
'title' => 'required|string|between:3,255',
'file_ticket' => 'mimes:jpeg,jpg,png,pdf|max:2048',
'file_ticket2' => 'mimes:jpeg,jpg,png,pdf|max:2048',
'is_internal' => 'required|boolean',

View file

@ -33,6 +33,7 @@ class Ticket extends Model
'type',
'status',
'text',
'title',
'is_internal',
'last_activity',
];

View file

@ -0,0 +1,44 @@
<?php
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('tickets', function (Blueprint $table) {
$table->string('title')
->after('type')
->comment('Titre du ticket');
});
DB::transaction(function () {
$tickets = Ticket::all();
foreach ($tickets as $ticket) {
$ticket->title = 'ts-' . $ticket->id;
$ticket->saveQuietly();
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('tickets', function (Blueprint $table) {
$table->dropColumn('title');
});
}
};

2
package-lock.json generated
View file

@ -1,5 +1,5 @@
{
"name": "supportweb",
"name": "srcs",
"lockfileVersion": 3,
"requires": true,
"packages": {

View file

@ -5,25 +5,31 @@
@section('bodyClass', 'col-md-8')
@section('content')
<div class="card">
<div class="card-header">
<h2 class="col h4">
<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>
<span>&nbsp;{{ __('Modifier un ticket') }}</span> -
{{ $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="card">
<div class="card-header">
<h2 class="col h4">
<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>
<span>&nbsp;{{ __('Modifier un ticket') }}</span> -
{{ $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>
<p class="col fs-5">
{{ $ticket->title }}
</p>
</div>
<div class="card-body">
<form method="POST" action="{{ route('bo.ticket.update', $ticket->id) }}" enctype="multipart/form-data">
@csrf
@method('PUT')
@include('bo.pages.tickets.form-inputs')
<div class="form-group text-center">
<input class="btn btn-primary" type="submit" value="Modifier">
</div>
</form>
</div>
</div>
<div class="card-body">
<form method="POST" action="{{ route('bo.ticket.update', $ticket->id) }}" enctype="multipart/form-data">
@csrf
@method('PUT')
@include('bo.pages.tickets.form-inputs')
<div class="form-group text-center">
<input type="submit" class="btn btn-primary" value="Modifier">
</div>
</form>
</div>
</div>
@endsection

View file

@ -1,125 +1,133 @@
@php
$userPr = Auth::user()->sites ?? collect([]);
$userPr = Auth::user()->sites ?? collect([]);
@endphp
<div class="form-row">
<div class="form-group col">
<label for="site" class="col-form-label">{{ __('Site') }}</label>
<select class="form-select" name="site_id" id="site">
@foreach($sites as $site)
@if (Auth::user()->isAdmin())
<option value="{{ $site->id }}" @if ($site->id == old('site_id') or (isset($ticket) and $ticket->site->id == $site->id))selected @endif>{{ $site->name }}</option>
@elseif ($userPr->filter(function($pr) use($site) { return $pr->id === $site->id; })->count())
<option value="{{ $site->id }}" selected>{{ $site->name }}</option>
@endif
<label class="col-form-label" for="site">{{ __('Site') }}</label>
<select class="form-select" id="site" name="site_id">
@foreach ($sites as $site)
@if (Auth::user()->isAdmin())
<option value="{{ $site->id }}" @if ($site->id == old('site_id') or isset($ticket) and $ticket->site->id == $site->id) selected @endif>{{ $site->name }}</option>
@elseif (
$userPr->filter(function ($pr) use ($site) {
return $pr->id === $site->id;
})->count())
<option value="{{ $site->id }}" selected>{{ $site->name }}</option>
@endif
@endforeach
</select>
</div>
<div class="form-group col">
<label for="type" class="col-form-label">{{ __('Type') }}</label>
<select class="form-select" name="type" id="type">
@foreach(\App\Enums\Tickets\TicketTypeEnum::cases() as $ticketType)
<option value="{{ $ticketType->value }}" @if($ticketType->value == old('type') or (isset($ticket) and $ticketType->equals($ticket->type)))selected @endif>{{ $ticketType->label() }}</option>
<label class="col-form-label" for="type">{{ __('Type') }}</label>
<select class="form-select" id="type" name="type">
@foreach (\App\Enums\Tickets\TicketTypeEnum::cases() as $ticketType)
<option value="{{ $ticketType->value }}" @if ($ticketType->value == old('type') or isset($ticket) and $ticketType->equals($ticket->type)) selected @endif>{{ $ticketType->label() }}
</option>
@endforeach
</select>
</div>
@can('changeStatus', App\Model\Ticket::class)
<div class="form-group col">
<label for="status" class="col-form-label">{{ __('Status') }}</label>
<select class="form-select" name="status" id="status">
@foreach(\App\Enums\Tickets\TicketStatusEnum::cases() as $ticketStatus)
<option value="{{ $ticketStatus->value }}" @if($ticketType->value == old('status') or (isset($ticket) and $ticketStatus->equals($ticket->status)))selected @endif>{{ $ticketStatus->label() }}</option>
@endforeach
</select>
</div>
@push('scripts')
<script nonce="{{ $nonce ?? null }}">
document.addEventListener('DOMContentLoaded', function () {
const typeSwitch = document.getElementById('type');
const textArea = document.getElementById('text');
const templates = {
@foreach(\App\Models\Ticket\TicketType::query()->get() as $ticketTypeModel)
@php $value = str_replace(["\r\n", "\n", "\r"], '\n', str_replace("<br />", '\n', strip_tags(nl2br($ticketTypeModel->template), '<br />'))); @endphp
"{{ $ticketTypeModel->type->value }}" : "{!! $value !!}",
@endforeach
};
const changeTextValue = () => {
switch(typeSwitch.value) {
@foreach(\App\Models\Ticket\TicketType::query()->get() as $ticketTypeModel)
case "{{ $ticketTypeModel->type->value }}":
// * Ignore if template already changed.
if(textArea.value !== (templates[textArea.template] ?? null) && textArea.value.length) {
return;
}
// Save actual template
textArea.template = typeSwitch.value;
// apply template
textArea.value = templates[typeSwitch.value];
break;
<div class="form-group col">
<label class="col-form-label" for="status">{{ __('Status') }}</label>
<select class="form-select" id="status" name="status">
@foreach (\App\Enums\Tickets\TicketStatusEnum::cases() as $ticketStatus)
<option value="{{ $ticketStatus->value }}" @if ($ticketType->value == old('status') or isset($ticket) and $ticketStatus->equals($ticket->status)) selected @endif>{{ $ticketStatus->label() }}
</option>
@endforeach
</select>
</div>
@push('scripts')
<script nonce="{{ $nonce ?? null }}">
document.addEventListener('DOMContentLoaded', function() {
const typeSwitch = document.getElementById('type');
const textArea = document.getElementById('text');
const templates = {
@foreach (\App\Models\Ticket\TicketType::query()->get() as $ticketTypeModel)
@php $value = str_replace(["\r\n", "\n", "\r"], '\n', str_replace("<br />", '\n', strip_tags(nl2br($ticketTypeModel->template), '<br />'))); @endphp
"{{ $ticketTypeModel->type->value }}": "{!! $value !!}",
@endforeach
default:
console.error(`Unkown value ${typeSwitch.value}`);
}
};
typeSwitch.addEventListener('change', changeTextValue);
changeTextValue();
});
</script>
@endpush
};
const changeTextValue = () => {
switch (typeSwitch.value) {
@foreach (\App\Models\Ticket\TicketType::query()->get() as $ticketTypeModel)
case "{{ $ticketTypeModel->type->value }}":
// * Ignore if template already changed.
if (textArea.value !== (templates[textArea.template] ?? null) && textArea.value.length) {
return;
}
// Save actual template
textArea.template = typeSwitch.value;
// apply template
textArea.value = templates[typeSwitch.value];
break;
@endforeach
default:
console.error(`Unkown value ${typeSwitch.value}`);
}
};
typeSwitch.addEventListener('change', changeTextValue);
changeTextValue();
});
</script>
@endpush
@else
<input type="hidden" name="status" value="{{ \App\Enums\Tickets\TicketStatusEnum::new }}" required>
<input name="status" type="hidden" value="{{ \App\Enums\Tickets\TicketStatusEnum::new }}" required>
@endcan
@can('assignLabels', App\Model\Ticket::class)
<div class="form-group col">
<label for="labels" class="col-form-label">{{ __('Étiquettes') }}</label>
<div class="row">
@php
$dataVue = [
'name' => 'labels',
'value' => optional($ticket ?? null)->labels,
'labels' => \App\Models\Label::all()
];
@endphp
<div
id="label-select"
class="sticky-top"
data-json='@json($dataVue)'>
<div class="form-group col">
<label class="col-form-label" for="labels">{{ __('Étiquettes') }}</label>
<div class="row">
@php
$dataVue = [
'name' => 'labels',
'value' => optional($ticket ?? null)->labels,
'labels' => \App\Models\Label::all(),
];
@endphp
<div class="sticky-top" id="label-select" data-json='@json($dataVue)'>
</div>
</div>
</div>
</div>
@endcan
</div>
<div class="form-group mb-3">
<label class="col-form-label text-md-right" for="title">{{ __('Titre du ticket') }}</label>
<input class="form-control" id="title" name="title" type="text" value="{{ old('title') ?? ($ticket->title ?? '') }}"
placeholder="{{ __('Titre du ticket') }} *">
</div>
<div class="form-group mb-5">
<label for="text" class="col-form-label text-md-right">{{ __('Description') }}</label>
<textarea rows="15" class="form-control" name="text" id="text" placeholder="{{ __('Description du ticket') }} *">{{ old('text') ?? $ticket->text ?? ''}}</textarea>
<label class="col-form-label text-md-right" for="text">{{ __('Description') }}</label>
<textarea class="form-control" id="text" name="text" rows="15" placeholder="{{ __('Description du ticket') }} *">{{ old('text') ?? ($ticket->text ?? '') }}</textarea>
</div>
<h4>Fichier joint 1</h4>
<div class="form-group mb-3">
<input type="file" name="file_ticket" accept="image/png, image/jpeg, image/jpg, .pdf">
<input name="file_ticket" type="file" accept="image/png, image/jpeg, image/jpg, .pdf">
@if (isset($ticket) and $ticket->file !== null)
<hr>
<div class="text-center">
<img class="img-fluid" src="{{ asset($ticket->file) }}">
</div>
<hr>
<div class="text-center">
<img class="img-fluid" src="{{ asset($ticket->file) }}">
</div>
@endif
</div>
<h4>Fichier joint 2</h4>
<div class="form-group">
<input type="file" name="file_ticket2" accept="image/png, image/jpeg, image/jpg, .pdf">
<input name="file_ticket2" type="file" accept="image/png, image/jpeg, image/jpg, .pdf">
@if (isset($ticket) and $ticket->file2 !== null)
<hr>
<div class="text-center">
<img class="img-fluid" src="{{ asset($ticket->file2) }}">
</div>
<hr>
<div class="text-center">
<img class="img-fluid" src="{{ asset($ticket->file2) }}">
</div>
@endif
</div>
@can('changeInternalStatus', App\Model\Ticket::class)
<div class="form-group text-center">
<input type="checkbox" name="is_internal" id="is_internal" @if(old('is_internal', isset($ticket) and $ticket->is_internal)) checked @endif>
<label for="is_internal" class="col-form-label">Ticket interne</label>
</div>
<div class="form-group text-center">
<input id="is_internal" name="is_internal" type="checkbox" @if (old('is_internal', isset($ticket) and $ticket->is_internal)) checked @endif>
<label class="col-form-label" for="is_internal">Ticket interne</label>
</div>
@endcan

View file

@ -5,267 +5,320 @@
@section('bodyClass', 'content ticketsIndex')
@section('content')
@php
$userPr = Auth::user()->sites ?? collect([]);
@endphp
<div class="container container-xxl">
<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 href="{{ route('bo.labels.index') }}" class="btn btn-info"><i class="fa-solid fa-tags"></i></a>
@endcan
<a href="{{ route('bo.ticket.create') }}" class="btn btn-primary"><i class="fa-solid fa-square-plus"></i>&nbsp;&nbsp;{{ __('ticket') }}</a>
@if(session('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value)
<a href="{{ route('bo.ticket.index', ['sts' => -1 ]) }}" class="btn btn-success"><i class="fa-solid fa-inbox"></i></a>
@else
<a href="{{ route('bo.ticket.index', ['st' => \App\Enums\Tickets\TicketStatusEnum::archived]) }}" class="float-end btn btn-secondary"><i class="fa-solid fa-box-archive"></i></a>
@endif
<a href="{{ route('bo.ticket.index', ['rst' => 1]) }}" class="btn btn-dark"><i class="fa-solid fa-eraser"></i>&nbsp;{{ __(' 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 id="selectProject" class="form-select">
<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
@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>&nbsp;&nbsp;{{ __('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>&nbsp;{{ __(' le tri') }}</a>
</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 id="selectStatus" class="form-select">
<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 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>
<div class="row">
@can('assignTickets', App\Models\Ticket::class)
<div class="col">
<div class="float-end mt-3 me-2">
<div class="input-group">
<label class="input-group-text" for="selectAssign"><i class="fa-solid fa-hat-wizard"></i></label>
<select id="selectAssign" class="form-select">
<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>
<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('selectAssign').addEventListener('change', function (e) {
window.location='{{ route('bo.ticket.index') }}?'+(this.value == -1 ? 'assr=-1' : 'ass='+this.value);
});</script>
<script nonce="{{ $nonce }}">
document.getElementById('searchDelete').addEventListener('click', function(e) {
document.getElementById('searchTicket').value = '';
document.getElementById('searchTicketForm').submit();
});
</script>
@endpush
</div>
</form>
</div>
</div>
@endcan
<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="{{ session()->get('tickets.search') }}">
<button id="searchDelete" class="btn btn-outline-danger" 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 table-hover">
<thead>
<tr>
<th scope="col">
<span>#&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'id'])</span>
</th>
<th scope="col">
<span>{{__('Type') }}&nbsp;</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é à') }}&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'assigned_to'])</span>
</th>
<div class="card-body">
<table class="table-hover table">
<thead>
<tr>
<th scope="col">
<span>#&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'id'])</span>
</th>
<th scope="col">
<span>{{ __('Titre') }}&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'title'])</span>
</th>
<th scope="col">
<span>{{ __('Type') }}&nbsp;</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é à') }}&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'assigned_to'])</span>
</th>
@endif
<th scope="col">
<span>{{ __('Le') }}&nbsp;</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
<th scope="col">
<span>{{__('Créé par') }}&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'created_by'])</span>
</th>
<th scope="col">
<span>{{__('Le') }}&nbsp;</span>
<span>@include('modules.sorter', ['colname' => 'created_at'])</span>
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@if(!count($tickets))
<tr>
<td colspan="@if(Auth::user()->isAdmin()) 6 @else 5 @endif" class="text-center">
<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 }}&nbsp;&nbsp;@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="rounded text-center {{ $ticket->status->class() }}">{{ $ticket->status->label() }}</span>
</span>
</div>
</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>{{ $ticket->user ? $ticket->user->name : __('Utilisateur supprimé') }}</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">
@if ($ticket->file !== null)
<a data-gallery="gallery{{ $ticket->id }}" href="{{ asset($ticket->file) }}" class="glightbox btn btn-outline-dark" target="_blank"><i class="fa-solid fa-file-image"></i></a>
@endif
@if ($ticket->file2 !== null)
<a data-gallery="gallery{{ $ticket->id }}" href="{{ asset($ticket->file2) }}" class="glightbox btn btn-outline-dark {{ $ticket->file !== null ? 'd-none' : '' }}" target="_blank"></a>
@endif
{{-- Modal du ticket --}}
<!-- Button trigger modal -->
<button type="button" class="btn btn-outline-info" data-bs-toggle="modal" data-bs-target="#ticket{{ $ticket->id }}Modal"><i class="fa-solid fa-eye"></i></button>
<a href="{{ route('bo.ticket.show', $ticket->id) }}" class="btn btn-outline-success"><i class="fa-solid fa-comment"></i></a>
@if(auth()->user()->isAdmin())
<a href="{{ route('bo.ticket.edit', $ticket) }}" class="btn btn-outline-primary"><i class="fa-solid fa-pen"></i></a>
@endif
@can('changeStatus', $ticket)
@if(!$ticket->status->equals(\App\Enums\Tickets\TicketStatusEnum::archived))
<form method="POST" action="{{ route('bo.ticket.archive', $ticket) }}" class="confirmJS">
@method('PUT')
@csrf
<button type="submit" class="btn btn-outline-danger rounded-0 rounded-end"><i class="fa-solid fa-box-archive"></i></button>
</form>
@endif
@endcan
@foreach ($tickets as $ticket)
<tr class="position-relative">
<td scope="row">
<div class="d-flex justify-content-between">
<span class="me-1">{{ $ticket->id }}&nbsp;&nbsp;@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>
</div>
</div>
<!-- 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">
@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>
</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
</u>&nbsp;-&nbsp;
<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">
@can('assignLabels', App\Models\Ticket::class)
<div class="mt-1 mb-3">
@foreach ($ticket->labels as $label)
<span class="badge label colorize" data-color="{{ $label->color }}">{{ $label->name }}</span>
@endforeach
@endcan
</div>
@endcan
<p>{!! clean(nl2br($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>
</tr>
@endforeach
</tbody>
</table>
{{ $tickets->withQueryString()->links() }}
<!-- 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>
</div>
</div>
</div>
</div>
@endsection

View file

@ -5,167 +5,253 @@
@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>
</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>
<button class="btn btn-danger" type="submit">{{ __('Réouvrir le ticket') }}</button>
</form>
</div>
@endcan
@endif
</div>
</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>
</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>
@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>
</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">
@ -220,56 +306,21 @@
</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
@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
@endcan
@endsection