Commit b0479154 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Divers

parent 7d82d39d
Loading
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Administration\DataSource;

use Application\Entity\Db\Annee;
use Application\Entity\Db\Perimetre;
use Unicaen\BddAdmin\BddAwareTrait;
use Workflow\Entity\Db\WorkflowEtapeDependance;
@@ -176,7 +177,7 @@ class DataSource
        $data             = $donneesParDefaut['STATUT'];

        $statuts = [];
        for ($a = 2010; $a <= 2099; $a++) {
        for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
            foreach ($data as $d) {
                $d['ANNEE_ID']              = $a;
                $d['HISTO_MODIFICATEUR_ID'] = null;
@@ -195,7 +196,7 @@ class DataSource
        $data             = $donneesParDefaut['FONCTION_REFERENTIEL'];

        $fonctions = [];
        for ($a = 2010; $a <= 2099; $a++) {
        for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
            foreach ($data as $d) {
                $d['ANNEE_ID']              = $a;
                $d['HISTO_MODIFICATEUR_ID'] = null;
@@ -214,7 +215,7 @@ class DataSource
        $data             = $donneesParDefaut['TYPE_PIECE_JOINTE_STATUT'];

        $statuts = [];
        for ($a = 2010; $a <= 2099; $a++) {
        for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
            foreach ($data as $d) {
                $d['ANNEE_ID']              = $a;
                $d['HISTO_MODIFICATEUR_ID'] = null;
@@ -347,7 +348,7 @@ class DataSource

        $tms = [];

        for ($a = 2010; $a <= 2099; $a++) {
        for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
            foreach ($data as $code => $tm) {
                $tms[] = [
                    'CODE'                     => $code,
@@ -433,7 +434,7 @@ class DataSource
                'histo_modificateur_id' => null,
            ];

            for ($a = 2010; $a <= 2099; $a++) {
            for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
                $edata['annee_id'] = $a;
                mpg_upper($edata);
                $etapes[] = $edata;
@@ -463,7 +464,7 @@ class DataSource
                        'histo_modificateur_id' => null,
                    ];

                    for ($a = 2010; $a <= 2099; $a++) {
                    for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
                        $ndep = $dep;
                        $ndep['etape_suivante_id'] .= '-'.(string)$a;
                        $ndep['etape_precedante_id'] .= '-'.(string)$a;
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ namespace Application\Entity\Db;
class Annee
{
    const MIN = 1950;
    const MIN_DATA = 2010;
    const MAX = 2099;

    /**
+22 −16
Original line number Diff line number Diff line
@@ -30,8 +30,11 @@ class WorkflowResetCommand extends Command
    {
        $io  = new SymfonyStyle($input, $output);
        $bdd = $this->getBdd()->setLogger($io);

        $io->title($this->getDescription());

        $confirmed = $io->confirm('Êtes-vous sûr de vouloir réinitialiser le workflow ?', false);

        if ($confirmed) {
            try {
                $bdd->data()->addAction('workflow-reset', 'Réinitialisation du workflow');

@@ -47,7 +50,10 @@ class WorkflowResetCommand extends Command
                $io->error($e->getMessage());
                return Command::FAILURE;
            }

            return Command::SUCCESS;
        } else {
            $io->warning('Opération annulée.');
            return Command::FAILURE;
        }
    }
}
 No newline at end of file
+33 −6
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ use Workflow\Model\FeuilleDeRoute;
 */
class WorkflowService extends AbstractService
{
    const ETAPES_CACHE_ID = 'Workflow_Service_WorkflowService_getEtapes';
    const string ETAPES_CACHE_ID = 'Workflow_Service_getEtapes';

    use ContextServiceAwareTrait;
    use EntityManagerAwareTrait;
@@ -57,9 +57,15 @@ class WorkflowService extends AbstractService
    /**
     * @return array|WorkflowEtape[]
     */
    public function getEtapes(): array
    public function getEtapes(Annee|int|null $annee = null): array
    {
        if ($annee instanceof Annee) {
            $anneeId = $annee->getId();
        } elseif (isset($annee)) {
            $anneeId = $annee;
        } else {
            $anneeId = $this->getServiceContext()->getAnnee()->getId();
        }

        if (empty($this->workflowEtapes)) {
            $this->workflowEtapes = [];
@@ -113,7 +119,7 @@ class WorkflowService extends AbstractService

        $cache = $em->getConfiguration()->getResultCache();
        $items = [];
        for( $a=2010;$a<=Annee::MAX;$a++){
        for ($a = Annee::MIN_DATA; $a <= Annee::MAX; $a++) {
            $items[] = self::ETAPES_CACHE_ID . '_' . $a;
        }
        $cache->deleteItems($items);
@@ -262,6 +268,7 @@ class WorkflowService extends AbstractService
     * @param Intervenant|null                                $intervenant
     * @param Structure|null                                  $structure
     * @return WorkflowEtape
     * @deprecated
     */
    public function getPreviousAccessibleEtape($etape, ?Intervenant $intervenant = null, ?Structure $structure = null)
    {
@@ -283,6 +290,13 @@ class WorkflowService extends AbstractService



    /**
     * @param                  $etape
     * @param Intervenant|null $intervenant
     * @param Structure|null   $structure
     * @return array
     * @deprecated
     */
    protected function prepareEtapeParams($etape, ?Intervenant $intervenant = null, ?Structure $structure = null)
    {
        switch (true) {
@@ -332,6 +346,7 @@ class WorkflowService extends AbstractService
     * @param Structure|null   $structure
     *
     * @return WorkflowEtape|null
     * @deprecated
     */
    public function getEtapeCourante(?Intervenant $intervenant = null, ?Structure $structure = null)
    {
@@ -352,6 +367,7 @@ class WorkflowService extends AbstractService
     * @param Structure|null   $structure
     *
     * @return WorkflowEtape[]
     * @deprecated
     */
    public function getFeuilleDeRouteOld(?Intervenant $intervenant = null, ?Structure $structure = null)
    {
@@ -408,6 +424,7 @@ class WorkflowService extends AbstractService
     * @param Intervenant|null $intervenant
     *
     * @return TblWorkflow[]
     * @deprecated
     */
    protected function getEtapesOld(Intervenant $intervenant, ?Structure $structure = null, bool $calcIfEmpty = true)
    {
@@ -546,6 +563,7 @@ class WorkflowService extends AbstractService
     * @param Structure|null                                  $structure
     *
     * @return WorkflowEtape
     * @deprecated
     */
    public function getEtape($etape, ?Intervenant $intervenant = null, ?Structure $structure = null)
    {
@@ -574,6 +592,7 @@ class WorkflowService extends AbstractService

    /**
     * @param $data WorkflowEtape[]
     * @deprecated
     */
    protected function calculEtats($data)
    {
@@ -615,6 +634,7 @@ class WorkflowService extends AbstractService
     * @param Structure|null                                  $structure
     *
     * @return WorkflowEtape
     * @deprecated
     */
    public function getNextEtape($etape, ?Intervenant $intervenant = null, ?Structure $structure = null)
    {
@@ -636,6 +656,12 @@ class WorkflowService extends AbstractService



    /**
     * @param $etape
     * @return bool
     * @throws \Exception
     * @deprecated
     */
    public function isAllowed($etape)
    {
        if ($etape instanceof WorkflowEtape) {
@@ -658,6 +684,7 @@ class WorkflowService extends AbstractService
     * @param Structure|null                                  $structure
     *
     * @return WorkflowEtape
     * @deprecated
     */
    public function getNextAccessibleEtape($etape, ?Intervenant $intervenant = null, ?Structure $structure = null)
    {