diff --git a/module/Agent/src/Controller/ValidateurController.php b/module/Agent/src/Controller/ValidateurController.php index f97850ea85472757cd8d2fdf85df927170053037..99a44ce4d88f9e057ef06847873529e3bf5ef54d 100644 --- a/module/Agent/src/Controller/ValidateurController.php +++ b/module/Agent/src/Controller/ValidateurController.php @@ -138,12 +138,14 @@ class ValidateurController extends AbstractActionController $fichier_path = $file['fichier']['tmp_name']; $mode = $data['mode']; + $header = isset($data['header'])?$data['header'] === '1':false; //reading $array = []; $warning = []; $chaines = []; $agents = []; + $info = []; if ($fichier_path === null or $fichier_path === '') { $error[] = "Aucun fichier !"; @@ -154,6 +156,10 @@ class ValidateurController extends AbstractActionController $array[] = $content; } + if ($header) { + $array = array_splice($array,1); + $info[] = "Retrait de la première ligne"; + } foreach ($array as $line) { $agent_id = $line[0]??null; $agent = $this->getAgentService()->getAgent($agent_id); @@ -169,7 +175,9 @@ class ValidateurController extends AbstractActionController if ($date_fin_st !== '' and $dateFin === false) $warning[] = "Impossibilité de calculé la date de fin à partir de [".$date_fin_st."]"; $chaines[] = [$agent, $responsable, $dateDebut, $dateFin]; - $agents[$agent->getId()] = $agent; + if ($agent !== null) { + $agents[$agent->getId()] = $agent; + } } } @@ -204,6 +212,7 @@ class ValidateurController extends AbstractActionController 'error' => $error, 'warning' => $warning, 'chaines' => $chaines, + 'info' => $info, ]); } diff --git a/module/Agent/view/agent/validateur/importer.phtml b/module/Agent/view/agent/validateur/importer.phtml index 26dfacfb4227fea7a71e06749c2540cf0772663e..414e3baf76380e1b835879281aee95a63c4465db 100644 --- a/module/Agent/view/agent/validateur/importer.phtml +++ b/module/Agent/view/agent/validateur/importer.phtml @@ -7,6 +7,7 @@ * @var string $type * @var string[] $error * @var string[] $warning + * @var string[] $info * @var Agent[] $chaines */ @@ -21,6 +22,12 @@ use Application\Form\CsvImportation\CsvImportationForm; <?php echo $this->form($form); ?> +<?php if (!empty($info)) : ?> + <div class="alert alert-info"> + <span class="icon icon-information"></span> + <?php echo implode('<br>', $info); ?> + </div> +<?php endif; ?> <?php if (!empty($error)) : ?> <div class="alert alert-danger"> <span class="icon icon-attention"></span> @@ -51,8 +58,8 @@ use Application\Form\CsvImportation\CsvImportationForm; <tbody> <?php foreach ($chaines as [$agent, $responsable, $dateDebut, $dateFin]) : ?> <tr> - <td> <?php echo $agent->getDenomination(); ?> </td> - <td> <?php echo $responsable->getDenomination(); ?> </td> + <td> <?php echo $agent?->getDenomination(); ?> </td> + <td> <?php echo $responsable?->getDenomination(); ?> </td> <td> <?php echo ($dateDebut)?$dateDebut->format('d/m/Y'):"---"; ?> </td> <td> <?php echo ($dateFin)?$dateFin->format('d/m/Y'):"---"; ?> </td> </tr> diff --git a/module/Application/src/Application/Form/CsvImportation/CsvImportationForm.php b/module/Application/src/Application/Form/CsvImportation/CsvImportationForm.php index c20c9f1d975c903c980e364ca63c89437c7c1c58..1bdc22f364ef81be4f79a9796930600c5ec04269 100644 --- a/module/Application/src/Application/Form/CsvImportation/CsvImportationForm.php +++ b/module/Application/src/Application/Form/CsvImportation/CsvImportationForm.php @@ -3,6 +3,7 @@ namespace Application\Form\CsvImportation; use Laminas\Form\Element\Button; +use Laminas\Form\Element\Checkbox; use Laminas\Form\Element\File; use Laminas\Form\Element\Select; use Laminas\Form\Form; @@ -37,6 +38,19 @@ class CsvImportationForm extends Form { 'id' => 'mode', ], ]); + //header + $this->add([ + 'type' => Checkbox::class, + 'name' => 'header', + 'options' => [ + 'label' => 'Retirer la première ligne (header)', + 'label_options' => [ 'disable_html_escape' => true, ], + ], + 'attributes' => [ + 'id' => 'header', + ], + ]); + //Submit $this->add([ 'type' => Button::class, @@ -54,6 +68,7 @@ class CsvImportationForm extends Form { $this->setInputFilter((new Factory())->createInputFilter([ 'fichier' => [ 'required' => true, ], 'mode' => ['required' => true, ], + 'header' => ['required' => false, ], ])); } } \ No newline at end of file