Commit cd7ad4f5 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

EtatFieldset + usage dans les PPP

parent 45676a64
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ use Formation\Service\Formation\FormationServiceAwareTrait;
use Formation\Service\FormationElement\FormationElementServiceAwareTrait;
use Formation\Service\HasFormationCollection\HasFormationCollectionServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;
use UnicaenEtat\Service\Etat\EtatServiceAwareTrait;
use UnicaenEtat\Service\EtatType\EtatTypeServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use UnicaenValidation\Entity\Db\ValidationInstance;
use UnicaenValidation\Service\ValidationInstance\ValidationInstanceServiceAwareTrait;
@@ -91,6 +93,9 @@ class AgentController extends AbstractActionController
    use AgentAccompagnementServiceAwareTrait;
    use AgentAccompagnementFormAwareTrait;

    use EtatTypeServiceAwareTrait;
    use EtatServiceAwareTrait;

    public function indexAction()
    {
        $fromQueries = $this->params()->fromQuery();
@@ -393,6 +398,9 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/ppp/ajouter', ['agent' => $agent->getId()], [], true));
        $form->bind($ppp);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('PPP');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -419,6 +427,9 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/ppp/modifier', ['ppp' => $ppp->getId()], [], true));
        $form->bind($ppp);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('PPP');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -496,6 +507,10 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/stageobs/ajouter', ['agent' => $agent->getId()], [], true));
        $form->bind($stageObservation);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('STAGE_OBSERVATION');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));


        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -522,6 +537,9 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/stageobs/modifier', ['stageobs' => $stageObservation->getId()], [], true));
        $form->bind($stageObservation);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('STAGE_OBSERVATION');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -599,6 +617,10 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/tutorat/ajouter', ['agent' => $agent->getId()], [], true));
        $form->bind($tutorat);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('TUTORAT');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));


        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -625,6 +647,9 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/tutorat/modifier', ['tutorat' => $tutorat->getId()], [], true));
        $form->bind($tutorat);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('TUTORAT');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -702,6 +727,9 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/accompagnement/ajouter', ['agent' => $agent->getId()], [], true));
        $form->bind($accompagnement);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('ACCOMPAGNEMENT');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
@@ -728,6 +756,10 @@ class AgentController extends AbstractActionController
        $form->setAttribute('action', $this->url()->fromRoute('agent/accompagnement/modifier', ['accompagnement' => $accompagnement->getId()], [], true));
        $form->bind($accompagnement);

        $type = $this->getEtatTypeService()->getEtatTypeByCode('ACCOMPAGNEMENT');
        $form->get('etat')->resetEtats($this->getEtatService()->getEtatsByType($type));


        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
+13 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ use Formation\Service\Formation\FormationService;
use Formation\Service\FormationElement\FormationElementService;
use Formation\Service\HasFormationCollection\HasFormationCollectionService;
use Interop\Container\ContainerInterface;
use UnicaenEtat\Service\Etat\EtatService;
use UnicaenEtat\Service\EtatType\EtatTypeService;
use UnicaenUtilisateur\Service\User\UserService;
use UnicaenValidation\Service\ValidationInstance\ValidationInstanceService;
use UnicaenValidation\Service\ValidationType\ValidationTypeService;
@@ -151,6 +153,17 @@ class AgentControllerFactory {
        $controller->setAgentTutoratForm($agentTutoratForm);
        $controller->setAgentAccompagnementService($agentAccompagnementService);
        $controller->setAgentAccompagnementForm($agentAccompagnementForm);

        /**
         * @var EtatService $etatService
         * @var EtatTypeService $etatTypeService
         */
        $etatService = $container->get(EtatService::class);
        $etatTypeService = $container->get(EtatTypeService::class);

        $controller->setEtatService($etatService);
        $controller->setEtatTypeService($etatTypeService);

        return $controller;
    }
}
 No newline at end of file
+9 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\Corps\CorpsServiceAwareTrait;
use Application\Service\Correspondance\CorrespondanceServiceAwareTrait;
use UnicaenApp\Form\Element\SearchAndSelect;
use UnicaenEtat\Form\EtatFieldset\EtatFieldset;
use UnicaenEtat\Service\Etat\EtatServiceAwareTrait;
use Zend\Form\Element\Button;
use Zend\Form\Element\Select;
@@ -71,8 +72,14 @@ class AgentAccompagnementForm extends Form
                'id' => 'periode',
            ]
        ]);
        // etat TODO
        //$this->get('etat')->setValueOptions($this->getEtatService()->getEtatsAsOption($type));
        // etat
        $this->add([
            'name' => 'etat',
            'type' => EtatFieldset::class,
            'attributes' => [
                'id' => 'etat',
            ]
        ]);

        // complement
        $this->add([
+4 −2
Original line number Diff line number Diff line
@@ -31,7 +31,9 @@ class AgentAccompagnementHydrator implements HydratorInterface {
                'date_debut' => ($object->getDateDebut())?$object->getDateDebut()->format('d/m/Y'):null,
                'date_fin'   => ($object->getDateFin())?$object->getDateFin()->format('d/m/Y'):null,
            ],
            'etat'              => [
                'etat' => ($object->getEtat())?$object->getEtat()->getId():null,
            ],
            'complement'        => $object->getComplement(),
            'resutlat'          => $object->getResultat(),
        ];
@@ -50,7 +52,7 @@ class AgentAccompagnementHydrator implements HydratorInterface {
        $corps = (isset($data['corps']) AND trim($data['corps']) !== '')?$this->getCorpsService()->getCorp($data['corps']):null;
        $dataDebut = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_debut']) AND trim($data['HasPeriode']['date_debut']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_debut']):null;
        $dateFin = (isset($data['HasPeriode']) AND isset($data['HasPeriode']['date_fin']) AND trim($data['HasPeriode']['date_fin']) !== '')?DateTime::createFromFormat(HasPeriodeFieldset::format, $data['HasPeriode']['date_fin']):null;
        $etat = (isset($data['etat']))?$this->getEtatService()->getEtat($data['etat']):null;
        $etat = (isset($data['etat']) AND isset($data['etat']['etat']))?$this->getEtatService()->getEtat($data['etat']['etat']):null;
        $complement = (isset($data['complement']) AND trim($data['complement']) !== '')?trim($data['complement']):null;
        $resultat = (isset($data['resultat']) AND trim($data['resultat']) !== '')?($data['resultat']):null;

+9 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Form\AgentPPP;

use Application\Form\HasPeriode\HasPeriodeFieldset;
use UnicaenEtat\Form\EtatFieldset\EtatFieldset;
use UnicaenEtat\Service\Etat\EtatServiceAwareTrait;
use Zend\Form\Element\Button;
use Zend\Form\Element\Number;
@@ -60,8 +61,14 @@ class AgentPPPForm extends Form {
                'id' => 'periode',
            ]
        ]);
        // etat TODO
        //$this->get('etat')->setValueOptions($this->getEtatService()->getEtatsAsOption($type));
        /// etat
        $this->add([
            'name' => 'etat',
            'type' => EtatFieldset::class,
            'attributes' => [
                'id' => 'etat',
            ]
        ]);

        // Utilisation du cpf
        $this->add([
Loading