Commit 3de51203 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Meilleur affichage des données de synchro : avant il y avait des pb, car les...

Meilleur affichage des données de synchro : avant il y avait des pb, car les statuts sources n'étaient pas correctement affichés : il se calquaient sur ceux de l'intervenant dans OSE.
Affichage des données concernées par le différentiel
parent fef11aab
Loading
Loading
Loading
Loading
+2
Changes for module/Application/src/Application/Controller/Factory/IntervenantControllerFactory.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Application\Controller\DossierController;
use Application\Controller\IntervenantController;
use Psr\Container\ContainerInterface;
use UnicaenImport\Processus\ImportProcessus;
use UnicaenImport\Service\DifferentielService;

class IntervenantControllerFactory
{
@@ -21,6 +22,7 @@ class IntervenantControllerFactory
        $controller = new IntervenantController();

        $controller->setProcessusImport($container->get(ImportProcessus::class));
        $controller->setServiceDifferentiel($container->get(DifferentielService::class));

        return $controller;
    }
+8 −44
Changes for module/Application/src/Application/Controller/IntervenantController.php: 8 added lines, 44 removed lines.
Original line number Diff line number Diff line
@@ -32,7 +32,9 @@ use Application\Entity\Db\Intervenant;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\IntervenantServiceAwareTrait;
use UnicaenApp\View\Model\MessengerViewModel;
use UnicaenImport\Entity\Differentiel\Query;
use UnicaenImport\Processus\Traits\ImportProcessusAwareTrait;
use UnicaenImport\Service\Traits\DifferentielServiceAwareTrait;
use Zend\View\Model\ViewModel;

/**
@@ -64,6 +66,7 @@ class IntervenantController extends AbstractController
    use UtilisateurServiceAwareTrait;
    use DossierServiceAwareTrait;
    use ImportProcessusAwareTrait;
    use DifferentielServiceAwareTrait;


    public function indexAction()
@@ -379,50 +382,11 @@ class IntervenantController extends AbstractController
        $data         = [];

        if ($isImportable) {
            $sql = "
            SELECT 
              i.id,
              si.libelle statut
             FROM 
              src_intervenant i 
              JOIN statut_intervenant si ON si.id = i.statut_id
            WHERE 
              i.annee_id = :annee AND i.code = :code";
            $d   = $this->em()->getConnection()->fetchAll($sql, ['annee' => $intervenant->getAnnee()->getID(), 'code' => $intervenant->getCode()]);
            foreach ($d as $da) {
                $id        = $da['ID'] ? (int)$da['ID'] : $da['STATUT'];
                $data[$id] = [
                    'source-statut'      => $da['STATUT'],
                    'id'                 => $da['ID'] ? (int)$da['ID'] : null,
                    'intervenant-statut' => null,
                    'histo-destruction'  => null,
                    'histo-destructeur'  => null,
                ];
            }

            $sql = "
            SELECT 
              i.id,
              si.libelle statut,
              to_char(i.histo_destruction, 'dd/mm/YYYY') histo_destruction, 
              u.display_name destructeur
             FROM 
              intervenant i 
              JOIN statut_intervenant si ON si.id = i.statut_id
              LEFT JOIN utilisateur u ON u.id = i.histo_destructeur_id
            WHERE 
              i.annee_id = :annee AND i.code = :code";
            $d   = $this->em()->getConnection()->fetchAll($sql, ['annee' => $intervenant->getAnnee()->getID(), 'code' => $intervenant->getCode()]);
            foreach ($d as $da) {
                $id = (int)$da['ID'];
                if (!isset($data[$id])) {
                    $data[$id] = ['source-statut' => null];
                }
                $data[$id]['id']                 = $id;
                $data[$id]['intervenant-statut'] = $da['STATUT'];
                $data[$id]['histo-destruction']  = $da['HISTO_DESTRUCTION'];
                $data[$id]['histo-destructeur']  = $da['DESTRUCTEUR'];
            }
            $query = new Query('INTERVENANT');
            $query->setNotNull([]); // Aucune colonne ne doit être non nulle !!
            $query->setLimit(101);
            $query->setColValues(['ANNEE_ID' => $intervenant->getAnnee()->getId(), 'CODE' => $intervenant->getCode()]);
            $data = $this->getServiceDifferentiel()->make($query, $query::SQL_FULL, true)->fetchAll();
        }

        return compact('intervenant', 'isImportable', 'data');
+15 −3
Changes for module/Application/src/Application/View/Helper/Import/IntervenantViewHelper.php: 15 added lines, 3 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper\Import;

use Application\Entity\Db\Intervenant;
use Application\Entity\Db\StatutIntervenant;
use Application\Entity\Db\Structure;
@@ -15,28 +17,35 @@ class IntervenantViewHelper extends DifferentielLigne
{
    public function getSujet()
    {
        $format = '%s %s (n° %s, %s)';
        $format = '%s %s (n° %s, %s, %s)';
        if ('insert' == $this->ligne->getAction() || 'undelete' == $this->ligne->getAction()) {
            $statut = $this->ligne->getEntityManager()->find(StatutIntervenant::class, $this->ligne->get('STATUT_ID'));
            
            return sprintf(
                $format,
                $this->ligne->get('NOM_USUEL'),
                $this->ligne->get('PRENOM'),
                        $this->ligne->getSourceCode(),
                $this->ligne->get('CODE'),
                $statut,
                $this->ligne->get('ANNEE_ID') . '-' . ($this->ligne->get('ANNEE_ID') + 1)
            );
        } else {
            $entity = $this->ligne->getEntity();

            /* @var $entity Intervenant */
            return sprintf(
                $format,
                $entity->getNomUsuel(),
                $entity->getPrenom(),
                        $this->ligne->getSourceCode(),
                $entity->getCode(),
                $entity->getStatut(),
                $entity->getAnnee()->getLibelle()
            );
        }
    }



    public function getColumnDetails($column, $value)
    {
        switch ($column) {
@@ -46,6 +55,7 @@ class IntervenantViewHelper extends DifferentielLigne
                } else {
                    $structure = null;
                }

                return 'change de structure pour ' . ($structure ? $structure->getLibelleCourt() : '<i>structure indéfinie</i>');
            case 'NOM_USUEL':
                return 'change de nom usuel pour ' . $value;
@@ -57,6 +67,7 @@ class IntervenantViewHelper extends DifferentielLigne
                    $oldStatut = 'Aucun';
                }
                $statut = $this->ligne->getEntityManager()->find(StatutIntervenant::class, $value);

                return 'changement de statut (' . $oldStatut . ' vers ' . $statut . ')';
            case 'TYPE_ID':
                $intervenant = $this->ligne->getEntity();
@@ -66,6 +77,7 @@ class IntervenantViewHelper extends DifferentielLigne
                    $oldType = 'Aucun';
                }
                $type = $this->ligne->getEntityManager()->find(TypeIntervenant::class, $value);

                return $oldType . ' devient ' . lcfirst($type);
            default:
                return parent::getColumnDetails($column, $value);
+3 −44
Changes for module/Application/view/application/intervenant/synchronisation.phtml: 3 added lines, 44 removed lines.
Original line number Diff line number Diff line
@@ -17,50 +17,9 @@ if (!$isImportable) {

$canRestaure = $this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_AJOUT_STATUT));
$canDelete   = $this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_SUPPRESSION));

?>
    <table class="table table-bordered table-condensed">
        <tr>
            <th>Source</th>
            <th colspan="2">OSE</th>
        </tr>
        <?php foreach ($data as $d): ?>
            <tr>
                <td><?= $d['source-statut'] ?></td>
                <td><?= $d['intervenant-statut'] ?></td>
                <td><?php
                    if ($d['histo-destruction']) {
                        echo 'Supprimée le ' . $d['histo-destruction'] . ' par ' . $d['histo-destructeur'] . ' ';
                        if (true) {
                            echo ' ' . $this->tag('a', [
                                    'class' => 'no-intranavigation',
                                    'href'  => $this->url('intervenant/voir', ['intervenant' => $d['id']]),
                                    'title' => 'Voir la fiche de l\'intervenant',
                                ])->html($this->tag('span', ['class' => 'glyphicon glyphicon-eye-open']));
                        }
                        if ($canRestaure) {
                            echo ' ' . $this->tag('a', [
                                    'class' => 'no-intranavigation',
                                    'href'  => $this->url('intervenant/restaurer', ['intervenant' => $d['id']]),
                                    'title' => 'Restaurer la fiche de l\'intervenant',
                                ])->html($this->tag('span', ['class' => 'glyphicon glyphicon-open']));
                        }
                    } else {
                        if ($canDelete && $d['id']) {
                            echo ' ' . $this->tag('a', [
                                    'class' => 'no-intranavigation',
                                    'href'  => $this->url('intervenant/historiser', ['intervenant' => $d['id']]),
                                    'title' => 'Historiser la fiche de l\'intervenant',
                                ])->html($this->tag('span', ['class' => 'glyphicon glyphicon-trash']));
                        }
                    }
                    ?></td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php

if ($isImportable) {
echo '<h4>Différentiel</h4>';
echo $this->differentielListe($data);
if ($isImportable && !empty($data)) {
    echo $this->tag('a', [
        'href'  => $this->url('intervenant/synchroniser', ['intervenant' => $intervenant->getId()]),
        'title' => 'Synchroniser (import vers OSE)',