135 lines
6.5 KiB
PHP
135 lines
6.5 KiB
PHP
@php
|
|
$userPr = Auth::user()->sites ?? collect([]);
|
|
@endphp
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<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 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 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
|
|
};
|
|
|
|
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 name="status" type="hidden" value="{{ \App\Enums\Tickets\TicketStatusEnum::new }}" required>
|
|
@endcan
|
|
|
|
@can('assignLabels', App\Model\Ticket::class)
|
|
<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>
|
|
@endcan
|
|
|
|
<div class="form-group col">
|
|
<label class="col-form-label" for="date_mep">{{ __('Date de mise en production souhaitée') }}</label>
|
|
<input class="form-control" id="date_mep" name="date_mep" type="date" min="{{ date('Y-m-j') }}" value="{{ old('date_mep') ?? (isset($ticket) && !is_null($ticket->date_mep) ? $ticket->date_mep->format('Y-m-j') : date('Y-m-j')) }}">
|
|
</div>
|
|
</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 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>
|
|
|
|
@for ($i = 1; $i < 6; $i++)
|
|
<h4>Fichier joint {{ $i }}</h4>
|
|
<div class="form-group mb-3">
|
|
<input name="file_tickets[]" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
|
@if (isset($ticket) and $ticket->file !== null)
|
|
@php
|
|
$fileNumber = 'file'. $i;
|
|
@endphp
|
|
<div class="text-center">
|
|
<img class="img-fluid" src="{{ asset($ticket->$fileNumber) }}">
|
|
</div>
|
|
@endif
|
|
</div>
|
|
<hr>
|
|
@endfor
|
|
|
|
@can('changeInternalStatus', App\Model\Ticket::class)
|
|
<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
|