Commit 2330b69d authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Ok pour les MEP

parent b5e6073a
Loading
Loading
Loading
Loading
+33 −24
Changes for module/Paiement/src/Controller/PaiementController.php: 33 added lines, 24 removed lines.
Original line number Diff line number Diff line
@@ -70,12 +70,14 @@ class PaiementController extends AbstractController
    }



    public function indexAction()
    {
        return [];
    }



    /**
     * @return int
     */
@@ -90,6 +92,7 @@ class PaiementController extends AbstractController
    }



    protected function isChangeIndexSaved($changeIndex)
    {
        $session = $this->getSessionContainer();
@@ -99,6 +102,7 @@ class PaiementController extends AbstractController
    }



    protected function setChangeIndexSaved($changeIndex)
    {
        $session = $this->getSessionContainer();
@@ -109,6 +113,7 @@ class PaiementController extends AbstractController
    }



    public function demandeMiseEnPaiementAction()
    {
        $role = $this->getServiceContext()->getSelectedIdentityRole();
@@ -204,6 +209,7 @@ class PaiementController extends AbstractController
    }



    public function visualisationMiseEnPaiementAction()
    {
        $intervenant = $this->getEvent()->getParam('intervenant');
@@ -227,6 +233,7 @@ class PaiementController extends AbstractController
    }



    public function editionMiseEnPaiementAction()
    {
        $intervenant = $this->getEvent()->getParam('intervenant');
@@ -329,6 +336,7 @@ class PaiementController extends AbstractController
    }



    public function etatPaiementAction()
    {
        $this->initFilters();
@@ -346,36 +354,30 @@ class PaiementController extends AbstractController
        $rechercheForm = $this->getFormPaiementMiseEnPaiementRecherche();
        $rechercheForm->bind($recherche);

        //@todo à revoir...
//        if ($role->getStructure()) {
//            $structures = [$role->getStructure()->getId() => $role->getStructure()];
//        } else {
//            $qb = $this->getServiceStructure()->finderByMiseEnPaiement();
//            $this->getServiceStructure()->finderByRole($role, $qb);
//            $this->getServiceMiseEnPaiement()->finderByTypeIntervenant($recherche->getTypeIntervenant(), $qb);
//            $this->getServiceMiseEnPaiement()->finderByEtat($recherche->getEtat(), $qb);
//            $structures = $this->getServiceStructure()->getList($qb);
//        }
//
//        $rechercheForm->populateStructures($structures);
        $qb = $this->getServiceStructure()->finderByMiseEnPaiement();
        $this->getServiceStructure()->finderByRole($role, $qb);
        $this->getServiceMiseEnPaiement()->finderByTypeIntervenant($recherche->getTypeIntervenant(), $qb);
        $this->getServiceMiseEnPaiement()->finderByEtat($recherche->getEtat(), $qb);
        $structures = $this->getServiceStructure()->getList($qb);
        $rechercheForm->populateStructures($structures);

        if (!$recherche->getStructure()) {
//            if (count($structures) == 1) {
//                $structure = current($structures);
//                $recherche->setStructure($structure);
//                $rechercheForm->get('structure')->setValue($structure->getId());
//                $noData = false;
//            } elseif (count($structures) == 0) {
//                $structure = $this->getServiceStructure()->get((int)$this->params()->fromPost('structure'));
//
//                $noData = true;
//                $recherche->setStructure($structure);
//            } else {
            if (count($structures) == 1) {
                $structure = current($structures);
                $recherche->setStructure($structure);
                $rechercheForm->get('structure')->setValue($structure->getId());
                $noData = false;
            } elseif (count($structures) == 0) {
                $structure = $this->getServiceStructure()->get((int)$this->params()->fromPost('structure'));

                $noData = true;
                $recherche->setStructure($structure);
            } else {
                $structure = $this->getServiceStructure()->get((int)$this->params()->fromPost('structure'));

                $noData = false;
                $recherche->setStructure($structure);
//            }
            }
        }

        if ($recherche->getStructure()) {
@@ -428,6 +430,7 @@ class PaiementController extends AbstractController
    }



    private function makeFilenameFromRecherche(MiseEnPaiementRecherche $recherche)
    {
        if ($recherche->getEtat() == MiseEnPaiement::A_METTRE_EN_PAIEMENT) {
@@ -444,6 +447,7 @@ class PaiementController extends AbstractController
    }



    public function misesEnPaiementCsvAction()
    {
        $this->initFilters();
@@ -464,6 +468,7 @@ class PaiementController extends AbstractController
    }



    public function extractionPaieAction()
    {
        $this->initFilters();
@@ -502,6 +507,7 @@ class PaiementController extends AbstractController
    }



    public function extractionPaiePrimeAction()
    {
        $this->initFilters();
@@ -528,6 +534,7 @@ class PaiementController extends AbstractController
    }



    public function imputationSihamAction()
    {
        $title = 'Export des données pour le chargement en masse des imputations budgétaires dans SIHAM';
@@ -594,6 +601,7 @@ class PaiementController extends AbstractController
    }



    public function miseEnPaiementAction()
    {
        $this->initFilters();
@@ -634,6 +642,7 @@ class PaiementController extends AbstractController
    }



    public function pilotageAction()
    {
        return [];
+11
Changes for module/Paiement/src/Form/Paiement/MiseEnPaiementRechercheForm.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -144,6 +144,17 @@ class MiseEnPaiementRechercheForm extends AbstractForm



    /**
     *
     * @param array $structures
     */
    public function populateStructures($structures)
    {
        $this->get('structure')->setValueOptions(\UnicaenApp\Util::collectionAsOptions($structures));
    }



    /**
     *
     * @param array $periodes