Commit f2b8bd82 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Meilleur intégration des validations de candidatures dans les règles de workflow

parent 05b83524
Loading
Loading
Loading
Loading
+8 −2
Changes for front/Mission/ListeCandidatures.vue: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -29,14 +29,20 @@
                       class="btn btn-success"
                       data-content="Êtes vous sûr de vouloir accepter cette candidature ?"
                       data-title="Accepter la candidature"
                       style="color:white;"
                       title="Accepter la candidature"
                       @click.prevent="validerCandidature">Accepter </a>&nbsp;
                       @click.prevent="validerCandidature">
                        <i class="fa-solid fa-check"></i>
                    </a>&nbsp;
                    <a :href="urlRefuserCandidature(candidature)"
                       class="btn btn-danger"
                       data-content="Êtes vous sûr de vouloir refuser cette candidature ?"
                       data-title="Refuser la candidature"
                       style="color:white;"
                       title="Refuser la candidature"
                       @click.prevent="refuserCandidature">Refuser </a>
                       @click.prevent="refuserCandidature">
                        <i class="fa-sharp fa-solid fa-xmark"></i>
                    </a>
                </td>
            </tr>

+11 −13
Changes for front/Mission/OffreEmploi.vue: 11 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -117,19 +117,14 @@
                        <span v-if="!candidature.validation && candidature.motif === null" class="badge rounded-pill bg-warning">En attente d'acceptation</span>
                    </td>
                    <td v-if="this.canValiderCandidature">
                        <a v-if="!candidature.validation" :href="urlAccepterCandidature(candidature)"
                           class="btn btn-success"
                           data-content="Êtes vous sûr de vouloir accepter cette candidature ?"
                           data-title="Accepter la candidature"
                           title="Accepter la candidature"
                           @click.prevent="validerCandidature">Accepter </a>&nbsp;
                        <a v-if="!candidature.motif && candidature.validation"
                           :href="urlRefuserCandidature(candidature)"
                           class="btn btn-danger"
                           data-content="Êtes vous sûr de vouloir refuser cette candidature ?"
                           data-title="Refuser la candidature"
                           title="Refuser la candidature"
                           @click.prevent="refuserCandidature">Refuser </a>
                        <a :href="urlVoirCandidature(candidature)"
                           class="btn btn-primary"
                           title="Consulter "
                        >
                            <u-icon name="eye"/>
                            Voir
                        </a>

                    </td>
                </tr>
                </tbody>
@@ -249,6 +244,9 @@ export default {
        urlVoir: function (candidature) {
            return unicaenVue.url('intervenant/:code/voir', {code: 'code:'+candidature.intervenant.code})
        },
        urlVoirCandidature: function (candidature) {
            return unicaenVue.url('intervenant/:code/candidature', {code: 'code:'+candidature.intervenant.code})
        },
        urlAccepterCandidature: function (candidature) {
            return unicaenVue.url('offre-emploi/accepter-candidature/:id', {id: candidature.id})
        },
+9 −1
Changes for module/Application/config/intervenant.config.php: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Application\Provider\Privilege\Privileges;
use Contrat\Controller\ContratController;
use Dossier\Assertion\IntervenantDossierAssertion;
use Dossier\Controller\IntervenantDossierController;
use Mission\Assertion\OffreEmploiAssertion;
use Paiement\Controller\PaiementController;
use UnicaenPrivilege\Guard\PrivilegeController;
use UnicaenPrivilege\Provider\Rule\PrivilegeRuleProvider;
@@ -351,7 +352,7 @@ return [
                    'controller' => 'Application\Controller\Intervenant',
                    'action'     => ['candidature', 'get-candidatures'],
                    'privileges' => [Privileges::MISSION_CANDIDATURE_VISUALISATION],
                    'assertion'  => IntervenantAssertion::class,
                    'assertion'  => OffreEmploiAssertion::class,
                ],
                [
                    'controller' => 'Application\Controller\Intervenant',
@@ -407,6 +408,13 @@ return [
                        'resources'  => ['Intervenant'],
                        'assertion'  => Assertion\IntervenantAssertion::class,
                    ],
                    [
                        'privileges' => [
                            Privileges::MISSION_CANDIDATURE_VALIDER,
                        ],
                        'resources'  => ['Intervenant'],
                        'assertion'  => OffreEmploiAssertion::class,
                    ],
                ],
            ],
        ],
+93 −92
Changes for module/Application/src/Controller/IntervenantController.php: 93 added lines, 92 removed lines.
Original line number Diff line number Diff line
@@ -95,6 +95,36 @@ class IntervenantController extends AbstractController



    /**
     *
     * @return array
     */
    protected function getIntervenantsRecents ()
    {
        $container = $this->getSessionContainer();
        //$container->recents = [];
        if (isset($container->recents)) {
            $recents = $container->recents;
            foreach ($recents as $i => $recent) {
                if (isset($recent['code'])) {
                    $intervenant = $this->getServiceIntervenant()->getByCode($recent['code']);
                } else {
                    $intervenant = null;
                }
                if (!$intervenant) {
                    unset($recents[$i]);
                    unset($container->recents[$i]);
                }
            }

            return $recents;
        } else {
            return [];
        }
    }



    public function rechercheJsonAction ()
    {
        $recherche         = $this->getProcessusIntervenant()->recherche();
@@ -137,16 +167,78 @@ class IntervenantController extends AbstractController



    /**
     *
     * @param \Application\Entity\Db\Intervenant $intervenant
     *
     * @return \Application\Controller\IntervenantController
     */
    protected function addIntervenantRecent (Intervenant $intervenant)
    {
        $container = $this->getSessionContainer();
        if (!isset($container->recents)) {
            $container->recents = [];
        }

        if (count($container->recents) > 4 && !isset($container->recents[$intervenant->getCode()])) {
            $prem = (int)date('U');
            foreach ($container->recents as $i) {
                $horo = $i['__horo_ajout__'];
                if ($horo) {
                    if ($prem >= $horo) $prem = $horo;
                }
            }
            foreach ($container->recents as $index => $i) {
                $horo = $i['__horo_ajout__'];
                if ($horo == $prem) {
                    unset($container->recents[$index]);
                }
            }
        }

        if (!isset($container->recents[$intervenant->getCode()])) {
            $container->recents[$intervenant->getCode()] = [
                'civilite'         => $intervenant->getCivilite() ? $intervenant->getCivilite()->getLibelleLong() : null,
                'nom'              => $intervenant->getNomUsuel(),
                'prenom'           => $intervenant->getPrenom(),
                'date-naissance'   => $intervenant->getDateNaissance(),
                'structure'        => (string)$intervenant->getStructure(),
                'statut'           => (string)$intervenant->getStatut(),
                'code'             => $intervenant->getCode(),
                'numero-personnel' => $intervenant->getCodeRh(),
                '__horo_ajout__'   => (int)date('U'),
            ];
        } else {
            if (!isset($container->recents[$intervenant->getCode()]['statut'])) {
                $container->recents[$intervenant->getCode()]['statut'] = [$container->recents[$intervenant->getCode()]['statut']];
            }
            if (is_array($container->recents[$intervenant->getCode()]['statut'])) {
                $container->recents[$intervenant->getCode()]['statut'][] = (string)$intervenant->getStatut();
            } else {
                $container->recents[$intervenant->getCode()]['statut'] = (string)$intervenant->getStatut();
            }
        }

        uasort($container->recents, function ($a, $b) {
            return $a['nom'] . ' ' . $a['prenom'] > $b['nom'] . ' ' . $b['prenom'] ? 1 : 0;
        });

        return $this;
    }



    public function candidatureAction ()
    {
        $intervenant           = $this->getEvent()->getParam('intervenant');
        $canValiderCandidature = $this->isAllowed($intervenant, Privileges::MISSION_CANDIDATURE_VALIDER);

        if (!$intervenant) {
            throw new \LogicException('Intervenant introuvable');
        }


        return compact('intervenant');
        return compact('intervenant', 'canValiderCandidature');
    }


@@ -443,95 +535,4 @@ class IntervenantController extends AbstractController

        return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => $intervenant->getId()]);
    }



    /**
     *
     * @return array
     */
    protected function getIntervenantsRecents()
    {
        $container = $this->getSessionContainer();
        //$container->recents = [];
        if (isset($container->recents)) {
            $recents = $container->recents;
            foreach ($recents as $i => $recent) {
                if (isset($recent['code'])) {
                    $intervenant = $this->getServiceIntervenant()->getByCode($recent['code']);
                } else {
                    $intervenant = null;
                }
                if (!$intervenant) {
                    unset($recents[$i]);
                    unset($container->recents[$i]);
                }
            }

            return $recents;
        } else {
            return [];
        }
    }



    /**
     *
     * @param \Application\Entity\Db\Intervenant $intervenant
     *
     * @return \Application\Controller\IntervenantController
     */
    protected function addIntervenantRecent(Intervenant $intervenant)
    {
        $container = $this->getSessionContainer();
        if (!isset($container->recents)) {
            $container->recents = [];
        }

        if (count($container->recents) > 4 && !isset($container->recents[$intervenant->getCode()])) {
            $prem = (int)date('U');
            foreach ($container->recents as $i) {
                $horo = $i['__horo_ajout__'];
                if ($horo) {
                    if ($prem >= $horo) $prem = $horo;
                }
            }
            foreach ($container->recents as $index => $i) {
                $horo = $i['__horo_ajout__'];
                if ($horo == $prem) {
                    unset($container->recents[$index]);
                }
            }
        }

        if (!isset($container->recents[$intervenant->getCode()])) {
            $container->recents[$intervenant->getCode()] = [
                'civilite'         => $intervenant->getCivilite() ? $intervenant->getCivilite()->getLibelleLong() : null,
                'nom'              => $intervenant->getNomUsuel(),
                'prenom'           => $intervenant->getPrenom(),
                'date-naissance'   => $intervenant->getDateNaissance(),
                'structure'        => (string)$intervenant->getStructure(),
                'statut'           => (string)$intervenant->getStatut(),
                'code'             => $intervenant->getCode(),
                'numero-personnel' => $intervenant->getCodeRh(),
                '__horo_ajout__'   => (int)date('U'),
            ];
        } else {
            if (!isset($container->recents[$intervenant->getCode()]['statut'])) {
                $container->recents[$intervenant->getCode()]['statut'] = [$container->recents[$intervenant->getCode()]['statut']];
            }
            if (is_array($container->recents[$intervenant->getCode()]['statut'])) {
                $container->recents[$intervenant->getCode()]['statut'][] = (string)$intervenant->getStatut();
            } else {
                $container->recents[$intervenant->getCode()]['statut'] = (string)$intervenant->getStatut();
            }
        }

        uasort($container->recents, function ($a, $b) {
            return $a['nom'] . ' ' . $a['prenom'] > $b['nom'] . ' ' . $b['prenom'] ? 1 : 0;
        });

        return $this;
    }
}
+1 −1
Changes for module/Application/view/application/intervenant/candidature.phtml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
use Application\Provider\Privilege\Privileges;

$this->intervenant($intervenant)->renderTitle('Candidature');
$canValiderCandidature = $this->isAllowed(Privileges::getResourceId(Privileges::MISSION_CANDIDATURE_VALIDER));
$canValiderCandidature = $this->isAllowed($intervenant, Privileges::MISSION_CANDIDATURE_VALIDER);


echo $this->vue('mission/liste-candidatures', [
Loading