Commit 5daa6b20 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

outils débogage tbl contrat OK

parent b27f69c3
Loading
Loading
Loading
Loading
Loading
+210 −21
Changes for code/contrats/debugTests.php: 210 added lines, 21 removed lines.
Original line number Diff line number Diff line
@@ -28,9 +28,10 @@ $noDisplayContrat = [
];

$noDisplayVh = [
    'source_id', 'source_code', 'auto_validation', 'tag_id', 'type_volume_horaire_id', 'contrat_id', 'horaire_debut', 'horaire_fin',
    'type_intervention_id',
    'histo_creation', 'histo_createur_id', 'histo_modification', 'histo_modificateur_id', 'histo_destructeur_id',
    'annee_id', 'intervenant_id', 'contrat_id', 'heures',
    'service_id', 'service_referentiel_id', 'mission_id',
    'volume_horaire_id', 'volume_horaire_ref_id', 'volume_horaire_mission_id',
    'autre_libelle',
];


@@ -57,20 +58,13 @@ ORDER BY

$vhData = $bdd->select("
SELECT
  vh.*,
  frvh.type_intervention_code,
  frvh.total hetd
  vh.*
FROM
  volume_horaire vh
  JOIN service s ON s.id = vh.service_id
  JOIN type_volume_horaire tvh ON tvh.code = 'PREVU'
  JOIN etat_volume_horaire evh ON evh.code = 'valide'
  JOIN formule_resultat_intervenant fri ON fri.intervenant_id = s.intervenant_id AND fri.type_volume_horaire_id = tvh.id AND fri.etat_volume_horaire_id = evh.id
  JOIN formule_resultat_volume_horaire frvh ON frvh.volume_horaire_id = vh.id AND frvh.formule_resultat_intervenant_id = fri.id
  v_tbl_contrat_volume_horaire vh
WHERE
  s.intervenant_id = :intervenant
  vh.intervenant_id = :intervenant
ORDER BY
  vh.id
  vh.volume_horaire_id, vh.volume_horaire_ref_id, vh.volume_horaire_mission_id
", ['intervenant' => $intervenantId], ['case' => CASE_LOWER]);

$contrats        = [];
@@ -79,18 +73,34 @@ $volumesHoraires = [];
foreach ($cData as $contrat) {
    $contrat['volumesHoraires'] = [];
    foreach ($vhData as $vh) {
        $volumesHoraires[$vh['id']] = $vh;
        if ($vh['volume_horaire_id']) {
            $vh['type']  = 'ens';
            $vh['vh_id'] = $vh['volume_horaire_id'];
        } elseif ($vh['volume_horaire_ref_id']) {
            $vh['type']  = 'ref';
            $vh['vh_id'] = $vh['volume_horaire_ref_id'];
        } elseif ($vh['volume_horaire_mission_id']) {
            $vh['type']  = 'mis';
            $vh['vh_id'] = $vh['volume_horaire_mission_id'];
        }

        if ($vh['service_id']) {
            $vh['s_id'] = $vh['service_id'];
        } elseif ($vh['service_referentiel_id']) {
            $vh['s_id'] = $vh['service_referentiel_id'];
        } elseif ($vh['mission_id']) {
            $vh['s_id'] = $vh['mission_id'];
        }

        $volumesHoraires[] = $vh;
        if ($vh['contrat_id'] == $contrat['id']) {
            $contrat['volumesHoraires'][$vh['id']] = $vh;
            $contrat['volumesHoraires'][] = $vh;
        }
    }
    $contrats[$contrat['id']] = $contrat;
}





// Affichage des données

echo "<h2>Intervenant ID = $intervenantId, Année ID = $anneeId</h2>";
@@ -122,7 +132,7 @@ foreach ($contrats as $contrat) {
            <div class="card-header"><?= implode(' | ', $title) ?></div>
            <div class="card-body">
                <div class="row">
                    <div class="col">
                    <div class="col-md-3">
                        <h4>Propriétés</h4>
                        <table class="table table-xs table">
                            <?php
@@ -134,7 +144,7 @@ foreach ($contrats as $contrat) {
                            ?>
                        </table>
                    </div>
                    <div class="col">
                    <div class="col-md-9">
                        <h4>Volumes horaires</h4>
                        <?php
                        if (empty($vhs)) {
@@ -208,3 +218,182 @@ foreach ($contrats as $contrat) {
        ?>
    </table>
<?php


// Génération d'un jeu de tests unitaires pour le TBL Contrat
echo "<h2>Génération d'un jeu de tests unitaires pour le TBL Contrat</h2>";

$contratIndex         = 0;
$avenantIndex         = 0;
$volumesHorairesIndex = 0;
$php                  = "";
foreach ($contrats as $cid => $contrat) {
    $isAvenant = $contrat['type_contrat_code'] == \Contrat\Entity\Db\TypeContrat::CODE_AVENANT;

    // Nommage de la variable
    if ($isAvenant) {
        $avenantIndex++;
        $contrat['variable'] = 'avenant' . $avenantIndex;
    } else {
        $contratIndex++;
        $contrat['variable'] = 'contrat' . $contratIndex;
    }
    $contrats[$cid]['variable'] = $contrat['variable'];
    $cnom                       = $contrat['variable'];

    $php .= "$" . $cnom . "                = new Contrat();\n";
    $php .= "$" . $cnom . "->id            = " . $contrat['id'] . "\n";
    if ($contrat['histo_destruction']) {
        $php .= "$" . $cnom . "->historise     = true;\n";
    }
    if ($contrat['structure_id']) {
        $php .= "$" . $cnom . "->structure_id  = " . $contrat['structure_id'] . ";\n";
    }
    if ($contrat['contrat_id']) {
        $php .= "$" . $cnom . "->setParent($" . $contrats[(int)$contrat['contrat_id']]['variable'] . ");\n";
    }
    if ($contrat['numero_avenant']) {
        $php .= "$" . $cnom . "->numeroAvenant = " . $contrat['numero_avenant'] . ";\n";
    }
    if ($contrat['debut_validite']) {
        $php .= "$" . $cnom . "->debutValidite = new \Datetime('" . substr($contrat['debut_validite'], 0, 10) . "');\n";
    }
    if ($contrat['fin_validite']) {
        $php .= "$" . $cnom . "->finValidite   = new \Datetime('" . substr($contrat['fin_validite'], 0, 10) . "');\n";
    }
    //if ($contrat['histo_creation']) {
    //    $php .= "$" . $cnom . "->histoCreation = new \Datetime('" . substr($contrat['histo_creation'], 0, 10) . "');\n";
    //}
    if ($contrat['validation_id'] && null == $contrat['validation_histo_destruction']) {
        $php .= "$" . $cnom . "->edite         = 1;\n";
    }
    if ($contrat['total_hetd']) {
        $php .= "$" . $cnom . "->totalHetd     = " . $contrat['total_hetd'] . ";\n";
    }

    $volumeHoraireVariables = [];

    $php .= "\n";
    foreach ($contrat['volumesHoraires'] as $volumesHoraire) {
        $volumesHorairesIndex++;
        $vnom = 'volumeHoraire' . $volumesHorairesIndex;

        $volumeHoraireVariables[] = $vnom;

        $php .= "$" . $vnom . " = new VolumeHoraire();\n";
        if ($volumesHoraire['structure_id']) {
            $php .= "$" . $vnom . "->structure_id       = " . $volumesHoraire['structure_id'] . ";\n";
        }
        if ($volumesHoraire['service_id']) {
            $php .= "$" . $vnom . "->serviceId          = " . $volumesHoraire['service_id'] . ";\n";
        }
        if ($volumesHoraire['service_referentiel_id']) {
            $php .= "$" . $vnom . "->serviceReferentielId = " . $volumesHoraire['service_referentiel_id'] . ";\n";
        }
        if ($volumesHoraire['mission_id']) {
            $php .= "$" . $vnom . "->missionId          = " . $volumesHoraire['mission_id'] . ";\n";
        }
        if ($volumesHoraire['volume_horaire_id']) {
            $php .= "$" . $vnom . "->volumeHoraireId    = " . $volumesHoraire['volume_horaire_id'] . ";\n";
        }
        if ($volumesHoraire['volume_horaire_ref_id']) {
            $php .= "$" . $vnom . "->volumeHoraireRefId = " . $volumesHoraire['volume_horaire_ref_id'] . ";\n";
        }
        if ($volumesHoraire['taux_remu_id']) {
            $php .= "$" . $vnom . "->tauxRemuId         = " . $volumesHoraire['taux_remu_id'] . ";\n";
        }
        if ($volumesHoraire['taux_remu_majore_id']) {
            $php .= "$" . $vnom . "->tauxRemuMajoreId   = " . $volumesHoraire['taux_remu_majore_id'] . ";\n";
        }
        if ($volumesHoraire['date_fin_mission']) {
            $php .= "$" . $vnom . "->dateFinMission     = new \Datetime('" . substr($contrat['date_fin_mission'], 0, 10) . "');\n";
        }
        if ($volumesHoraire['cm']){
            $php .= "$" . $vnom . "->cm                 = " . $volumesHoraire['cm'] . ";\n";
        }
        if ($volumesHoraire['td']){
            $php .= "$" . $vnom . "->td                 = " . $volumesHoraire['td'] . ";\n";
        }
        if ($volumesHoraire['tp']){
            $php .= "$" . $vnom . "->tp                 = " . $volumesHoraire['tp'] . ";\n";
        }
        if ($volumesHoraire['autres']){
            $php .= "$" . $vnom . "->autres             = " . $volumesHoraire['autres'] . ";\n";
        }
        if ($volumesHoraire['heures']){
            $php .= "$" . $vnom . "->heures             = " . $volumesHoraire['heures'] . ";\n";
        }
        if ($volumesHoraire['hetd']){
            $php .= "$" . $vnom . "->hetd               = " . $volumesHoraire['hetd'] . ";\n";
        }
        $php .= "\n";
    }

    if (!empty($volumeHoraireVariables)) {
        $php .= "$".$cnom."->volumesHoraires = [$".implode(', $', $volumeHoraireVariables)."];\n";
        $php .= "\n";
    }
}

echo '<pre>';
phpDump($php);
echo '</pre>';


/* Jeu de données initial *
//Contrat 1 global
$contrat1              = new Contrat();
$contrat1->id          = 1;
$contrat1->uuid        = 'contrat_principal';
$contrat1->isMission   = true;
$contrat1->structureId = null;
$contrat1->edite       = true;
$contrat1->avenants    = [];
// Création des objets VolumeHoraire
$volumeHoraire1              = new VolumeHoraire();
$volumeHoraire1->missionId   = 1;
$volumeHoraire1->structureId = 1;
$volumeHoraire2              = new VolumeHoraire();
$volumeHoraire2->missionId   = 1;
$volumeHoraire2->structureId = 1;
$volumeHoraire3              = new VolumeHoraire();
$volumeHoraire3->missionId   = 1;
$volumeHoraire3->structureId = 2;
// Ajout des objets dans l'array volumesHoraires

$contrat1->volumesHoraires = [$volumeHoraire1, $volumeHoraire2, $volumeHoraire3];

//Contrat 2 par composante
$contrat2              = new Contrat();
$contrat2->id          = 2;
$contrat2->uuid        = 'avenant_edite';
$contrat2->isMission   = true;
$contrat2->setParent($contrat1);
$contrat2->structureId = 1;
$contrat2->avenants    = [];

// Création des objets VolumeHoraire
$volumeHoraire1              = new VolumeHoraire();
$volumeHoraire1->missionId   = 1;
$volumeHoraire1->structureId = 1;

// Ajout des objets dans l'array volumesHoraires
$contrat2->volumesHoraires = [$volumeHoraire1];


//COntrat 3 par composante sur structure 2
$contrat3              = new Contrat();
$contrat3->id          = null;
$contrat1->uuid        = 'avenant_a_calculer';
$contrat3->isMission   = true;
$contrat3->parent      = null;
$contrat3->structureId = 2;
$contrat3->avenants    = [];

// Création des objets VolumeHoraire
$volumeHoraire1            = new VolumeHoraire();
$volumeHoraire1->missionId = 1;

// Ajout des objets dans l'array volumesHoraires
$contrat3->volumesHoraires = [$volumeHoraire1];
*/
−1
Changes for code/contrats/runTbl.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
 * @var $input      \Symfony\Component\Console\Input\Input
 */

use Symfony\Component\Console\Style\SymfonyStyle;
use UnicaenTbl\Event;

$tbl = $container->get(\UnicaenTbl\Service\TableauBordService::class);