Loading module/Application/config/structure.config.php +3 −14 Original line number Diff line number Diff line Loading @@ -31,17 +31,6 @@ return [ ], ], ], 'index2' => [ 'type' => 'Segment', 'options' => [ 'route' => '/index2/:structure', 'constraints' => [ ], 'defaults' => [ 'action' => 'index2', ], ], ], 'delete' => [ 'type' => 'Segment', 'options' => [ Loading Loading @@ -81,7 +70,7 @@ return [ 'label' => 'Structure', 'icon' => 'fa fa-graduation-cap', 'route' => 'structure', 'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index2'), 'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index'), 'order' => 80, 'border-color' => '#BBCF55', ], Loading @@ -102,7 +91,7 @@ return [ PrivilegeController::class => [ [ 'controller' => 'Application\Controller\Structure', 'action' => ['index2'], 'action' => ['index'], 'privileges' => Privileges::STRUCTURES_ADMINISTRATION_VISUALISATION, ], [ Loading module/Application/src/Application/Controller/StructureController.php +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ class StructureController extends AbstractController use StructureSaisieFormAwareTrait; public function index2Action() public function indexAction() { $this->em()->getFilters()->enable('historique')->init([ Structure::class, Loading module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Structure.dcm.xml +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ <field name="libelleLong" type="string" column="LIBELLE_LONG" length="60" nullable="false"/> <field name="sourceCode" type="string" column="SOURCE_CODE" length="100" nullable="true"/> <field name="enseignement" type="boolean" column="ENSEIGNEMENT" nullable="false"/> <field name="plafondReferentiel" type="float" column="PLAFOND_REFERENTIEL" precision="126" scale="0" nullable="true"/> <field name="affAdresseContrat" type="boolean" column="AFF_ADRESSE_CONTRAT" nullable="false"/> <many-to-one field="source" target-entity="UnicaenImport\Entity\Db\Source"> <join-columns> <join-column name="SOURCE_ID" referenced-column-name="ID"/> Loading module/Application/src/Application/Entity/Db/Structure.php +91 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,21 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw */ protected $enseignement; /** * @var float */ protected $plafondReferentiel; /** * @var boolean */ protected $affAdresseContrat; /** * @var string */ protected $sourceCode; function __construct() Loading Loading @@ -166,6 +181,28 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw } /** * @return string */ public function getSourceCode() { return $this->sourceCode; } /** * @param string $sourceCode * * @return Structure */ public function setSourceCode($sourceCode) { $this->sourceCode = $sourceCode; return $this; } /** * Add elementPedagogique Loading Loading @@ -283,6 +320,58 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw /** * Set plafondReferentiel * * @param string $plafondReferentiel * * @return Structure */ public function setPlafondReferentiel($plafondReferentiel) { $this->plafondReferentiel = $plafondReferentiel; return $this; } /** * Get plafondReferentiel * * @return float */ public function getPlafondReferentiel() { return $this->plafondReferentiel; } /** * @return bool */ public function isAffAdresseContrat() { return $this->affAdresseContrat; } /** * @param bool $affAdresseContrat * * @return Structure */ public function setAffAdresseContrat($affAdresseContrat) { $this->affAdresseContrat = $affAdresseContrat; return $this; } /** * Retourne la représentation littérale de cet objet. * Loading Loading @@ -342,6 +431,8 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw $this->setEntityManager($objectManager); } function __sleep() { return []; Loading module/Application/src/Application/Form/Structure/StructureSaisieForm.php 0 → 100755 +218 −0 Original line number Diff line number Diff line <?php namespace Application\Form\Structure; use Application\Form\AbstractForm; use Zend\Form\Element\Csrf; use Zend\Stdlib\Hydrator\HydratorInterface; use Application\Service\Traits\SourceServiceAwareTrait; use Application\Filter\FloatFromString; use Application\Filter\StringFromFloat; /** * Description of StructureSaisieForm * * @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky@unicaen.fr> */ class StructureSaisieForm extends AbstractForm { use SourceServiceAwareTrait; public function init() { $hydrator = new StructureHydrator(); $this->setHydrator($hydrator); $this->setAttribute('action', $this->getCurrentUrl()); $this->add([ 'name' => 'code', 'options' => [ 'label' => "Code", ], 'type' => 'Text', ]); $this->add([ 'name' => 'libelle-court', 'options' => [ 'label' => "Libelle Court", ], 'type' => 'Text', ]); $this->add([ 'name' => 'libelle-long', 'options' => [ 'label' => "Libelle Long", ], 'type' => 'Text', ]); $this->add([ 'name' => 'enseignement', 'options' => [ 'label' => "Enseignement", ], 'type' => 'Checkbox', ]); $this->add([ 'name' => 'source-code', 'options' => [ 'label' => "Source Code", ], 'type' => 'Text', ]); $this->add([ 'name' => 'plafond-referentiel', 'options' => [ 'label' => "Plafond Referentiel", ], 'type' => 'Text', ]); $this->add([ 'name' => 'aff-adresse-contrat', 'options' => [ 'label' => "Aff Adresse Contrat", ], 'type' => 'Checkbox', ]); $this->add([ 'name' => 'source', 'options' => [ 'label' => 'Source', ], 'attributes' => [ 'class' => 'selectpicker', 'data-live-search' => 'true', ], 'type' => 'Select', ]); $this->get('source') ->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServiceSource()->getList())); $this->add(new Csrf('security')); $this->add([ 'name' => 'submit', 'type' => 'Submit', 'attributes' => [ 'value' => "Enregistrer", 'class' => 'btn btn-primary', ], ]); return $this; } /** * Should return an array specification compatible with * {@link Zend\InputFilter\Factory::createInputFilter()}. * * @return array */ public function getInputFilterSpecification() { return [ 'code' => [ 'required' => true, ], 'libelle-court' => [ 'required' => true, ], 'libelle-long' => [ 'required' => true, ], 'enseignement' => [ 'required' => true, ], 'source' => [ 'required' => true, ], 'aff-adresse-contrat' => [ 'required' => true, ], 'plafond-referentiel' => [ 'required' => true, 'validators' => [ new \Zend\Validator\Callback([ 'messages' => [\Zend\Validator\Callback::INVALID_VALUE => '%value% doit être >= 0'], 'callback' => function ($value) { if ($value == null) return true; return (FloatFromString::run($value) >= 0.0 ? true : false); }]), ], ], ]; } } class StructureHydrator implements HydratorInterface { use SourceServiceAwareTrait; /** * Hydrate $object with the provided $data. * * @param array $data * @param \Application\Entity\Db\Structure $object * * @return object */ public function hydrate(array $data, $object) { $object->setCode($data['code']); $object->setLibelleCourt($data['libelle-court']); $object->setLibelleLong($data['libelle-long']); $object->setEnseignement($data['enseignement']); $object->setSourceCode($data['source-code']); $object->setPlafondReferentiel(FloatFromString::run($data['plafond-referentiel'])); $object->setAffAdresseContrat($data['aff-adresse-contrat']); if (array_key_exists('source', $data)) { $object->setSource($this->getServiceSource()->get($data['source'])); } return $object; } /** * Extract values from an object * * @param \Application\Entity\Db\Structure $object * * @return array */ public function extract($object) { $data = [ 'id' => $object->getId() , 'code' => $object->getCode() , 'libelle-court' => $object->getLibelleCourt() , 'libelle-long' => $object->getLibelleLong() , 'enseignement' => $object->isEnseignement() , 'source-code' => $object->getSourceCode() , 'plafond-referentiel' => StringFromFloat::run($object->getPlafondReferentiel()) , 'aff-adresse-contrat' => $object->isAffAdresseContrat() , 'source' => ($s = $object->getSource()) ? $s->getId() : null, ]; return $data; } } Loading
module/Application/config/structure.config.php +3 −14 Original line number Diff line number Diff line Loading @@ -31,17 +31,6 @@ return [ ], ], ], 'index2' => [ 'type' => 'Segment', 'options' => [ 'route' => '/index2/:structure', 'constraints' => [ ], 'defaults' => [ 'action' => 'index2', ], ], ], 'delete' => [ 'type' => 'Segment', 'options' => [ Loading Loading @@ -81,7 +70,7 @@ return [ 'label' => 'Structure', 'icon' => 'fa fa-graduation-cap', 'route' => 'structure', 'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index2'), 'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index'), 'order' => 80, 'border-color' => '#BBCF55', ], Loading @@ -102,7 +91,7 @@ return [ PrivilegeController::class => [ [ 'controller' => 'Application\Controller\Structure', 'action' => ['index2'], 'action' => ['index'], 'privileges' => Privileges::STRUCTURES_ADMINISTRATION_VISUALISATION, ], [ Loading
module/Application/src/Application/Controller/StructureController.php +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ class StructureController extends AbstractController use StructureSaisieFormAwareTrait; public function index2Action() public function indexAction() { $this->em()->getFilters()->enable('historique')->init([ Structure::class, Loading
module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Structure.dcm.xml +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ <field name="libelleLong" type="string" column="LIBELLE_LONG" length="60" nullable="false"/> <field name="sourceCode" type="string" column="SOURCE_CODE" length="100" nullable="true"/> <field name="enseignement" type="boolean" column="ENSEIGNEMENT" nullable="false"/> <field name="plafondReferentiel" type="float" column="PLAFOND_REFERENTIEL" precision="126" scale="0" nullable="true"/> <field name="affAdresseContrat" type="boolean" column="AFF_ADRESSE_CONTRAT" nullable="false"/> <many-to-one field="source" target-entity="UnicaenImport\Entity\Db\Source"> <join-columns> <join-column name="SOURCE_ID" referenced-column-name="ID"/> Loading
module/Application/src/Application/Entity/Db/Structure.php +91 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,21 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw */ protected $enseignement; /** * @var float */ protected $plafondReferentiel; /** * @var boolean */ protected $affAdresseContrat; /** * @var string */ protected $sourceCode; function __construct() Loading Loading @@ -166,6 +181,28 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw } /** * @return string */ public function getSourceCode() { return $this->sourceCode; } /** * @param string $sourceCode * * @return Structure */ public function setSourceCode($sourceCode) { $this->sourceCode = $sourceCode; return $this; } /** * Add elementPedagogique Loading Loading @@ -283,6 +320,58 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw /** * Set plafondReferentiel * * @param string $plafondReferentiel * * @return Structure */ public function setPlafondReferentiel($plafondReferentiel) { $this->plafondReferentiel = $plafondReferentiel; return $this; } /** * Get plafondReferentiel * * @return float */ public function getPlafondReferentiel() { return $this->plafondReferentiel; } /** * @return bool */ public function isAffAdresseContrat() { return $this->affAdresseContrat; } /** * @param bool $affAdresseContrat * * @return Structure */ public function setAffAdresseContrat($affAdresseContrat) { $this->affAdresseContrat = $affAdresseContrat; return $this; } /** * Retourne la représentation littérale de cet objet. * Loading Loading @@ -342,6 +431,8 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw $this->setEntityManager($objectManager); } function __sleep() { return []; Loading
module/Application/src/Application/Form/Structure/StructureSaisieForm.php 0 → 100755 +218 −0 Original line number Diff line number Diff line <?php namespace Application\Form\Structure; use Application\Form\AbstractForm; use Zend\Form\Element\Csrf; use Zend\Stdlib\Hydrator\HydratorInterface; use Application\Service\Traits\SourceServiceAwareTrait; use Application\Filter\FloatFromString; use Application\Filter\StringFromFloat; /** * Description of StructureSaisieForm * * @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky@unicaen.fr> */ class StructureSaisieForm extends AbstractForm { use SourceServiceAwareTrait; public function init() { $hydrator = new StructureHydrator(); $this->setHydrator($hydrator); $this->setAttribute('action', $this->getCurrentUrl()); $this->add([ 'name' => 'code', 'options' => [ 'label' => "Code", ], 'type' => 'Text', ]); $this->add([ 'name' => 'libelle-court', 'options' => [ 'label' => "Libelle Court", ], 'type' => 'Text', ]); $this->add([ 'name' => 'libelle-long', 'options' => [ 'label' => "Libelle Long", ], 'type' => 'Text', ]); $this->add([ 'name' => 'enseignement', 'options' => [ 'label' => "Enseignement", ], 'type' => 'Checkbox', ]); $this->add([ 'name' => 'source-code', 'options' => [ 'label' => "Source Code", ], 'type' => 'Text', ]); $this->add([ 'name' => 'plafond-referentiel', 'options' => [ 'label' => "Plafond Referentiel", ], 'type' => 'Text', ]); $this->add([ 'name' => 'aff-adresse-contrat', 'options' => [ 'label' => "Aff Adresse Contrat", ], 'type' => 'Checkbox', ]); $this->add([ 'name' => 'source', 'options' => [ 'label' => 'Source', ], 'attributes' => [ 'class' => 'selectpicker', 'data-live-search' => 'true', ], 'type' => 'Select', ]); $this->get('source') ->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServiceSource()->getList())); $this->add(new Csrf('security')); $this->add([ 'name' => 'submit', 'type' => 'Submit', 'attributes' => [ 'value' => "Enregistrer", 'class' => 'btn btn-primary', ], ]); return $this; } /** * Should return an array specification compatible with * {@link Zend\InputFilter\Factory::createInputFilter()}. * * @return array */ public function getInputFilterSpecification() { return [ 'code' => [ 'required' => true, ], 'libelle-court' => [ 'required' => true, ], 'libelle-long' => [ 'required' => true, ], 'enseignement' => [ 'required' => true, ], 'source' => [ 'required' => true, ], 'aff-adresse-contrat' => [ 'required' => true, ], 'plafond-referentiel' => [ 'required' => true, 'validators' => [ new \Zend\Validator\Callback([ 'messages' => [\Zend\Validator\Callback::INVALID_VALUE => '%value% doit être >= 0'], 'callback' => function ($value) { if ($value == null) return true; return (FloatFromString::run($value) >= 0.0 ? true : false); }]), ], ], ]; } } class StructureHydrator implements HydratorInterface { use SourceServiceAwareTrait; /** * Hydrate $object with the provided $data. * * @param array $data * @param \Application\Entity\Db\Structure $object * * @return object */ public function hydrate(array $data, $object) { $object->setCode($data['code']); $object->setLibelleCourt($data['libelle-court']); $object->setLibelleLong($data['libelle-long']); $object->setEnseignement($data['enseignement']); $object->setSourceCode($data['source-code']); $object->setPlafondReferentiel(FloatFromString::run($data['plafond-referentiel'])); $object->setAffAdresseContrat($data['aff-adresse-contrat']); if (array_key_exists('source', $data)) { $object->setSource($this->getServiceSource()->get($data['source'])); } return $object; } /** * Extract values from an object * * @param \Application\Entity\Db\Structure $object * * @return array */ public function extract($object) { $data = [ 'id' => $object->getId() , 'code' => $object->getCode() , 'libelle-court' => $object->getLibelleCourt() , 'libelle-long' => $object->getLibelleLong() , 'enseignement' => $object->isEnseignement() , 'source-code' => $object->getSourceCode() , 'plafond-referentiel' => StringFromFloat::run($object->getPlafondReferentiel()) , 'aff-adresse-contrat' => $object->isAffAdresseContrat() , 'source' => ($s = $object->getSource()) ? $s->getId() : null, ]; return $data; } }