Loading data/Etats de sortie/export_services_csv.php 0 → 100644 +2 −0 Original line number Diff line number Diff line <?php module/Application/src/Application/Entity/Db/EtatSortie.php +35 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,11 @@ class EtatSortie */ protected $pdfTraitement; /** * @var string */ protected $csvTraitement; /** * @var bool */ Loading Loading @@ -370,6 +375,35 @@ class EtatSortie /** * @return string */ public function getCsvTraitement() { return $this->csvTraitement; } /** * @param string $csvTraitement * * @return EtatSortie */ public function setCsvTraitement($csvTraitement): EtatSortie { $fichierGenerique = getcwd() . '/' . $this->csvTraitement; if (file_exists($fichierGenerique)) { $this->csvTraitement = substr(file_get_contents($fichierGenerique), 5); } $this->csvTraitement = $csvTraitement; return $this; } /** * @return bool */ Loading Loading @@ -426,6 +460,7 @@ class EtatSortie return true; } else { $fichierGenerique = getcwd() . '/data/Etats de sortie/' . $this->getCode() . '.odt'; return file_exists($fichierGenerique); } } Loading module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.EtatSortie.dcm.xml +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ <field name="cle" type="string" column="CLE" nullable="true"/> <field name="csvParams" type="string" column="CSV_PARAMS" nullable="true"/> <field name="pdfTraitement" type="string" column="PDF_TRAITEMENT" nullable="true"/> <field name="csvTraitement" type="string" column="CSV_TRAITEMENT" nullable="true"/> <field name="autoBreak" type="boolean" column="AUTO_BREAK" nullable="false"/> <field name="fichier" type="blob" column="FICHIER" nullable="false"/> <field name="requete" type="string" column="REQUETE" nullable="false"/> Loading module/Application/src/Application/Form/EtatSortieForm.php +14 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ namespace Application\Form; use Application\Entity\Db\EtatSortie; use Application\Form\AbstractForm; use Application\Service\Traits\StatutIntervenantServiceAwareTrait; use Application\Service\Traits\StructureServiceAwareTrait; use Zend\Stdlib\Hydrator\HydratorInterface; Loading Loading @@ -76,6 +75,18 @@ class EtatSortieForm extends AbstractForm ], ]); $this->add([ 'type' => 'TextArea', 'name' => 'csv-traitement', 'options' => [ 'label' => "Traitement des données", ], 'attributes' => [ 'id' => 'csv-traitement', 'rows' => '25', ], ]); $this->add([ 'type' => 'Checkbox', 'name' => 'auto-break', Loading Loading @@ -210,6 +221,7 @@ class EtatSortieHydrator implements HydratorInterface $object->setCle($data['cle']); $object->setCsvParams($data['csv-params']); $object->setPdfTraitement($data['pdf-traitement']); $object->setCsvTraitement($data['csv-traitement']); $object->setAutoBreak($data['auto-break'] === 'true'); $object->setRequete($data['requete']); if (isset($data['fichier']['tmp_name']) && $data['fichier']['tmp_name']) { Loading Loading @@ -249,6 +261,7 @@ class EtatSortieHydrator implements HydratorInterface 'cle' => $object->getCle(), 'csv-params' => $object->getCsvParams(), 'pdf-traitement' => $object->getPdfTraitement(), 'csv-traitement' => $object->getCsvTraitement(), 'auto-break' => $object->isAutoBreak() ? 'true' : 'false', 'requete' => $object->getRequete(), ]; Loading module/Application/src/Application/Service/EtatSortieService.php +30 −11 Original line number Diff line number Diff line Loading @@ -122,14 +122,35 @@ class EtatSortieService extends AbstractEntityService /** * @param EtatSortie $etatSortie * @param array $filtres * @param array $options * * @return CsvModel * @throws \Exception */ public function genererCsv(EtatSortie $etatSortie, array $filtres): CsvModel public function genererCsv(EtatSortie $etatSortie, array $filtres, array $options = []): CsvModel { $params = $etatSortie->getCsvParamsArray(); $csv = new CsvModel(); $data = $this->generateData($etatSortie, $filtres); $role = $this->getServiceContext()->getSelectedIdentityRole(); // à fournir à l'évaluateur... if (trim($etatSortie->getCsvTraitement())) { $__PHP__CODE__TRAITEMENT__ = $etatSortie->getCsvTraitement(); // Isolation de traitement pour éviter tout débordement... $traitement = function () use ($csv, $etatSortie, $data, $filtres, $role, $options, $__PHP__CODE__TRAITEMENT__) { eval($__PHP__CODE__TRAITEMENT__); return $data; }; $data = $traitement(); } if (!$csv->getFilename()) { $csv->setFilename($etatSortie->getLibelle() . '.csv'); } if (empty($csv->getHeader()) && empty($csv->getData())) { $params = $etatSortie->getCsvParamsArray(); $blocs = $etatSortie->getBlocs(); $bkey = null; Loading @@ -138,8 +159,6 @@ class EtatSortieService extends AbstractEntityService break; } $csvModel = new CsvModel(); foreach ($data as $k => $d) { /* On récupère les sous-données éventuelles */ Loading @@ -159,25 +178,25 @@ class EtatSortieService extends AbstractEntityService /* Si il y a des sous-données */ if ($bdata) { foreach ($bdata as $bd) { $csvModel->addLine($this->filterData($d + $bd, $params)); $csv->addLine($this->filterData($d + $bd, $params)); } } else { $csvModel->addLine($this->filterData($d, $params)); $csv->addLine($this->filterData($d, $params)); } } $csvModel->setFilename($etatSortie->getLibelle() . '.csv'); if (isset($csvModel->getData()[0])) { $head = array_keys($csvModel->getData()[0]); if (isset($csv->getData()[0])) { $head = array_keys($csv->getData()[0]); foreach ($head as $k => $v) { if (isset($params[$v]['libelle']) && $params[$v]['libelle']) { $head[$k] = $params[$v]['libelle']; } } $csvModel->setHeader($head); $csv->setHeader($head); } } return $csvModel; return $csv; } Loading Loading
data/Etats de sortie/export_services_csv.php 0 → 100644 +2 −0 Original line number Diff line number Diff line <?php
module/Application/src/Application/Entity/Db/EtatSortie.php +35 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,11 @@ class EtatSortie */ protected $pdfTraitement; /** * @var string */ protected $csvTraitement; /** * @var bool */ Loading Loading @@ -370,6 +375,35 @@ class EtatSortie /** * @return string */ public function getCsvTraitement() { return $this->csvTraitement; } /** * @param string $csvTraitement * * @return EtatSortie */ public function setCsvTraitement($csvTraitement): EtatSortie { $fichierGenerique = getcwd() . '/' . $this->csvTraitement; if (file_exists($fichierGenerique)) { $this->csvTraitement = substr(file_get_contents($fichierGenerique), 5); } $this->csvTraitement = $csvTraitement; return $this; } /** * @return bool */ Loading Loading @@ -426,6 +460,7 @@ class EtatSortie return true; } else { $fichierGenerique = getcwd() . '/data/Etats de sortie/' . $this->getCode() . '.odt'; return file_exists($fichierGenerique); } } Loading
module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.EtatSortie.dcm.xml +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ <field name="cle" type="string" column="CLE" nullable="true"/> <field name="csvParams" type="string" column="CSV_PARAMS" nullable="true"/> <field name="pdfTraitement" type="string" column="PDF_TRAITEMENT" nullable="true"/> <field name="csvTraitement" type="string" column="CSV_TRAITEMENT" nullable="true"/> <field name="autoBreak" type="boolean" column="AUTO_BREAK" nullable="false"/> <field name="fichier" type="blob" column="FICHIER" nullable="false"/> <field name="requete" type="string" column="REQUETE" nullable="false"/> Loading
module/Application/src/Application/Form/EtatSortieForm.php +14 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ namespace Application\Form; use Application\Entity\Db\EtatSortie; use Application\Form\AbstractForm; use Application\Service\Traits\StatutIntervenantServiceAwareTrait; use Application\Service\Traits\StructureServiceAwareTrait; use Zend\Stdlib\Hydrator\HydratorInterface; Loading Loading @@ -76,6 +75,18 @@ class EtatSortieForm extends AbstractForm ], ]); $this->add([ 'type' => 'TextArea', 'name' => 'csv-traitement', 'options' => [ 'label' => "Traitement des données", ], 'attributes' => [ 'id' => 'csv-traitement', 'rows' => '25', ], ]); $this->add([ 'type' => 'Checkbox', 'name' => 'auto-break', Loading Loading @@ -210,6 +221,7 @@ class EtatSortieHydrator implements HydratorInterface $object->setCle($data['cle']); $object->setCsvParams($data['csv-params']); $object->setPdfTraitement($data['pdf-traitement']); $object->setCsvTraitement($data['csv-traitement']); $object->setAutoBreak($data['auto-break'] === 'true'); $object->setRequete($data['requete']); if (isset($data['fichier']['tmp_name']) && $data['fichier']['tmp_name']) { Loading Loading @@ -249,6 +261,7 @@ class EtatSortieHydrator implements HydratorInterface 'cle' => $object->getCle(), 'csv-params' => $object->getCsvParams(), 'pdf-traitement' => $object->getPdfTraitement(), 'csv-traitement' => $object->getCsvTraitement(), 'auto-break' => $object->isAutoBreak() ? 'true' : 'false', 'requete' => $object->getRequete(), ]; Loading
module/Application/src/Application/Service/EtatSortieService.php +30 −11 Original line number Diff line number Diff line Loading @@ -122,14 +122,35 @@ class EtatSortieService extends AbstractEntityService /** * @param EtatSortie $etatSortie * @param array $filtres * @param array $options * * @return CsvModel * @throws \Exception */ public function genererCsv(EtatSortie $etatSortie, array $filtres): CsvModel public function genererCsv(EtatSortie $etatSortie, array $filtres, array $options = []): CsvModel { $params = $etatSortie->getCsvParamsArray(); $csv = new CsvModel(); $data = $this->generateData($etatSortie, $filtres); $role = $this->getServiceContext()->getSelectedIdentityRole(); // à fournir à l'évaluateur... if (trim($etatSortie->getCsvTraitement())) { $__PHP__CODE__TRAITEMENT__ = $etatSortie->getCsvTraitement(); // Isolation de traitement pour éviter tout débordement... $traitement = function () use ($csv, $etatSortie, $data, $filtres, $role, $options, $__PHP__CODE__TRAITEMENT__) { eval($__PHP__CODE__TRAITEMENT__); return $data; }; $data = $traitement(); } if (!$csv->getFilename()) { $csv->setFilename($etatSortie->getLibelle() . '.csv'); } if (empty($csv->getHeader()) && empty($csv->getData())) { $params = $etatSortie->getCsvParamsArray(); $blocs = $etatSortie->getBlocs(); $bkey = null; Loading @@ -138,8 +159,6 @@ class EtatSortieService extends AbstractEntityService break; } $csvModel = new CsvModel(); foreach ($data as $k => $d) { /* On récupère les sous-données éventuelles */ Loading @@ -159,25 +178,25 @@ class EtatSortieService extends AbstractEntityService /* Si il y a des sous-données */ if ($bdata) { foreach ($bdata as $bd) { $csvModel->addLine($this->filterData($d + $bd, $params)); $csv->addLine($this->filterData($d + $bd, $params)); } } else { $csvModel->addLine($this->filterData($d, $params)); $csv->addLine($this->filterData($d, $params)); } } $csvModel->setFilename($etatSortie->getLibelle() . '.csv'); if (isset($csvModel->getData()[0])) { $head = array_keys($csvModel->getData()[0]); if (isset($csv->getData()[0])) { $head = array_keys($csv->getData()[0]); foreach ($head as $k => $v) { if (isset($params[$v]['libelle']) && $params[$v]['libelle']) { $head[$k] = $params[$v]['libelle']; } } $csvModel->setHeader($head); $csv->setHeader($head); } } return $csvModel; return $csv; } Loading