Commit 02c89763 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Réorganisation de la partie unicaenCode de l'appli

parent 0a45240b
Loading
Loading
Loading
Loading

code/DiagrammeBdd.php

0 → 100755
+219 −0
Original line number Diff line number Diff line
<?php

/**
 * @var $this       \Application\View\Renderer\PhpRenderer
 * @var $controller \Laminas\Mvc\Controller\AbstractController
 * @var $container  \Psr\Container\ContainerInterface
 * @var $viewName   string
 * @var $viewFile   string
 */

$bdd = adminBdd();

/*$tables = [
    [
        'key'    => "Corps",
        'fields' => [
            ['name' => "field1", 'info' => "", 'color' => "#F7B84B", 'figure' => "Ellipse"],
            ['name' => "field2", 'info' => "the second one", 'color' => "#F25022", 'figure' => "Ellipse"],
            ['name' => "fieldThree", 'info' => "3rd", 'color' => "#00BCF2"],
        ],
        'loc'    => "0 0",
    ],
    [
        'key'    => "Grade",
        'fields' => [
            ['name' => "fieldA", 'info' => "", 'color' => "#FFB900", 'figure' => "Diamond"],
            ['name' => "fieldB", 'info' => "", 'color' => "#F25022", 'figure' => "Rectangle"],
            ['name' => "fieldC", 'info' => "", 'color' => "#7FBA00", 'figure' => "Diamond"],
            ['name' => "fieldD", 'info' => "fourth", 'color' => "#00BCF2", 'figure' => "Rectangle"],
        ],
        'loc'    => "280 50",
    ],
];*/

$list = [
    'ANNEE', 'INTERVENANT', 'CORPS', 'GRADE', 'GROUPE_TYPE_FORMATION', 'TYPE_FORMATION', 'ETAPE', 'ELEMENT_PEDAGOGIQUE',
    'CHEMIN_PEDAGOGIQUE', 'VOLUME_HORAIRE_ENS', 'TYPE_INTERVENTION',
];

$tables = [];
$tbls   = $bdd->table()->get($list);
foreach ($tbls as $tbl) {
    $table = [
        'key'    => $tbl['name'],
        'fields' => [],
        'loc'    => '0 0',
    ];
    foreach ($tbl['columns'] as $col) {
        $type = $col['type'];
        if ($col['length']) {
            $type .= ' (' . $col['length'] . ')';
        }
        $column            = [
            'name' => $col['name'],
            'type' => $type,
        ];
        $table['fields'][] = $column;
    }

    $tables[] = $table;
}

$cles = [];
$cls  = $bdd->refConstraint()->get();
foreach ($cls as $cl) {
    foreach ($cl['columns'] as $col => $rcol) {
        $cle    = [
            'from'    => $cl['table'],
            'fromCol' => $col,
            'to'      => $cl['rtable'],
            'toCol'   => $rcol,
        ];
        $cles[] = $cle;
    }
}


?>
<div id="sample">
    <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:1000px"></div>


    <p>For a variation on this sample with selectable fields in the record nodes, see the <a href="selectableFields.html">selectable
            fields</a> sample.</p>
    <div>
        Diagram Model saved in JSON format, automatically updated after each change or undo or redo:
        <textarea id="mySavedModel" style="width:100%;height:250px"></textarea>
        <div style="display: none; position: absolute; width: 0px; height: 0px; margin-top: -1px;"></div>
    </div>
</div>
<script>


    $(function () {

        WidgetInitializer.includeJs(Url('vendor/go.js'));

        var $ = go.GraphObject.make;

        myDiagram =
            $(go.Diagram, "myDiagramDiv",
                {
                    layout: $(go.LayeredDigraphLayout, {direction: 0}),

                    validCycle: go.Diagram.CycleNotDirected,  // don't allow loops
                    // For this sample, automatically show the state of the diagram's model on the page
                    "ModelChanged": function (e) {
                        if (e.isTransactionFinished) showModel();
                    },
                    "undoManager.isEnabled": true
                });

        var columnTemplate =
            $(go.Panel, "TableRow",  // this Panel is a row in the containing Table
                new go.Binding("portId", "name"),  // this Panel is a "port"
                {
                    background: "transparent",  // so this port's background can be picked by the mouse
                    fromSpot: go.Spot.Right,  // links only go from the right side to the left side
                    toSpot: go.Spot.Left,
                    // allow drawing links from or to this port:
                    fromLinkable: false, toLinkable: false
                },
                $(go.TextBlock,
                    {
                        margin: new go.Margin(0, 0), column: 1, font: "normal 10px sans-serif",
                        alignment: go.Spot.Left,
                        // and disallow drawing links from or to this text:
                        fromLinkable: false, toLinkable: false
                    },
                    new go.Binding("text", "name")),
                $(go.TextBlock,
                    {
                        margin: new go.Margin(0, 5),
                        column: 2,
                        stroke: "#ef9b0b",
                        font: "normal 9px sans-serif",
                        alignment: go.Spot.Left
                    },
                    new go.Binding("text", "type"))
            );

        // This template represents a whole "record".
        myDiagram.nodeTemplate =
            $(go.Node, "Auto",
                {copyable: false, deletable: false},
                //new go.Binding("location"),
                //new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
                // this rectangular shape surrounds the content of the node
                $(go.Shape,
                    {stroke: "#efd47e", strokeWidth: 2, fill: "#fff4eb"}),
                // the content consists of a header and a list of items
                $(go.Panel, "Vertical",
                    // this is the header for the whole node
                    $(go.Panel, "Auto",
                        {stretch: go.GraphObject.Horizontal},  // as wide as the whole node
                        $(go.Shape,
                            {fill: "#ffe6cf", stroke: null}),
                        $(go.TextBlock,
                            {
                                alignment: go.Spot.Center,
                                margin: 1,
                                stroke: "black",
                                textAlign: "center",
                                font: "bold 10pt sans-serif"
                            },
                            new go.Binding("text", "key"))),
                    // this Panel holds a Panel for each item object in the itemArray;
                    // each item Panel is defined by the itemTemplate to be a TableRow in this Table
                    $(go.Panel, "Table",
                        {
                            padding: 2,
                            minSize: new go.Size(100, 10),
                            defaultStretch: go.GraphObject.Horizontal,
                            itemTemplate: columnTemplate
                        },
                        new go.Binding("itemArray", "fields")
                    )  // end Table Panel of items
                )  // end Vertical Panel
            );  // end Node

        myDiagram.linkTemplate =
            $(go.Link,  // the whole link panel
                {relinkableFrom: false, relinkableTo: false, reshapable: true, resegmentable: true},
                {
                    //routing: go.Link.AvoidsNodes,  // but this is changed to go.Link.Orthgonal when the Link is reshaped
                    adjusting: go.Link.End,
                    curve: go.Link.JumpOver,
                    corner: 1,
                    toShortLength: 4
                },
                new go.Binding("points").makeTwoWay(),
                // remember the Link.routing too
                new go.Binding("routing", "routing", go.Binding.parseEnum(go.Link, go.Link.AvoidsNodes))
                    .makeTwoWay(go.Binding.toString),
                $(go.Shape,  // the link path shape
                    {isPanelMain: true, strokeWidth: 1}),
                $(go.Shape,  // the arrowhead
                    {toArrow: "Standard", stroke: null})
            );

        myDiagram.model =
            $(go.GraphLinksModel,
                {
                    copiesArrays: true,
                    copiesArrayObjects: true,
                    linkFromPortIdProperty: "fromCol",
                    linkToPortIdProperty: "toCol",
                    nodeDataArray: <?php echo json_encode($tables) ?>,
                    linkDataArray: <?php echo json_encode($cles) ?>,
                });

        showModel();  // show the diagram's initial model

        function showModel()
        {
            document.getElementById("mySavedModel").textContent = myDiagram.model.toJson();
        }
    });
</script>
 No newline at end of file
+52 −0
Original line number Diff line number Diff line
<?php

/**
 * @var $this       \Application\View\Renderer\PhpRenderer
 * @var $controller \Laminas\Mvc\Controller\AbstractController
 * @var $container  \Psr\Container\ContainerInterface
 * @var $viewName   string
 * @var $viewFile   string
 */

phpinfo();

return;

$introspection = \UnicaenCode\Util::introspection();


$traits = $introspection->getTraits();
//$traits = [\Application\Form\OffreFormation\Traits\ElementPedagogiqueRechercheFieldsetAwareTrait::class];
foreach ($traits as $trait) {
    $params = $introspection->getTraitParams($trait);
    if ($params['aware']) {
        if ($params['targetClass']) {
            \UnicaenCode\Util::codeGenerator()->generer('awareTrait', [
                'class'     => $params['targetClass'],
                'useGetter' => true,
                'subDir'    => $params['subDir'],
                'expanded'  => false,
            ]);
        } else {
            echo "ATTENTION : L'awareTrait $trait ne fait référence à aucune classe connue et identifiée<br />\n";
        }
    }
}

$interfaces = $introspection->getInterfaces();
//$interfaces = [];
foreach ($interfaces as $interface) {
    $params = $introspection->getInterfaceParams($interface);
    if ($params['aware']) {
        if ($params['targetClass']) {
            \UnicaenCode\Util::codeGenerator()->generer('awareInterface', [
                'class'     => $params['targetClass'],
                'useGetter' => true,
                'subDir'    => $params['subDir'],
                'expanded'  => false,
            ]);
        } else {
            echo "ATTENTION : L'awareInterface' $interface ne fait référence à aucune classe connue et identifiée<br />\n";
        }
    }
}
 No newline at end of file
+121 −0
Original line number Diff line number Diff line
<?php

/**
 * @var $this       \Application\View\Renderer\PhpRenderer
 * @var $controller \Laminas\Mvc\Controller\AbstractController
 * @var $container  \Psr\Container\ContainerInterface
 * @var $viewName   string
 * @var $viewFile   string
 */

$effectifs = 100;
$cmin      = [0, 4];
$cmax      = [0, 4];

//$cmin      = [2,2];
//$cmax      = [2,2];

$noeuds = [
    1,
    5,
    2,
    8,
];

/*$noeuds = [
    1,
    1,
    3
];*/

$totalPoids = array_sum($noeuds);
$nbChoix    = count($noeuds);
$maxPoids   = 0;
foreach ($noeuds as $poids) {
    if ($poids > $maxPoids) $maxPoids = $poids;
}


function calc($choixMin, $choixMax, $poids, $maxPoids, $totalPoids, $nbChoix)
{
    $coefChoix = ($choixMin + $choixMax) / 2 / $nbChoix;

    $coefPoids = $poids / $totalPoids;

    $maxCoefPoids = $maxPoids / $totalPoids;

    $resMax = $coefChoix * $maxCoefPoids * $nbChoix;
    if (($resMax) <= 1) {
        return 0;

        return $coefChoix * $coefPoids * $nbChoix;
    } else {
//        $res = $coefChoix * $nbChoix * ($coefPoids+(((1/$nbChoix)-$coefPoids)*0));
//        $resMax = $coefChoix * $nbChoix * $maxCoefPoids;

        $delta = $resMax;

        return $delta;
        $res = $coefChoix;

        //$res = 1 / (($coefChoix * $nbChoix * $coefPoids) - 1);
//return $res;
        $correcteur = $res;
        $res        = $coefChoix * $nbChoix * ($coefPoids + (((1 / $nbChoix) - $coefPoids) * $correcteur));


        return $res;
    }
}

//var_dump(calc(3,3,3,3,5,3));

echo "Effectifs = " . $effectifs . '<br />';
echo "Total Poids = " . $totalPoids . '<br />';
echo "Nombre de noeuds = " . $nbChoix . '<br />';
?>
<table class="table table-bordered table-condensed">
    <thead>
    <tr>
        <th rowspan="2" style="width:5em">Choix min</th>
        <th rowspan="2" style="width:5em">Choix max</th>
        <?php foreach ($noeuds as $poids): ?>
            <th colspan="2">Noeud de poids = <?= $poids ?></th>
        <?php endforeach; ?>
        <th style="width:5em" rowspan="2">Tot Eff.</th>
    </tr>
    <tr>
        <?php foreach ($noeuds as $poids): ?>
            <th style="width:5em">Coef</th>
            <th style="width:5em">Effectifs</th>
        <?php endforeach; ?>
    </tr>
    </thead>
    <tbody>
    <?php for ($choixMin = $cmin[0]; $choixMin <= $cmin[1]; $choixMin++) {
        for ($choixMax = $cmax[0]; $choixMax <= $cmax[1]; $choixMax++) {
            $totEff = 0;

            ?>
            <tr>
                <th><?= $choixMin ?></th>
                <th><?= $choixMax ?></th>
                <?php foreach ($noeuds as $poids):

                    $coef = calc($choixMin, $choixMax, $poids, $maxPoids, $totalPoids, $nbChoix);
                    $eff = $coef * $effectifs;
                    $totEff += $eff;
                    ?>
                    <td><?= $coef ?></td>
                    <td><?= $eff ?></td>
                <?php endforeach; ?>
                <td><?= $totEff ?></td>
            </tr>

        <?php }
    } ?>
    </tbody>
</table>


code/test1.php

100755 → 100644
+12 −205
Original line number Diff line number Diff line
@@ -8,213 +8,20 @@
 * @var $viewFile   string
 */

$bdd    = adminBdd();
$schema = new \BddAdmin\Schema($bdd);
/** @var $em \Doctrine\ORM\EntityManager */
$em = $container->get(\Application\Constants::BDD);

/*$tables = [
    [
        'key'    => "Corps",
        'fields' => [
            ['name' => "field1", 'info' => "", 'color' => "#F7B84B", 'figure' => "Ellipse"],
            ['name' => "field2", 'info' => "the second one", 'color' => "#F25022", 'figure' => "Ellipse"],
            ['name' => "fieldThree", 'info' => "3rd", 'color' => "#00BCF2"],
        ],
        'loc'    => "0 0",
    ],
    [
        'key'    => "Grade",
        'fields' => [
            ['name' => "fieldA", 'info' => "", 'color' => "#FFB900", 'figure' => "Diamond"],
            ['name' => "fieldB", 'info' => "", 'color' => "#F25022", 'figure' => "Rectangle"],
            ['name' => "fieldC", 'info' => "", 'color' => "#7FBA00", 'figure' => "Diamond"],
            ['name' => "fieldD", 'info' => "fourth", 'color' => "#00BCF2", 'figure' => "Rectangle"],
        ],
        'loc'    => "280 50",
    ],
];*/

$list = [
    'ANNEE', 'INTERVENANT', 'CORPS', 'GRADE', 'GROUPE_TYPE_FORMATION', 'TYPE_FORMATION', 'ETAPE', 'ELEMENT_PEDAGOGIQUE',
    'CHEMIN_PEDAGOGIQUE', 'VOLUME_HORAIRE_ENS', 'TYPE_INTERVENTION',
];
/** @var \Intervenant\Entity\Db\Statut $s */
$s = $em->find(\Intervenant\Entity\Db\Statut::class, 7);
//$s->setConseilAcademique(false);
//$em->persist($s);
//$em->flush($s);

$tables = [];
$tbls   = $bdd->getSchema()->table()->get($list);
foreach ($tbls as $tbl) {
    $table = [
        'key'    => $tbl['name'],
        'fields' => [],
        'loc'    => '0 0',
    ];
    foreach ($tbl['columns'] as $col) {
        $type = $col['type'];
        if ($col['length']) {
            $type .= ' (' . $col['length'] . ')';
        }
        $column            = [
            'name' => $col['name'],
            'type' => $type,
        ];
        $table['fields'][] = $column;
    }
/** @var \Plafond\Entity\Db\PlafondStatut $ps */
$ps = $em->find(\Plafond\Entity\Db\PlafondStatut::class, 1);
$ps->setHeures(1);
$em->persist($ps);
$em->flush($ps);

    $tables[] = $table;
}
$cles = [];
$cls  = $bdd->getSchema()->refConstraint()->get();
foreach ($cls as $cl) {
    foreach ($cl['columns'] as $col => $rcol) {
        $cle    = [
            'from'    => $cl['table'],
            'fromCol' => $col,
            'to'      => $cl['rtable'],
            'toCol'   => $rcol,
        ];
        $cles[] = $cle;
    }
}


?>
<div id="sample">
    <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:1000px"></div>


    <p>For a variation on this sample with selectable fields in the record nodes, see the <a href="selectableFields.html">selectable
            fields</a> sample.</p>
    <div>
        Diagram Model saved in JSON format, automatically updated after each change or undo or redo:
        <textarea id="mySavedModel" style="width:100%;height:250px"></textarea>
        <div style="display: none; position: absolute; width: 0px; height: 0px; margin-top: -1px;"></div>
    </div>
</div>
<script>


    $(function () {

        WidgetInitializer.includeJs(Url('vendor/go.js'));

        var $ = go.GraphObject.make;

        myDiagram =
            $(go.Diagram, "myDiagramDiv",
                {
                    layout: $(go.LayeredDigraphLayout, {direction: 0}),

                    validCycle: go.Diagram.CycleNotDirected,  // don't allow loops
                    // For this sample, automatically show the state of the diagram's model on the page
                    "ModelChanged": function (e) {
                        if (e.isTransactionFinished) showModel();
                    },
                    "undoManager.isEnabled": true
                });

        var columnTemplate =
            $(go.Panel, "TableRow",  // this Panel is a row in the containing Table
                new go.Binding("portId", "name"),  // this Panel is a "port"
                {
                    background: "transparent",  // so this port's background can be picked by the mouse
                    fromSpot: go.Spot.Right,  // links only go from the right side to the left side
                    toSpot: go.Spot.Left,
                    // allow drawing links from or to this port:
                    fromLinkable: false, toLinkable: false
                },
                $(go.TextBlock,
                    {
                        margin: new go.Margin(0, 0), column: 1, font: "normal 10px sans-serif",
                        alignment: go.Spot.Left,
                        // and disallow drawing links from or to this text:
                        fromLinkable: false, toLinkable: false
                    },
                    new go.Binding("text", "name")),
                $(go.TextBlock,
                    {
                        margin: new go.Margin(0, 5),
                        column: 2,
                        stroke: "#ef9b0b",
                        font: "normal 9px sans-serif",
                        alignment: go.Spot.Left
                    },
                    new go.Binding("text", "type"))
            );

        // This template represents a whole "record".
        myDiagram.nodeTemplate =
            $(go.Node, "Auto",
                {copyable: false, deletable: false},
                //new go.Binding("location"),
                //new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
                // this rectangular shape surrounds the content of the node
                $(go.Shape,
                    {stroke: "#efd47e", strokeWidth: 2, fill: "#fff4eb"}),
                // the content consists of a header and a list of items
                $(go.Panel, "Vertical",
                    // this is the header for the whole node
                    $(go.Panel, "Auto",
                        {stretch: go.GraphObject.Horizontal},  // as wide as the whole node
                        $(go.Shape,
                            {fill: "#ffe6cf", stroke: null}),
                        $(go.TextBlock,
                            {
                                alignment: go.Spot.Center,
                                margin: 1,
                                stroke: "black",
                                textAlign: "center",
                                font: "bold 10pt sans-serif"
                            },
                            new go.Binding("text", "key"))),
                    // this Panel holds a Panel for each item object in the itemArray;
                    // each item Panel is defined by the itemTemplate to be a TableRow in this Table
                    $(go.Panel, "Table",
                        {
                            padding: 2,
                            minSize: new go.Size(100, 10),
                            defaultStretch: go.GraphObject.Horizontal,
                            itemTemplate: columnTemplate
                        },
                        new go.Binding("itemArray", "fields")
                    )  // end Table Panel of items
                )  // end Vertical Panel
            );  // end Node

        myDiagram.linkTemplate =
            $(go.Link,  // the whole link panel
                {relinkableFrom: false, relinkableTo: false, reshapable: true, resegmentable: true},
                {
                    //routing: go.Link.AvoidsNodes,  // but this is changed to go.Link.Orthgonal when the Link is reshaped
                    adjusting: go.Link.End,
                    curve: go.Link.JumpOver,
                    corner: 1,
                    toShortLength: 4
                },
                new go.Binding("points").makeTwoWay(),
                // remember the Link.routing too
                new go.Binding("routing", "routing", go.Binding.parseEnum(go.Link, go.Link.AvoidsNodes))
                    .makeTwoWay(go.Binding.toString),
                $(go.Shape,  // the link path shape
                    {isPanelMain: true, strokeWidth: 1}),
                $(go.Shape,  // the arrowhead
                    {toArrow: "Standard", stroke: null})
            );

        myDiagram.model =
            $(go.GraphLinksModel,
                {
                    copiesArrays: true,
                    copiesArrayObjects: true,
                    linkFromPortIdProperty: "fromCol",
                    linkToPortIdProperty: "toCol",
                    nodeDataArray: <?php echo json_encode($tables) ?>,
                    linkDataArray: <?php echo json_encode($cles) ?>,
                });

        showModel();  // show the diagram's initial model

        function showModel()
        {
            document.getElementById("mySavedModel").textContent = myDiagram.model.toJson();
        }
    });
</script>
 No newline at end of file

code/test5.php

100755 → 100644
+0 −112

File changed.File mode changed from 100755 to 100644.

Preview size limit exceeded, changes collapsed.

Loading