Commit b1dd1d9a authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Merge branch 'sb/spartan-recall-timesheet' of git.unicaen.fr:open-source/oscar...

Merge branch 'sb/spartan-recall-timesheet' of git.unicaen.fr:open-source/oscar into sb/spartan-recall-timesheet
parents 08ed5a10 9ff71aa4
Loading
Loading
Loading
Loading
Loading
+3 −34
Original line number Diff line number Diff line
@@ -166,36 +166,6 @@ class AdministrationController extends AbstractOscarController implements UsePro
                        $this->redirect()->toRoute('administration/listdeclarers');
                    break;

                case 'add-to-blacklist' :
                    $personIds = $this->params()->fromPost('persons');
                    if( !$personIds ){
                        $this->flashMessenger()->addWarningMessage(
                            "Rien à ajouter"
                        );
                    }
                    else {
                        $persons = $this->getProjectGrantService()->getPersonService()->getPersonsByIds($personIds);
                        $adder = $this->getCurrentPerson();
                        $this->getProjectGrantService()->getPersonService()->addDeclarersToBlacklist(
                            $persons,
                            $adder
                        );
                        $this->redirect()->toRoute('administration/listdeclarers');
                    }
                    break;

                case 'remove-from-blacklist' :
                    $personId = $this->params()->fromPost('personid');
                    $persons = $this->getProjectGrantService()->getPersonService()->removeDeclarersFromBlacklist($personId);
                    $this->redirect()->toRoute('administration/listdeclarers');
                    break;

                case 'remove-from-whitelist' :
                    $personId = $this->params()->fromPost('personid');
                    $persons = $this->getProjectGrantService()->getPersonService()->removeDeclarersFromWhitelist($personId);
                    $this->redirect()->toRoute('administration/listdeclarers');
                    break;

                default:
                    throw new OscarException("Action inconnue");
            }
@@ -206,7 +176,6 @@ class AdministrationController extends AbstractOscarController implements UsePro
        return [
            "useWhiteList" => $useWhitelist,
            "whitelist" => $useWhitelist ? $this->getProjectGrantService()->getPersonService()->getDeclarersWhitelist() : null,
            "blacklist" => $this->getProjectGrantService()->getPersonService()->getDeclarersBlacklist()
        ];
    }

+24 −32
Original line number Diff line number Diff line
@@ -1054,20 +1054,19 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U
    /**
     * Retourne la liste des identifiants des personnes qui déclarent des feuilles de temps.
     *
     * @return int[]
     * @return array
     */
    public function getDeclarersIds(): array
    public function getDeclarersIds()
    {
        return $this->getPersonRepository()->getIdsDeclarers();
    }
        $persons = $this->getEntityManager()->createQueryBuilder()->select('DISTINCT(p.id)')
            ->from(Person::class, 'p')
            ->innerJoin('p.workPackages', 'wp')
            ->getQuery()
            ->getResult(Query::HYDRATE_ARRAY);

    /**
     * @param string $periodStr
     * @return int[]
     */
    public function getDeclarersIdsPeriod(string $periodStr): array
    {
        return $this->getPersonRepository()->getIdsDeclarers($periodStr, $periodStr);
        $declarersIds = array_map('current', $persons);

        return $declarersIds;
    }

    /**
@@ -1500,24 +1499,15 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U
    }

    /**
     * Liste des personnes dans la liste noire
     *
     * @return RecallException[]
     */
    public function getDeclarersBlacklist()
    {
        return $this->getRecallExceptionRepository()->getBlacklist();
    }

    /**
     * Ajout d'une personne dans la liste blanche.
     *
     * @param Person[] $persons
     * @param Person $adder
     */
    public function addDeclarersToWhitelist(array $persons, Person $adder): void
    {
        $included = $this->getRecallExceptionRepository()->getIncludedPersonsIds();
        /** @var RecallExceptionRepository $recallExceptions */
        $recallExceptions = $this->getEntityManager()->getRepository(RecallException::class);

        $included = $recallExceptions->getIncludedPersonsIds();
        foreach ($persons as $person) {
            if (!in_array($person->getId(), $included)) {
                $include = new RecallException();
@@ -1528,6 +1518,16 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U
        }
        $this->getEntityManager()->flush();
    }
    /**
     * Liste des personnes dans la liste noire
     *
     * @return RecallException[]
     */
    public function getDeclarersBlacklist()
    {
        return $this->getRecallExceptionRepository()->getBlacklist();
    }


    /**
     * Ajout d'une personne dans la liste noire.
@@ -1911,12 +1911,4 @@ class PersonService implements UseOscarConfigurationService, UseEntityManager, U
    {
        return $this->getServiceContainer()->get(OrganizationService::class);
    }

    /**
     * @return MailingService
     */
    public function getMailingService()
    {
        return $this->getServiceContainer()->get(MailingService::class);
    }
}
+30 −84
Original line number Diff line number Diff line
@@ -3,8 +3,7 @@
    <div class="row">
        <div class="col-md-6">
            <h2>Liste blanche</h2>
            <?php
            if ($useWhiteList): ?>
            <?php if( $useWhiteList ):?>
                <form action="" method="post">
                    <div class="alert alert-warning">
                        <div><em>Whitelist</em> : <strong>ACTIVE</strong></div>
@@ -12,8 +11,7 @@
                            Le système de rappel des déclarants est en mode <em>Whitelist</em>,
                            seul les déclarants identifiés en liste blanche seront notifiés par mail
                            en cas de défaut de déclaration. <br>
                            Il y'a pour le moment <strong><?= count($whitelist) ?> personne(s) en
                                <em>whitelist</em></strong></small>
                            Il y'a pour le moment <strong><?= count($whitelist) ?> personne(s) en <em>whitelist</em></strong></small>
                        </div>
                    <input type="hidden" name="action" value="disabled-whitelist" />
                    <button type="submit" class="btn btn-danger">
@@ -24,53 +22,30 @@
                <hr>
                <section>

                    <?php
                    if (count($whitelist) == 0): ?>
                    <?php if(count($whitelist) == 0):?>
                        <div class="alert alert-warning">
                            Aucun déclarant
                        </div>
                    <?php
                    else: ?>
                        <?php
                        foreach ($whitelist as $exception): ?>
                            <div class="card">
                                <h3 class="card-title">
                                    <div>
                                        <?= $exception->getPerson() ?> <small>(<?= $exception->getPerson(
                                            )->getLdapAffectation() ?>)</small><br>
                                        <small><?= $exception->getPerson()->getEmail() ?></small>
                                    </div>
                                    <form action="" method="post" class="form-inline right">
                                        <input type="hidden" name="action" value="remove-from-whitelist"/>
                                        <input type="hidden" name="personid"
                                               value="<?= $exception->getPerson()->getId() ?>"/>
                                        <button type="submit" class="btn btn-danger btn-sm">
                                            <i class="icon-minus-circled"></i>
                                            Retirer
                                        </button>
                                    </form>
                                </h3>
                            </div>
                        <?php
                        endforeach; ?>
                    <?php
                    endif; ?>
                    <?php else: ?>
                        <?php foreach ($whitelist as $exception): ?>
                        <article class="card xs">
                            <h3 class="card-title"><?= $exception->getPerson() ?></h3>
                        </article>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </section>

                <form action="" method="post">
                    <input type="hidden" name="action" value="add-to-whitelist" />

                    <select name="persons[]" multiple="multiple" data-url="<?= $this->url('person/search') ?>"
                            class="select2"></select>
                    <select name="persons[]" multiple="multiple" data-url="<?= $this->url('person/search') ?>" class="select2"></select>
                    <button type="submit" class="btn btn-success">
                        <i class="icon-plus-circled"></i>
                        Ajouter à la liste blanche
                    </button>
                        Ajouter à la liste blanche</button>

                </form>

            <?php
            else: ?>
            <?php else: ?>
                <form action="" method="post">
                    <div class="alert alert-success">
                        <div><em>Whitelist</em> : <strong>INACTIVE</strong></div>
@@ -84,49 +59,22 @@

                    </button>
                </form>
            <?php
            endif; ?>
            <?php endif; ?>
        </div>
        <div class="col-md-6">
            <h2>Liste noire</h2>
            <div class="alert alert-danger">
                Les personnes listées ci-dessous ne seront jamais notifiées par email dans le cadre des déclarations de
                temps.
                Les personnes listées ci-dessous ne seront jamais notifiées par email dans le cadre des déclarations de temps.
            </div>

            <?php
            foreach ($blacklist as $exception): ?>
                <article class="card xs">
                    <h3 class="card-title">
                        <div>
                            <?= $exception->getPerson() ?> <small>(<?= $exception->getPerson()->getLdapAffectation() ?>
                                )</small><br>
                            <small><?= $exception->getPerson()->getEmail() ?></small>
                        </div>
                        <form action="" method="post" class="form-inline right">
                            <input type="hidden" name="action" value="remove-from-blacklist"/>
                            <input type="hidden" name="personid" value="<?= $exception->getPerson()->getId() ?>"/>
                            <button type="submit" class="btn btn-danger btn-sm">
                                <i class="icon-minus-circled"></i>
                                Retirer
                            </button>
                        </form>
                    </h3>
                </article>
            <?php
            endforeach; ?>


            <form action="" method="post">
                <input type="hidden" name="action" value="add-to-blacklist" />


                <select id="blacklisted" name="persons[]" multiple="multiple"
                        data-url="<?= $this->url('person/search') ?>" class="select2"></select>
                <select name="persons[]" multiple="multiple" data-url="<?= $this->url('person/search') ?>" class="select2"></select>
                <button type="submit" class="btn btn-danger">
                    <i class="icon-plus-circled"></i>
                    Ajouter à la liste noire
                </button>
                    Ajouter à la liste noire</button>

            </form>

@@ -139,7 +87,6 @@
    .select2-close-mask{
        z-index: 2099;
    }

    .select2-dropdown{
        z-index: 3051;
    }
@@ -175,8 +122,7 @@

        Initer.ready(function(){
            require(['select2'], function () {
                $.fn.modal.Constructor.prototype.enforceFocus = function () {
                };
                $.fn.modal.Constructor.prototype.enforceFocus = function() {};

                if( $('.select2').length === 0 ){
                    return;