Commit 6a810ea1 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Suppression de PlafondApplication

Redondances avec les paramétrages/statut-FR-structures
parent b23788af
Loading
Loading
Loading
Loading
+29 −84
Changes for code/test4.php: 29 added lines, 84 removed lines.
Original line number Diff line number Diff line
@@ -8,94 +8,39 @@
 * @var $viewFile   string
 */

exec('php ' . getcwd() . '/public/index.php UnicaenCode test6' . " > /dev/null &");

$test4 = new Test4($controller, $container);
$test4->run();
?>
<div class="aff">
    Affichage...
</div>
<script type="application/javascript">





class Test4
    function affRes()
    {
    /**
     * @var \Laminas\Mvc\Controller\AbstractController
     */
    public $controller;

    /**
     * @var Psr\Container\ContainerInterface
     */
    public $container;

    /**
     * @var \Doctrine\ORM\EntityManager
     */
    public $em;



    /**
     * @param $controller
     * @param $container
     */
    public function __construct($controller, $container)
    {
        $this->controller = $controller;
        $this->container  = $container;
        $this->em         = $this->container->get(\Application\Constants::BDD);
        $.ajax({
            type: 'POST',
            url: '/unicaen-code/test6',
            data: {},
            success: function (data) {
                var endOfFlux = '<END-OF-FLUX />';
                var theEnd = false;
                if (data.substr(-endOfFlux.length) === endOfFlux) {
                    theEnd = true;
                    data = data.substr(0, data.length - endOfFlux.length);
                }



    /**
     * @var \Plafond\Service\PlafondService
     */
    public $sp;

    /**
     * @var \Application\Entity\Db\TypeVolumeHoraire
     */
    public $tvh;



    public function run()
    {
        $this->sp = $this->container->get(\Plafond\Service\PlafondService::class);

        $intervenantId = 58753;
        $elementId     = 160230;
        $structureId   = 594;
        $tvhId         = 1;

        $this->tvh = $this->em->find(\Application\Entity\Db\TypeVolumeHoraire::class, $tvhId);

        $intervenant = $this->em->find(\Application\Entity\Db\Intervenant::class, $intervenantId);
        $element     = $this->em->find(\Application\Entity\Db\ElementPedagogique::class, $elementId);
        $structure   = $this->em->find(\Application\Entity\Db\Structure::class, $structureId);
        $vh          = $this->em->find(\Application\Entity\Db\VolumeHoraire::class, 414168);
        $fr          = $this->em->find(\Application\Entity\Db\FonctionReferentiel::class, 151);

        $this->aff($intervenant);
        $this->aff($element);
        $this->aff($structure);
        $this->aff($vh);
        $this->aff($fr);
                if (!theEnd) {
                    data += '<span class="loading">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Chargement en cours...';
                }



    private function aff($entity)
    {
        echo '<h1>' . get_class($entity) . '</h1>';

        echo '<h2>Tous les contrôles</h2>';
        $r = $this->sp->controle($this->tvh, $entity, false);
        var_dump($r);

        echo '<h2>Uniquement s\'il y a blocage</h2>';
        $r = $this->sp->controle($this->tvh, $entity, true);
        var_dump($r);
                $('.aff').html(data);
                if (!theEnd) {
                    setTimeout(affRes, 1000);
                }
            },
        });
    }

    $(function () {
        setTimeout(affRes, 1000);
    });
</script>
 No newline at end of file
+5
Changes for code/test5.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,7 +8,12 @@
 * @var $viewFile   string
 */

$filename = getcwd() . '/cache/testRunner';
echo file_get_contents($filename);

/*
$oseAdmin = oseAdmin();
$dataGen  = new DataGen($oseAdmin);
var_dump($dataGen);
//$dataGen->update('PRIVILEGE');
*/
 No newline at end of file
+92
Changes for code/test6.php: 92 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,3 +7,95 @@
 * @var $viewName   string
 * @var $viewFile   string
 */





class Flux
{
    private static ?self $instance = null;

    private string       $filename = '';

    private              $buffer;



    public function demarrer(string $filename): bool
    {
        $this->filename = $filename;

        if (!\Unicaen\Console\Console::isConsole()) {
            echo file_get_contents($this->filename);

            return false;
        }

        $this->buffer = fopen($this->filename, 'w');

        return true;
    }



    public function stopper()
    {
        fwrite($this->buffer, '<END-OF-FLUX />');
        fclose($this->buffer);
    }



    public function ecrire(string $data)
    {
        fwrite($this->buffer, $data);
    }



    public function alert(string $message, string $type)
    {
        $this->ecrire('<div class="alert alert-' . $type . '">' . $message . '</div>');
    }



    public static function getInstance(): self
    {
        if (!self::$instance) {
            self::$instance = new self;
        }

        return self::$instance;
    }
}





$filename = getcwd() . '/cache/testRunner';
if (!Flux::getInstance()->demarrer($filename)) return;

$ws = $container->get(\Application\Service\WorkflowService::class);

$result = $ws->calculerTousTableauxBord(function (array $d) {
    Flux::getInstance()->ecrire('<h3>' . $d['tableau-bord'] . '</h3>');
}, function (array $d) {
    if ($d['result']) {
        $duree = round($d['duree'], 3) . ' secondes';
        Flux::getInstance()->ecrire('<div>Calcul effectué en ' . $duree . '</div>');
    } else {
        Flux::getInstance()->alert($d['exception']->getMessage(), 'danger');
    }
});

Flux::getInstance()->ecrire('Fin du calcul des tableaux de bord');
if ($result) {
    Flux::getInstance()->alert('Tout c\'est bien passé', 'success');
} else {
    Flux::getInstance()->alert('Attention : des erreurs ont été rencontrées!!', 'danger');
}

Flux::getInstance()->stopper();
 No newline at end of file
−14

File deleted.

−14

File deleted.

Loading