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

Modification date et lieu + validation

parent 69593cf4
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ class ValidationRepository extends DefaultEntityRepository
     * @param These  $these
     * @return Validation[]
     */
    public function findValidationByCodeAndThese($code, These $these)
    public function findValidationByCodeAndThese(string $code, These $these) : array
    {
        $qb = $this->createQueryBuilder('v')
            ->where('t = :these')
@@ -35,29 +35,31 @@ class ValidationRepository extends DefaultEntityRepository
    }

    /**
     * @param These $these
     * @param string $code
     * @param Individu $individu
     * @return Validation[]
     */
    public function findValidationByCodeAndIndividu($code, $individu)
    public function findValidationByTheseAndCodeAndIndividu(These $these, string $code, Individu $individu) : array
    {
        $qb = $this->createQueryBuilder('v')
            ->where('tv.code = :code')
            ->andWhere('v.individu = :individu')
            ->andWhere('v.these = :these')
            ->andWhere('1 = pasHistorise(v)')
            ->setParameter('code', $code)
            ->setParameter('individu', $individu)
            ->setParameter('these', $these)
        ;

        return $qb->getQuery()->getResult();
    }

    /**
     * @param string $code
     * @param These  $these
     * @return Validation[]
     */
    public function findValidationsByThese(These $these)
    public function findValidationsByThese(These $these) : array
    {
        $qb = $this->createQueryBuilder('v')
            ->where('t = :these')
+23 −2
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ use Application\Entity\Db\These;
use Application\Entity\Db\TypeValidation;
use Application\Service\UserContextServiceAwareTrait;
use Application\Service\Validation\ValidationServiceAwareTrait;
use DateInterval;
use DateTime;
use Soutenance\Entity\Proposition;
use Soutenance\Provider\Privilege\PropositionPrivileges;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Assertion\AssertionInterface;
@@ -37,6 +40,18 @@ class PropositionAssertion implements AssertionInterface {
    {
        /** @var These $these */
        $these = $resource;
        $proposition = null;
        /** @var Proposition $p */
        foreach ($these->getPropositions() as $p) {
            if ($p->estNonHistorise()) {
                $proposition = $p;
                break;
            }
        }
        $sursis = ($proposition)?$proposition->hasSursis():false;
        $dateValidationMax = DateTime::createFromFormat('d/m/Y',$proposition->getDate()->format('d/m/Y'))->sub(new DateInterval('P2M'));
        $dateCurrent = new DateTime();

        $role = $this->userContextService->getSelectedIdentityRole()->getCode();
        $structure = $this->userContextService->getSelectedIdentityRole()->getStructure();
        $individu = $this->userContextService->getIdentityDb()->getIndividu();
@@ -98,13 +113,19 @@ class PropositionAssertion implements AssertionInterface {
                        break;
                }
            case PropositionPrivileges::PROPOSITION_VALIDER_ACTEUR:

                switch ($role) {
                    case Role::CODE_DOCTORANT :
                        return $doctorant->getId() === $individu->getId();
                        $isDoctorant = $doctorant->getId() === $individu->getId();
                        $dateOk = ($sursis OR ($dateCurrent <= $dateValidationMax));
                        return ($isDoctorant AND $dateOk);

                        break;
                    case Role::CODE_DIRECTEUR_THESE :
                    case Role::CODE_CODIRECTEUR_THESE :
                        return (array_search($individu, $directeurs) !== false);
                        $idDirecteur = (array_search($individu, $directeurs) !== false);
                        $dateOk = ($sursis OR ($dateCurrent <= $dateValidationMax));
                        return ($idDirecteur AND $dateOk);
                        break;
                    default:
                        return false;
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ class PresoutenanceController extends AbstractController
        $this->getRoleService()->removeIndividuRole($acteur->getIndividu(), $acteur->getRole());


        $validations = $this->getValidationService()->getRepository()->findValidationByCodeAndIndividu(TypeValidation::CODE_ENGAGEMENT_IMPARTIALITE, $acteur->getIndividu());
        $validations = $this->getValidationService()->getRepository()->findValidationByTheseAndCodeAndIndividu($these, TypeValidation::CODE_ENGAGEMENT_IMPARTIALITE, $acteur->getIndividu());
        if (!empty($validations)) {
            $this->getValidationService()->unsignEngagementImpartialite(current($validations));
        }
+0 −19
Original line number Diff line number Diff line
@@ -396,25 +396,6 @@ class Proposition {
        return $this;
    }

    /**
     * @return bool
     */
    public function isDelaiOk()
    {
        $soutenance = $this->getDate();
        if ($soutenance === null) return false;

        try {
            $deux = new DateInterval('P2M');
            $date = new DateTime();
        } catch(Exception $e) {
            throw new RuntimeException("Problème de récupération de la date", 0, $e);
        }
        $date_ = $date->add($deux);

        return ($date_ < $soutenance);
    }

    /**
     * @var bool $sursis
     * @return Proposition
+7 −58
Original line number Diff line number Diff line
@@ -26,10 +26,12 @@ class DateLieuForm extends Form {
                'label_attributes' => [
                    'class' => 'control-label',
                ],
                'format' => 'd/m/Y',
            ],
            'attributes' => [
                'class' => 'form-control',
                'min'  => $twomonth->format('Y-m-d'),

                //'min'  => $twomonth->format('Y-m-d'),
            ]
        ]);

@@ -93,63 +95,10 @@ class DateLieuForm extends Form {
        ]);

        $this->setInputFilter((new Factory())->createInputFilter([
            'date' => [
                'name' => 'date',
                'required' => true,
                'validators' => [
                    [
                        'name' => DateGreaterThan::class,
                        'options' => [
                            'min' => (new DateTime("+2 months"))->format('Y-m-d'),
                            'inclusive' => true,
                            'messages' => [
                                DateGreaterThan::NOT_GREATER => "La soutenance doit être déclarée deux mois avant qu'elle est lieu",
                                DateGreaterThan::NOT_GREATER_INCLUSIVE => "La soutenance doit être déclarée deux mois avant qu'elle est lieu",
                            ],
                            //'break_chain_on_failure' => true,
                        ],
                    ],
                ],
                'heure' => [
                    'required' => true,
                ],
            ],
            'date' => [ 'required' => true, ],
            'heure' => [ 'required' => true, ],
            'lieu' => [ 'required' => true, ],
            'exterieur' => [ 'required' => true, ],
        ]));
    }

//    public function getInputFilterSpecification()
//    {
//        return [
//            'date' => [
//                'name' => 'date',
//                'required' => true,
//                'validators' => [
//                    [
//                        'name' => GreaterThan::class,
//                        'options' => [
//                            'min' => new DateTime("+2 months"),
//                            'inclusive' => true,
//                            'messages' => [
//                                GreaterThan::NOT_GREATER => "La soutenance doit être déclarée deux mois avant qu'elle est lieu",
//                                GreaterThan::NOT_GREATER_INCLUSIVE => "La soutenance doit être déclarée deux mois avant qu'elle est lieu",
//                            ],
//                            //'break_chain_on_failure' => true,
//                        ],
//                    ],
//                ],
//            ],
//            'heure' => [
//                'name' => 'heure',
//                'required' => true,
//            ],
//            'lieu' => [
//                'name' => 'lieu',
//                'required' => false,
//            ],
//            'exterieur' => [
//                'name' => 'exterieur',
//                'required' => false,
//            ],
//        ];
//    }
}
 No newline at end of file
Loading