Commit c91f8dbb authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Obligation de scinder Diffusion et Attestation en 2 pour différencier version...

Obligation de scinder Diffusion et Attestation en 2 pour différencier version initiale et version corrigée
parent 01cffa38
Loading
Loading
Loading
Loading
+1 −2
Changes for module/Application/src/Application/Assertion/These/TheseEntityAssertion.php: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -70,10 +70,9 @@ class TheseEntityAssertion extends GeneratedTheseEntityAssertion
        return !empty($validations);
    }


    protected function isInfosBuSaisies()
    {
        return ($rdvBu = $this->these->getRdvBu()) && $rdvBu->isInfosBuSaisies();
        return $this->theseService->isInfosBuSaisies($this->these);
    }

    protected function isExisteValidationRdvBu()
+3 −3
Changes for module/Application/src/Application/Controller/Plugin/Url/UrlThesePlugin.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ use Zend\Mvc\Controller\Plugin\AbstractPlugin;
 * @method modifierMetadonneesUrl(These $these)
 * @method modifierCorrecAutoriseeForceeUrl(These $these)
 * @method certifierConformiteTheseRetraiteUrl(These $these, $version)
 * @method modifierAttestationUrl(These $these)
 * @method modifierDiffusionUrl(These $these)
 * @method exporterConventionMiseEnLigneUrl(These $these)
 * @method modifierAttestationUrl(These $these, VersionFichier $version)
 * @method modifierDiffusionUrl(These $these, VersionFichier $version)
 * @method exporterConventionMiseEnLigneUrl(These $these, VersionFichier $version)
 * @method modifierRdvBuUrl(These $these)
 * @method validerRdvBuUrl(These $these)
 * @method devaliderRdvBuUrl(These $these)
+58 −67
Changes for module/Application/src/Application/Controller/TheseController.php: 58 added lines, 67 removed lines.
Original line number Diff line number Diff line
@@ -345,10 +345,9 @@ class TheseController extends AbstractController
            'attestationUrl'   => $this->urlThese()->attestationThese($these, $codeVersion),
            'diffusionUrl'     => $this->urlThese()->diffusionThese($these, $codeVersion),
            'nextStepUrl'      => $this->urlWorkflow()->nextStepBox($these, null, [
                WfEtape::CODE_DEPOT_VERSION_ORIGINALE,
                WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE,
                WfEtape::CODE_ATTESTATIONS,
                WfEtape::CODE_AUTORISATION_DIFFUSION_THESE,
                $versionCorrigee ? WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE : WfEtape::CODE_DEPOT_VERSION_ORIGINALE,
                $versionCorrigee ? WfEtape::CODE_ATTESTATIONS_VERSION_CORRIGEE : WfEtape::CODE_ATTESTATIONS,
                $versionCorrigee ? WfEtape::CODE_AUTORISATION_DIFFUSION_THESE_VERSION_CORRIGEE : WfEtape::CODE_AUTORISATION_DIFFUSION_THESE,
                WfEtape::PSEUDO_ETAPE_FINALE,
            ]),
        ]);
@@ -582,6 +581,7 @@ class TheseController extends AbstractController
    {
        $these = $this->requestedThese();
        $estDoctorant = (bool) $this->userContextService->getSelectedRoleDoctorant();
        $isExemplPapierFourniPertinent = $this->theseService->isExemplPapierFourniPertinent($these);

        $validationsPdc = $this->validationService->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_PAGE_DE_COUVERTURE, $these);
        $pageCouvValidee = !empty($validationsPdc);
@@ -593,7 +593,7 @@ class TheseController extends AbstractController
        $form = $this->getServiceLocator()->get('formElementManager')->get($estDoctorant ? 'RdvBuTheseDoctorantForm' : 'RdvBuTheseForm');
        $form->bind($rdvBu);

        if (! $rdvBu->isExemplPapierFourniPertinent()) {
        if (! $this->theseService->isExemplPapierFourniPertinent($these)) {
            $form->disableExemplPapierFourni();
        }

@@ -634,6 +634,7 @@ class TheseController extends AbstractController
            'form'  => $form,
            'title' => "Rendez-vous BU",
            'pageCouvValidee' => $pageCouvValidee,
            'isExemplPapierFourniPertinent' => $isExemplPapierFourniPertinent,
        ]);

        $vm->setTemplate('application/these/modifier-rdv-bu' . ($estDoctorant ? '-doctorant' : null));
@@ -644,6 +645,9 @@ class TheseController extends AbstractController
    public function validationTheseCorrigeeAction()
    {
        $these = $this->requestedThese();
        $version = $this->fichierTheseService->fetchVersionFichier(VersionFichier::CODE_ORIG_CORR);

        $isRemiseExemplairePapierRequise = $this->theseService->isRemiseExemplairePapierRequise($these, $version);

        $hasVAC = $this->fichierTheseService->getRepository()->hasVersion($these, VersionFichier::CODE_ARCHI_CORR);
        $hasVDC = $this->fichierTheseService->getRepository()->hasVersion($these, VersionFichier::CODE_DIFF_CORR);
@@ -656,7 +660,9 @@ class TheseController extends AbstractController
                WfEtape::CODE_DEPOT_VERSION_CORRIGEE_VALIDATION_DOCTORANT,
                WfEtape::CODE_DEPOT_VERSION_CORRIGEE_VALIDATION_DIRECTEUR,
            ], [
                'message' => "Il ne reste plus qu'à fournir à la BU un exemplaire imprimé de la version corrigée pour valider le dépôt.",
                'message' => $isRemiseExemplairePapierRequise ?
                    "Il ne reste plus qu'à fournir à la BU un exemplaire imprimé de la version corrigée pour valider le dépôt." :
                    null,
            ]),
            'hasVAC' => $hasVAC,
            'hasVDC' => $hasVDC,
@@ -1054,14 +1060,14 @@ class TheseController extends AbstractController
        $versionCorrigeeAtteignable = $this->workflowService->findOneByEtape($these, WfEtape::CODE_ATTESTATIONS_VERSION_CORRIGEE)->getAtteignable();
        return
            $version->estVersionCorrigee() && $versionCorrigeeAtteignable ||
            !$version->estVersionCorrigee() && $versionInitialeAtteignable && !$versionCorrigeeAtteignable;
            !$version->estVersionCorrigee() && $versionInitialeAtteignable /*&& !$versionCorrigeeAtteignable*/;
    }

    public function attestationAction()
    {
        $these = $this->requestedThese();
        $attestation = $these->getAttestation();
        $version = $this->fichierTheseService->fetchVersionFichier($this->params()->fromQuery('version'));
        $attestation = $these->getAttestationForVersion($version);
        $hasFichierThese = ! empty($this->fichierTheseService->getRepository()->fetchFichierTheses($these, NatureFichier::CODE_THESE_PDF, $version, false));

        if (! $this->isEtapeAttestationVisible($these, $version)) {
@@ -1071,14 +1077,12 @@ class TheseController extends AbstractController
            return false;
        }

        $form = $this->getAttestationTheseForm();

        $view = new ViewModel([
            'these'                  => $these,
            'version'                => $version,
            'attestation'            => $attestation,
            'form'                   => $form,
            'modifierAttestationUrl' => $this->urlThese()->modifierAttestationUrl($these),
            'form'                   => $this->getAttestationTheseForm($version), // les labels des cases à cocher sont affichés
            'modifierAttestationUrl' => $this->urlThese()->modifierAttestationUrl($these, $version),
            'hasFichierThese'        => $hasFichierThese,
        ]);
        $view->setTemplate('application/these/attestation');
@@ -1089,7 +1093,16 @@ class TheseController extends AbstractController
    public function modifierAttestationAction()
    {
        $these = $this->requestedThese();
        $form = $this->getAttestationTheseForm();
        $version = $this->fichierTheseService->fetchVersionFichier($this->params()->fromQuery('version'));
        $attestation = $these->getAttestationForVersion($version);
        $form = $this->getAttestationTheseForm($version);

        if ($attestation === null) {
            $attestation = new Attestation();
            $attestation->setThese($these);
        }

        $form->bind($attestation);

        if ($this->getRequest()->isPost()) {
            /** @var ParametersInterface $post */
@@ -1099,6 +1112,8 @@ class TheseController extends AbstractController
            if ($isValid) {
                /** @var Attestation $attestation */
                $attestation = $form->getData();
                $attestation->setVersionCorrigee($version->estVersionCorrigee());

                $this->theseService->updateAttestation($these, $attestation);

                if (! $this->getRequest()->isXmlHttpRequest()) {
@@ -1107,7 +1122,7 @@ class TheseController extends AbstractController
            }
        }

        $form->setAttribute('action', $this->urlThese()->modifierAttestationUrl($these));
        $form->setAttribute('action', $this->urlThese()->modifierAttestationUrl($these, $version));

        return new ViewModel([
            'these' => $these,
@@ -1117,37 +1132,20 @@ class TheseController extends AbstractController
    }

    /**
     * @param VersionFichier $version
     * @return AttestationTheseForm
     */
    private function getAttestationTheseForm()
    private function getAttestationTheseForm(VersionFichier $version)
    {
        $these = $this->requestedThese();

        /** @var AttestationTheseForm $form */
        $form = $this->getServiceLocator()->get('formElementManager')->get('AttestationTheseForm');

        if (! $these->getDiffusion()->isRemiseExemplairePapierRequise()) {
        if (! $these->getDiffusionForVersion($version)->isRemiseExemplairePapierRequise()) {
            $form->disableExemplaireImprimeConformeAVersionDeposee();
        }

        $attestation = $these->getAttestation();

        if ($attestation === null) {
            // si l'on est dans le cadre du dépôt de la version corrigée, on rappelle les infos historisées
            if ($this->theseService->existeVersionCorrigee($these)) {
                $attestations = $these->getAttestations($historise = true);
                $attestationPrec = $attestations->last() ?: null; // la plus récente

                /** @var Attestation $attestation */
                $attestation = clone $attestationPrec;
            } else {
                $attestation = new Attestation();
                $attestation->setThese($these);
            }
        }

        $form->bind($attestation);

        return $form;
    }

@@ -1157,13 +1155,14 @@ class TheseController extends AbstractController
        $versionCorrigeeAtteignable = $this->workflowService->findOneByEtape($these, WfEtape::CODE_AUTORISATION_DIFFUSION_THESE_VERSION_CORRIGEE)->getAtteignable();
        return
            $version->estVersionCorrigee() && $versionCorrigeeAtteignable ||
            !$version->estVersionCorrigee() && $versionInitialeAtteignable && !$versionCorrigeeAtteignable;
            !$version->estVersionCorrigee() && $versionInitialeAtteignable /*&& !$versionCorrigeeAtteignable*/;
    }

    public function diffusionAction()
    {
        $these = $this->requestedThese();
        $version = $this->fichierTheseService->fetchVersionFichier($this->params()->fromQuery('version'));
        $diffusion = $these->getDiffusionForVersion($version);
        $hasFichierThese = ! empty($this->fichierTheseService->getRepository()->fetchFichierTheses($these, NatureFichier::CODE_THESE_PDF, $version, false));

        if (! $this->isEtapeDiffusionVisible($these, $version)) {
@@ -1180,7 +1179,7 @@ class TheseController extends AbstractController
        $theseFichiersExpurges = $this->fichierTheseService->getRepository()->fetchFichierTheses($these, NatureFichier::CODE_THESE_PDF, $versionExpurgee, false);
        $annexesFichiersExpurges = $this->fichierTheseService->getRepository()->fetchFichierTheses($these, NatureFichier::CODE_FICHIER_NON_PDF, $versionExpurgee, false);

        if ($diffusion = $these->getDiffusion()) {
        if ($diffusion) {
            $form->bind($diffusion);
        }

@@ -1199,12 +1198,13 @@ class TheseController extends AbstractController

        $view = new ViewModel([
            'these'                        => $these,
            'diffusion'                    => $diffusion,
            'version'                      => $version,
            'form'                         => $form,
            'theseFichiersExpurgesItems'   => $theseFichiersExpurgesItems,
            'annexesFichiersExpurgesItems' => $annexesFichiersExpurgesItems,
            'modifierDiffusionUrl'         => $this->urlThese()->modifierDiffusionUrl($these),
            'exporterConventionMelUrl'     => $this->urlThese()->exporterConventionMiseEnLigneUrl($these),
            'modifierDiffusionUrl'         => $this->urlThese()->modifierDiffusionUrl($these, $version),
            'exporterConventionMelUrl'     => $this->urlThese()->exporterConventionMiseEnLigneUrl($these, $version),
            'hasFichierThese'              => $hasFichierThese,
        ]);
        $view->setTemplate('application/these/diffusion');
@@ -1218,14 +1218,17 @@ class TheseController extends AbstractController

        // si le fichier de la thèse originale est une version corrigée, la version de diffusion est aussi en version corrigée
        $existeVersionOrigCorrig = ! empty($this->fichierTheseService->getRepository()->fetchFichierTheses($these, NatureFichier::CODE_THESE_PDF , VersionFichier::CODE_ORIG_CORR));
        $version = $existeVersionOrigCorrig ? VersionFichier::CODE_DIFF_CORR : VersionFichier::CODE_DIFF;
        $version = $this->fichierTheseService->fetchVersionFichier($existeVersionOrigCorrig ? VersionFichier::CODE_DIFF_CORR : VersionFichier::CODE_DIFF);
        $diffusion = $these->getDiffusionForVersion($version);

        $form = $this->getDiffusionForm($version);

        /** @var Diffusion $diffusion */
        $diffusion = $form->getObject();
        if ($diffusion === null) {
            $diffusion = new Diffusion();
            $diffusion->setThese($these);
        }

        $isUpdate = $diffusion->getId() !== null;
        $form->bind($diffusion);

        if ($this->getRequest()->isPost()) {
            /** @var ParametersInterface $post */
@@ -1235,8 +1238,9 @@ class TheseController extends AbstractController
            if ($isValid) {
                /** @var Diffusion $diffusion */
                $diffusion = $form->getData();
                $diffusion->setVersionCorrigee($version->estVersionCorrigee());

                $this->theseService->updateDiffusion($these, $diffusion);
                $this->theseService->updateDiffusion($these, $diffusion, $version);

                // suppression des fichiers expurgés éventuellement déposés en l'absence de pb de droit d'auteur
                $besoinVersionExpurgee = ! $diffusion->getDroitAuteurOk();
@@ -1247,53 +1251,35 @@ class TheseController extends AbstractController
                }

                if (! $this->getRequest()->isXmlHttpRequest()) {
                    $url = $this->urlThese()->depotThese($these, $version);
                    $url = $this->urlThese()->depotThese($these, $version->getCode());
                    return $this->redirect()->toUrl($url);
                }
            }
        }

        $form->setAttribute('action', $this->urlThese()->modifierDiffusionUrl($these));
        $form->setAttribute('action', $this->urlThese()->modifierDiffusionUrl($these, $version));

        return new ViewModel([
            'these'      => $these,
            'diffusion'  => $diffusion,
            'form'       => $form,
            'title'      => "Autorisation de diffusion",
            'theseUrl'   => $this->urlThese()->depotFichiers($these, NatureFichier::CODE_THESE_PDF, $version),
//            'annexesUrl' => $this->urlThese()->fichiersAnnexes($these, NatureFichier::CODE_FICHIER_NON_PDF, $version),
            'annexesUrl' => $this->urlThese()->depotFichiers($these, NatureFichier::CODE_FICHIER_NON_PDF, $version),
        ]);
    }

    /**
     * @param string $version
     * @param VersionFichier $version
     * @return DiffusionTheseForm
     */
    private function getDiffusionForm($version)
    private function getDiffusionForm(VersionFichier $version)
    {
        $these = $this->requestedThese();

        /** @var DiffusionTheseForm $form */
        $form = $this->getServiceLocator()->get('formElementManager')->get('DiffusionTheseForm');
        $form->setVersionFichier($this->versionFichierService->getRepository()->findOneByCode($version));

        $diffusion = $these->getDiffusion();

        if ($diffusion === null) {
            // si l'on est dans le cadre du dépôt de la version corrigée, on rappelle les infos historisées
            if ($this->theseService->existeVersionCorrigee($these)) {
                $diffusions = $these->getDiffusions($historise = true);
                $diffusionPrec = $diffusions->last() ?: null; // la plus récente

                /** @var Diffusion $diffusion */
                $diffusion = clone $diffusionPrec;
            } else {
                $diffusion = new Diffusion();
                $diffusion->setThese($these);
            }
        }

        $form->bind($diffusion);
        $form->setVersionFichier($version);

        return $form;
    }
@@ -1301,6 +1287,9 @@ class TheseController extends AbstractController
    public function exporterConventionMiseEnLigneAction()
    {
        $these = $this->requestedThese();
        $version = $this->fichierTheseService->fetchVersionFichier($this->params()->fromQuery('version'));
        $diffusion = $these->getDiffusionForVersion($version);
        $attestation = $these->getAttestationForVersion($version);

        /** @var DiffusionTheseForm $form */
        $form = $this->getServiceLocator()->get('formElementManager')->get('DiffusionTheseForm');
@@ -1324,6 +1313,8 @@ class TheseController extends AbstractController
        $exporter = new ConventionPdfExporter($renderer, 'A4');
        $exporter->setVars([
            'these'              => $these,
            'diffusion'          => $diffusion,
            'attestation'        => $attestation,
            'form'               => $form,
            'libEtablissement'   => $etab,
            'libEtablissementA'  => $libEtablissementA,
+26 −0
Changes for module/Application/src/Application/Entity/Db/Attestation.php: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,11 @@ class Attestation implements HistoriqueAwareInterface
{
    use HistoriqueAwareTrait;

    /**
     * @var bool
     */
    private $versionCorrigee = false;

    /**
     * @var boolean
     */
@@ -40,6 +45,25 @@ class Attestation implements HistoriqueAwareInterface
        $this->id = null;
    }

    /**
     * @return bool
     */
    public function getVersionCorrigee(): bool
    {
        return $this->versionCorrigee;
    }

    /**
     * @param bool $versionCorrigee
     * @return Attestation
     */
    public function setVersionCorrigee(bool $versionCorrigee): Attestation
    {
        $this->versionCorrigee = $versionCorrigee;

        return $this;
    }

    /**
     * @return bool
     */
@@ -111,4 +135,6 @@ class Attestation implements HistoriqueAwareInterface
    {
        return $this->these;
    }


}
+26 −2
Changes for module/Application/src/Application/Entity/Db/Diffusion.php: 26 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ class Diffusion implements HistoriqueAwareInterface
    const DROIT_AUTEUR_OK_OUI = '1';
    const DROIT_AUTEUR_OK_NON = '0';

    /**
     * @var bool
     */
    private $versionCorrigee = false;

    /**
     * @var boolean
     */
@@ -95,6 +100,25 @@ class Diffusion implements HistoriqueAwareInterface
        $this->id = null;
    }

    /**
     * @return bool
     */
    public function getVersionCorrigee(): bool
    {
        return $this->versionCorrigee;
    }

    /**
     * @param bool $versionCorrigee
     * @return Diffusion
     */
    public function setVersionCorrigee(bool $versionCorrigee): Diffusion
    {
        $this->versionCorrigee = $versionCorrigee;

        return $this;
    }

    /**
     * @return boolean
     */
@@ -162,7 +186,7 @@ class Diffusion implements HistoriqueAwareInterface
     */
    public function getDroitAuteurOk()
    {
        return (bool) $this->droitAuteurOk;
        return $this->droitAuteurOk;
    }

    /**
@@ -170,7 +194,7 @@ class Diffusion implements HistoriqueAwareInterface
     */
    public function getCertifCharteDiff()
    {
        return (bool) $this->certifCharteDiff;
        return $this->certifCharteDiff;
    }

    /**
Loading