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

Modification et correction du bug de calcul de la quotite travaillé

parent 7847c609
Loading
Loading
Loading
Loading
+11 −6
Changes for module/Application/src/Application/Controller/FichePosteController.php: 11 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -110,8 +110,13 @@ class FichePosteController extends AbstractActionController {

    public function detruireAction()
    {
        $structureId = $this->params()->fromQuery('structure');
        $structure = $this->getStructureService()->getStructure($structureId);

        $fiche = $this->getFichePosteService()->getRequestedFichePoste($this, 'fiche-poste');
        $this->getFichePosteService()->delete($fiche);

        if ($structure !== null) return $this->redirect()->toRoute('mes-structures', ['structure' => $structure->getId()], [], true);
        return $this->redirect()->toRoute('fiche-poste', [], [], true);
    }

@@ -215,7 +220,7 @@ class FichePosteController extends AbstractActionController {
                $this->getFichePosteService()->createFicheTypeExterne($ficheTypeExterne);

                if ($ficheTypeExterne->getPrincipale()) {
                    var_dump('principale is 1');
//                    var_dump('principale is 1');
                    foreach ($fiche->getFichesMetiers() as $ficheMetier) {
                        if ($ficheMetier !== $ficheTypeExterne && $ficheMetier->getPrincipale()) {
                            $ficheMetier->setPrincipale(false);
@@ -251,6 +256,7 @@ class FichePosteController extends AbstractActionController {
        $fichePoste = $this->getFichePosteService()->getRequestedFichePoste($this, 'fiche-poste');
        $ficheTypeExterneId = $this->params()->fromRoute('fiche-type-externe');
        $ficheTypeExterne = $this->getFichePosteService()->getFicheTypeExterne($ficheTypeExterneId);
        $previous = $ficheTypeExterne->getQuotite();

        $form = $this->getAjouterFicheTypeForm();
        $form->setAttribute('action', $this->url()->fromRoute('fiche-poste/modifier-fiche-metier', ['fiche-poste' => $fichePoste->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true));
@@ -260,9 +266,8 @@ class FichePosteController extends AbstractActionController {
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();

            $form->setData($data);

            $data["old"] = $previous;
            $res = $this->checkValidite($fichePoste, $data);
            if ($res) return $res;

@@ -373,15 +378,15 @@ class FichePosteController extends AbstractActionController {
    private function checkValidite($fiche, $data)
    {
        $cut = false;
        if ($data['est_principale'] === "1"  && $data['quotite'] < 50) {
        if ($data['est_principale'] === "1"  && ((int) $data['quotite']) < 50) {
            $cut = true;
            $this->flashMessenger()->addErrorMessage("La fichie métier principale doit avoir une quotité d'au moins 50%.");
        }
        if ($data['est_principale'] === "0" && $data['quotite'] >= 50) {
        if ($data['est_principale'] === "0" && ((int) $data['quotite']) >= 50) {
            $cut = true;
            $this->flashMessenger()->addErrorMessage("La fichie métier non principale doit avoir une quotité infiérieure à 50%.");
        }
        if ($fiche->getQuotiteTravaillee() + $data['quotite'] > 100) {
        if ($fiche->getQuotiteTravaillee() + ((int) $data['quotite']) - ((int) $data['old']) > 100) {
            $cut = true;
            $this->flashMessenger()->addErrorMessage("La somme des quotités travaillées ne peut dépasser 100%.");
        }
+30
Changes for module/Application/src/Application/Form/AjouterFicheMetier/AjouterFicheMetierForm.php: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Application\Service\FamilleProfessionnelle\FamilleProfessionnelleServiceAwar
use Application\Service\FicheMetier\FicheMetierServiceAwareTrait;
use Zend\Form\Element\Button;
use Zend\Form\Element\Checkbox;
use Zend\Form\Element\Hidden;
use Zend\Form\Element\Select;
use Zend\Form\Form;
use Zend\InputFilter\Factory;
@@ -14,6 +15,26 @@ class AjouterFicheMetierForm extends Form {
    use FicheMetierServiceAwareTrait;
    use FamilleProfessionnelleServiceAwareTrait;

    private $previous;

    /**
     * @return mixed
     */
    public function getPrevious()
    {
        return $this->previous;
    }

    /**
     * @param mixed $previous
     * @return AjouterFicheMetierForm
     */
    public function setPrevious($previous)
    {
        $this->previous = $previous;
        return $this;
    }

    public function init()
    {
        //Fiche Type
@@ -30,6 +51,14 @@ class AjouterFicheMetierForm extends Form {
            ],
        ]);

        $this->add([
            'type' => Hidden::class,
            'name' => 'old',
            'attributes' => [
                'value' => $this->previous,
            ],
        ]);

        //Quotite
        //Fiche Type
        $this->add([
@@ -76,6 +105,7 @@ class AjouterFicheMetierForm extends Form {
        $this->setInputFilter((new Factory())->createInputFilter([
            'fiche_type'        => [ 'required' => true,  ],
            'quotite'           => [ 'required' => true,  ],
            'old'               => [ 'required' => false,  ],
        ]));
    }

−1
Changes for module/Application/src/Application/Service/Agent/AgentService.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -164,7 +164,6 @@ class AgentService {
            ->setParameter('today', $today)
            ->setParameter('noEnd', $noEnd)
            ->setParameter('true', 'O')

        ;

        if ($structure !== null) {
+1 −1
Changes for module/Application/src/Application/View/Helper/partial/fiche-metier-externe.phtml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ use Application\Entity\Db\FicheTypeExterne;
                    <a href="<?php echo $this->url('fiche-poste/selectionner-activite', ['fiche-poste' => $fiche->getFichePoste()->getId(), 'fiche-type-externe' => $fiche->getId()], [], true); ?>"
                       class="ajax-modal" data-event="modification">
                       <span class="icon listing" title="Sélectionner les activités associées"></span></a>
                    <a href="<?php $this->url('fiche-poste/retirer-fiche-metier', ['fiche-poste' => $fiche->getFichePoste()->getId(), 'fiche-type-externe' => $fiche->getId()], [], true); ?>">
                    <a href="<?php echo $this->url('fiche-poste/retirer-fiche-metier', ['fiche-poste' => $fiche->getFichePoste()->getId(), 'fiche-type-externe' => $fiche->getId()], [], true); ?>">
                        <span class="icon detruire" title="Retirer la fiche type externe"></span></a>
                <?php endif; ?>
            </div>
+2 −2
Changes for module/Application/view/application/fiche-poste/editer.phtml: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ $canEditer = $this->isAllowed(FichePostePrivileges::getResourceId(FichePostePriv
            </div>
            <div class="col-md-6">
                <?php if($canAssocierAgent) : ?>
                    <a href="<?php echo $this->url('fiche-poste/associer-agent',['fiche-poste' => $fiche->getId()], ["query" => ["structure" => $structure->getId()]], true); ?>"
                    <a href="<?php echo $this->url('fiche-poste/associer-agent',['fiche-poste' => $fiche->getId()], ["query" => ["structure" => ($structure)?$structure->getId():null]], true); ?>"
                       class="btn btn-primary action ajax-modal pull-right"
                       data-event="modification"
                    >
@@ -88,7 +88,7 @@ $canEditer = $this->isAllowed(FichePostePrivileges::getResourceId(FichePostePriv
            </div>
            <div class="col-md-6">
                <?php if($canAssocierAgent) : ?>
                    <a href="<?php echo $this->url('fiche-poste/associer-poste',['fiche-poste' => $fiche->getId()], ["query" => ["structure" => $structure->getId()]], true); ?>"
                    <a href="<?php echo $this->url('fiche-poste/associer-poste',['fiche-poste' => $fiche->getId()], ["query" => ["structure" => ($structure)?$structure->getId():null]], true); ?>"
                       class="btn btn-primary action ajax-modal pull-right"
                       data-event="modification"
                    >
Loading