Loading code/test4.php +5 −25 Changes for code/test4.php: 5 added lines, 25 removed lines. Original line number Diff line number Diff line Loading @@ -9,31 +9,11 @@ */ /** @var \Application\Processus\IntervenantProcessus $ip */ $ip = $container->get(\Application\Processus\IntervenantProcessus::class); $is = $ip->suppression(); /** @var \Application\Service\IntervenantService $si */ $si = $container->get(\Application\Service\IntervenantService::class); $intervenant = $container->get(\Application\Service\IntervenantService::class)->get(191233); $data = $is->getData($intervenant); var_dump($data); $tree = $is->getTree($intervenant); affNode($tree); $intervenant = $container->get(\Application\Service\IntervenantService::class)->get(195999); function affNode(\Application\Model\TreeNode $n) { echo '<div style="margin-left:2em">'; echo '<span class="' . $n->getIcon() . '"></span> ' . $n->getLabel(); echo ' <span style="color:#eee">id=' . $n->getId() . '</span>'; echo '<br />'; $childs = $n->getChildren(); foreach ($childs as $c) { affNode($c); } echo '</div>'; } No newline at end of file $data = $si->isImportable($intervenant); var_dump($data); No newline at end of file module/Application/config/intervenant.config.php +13 −2 Changes for module/Application/config/intervenant.config.php: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -87,6 +87,15 @@ return [ ], ], ], 'synchroniser' => [ 'type' => 'Segment', 'options' => [ 'route' => '/:intervenant/synchroniser', 'defaults' => [ 'action' => 'synchroniser', ], ], ], 'supprimer' => [ 'type' => 'Segment', 'options' => [ Loading Loading @@ -450,7 +459,7 @@ return [ ], [ 'controller' => 'Application\Controller\Intervenant', 'action' => ['saisir', 'definir-par-defaut'], 'action' => ['saisir', 'definir-par-defaut', 'synchroniser'], 'privileges' => [ Privileges::INTERVENANT_EDITION, ], Loading Loading @@ -540,8 +549,10 @@ return [ ], ], 'controllers' => [ 'factories' => [ 'Application\Controller\Intervenant' => Controller\Factory\IntervenantControllerFactory::class, ], 'invokables' => [ 'Application\Controller\Intervenant' => Controller\IntervenantController::class, 'Application\Controller\ModificationServiceDu' => Controller\ModificationServiceDuController::class, ], ], Loading module/Application/src/Application/Controller/Factory/IntervenantControllerFactory.php 0 → 100755 +28 −0 Changes for module/Application/src/Application/Controller/Factory/IntervenantControllerFactory.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Controller\Factory; use Application\Controller\DossierController; use Application\Controller\IntervenantController; use Psr\Container\ContainerInterface; use UnicaenImport\Processus\ImportProcessus; class IntervenantControllerFactory { /** * Create controller * * @param ContainerInterface $container * * @return IntervenantController */ public function __invoke(ContainerInterface $container, $requestedName, $options = null) { $controller = new IntervenantController(); $controller->setProcessusImport($container->get(ImportProcessus::class)); return $controller; } } No newline at end of file module/Application/src/Application/Controller/IntervenantController.php +35 −3 Changes for module/Application/src/Application/Controller/IntervenantController.php: 35 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ use Application\Entity\Db\Intervenant; use Application\Service\Traits\ContextServiceAwareTrait; use Application\Service\Traits\IntervenantServiceAwareTrait; use UnicaenApp\View\Model\MessengerViewModel; use UnicaenImport\Processus\Traits\ImportProcessusAwareTrait; use Zend\View\Model\ViewModel; /** Loading Loading @@ -62,6 +63,7 @@ class IntervenantController extends AbstractController use SourceServiceAwareTrait; use UtilisateurServiceAwareTrait; use DossierServiceAwareTrait; use ImportProcessusAwareTrait; public function indexAction() Loading Loading @@ -366,7 +368,23 @@ class IntervenantController extends AbstractController } } return compact('intervenant', 'form', 'errors', 'title', 'definiParDefaut', 'actionDetail'); $isImportable = $this->getServiceIntervenant()->isImportable($intervenant); $vm = new ViewModel(); $vm->setTemplate('application/intervenant/saisir'); $vm->setVariables(compact('intervenant', 'form', 'errors', 'title', 'definiParDefaut', 'actionDetail', 'isImportable')); return $vm; } public function synchroniserAction() { $intervenant = $this->getEvent()->getParam('intervenant'); $this->getProcessusImport()->execMaj('INTERVENANT', 'CODE', $intervenant->getCode()); return $this->saisirAction(); } Loading Loading @@ -504,7 +522,20 @@ class IntervenantController extends AbstractController $container = $this->getSessionContainer(); //$container->recents = []; if (isset($container->recents)) { return $container->recents; $recents = $container->recents; foreach ($recents as $i => $recent) { if (isset($recent['code'])) { $intervenant = $this->getServiceIntervenant()->getByCode($recent['code']); } else { $intervenant = null; } if (!$intervenant) { unset($recents[$i]); unset($container->recents[$i]); } } return $recents; } else { return []; } Loading Loading @@ -549,7 +580,8 @@ class IntervenantController extends AbstractController 'date-naissance' => $intervenant->getDateNaissance(), 'structure' => (string)$intervenant->getStructure(), 'statut' => (string)$intervenant->getStatut(), 'numero-personnel' => $intervenant->getSourceCode(), 'code' => $intervenant->getCode(), 'numero-personnel' => $intervenant->getCode(), '__horo_ajout__' => (int)date('U'), ]; } else { Loading module/Application/src/Application/Service/IntervenantService.php +16 −0 Changes for module/Application/src/Application/Service/IntervenantService.php: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -217,6 +217,22 @@ class IntervenantService extends AbstractEntityService public function isImportable(Intervenant $intervenant): bool { $connection = $this->getEntityManager()->getConnection(); $sqlEnabled = "SELECT sync_enabled FROM import_tables WHERE table_name = 'INTERVENANT'"; $res = $connection->fetchAssociative($sqlEnabled); if (false === $res || '0' == $res['SYNC_ENABLED']) return false; $sql = "SELECT code FROM SRC_INTERVENANT WHERE code = :code AND annee_id = :annee"; $res = $connection->fetchAssociative($sql, ['code' => $intervenant->getCode(), 'annee' => $intervenant->getAnnee()->getId()]); return ($res !== false) && isset($res['CODE']) && ($intervenant->getCode() == $res['CODE']); } private function getIntervenantIdParDefaut(string $code, int $anneeId): ?int { if (!$code || !$anneeId) return null; Loading Loading
code/test4.php +5 −25 Changes for code/test4.php: 5 added lines, 25 removed lines. Original line number Diff line number Diff line Loading @@ -9,31 +9,11 @@ */ /** @var \Application\Processus\IntervenantProcessus $ip */ $ip = $container->get(\Application\Processus\IntervenantProcessus::class); $is = $ip->suppression(); /** @var \Application\Service\IntervenantService $si */ $si = $container->get(\Application\Service\IntervenantService::class); $intervenant = $container->get(\Application\Service\IntervenantService::class)->get(191233); $data = $is->getData($intervenant); var_dump($data); $tree = $is->getTree($intervenant); affNode($tree); $intervenant = $container->get(\Application\Service\IntervenantService::class)->get(195999); function affNode(\Application\Model\TreeNode $n) { echo '<div style="margin-left:2em">'; echo '<span class="' . $n->getIcon() . '"></span> ' . $n->getLabel(); echo ' <span style="color:#eee">id=' . $n->getId() . '</span>'; echo '<br />'; $childs = $n->getChildren(); foreach ($childs as $c) { affNode($c); } echo '</div>'; } No newline at end of file $data = $si->isImportable($intervenant); var_dump($data); No newline at end of file
module/Application/config/intervenant.config.php +13 −2 Changes for module/Application/config/intervenant.config.php: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -87,6 +87,15 @@ return [ ], ], ], 'synchroniser' => [ 'type' => 'Segment', 'options' => [ 'route' => '/:intervenant/synchroniser', 'defaults' => [ 'action' => 'synchroniser', ], ], ], 'supprimer' => [ 'type' => 'Segment', 'options' => [ Loading Loading @@ -450,7 +459,7 @@ return [ ], [ 'controller' => 'Application\Controller\Intervenant', 'action' => ['saisir', 'definir-par-defaut'], 'action' => ['saisir', 'definir-par-defaut', 'synchroniser'], 'privileges' => [ Privileges::INTERVENANT_EDITION, ], Loading Loading @@ -540,8 +549,10 @@ return [ ], ], 'controllers' => [ 'factories' => [ 'Application\Controller\Intervenant' => Controller\Factory\IntervenantControllerFactory::class, ], 'invokables' => [ 'Application\Controller\Intervenant' => Controller\IntervenantController::class, 'Application\Controller\ModificationServiceDu' => Controller\ModificationServiceDuController::class, ], ], Loading
module/Application/src/Application/Controller/Factory/IntervenantControllerFactory.php 0 → 100755 +28 −0 Changes for module/Application/src/Application/Controller/Factory/IntervenantControllerFactory.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Controller\Factory; use Application\Controller\DossierController; use Application\Controller\IntervenantController; use Psr\Container\ContainerInterface; use UnicaenImport\Processus\ImportProcessus; class IntervenantControllerFactory { /** * Create controller * * @param ContainerInterface $container * * @return IntervenantController */ public function __invoke(ContainerInterface $container, $requestedName, $options = null) { $controller = new IntervenantController(); $controller->setProcessusImport($container->get(ImportProcessus::class)); return $controller; } } No newline at end of file
module/Application/src/Application/Controller/IntervenantController.php +35 −3 Changes for module/Application/src/Application/Controller/IntervenantController.php: 35 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ use Application\Entity\Db\Intervenant; use Application\Service\Traits\ContextServiceAwareTrait; use Application\Service\Traits\IntervenantServiceAwareTrait; use UnicaenApp\View\Model\MessengerViewModel; use UnicaenImport\Processus\Traits\ImportProcessusAwareTrait; use Zend\View\Model\ViewModel; /** Loading Loading @@ -62,6 +63,7 @@ class IntervenantController extends AbstractController use SourceServiceAwareTrait; use UtilisateurServiceAwareTrait; use DossierServiceAwareTrait; use ImportProcessusAwareTrait; public function indexAction() Loading Loading @@ -366,7 +368,23 @@ class IntervenantController extends AbstractController } } return compact('intervenant', 'form', 'errors', 'title', 'definiParDefaut', 'actionDetail'); $isImportable = $this->getServiceIntervenant()->isImportable($intervenant); $vm = new ViewModel(); $vm->setTemplate('application/intervenant/saisir'); $vm->setVariables(compact('intervenant', 'form', 'errors', 'title', 'definiParDefaut', 'actionDetail', 'isImportable')); return $vm; } public function synchroniserAction() { $intervenant = $this->getEvent()->getParam('intervenant'); $this->getProcessusImport()->execMaj('INTERVENANT', 'CODE', $intervenant->getCode()); return $this->saisirAction(); } Loading Loading @@ -504,7 +522,20 @@ class IntervenantController extends AbstractController $container = $this->getSessionContainer(); //$container->recents = []; if (isset($container->recents)) { return $container->recents; $recents = $container->recents; foreach ($recents as $i => $recent) { if (isset($recent['code'])) { $intervenant = $this->getServiceIntervenant()->getByCode($recent['code']); } else { $intervenant = null; } if (!$intervenant) { unset($recents[$i]); unset($container->recents[$i]); } } return $recents; } else { return []; } Loading Loading @@ -549,7 +580,8 @@ class IntervenantController extends AbstractController 'date-naissance' => $intervenant->getDateNaissance(), 'structure' => (string)$intervenant->getStructure(), 'statut' => (string)$intervenant->getStatut(), 'numero-personnel' => $intervenant->getSourceCode(), 'code' => $intervenant->getCode(), 'numero-personnel' => $intervenant->getCode(), '__horo_ajout__' => (int)date('U'), ]; } else { Loading
module/Application/src/Application/Service/IntervenantService.php +16 −0 Changes for module/Application/src/Application/Service/IntervenantService.php: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -217,6 +217,22 @@ class IntervenantService extends AbstractEntityService public function isImportable(Intervenant $intervenant): bool { $connection = $this->getEntityManager()->getConnection(); $sqlEnabled = "SELECT sync_enabled FROM import_tables WHERE table_name = 'INTERVENANT'"; $res = $connection->fetchAssociative($sqlEnabled); if (false === $res || '0' == $res['SYNC_ENABLED']) return false; $sql = "SELECT code FROM SRC_INTERVENANT WHERE code = :code AND annee_id = :annee"; $res = $connection->fetchAssociative($sql, ['code' => $intervenant->getCode(), 'annee' => $intervenant->getAnnee()->getId()]); return ($res !== false) && isset($res['CODE']) && ($intervenant->getCode() == $res['CODE']); } private function getIntervenantIdParDefaut(string $code, int $anneeId): ?int { if (!$code || !$anneeId) return null; Loading