Commit 0e501106 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Module Substitutions : mise en place de limitations et d'alertes en cas de...

Module Substitutions : mise en place de limitations et d'alertes en cas de substitution ayant un unique substitué (théoriquement impossible mais bon !)
parent ebc06355
Loading
Loading
Loading
Loading
+7 −0
Changes for module/Substitution/src/Substitution/Constants.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -21,4 +21,11 @@ class Constants
    ];

    const TYPES_REGEXP_CONSTRAINT = '(structure|etablissement|ecole_doct|unite_rech|individu|doctorant)';

    const ALERTE_1_SEUL_SUBSTITUE = "Cette substitution ne met en jeu qu'un seul enregistrement substitué,
        ce qui n'est pas une situation normale puisque le moteur de substitutions automatiques se base sur la recherche
        de doublons. Donc il s'agit sans doute d'une substitution de 2 enregistrements qui a été modifiée manuellement
        (retrait d'un des 2 substitués par le forçage de son NPD) et dont le substituant n'a pu être supprimé comme prévu
        en raison d'une contrainte d'intégrité (référencement dans une autre table), alors qu'il aurait dû l'être du fait
        qu'il ne restait plus qu'un seul substitué.";
}
 No newline at end of file
+4 −0
Changes for module/Substitution/src/Substitution/Controller/SubstitutionController.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -153,7 +153,11 @@ class SubstitutionController extends AbstractActionController
        Assert::keyExists($post, 'substitue');

        $substitueId = $post['substitue'];

        $substitutionData = $this->fetchSubstitutionData($type, $substituantId);
        Assert::minCount($substitutionData['substitues'], 2,
            "Impossible de retirer de cette substitution l'unique enregistrement substitué");

        $npd = $substitutionData['substitution']['npd'];

        $this->substitutionService->removeSubstitueFromSubstitutionForType($type, $substitueId, $npd);
+13 −0
Changes for module/Substitution/view/substitution/substitution/modifier.phtml: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,6 +41,13 @@ $voirSubstitueUrl = $this->url('substitution/substitution/voir/voir-substituable
    <code><abbr title="NPD"><?php echo $substitution['npd'] ?></abbr></code>
</h1>

<?php if (count($substitues) === 1): ?>
    <p class="alert alert-danger">
        <span class="icon icon-attention"></span> <strong>Votre attention, svp ! :</strong>
        <?php echo \Substitution\Constants::ALERTE_1_SEUL_SUBSTITUE ?>
    </p>
<?php endif; ?>

<p class="lead">

</p>
@@ -84,6 +91,7 @@ $voirSubstitueUrl = $this->url('substitution/substitution/voir/voir-substituable
                    ?>
                    <form method="post" action="<?php echo $this->url('substitution/substitution/voir/retirer-substitue', ['type' => $type, 'id' => $substituant->getId()]) ?>">
                        <input type="hidden" value="<?php echo $substitue->getId() ?>" name="substitue"/>
                        <?php if (count($substitues) > 1): ?>
                            <?php if ($estSubstitueManuellement): ?>
                                <input type="submit" value="Retirer"
                                       title="Retirer de la substitution cet enregistrement ajouté manuellement"
@@ -95,6 +103,11 @@ $voirSubstitueUrl = $this->url('substitution/substitution/voir/voir-substituable
                                       class="btn btn-danger float-end"
                                       onclick="return confirm('Êtes-vous certain·e de vouloir retirer ce faux doublon ?')"/>
                            <?php endif ?>
                        <?php else: ?>
                            <input type="submit" value="Impossible de retirer l'unique enregistrement substitué"
                                   class="btn btn-danger float-end disabled"
                                   onclick="return false"/>
                        <?php endif ?>
                    </form>
                </div>
            <?php endforeach; ?>
+7 −0
Changes for module/Substitution/view/substitution/substitution/voir.phtml: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,6 +41,13 @@ $this->headTitle("Substitution par " . $substituant->getId());
    <code><abbr title="NPD"><?php echo $substitution['npd'] ?></abbr></code>
</h1>

<?php if (count($substitues) === 1): ?>
    <p class="alert alert-danger">
        <span class="icon icon-attention"></span> <strong>Votre attention, svp ! :</strong>
        <?php echo \Substitution\Constants::ALERTE_1_SEUL_SUBSTITUE ?>
    </p>
<?php endif; ?>

<p>
    <?php echo count($substitues) ?> enregistrements substitués.
</p>