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

...

parent 4b48fbb1
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ use Formation\Provider\Etat\InscriptionEtats;
use Formation\Provider\Validation\DemandeExterneValidations;
use Formation\Service\DemandeExterne\DemandeExterneServiceAwareTrait;
use Formation\Service\Notification\NotificationServiceAwareTrait;
use Laminas\Form\Element\Select;
use Laminas\Http\Request;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\AbstractActionController;
@@ -224,17 +225,20 @@ class DemandeExterneController extends AbstractActionController {
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                if ($demande->getJustificationResponsable() === null) {
            $justification = $data['HasDescription']['description'];
//            if ($form->isValid()) {
//              if ($demande->getJustificationResponsable() === null) {
            if ($justification === null || trim($justification) === '') {
                    $this->flashMessenger()->addErrorMessage("<strong> Échec de la validation </strong> <br/> Veuillez justifier votre validation !");
                } else {
                    $this->getValidationInstanceService()->setValidationActive($demande, DemandeExterneValidations::FORMATION_DEMANDE_RESPONSABLE);
                    $demande->setJustificationResponsable($justification);
                    $this->getDemandeExterneService()->update($demande);
                    $this->flashMessenger()->addSuccessMessage("Validation effectuée.");
                    $this->getNotificationService()->triggerValidationResponsableAgent($demande);
                    $this->getNotificationService()->triggerValidationResponsableDrh($demande);
                }
            }
//            }
        }

        $vm =  new ViewModel([
@@ -295,15 +299,13 @@ class DemandeExterneController extends AbstractActionController {
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getValidationInstanceService()->setValidationActive($demande, DemandeExterneValidations::FORMATION_DEMANDE_DRH);
            $justification = $data['HasDescription']['description'];
            $this->getValidationInstanceService()->setValidationActive($demande, DemandeExterneValidations::FORMATION_DEMANDE_DRH, $justification);
            $this->getDemandeExterneService()->update($demande);
            $this->flashMessenger()->addSuccessMessage("Validation effectuée.");
            $this->getNotificationService()->triggerValidationDrh($demande);
            $this->getNotificationService()->triggerValidationComplete($demande);
        }
        }

        $vm =  new ViewModel([
            'title' => "Validation de la demande de ". $demande->getAgent()->getDenomination() ." à la formation ".$demande->getLibelle(),
@@ -416,7 +418,9 @@ class DemandeExterneController extends AbstractActionController {
        $fichier->setNature($devisNature);
        $form = $this->getUploadForm();
        $form->setAttribute('action', $this->url()->fromRoute('formation/demande-externe/ajouter-devis', ['demande-externe' => $demande->getId()], [], true));
        $form->get('nature')->setValueOptions([$devisNature->getId() => $devisNature->getLibelle()]);
        /** @var Select $select */
        $select = $form->get('nature');
        $select->setValueOptions([$devisNature->getId() => $devisNature->getLibelle()]);
        $form->bind($fichier);


@@ -433,7 +437,7 @@ class DemandeExterneController extends AbstractActionController {
                $demande->addDevis($fichier);
                $this->getDemandeExterneService()->update($demande);
            }
            return $this->redirect()->toRoute('inscription-formation', [], [], true);
            return $this->redirect()->toRoute('inscription-externe', [], [], true);
        }

        $vm = new ViewModel();
+8 −4
Original line number Diff line number Diff line
@@ -252,11 +252,13 @@ class FormationInstance implements HistoriqueAwareInterface, HasSourceInterface,
                    if ($minimum === null or $reversed < $minimum) $minimum = $reversed;
                }
                if ($journee->getType() === Seance::TYPE_VOLUME) {
                    if ($journee->getVolumeDebut()) {
                        $debut = $journee->getVolumeDebut()->format("Y/m/d");
                        if ($minimum === null or $debut < $minimum) $minimum = $debut;
                    }
                }
            }
        }
        if ($minimum !== null) {
            $split = explode("/", $minimum);
            $minimum = $split[2] . "/" . $split[1] . "/" . $split[0];
@@ -279,11 +281,13 @@ class FormationInstance implements HistoriqueAwareInterface, HasSourceInterface,
                    if ($maximum === null or $reversed > $maximum) $maximum = $reversed;
                }
                if ($journee->getType() === Seance::TYPE_VOLUME) {
                    if ($journee->getVolumeFin()) {
                        $fin = $journee->getVolumeFin()->format("Y/m/d");
                        if ($maximum === null or $fin > $maximum) $maximum = $fin;
                    }
                }
            }
        }
        if ($maximum !== null) {
            $split = explode("/", $maximum);
            $maximum = $split[2] . "/" . $split[1] . "/" . $split[0];
+70 −71
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ use Formation\Entity\Db\Seance;
use Formation\Provider\Etat\DemandeExterneEtats;
use Formation\Provider\Etat\InscriptionEtats;
use Formation\Provider\Etat\SessionEtats;
use Formation\Provider\Validation\DemandeExterneValidations;
use Formation\Service\Formation\FormationServiceAwareTrait;
use Formation\Service\FormationGroupe\FormationGroupeServiceAwareTrait;
use Formation\Service\FormationInstance\FormationInstanceServiceAwareTrait;
@@ -34,12 +33,11 @@ use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenEtat\Entity\Db\EtatType;
use UnicaenEtat\Service\EtatInstance\EtatInstanceServiceAwareTrait;
use UnicaenEtat\Service\EtatType\EtatTypeServiceAwareTrait;
use UnicaenValidation\Entity\Db\ValidationInstance;
use UnicaenValidation\Entity\Db\ValidationType;
use UnicaenValidation\Service\ValidationInstance\ValidationInstanceServiceAwareTrait;
use UnicaenValidation\Service\ValidationType\ValidationTypeServiceAwareTrait;

class DemandeExterneService {
class DemandeExterneService
{
    use EntityManagerAwareTrait;
    use EtatInstanceServiceAwareTrait;
    use EtatTypeServiceAwareTrait;
@@ -119,6 +117,7 @@ class DemandeExterneService {
                ->join('demande.agent', 'agent')->addSelect('agent')
                ->join('demande.etats', 'etat')->addSelect('etat')
                ->join('etat.type', 'type')->addSelect('type')
                ->andWhere('etat.histoDestruction IS NULL')
                ;
        } catch (NotSupported $e) {
            throw new RuntimeException("Un problème est survenu lors de la création du QueryBuilder de [" . DemandeExterne::class . "]", 0, $e);
@@ -169,26 +168,26 @@ class DemandeExterneService {
        $qb = $this->createQueryBuilder()->orderBy('demande.' . $champ, $ordre);

        if (isset($params['agent'])) $qb = $qb->andWhere('demande.agent = :agent')->setParameter('agent', $params['agent']);
        if (isset($params['organisme']) AND trim($params['organisme'] !== '')) $qb = $qb->andWhere('demande.organisme = :organisme')->setParameter('organisme', $params['organisme']);
        if (isset($params['etat'])) $qb = $qb->andWhere('etat.type = :etat')->setParameter('etat', $params['etat']);
        if (isset($params['organisme']) && trim($params['organisme'] !== '')) $qb = $qb->andWhere('demande.organisme = :organisme')->setParameter('organisme', $params['organisme']);
        if (isset($params['etat'])) $qb = $qb->andWhere('etat.type = :etat')->setParameter('etat', $params['etat'])->andWhere('etat.histoDestruction IS NULL');
        if (isset($params['historise'])) {
            if ($params['historise'] === '1') $qb = $qb->andWhere('demande.histoDestruction IS NOT NULL');
            if ($params['historise'] === '0') $qb = $qb->andWhere('demande.histoDestruction IS NULL');
        }
        if (isset($params['annee']) AND $params['annee'] !== '') {
        if (isset($params['annee']) and $params['annee'] !== '') {
            $annee = (int)$params['annee'];
            $debut = DateTime::createFromFormat('d/m/Y', '01/09/' . $annee);
            $fin = DateTime::createFromFormat('d/m/Y', '31/08/' . ($annee + 1));
            $qb = $qb
                ->andWhere('demande.fin >= :debut')->setParameter('debut', $debut)
                ->andWhere('demande.debut <= :fin')->setParameter('fin', $fin)
            ;
                ->andWhere('demande.debut <= :fin')->setParameter('fin', $fin);
        }

        $result = $qb->getQuery()->getResult();
        return $result;

    }

    /**
     * @param Agent $agent
     * @param string $champ
@@ -238,8 +237,7 @@ class DemandeExterneService {

            $qb = $qb->andWhere('demande.histoCreation >= :mini AND demande.histoCreation <= :maxi')
                ->setParameter('mini', $mini)
                ->setParameter('maxi', $maxi)
            ;
                ->setParameter('maxi', $maxi);
        }

        $result = $qb->getQuery()->getResult();
@@ -255,8 +253,7 @@ class DemandeExterneService {
        $qb = $this->createQueryBuilder()->orderBy('demande.histoCreation', 'asc')
            ->andWhere('demande.agent in (:agents)')->setParameter('agents', $agents)
            ->andWhere('demande.histoCreation >= :debut')->setParameter('debut', $debut)
            ->andWhere('demande.histoCreation <= :fin')->setParameter('fin', $fin)
        ;
            ->andWhere('demande.histoCreation <= :fin')->setParameter('fin', $fin);
        /** @var FormationInstanceInscrit[] $result */
        $result = $qb->getQuery()->getResult();

@@ -317,8 +314,10 @@ class DemandeExterneService {
            $theme = new FormationGroupe();
            $theme->setLibelle('Stage externe');
            $theme->setOrdre(99999999);
            //source ... todo
            $theme->setSource(HasSourceInterface::SOURCE_EMC2);
            $this->getFormationGroupeService()->create($theme);
            $theme->setIdSource($theme->getId());
            $this->getFormationGroupeService()->update($theme);
        }

        //creation de l'action de formation
@@ -327,8 +326,10 @@ class DemandeExterneService {
        $formation->setGroupe($theme);
        $formation->setDescription("Action de formation générée depuis la demande " . $demande->getId());
        $formation->setAffichage(false);
        //source ... todo
        $theme->setSource(HasSourceInterface::SOURCE_EMC2);
        $this->getFormationService()->create($formation);
        $theme->setIdSource($formation->getId());
        $this->getFormationService()->update($formation);

        //session
        $session = new FormationInstance();
@@ -340,6 +341,7 @@ class DemandeExterneService {
        $session->setSource(HasSourceInterface::SOURCE_EMC2);
        $this->getFormationInstanceService()->create($session);
        $this->getEtatInstanceService()->setEtatActif($session, SessionEtats::ETAT_CLOTURE_INSTANCE);
        $session->setIdSource($formation->getId() . "-" . $session->getId());
        $this->getFormationInstanceService()->update($session);

        //inscription
@@ -354,15 +356,19 @@ class DemandeExterneService {

        $absence = $volume - $suivi;

        if ($suivi !== 0) {
        if ($suivi != 0) {
            //seance
            $seance = new Seance();
            $seance->setInstance($session);
            $seance->setVolume($suivi);
            $seance->setLieu("");
            $seance->setType(Seance::TYPE_VOLUME);
            //source ... todo
            $seance->setVolumeDebut($demande->getDebut());
            $seance->setVolumeFin($demande->getFin());
            $inscription->setSource(HasSourceInterface::SOURCE_EMC2);
            $this->getSeanceService()->create($seance);
            $seance->setIdSource($formation->getId() . "-" . $session->getId() . "-" . $seance->getId());
            $this->getSeanceService()->update($seance);

            //presence true
            $presence = new Presence();
@@ -374,7 +380,7 @@ class DemandeExterneService {
            $this->getPresenceService()->create($presence);
        }

        if ($absence !== 0) {
        if ($absence != 0) {
            //seance
            $seance = new Seance();
            $seance->setInstance($session);
@@ -409,19 +415,12 @@ class DemandeExterneService {
        $debut = DateTime::createFromFormat('d/m/Y', '01/09/' . $annee);
        $fin = DateTime::createFromFormat('d/m/Y', '31/08/' . ($annee + 1));

        try {
//            $qb = $this->getEntityManager()->getRepository(DemandeExterne::class)->createQueryBuilder('demande')
//                ->join('demande.etat', 'etat')->addSelect('etat')
//                ->join('demande.agent', 'agent')->addSelect('agent')
        $qb = $this->createQueryBuilder()
            ->andWhere('demande.histoDestruction IS NULL')
            ->andWhere('type.code in (:etats)')->setParameter('etats', $etats)
            ->andWhere('demande.debut > :debut')->setParameter('debut', $debut)
            ->andWhere('demande.debut < :fin')->setParameter('fin', $fin)
            ->andWhere('agent in (:agents)')->setParameter('agents', $agents);
        } catch (NotSupported $e) {
            throw new RuntimeException("Un problème est survenu lors de la création du QueryBuilder de [".DemandeExterne::class."]", 0 ,$e);
        }

        $result = $qb->getQuery()->getResult();
        return $result;
+7 −2
Original line number Diff line number Diff line
@@ -46,7 +46,9 @@ $canValider = $this->isAllowed(DemandeexternePrivileges::getResourceId(Deman
            <td> <?php echo $demande->getAgent()->getDenomination(); ?> </td>
            <td> <?php echo $demande->getInstance()->getFormation()->getLibelle(); ?> </td>
            <td> <?php echo $demande->getInstance()->getType(); ?> </td>
            <td> <?php echo $this->etatinstance($demande->getEtatActif()); ?> </td>
            <td> <?php
                echo $this->etatinstance($demande->getEtatActif());
                ?> </td>
            <td class="action">
                <?php if ($canAfficher) : ?>
                    <?php /** @see \Formation\Controller\FormationInstanceInscritController::afficherAgentAction() */ ?>
@@ -120,7 +122,10 @@ $canValider = $this->isAllowed(DemandeexternePrivileges::getResourceId(Deman
            <td> <?php echo $demande->getAgent()->getDenomination(); ?> </td>
            <td> <?php echo $demande->getLibelle(); ?> </td>
            <td> <?php echo $demande->getOrganisme(); ?> </td>
            <td> <?php echo $this->etatinstance($demande->getEtatActif()); ?> </td>
            <td>
                <?php
                echo $this->etatinstance($demande->getEtatActif());
                ?> </td>
            <td class="action">
                <?php if ($canAfficher) : ?>
                    <?php /** @see \Formation\Controller\DemandeExterneController::afficherAction() */ ?>