Merge branch 'trunk'
This commit is contained in:
commit
f64e2269cf
4 changed files with 78 additions and 2 deletions
|
|
@ -42,7 +42,7 @@ class ImportRequest extends FormRequest
|
|||
) {
|
||||
$fail(__('Le fichier doit être d\'un mime type text/csv ou application/vnd.ms-excel'));
|
||||
}
|
||||
if (!$content or mb_detect_encoding($content, ['ISO-8859-1'], false) !== 'ISO-8859-1') {
|
||||
if (!$content or mb_detect_encoding($content, ['ISO-8859-1'], true) !== 'ISO-8859-1') {
|
||||
$fail(__('Le fichier doit etre encodé en ISO-8859-1'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ use Illuminate\Support\Arr;
|
|||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
|
||||
class SalariesImport implements ToModel, WithCustomCsvSettings, WithHeadingRow
|
||||
class SalariesImport implements ToModel, WithCustomCsvSettings, WithHeadingRow, WithValidation
|
||||
{
|
||||
/**
|
||||
* @var array $salariesImport
|
||||
|
|
@ -56,4 +57,23 @@ class SalariesImport implements ToModel, WithCustomCsvSettings, WithHeadingRow
|
|||
$this->salariesImport = array_merge($this->salariesImport, [Arr::get($row, 'matricule')]);
|
||||
return $salarie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'matricule' => 'required|numeric|digits:6',
|
||||
'nom' => 'required|string|max:255',
|
||||
'prenom' => 'required|string|max:255',
|
||||
'etablissement' => 'required|string|max:255',
|
||||
'site' => 'required|string|max:255',
|
||||
'service' => 'required|string|max:255',
|
||||
'date_fin' => 'sometimes|nullable|date_format:d/m/Y',
|
||||
'date_fin_prevue' => 'sometimes|nullable|date_format:d/m/Y'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<span class="float-center text-success">{{ session('success') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
@include('modules.flash-messages')
|
||||
<form action="{{ route('bo.salaries.file') }}" method="POST" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<legend>{{ __('Importer des salariés') }}</legend>
|
||||
|
|
|
|||
55
resources/views/modules/flash-messages.blade.php
Normal file
55
resources/views/modules/flash-messages.blade.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
@if (!request()->routeIs('login'))
|
||||
@if ($message = session()->get('success', session()->get('bo.success')))
|
||||
<div class="alert alert-success alert-dismissible fade show m-0 mb-3" role="alert">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($message = session()->get('error', session()->get('bo.error')))
|
||||
<div class="alert alert-danger alert-dismissible fade show m-0 mb-3" role="alert">
|
||||
<i class="fa-solid fa-circle-xmark"></i>
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($message = session()->get('warning', session()->get('bo.warning')))
|
||||
<div class="alert alert-warning alert-dismissible fade show m-0 mb-3" role="alert">
|
||||
<i class="fa-solid fa-circle-exclamation"></i>
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($message = session()->get('status', session()->get('bo.status')))
|
||||
<div class="alert alert-info alert-dismissible fade show m-0 mb-3" role="alert">
|
||||
<i class="fa-solid fa-circle-info"></i>
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($message = session()->get('info', session()->get('bo.info')))
|
||||
<div class="alert alert-info alert-dismissible fade show m-0 mb-3" role="alert">
|
||||
<i class="fa-solid fa-circle-info"></i>
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible fade show m-0 mb-3" role="alert">
|
||||
<p class="fw-bold m-0"><i class="fa-solid fa-circle-exclamation"></i> Liste des erreurs :</p>
|
||||
@if ($errors->any())
|
||||
<ul class="list-unstyled m-0">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
Loading…
Add table
Reference in a new issue