Loading module/Plafond/src/Service/IndicateurService.php 0 → 100755 +163 −0 Changes for module/Plafond/src/Service/IndicateurService.php: 163 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\Service; use Application\Service\Traits\TypeVolumeHoraireServiceAwareTrait; use Indicateur\Entity\Db\Indicateur; use Plafond\Entity\Db\PlafondPerimetre; /** * Description of IndicateurService * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class IndicateurService { use PlafondServiceAwareTrait; use TypeVolumeHoraireServiceAwareTrait; public function makeQuery(Indicateur $indicateur): string { switch ($indicateur->getTypeIndicateur()->getPlafondPerimetreCode()) { case PlafondPerimetre::INTERVENANT: return $this->makeQueryIntervenant($indicateur); case PlafondPerimetre::STRUCTURE: return $this->makeQueryStructure($indicateur); case PlafondPerimetre::REFERENTIEL: return $this->makeQueryReferentiel($indicateur); case PlafondPerimetre::ELEMENT: return $this->makeQueryElement($indicateur); case PlafondPerimetre::VOLUME_HORAIRE: return $this->makeQueryVolumeHoraire($indicateur); } throw new \Exception('La requête n\'a pas pu être construite : le périmètre de plafond n\'a pas été identifié'); } protected function makeQueryIntervenant(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_INTERVENANT v WHERE v.numero = $numero "; } protected function makeQueryStructure(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_STRUCTURE v WHERE v.numero = $numero "; } protected function makeQueryReferentiel(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", v.fonction \"Fonction\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_REFERENTIEL v WHERE v.numero = $numero "; } protected function makeQueryElement(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", v.element \"Élément pédagogique\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_ELEMENT v WHERE v.numero = $numero "; } protected function makeQueryVolumeHoraire(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", v.element \"Élément pédagogique\", v.type_intervention \"Type d'intervention\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_VOLUME_HORAIRE v WHERE v.numero = $numero "; } public function getIndicateursData() { $typesVolumesHoraires = $this->getServiceTypeVolumeHoraire()->getList(); var_dump($typesVolumesHoraires); $plafondConfigs = $this->getServicePlafond()->getPlafondsConfig(); foreach ($plafondConfigs as $plafondConfig) { $plafond = $plafondConfig->getPlafond(); varDump($plafond->getNumero()); } } } No newline at end of file module/Plafond/src/Service/IndicateurServiceAwareTrait.php 0 → 100755 +39 −0 Changes for module/Plafond/src/Service/IndicateurServiceAwareTrait.php: 39 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\Service; /** * Description of IndicateurServiceAwareTrait * * @author UnicaenCode */ trait IndicateurServiceAwareTrait { protected ?IndicateurService $serviceIndicateur = null; /** * @param IndicateurService $serviceIndicateur * * @return self */ public function setServiceIndicateur(?IndicateurService $serviceIndicateur) { $this->serviceIndicateur = $serviceIndicateur; return $this; } public function getServiceIndicateur(): ?IndicateurService { if (empty($this->serviceIndicateur)) { $this->serviceIndicateur = \Application::$container->get(IndicateurService::class); } return $this->serviceIndicateur; } } No newline at end of file module/Plafond/src/Service/IndicateurServiceFactory.php 0 → 100755 +31 −0 Changes for module/Plafond/src/Service/IndicateurServiceFactory.php: 31 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\Service; use Psr\Container\ContainerInterface; /** * Description of IndicateurServiceFactory * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class IndicateurServiceFactory { /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * * @return IndicateurService */ public function __invoke(ContainerInterface $container, $requestedName, $options = null): IndicateurService { $service = new IndicateurService; /* Injectez vos dépendances ICI */ return $service; } } No newline at end of file module/Plafond/src/View/Helper/PlafondsViewHelper.php 0 → 100755 +177 −0 Changes for module/Plafond/src/View/Helper/PlafondsViewHelper.php: 177 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\View\Helper; use Application\Entity\Db\ElementPedagogique; use Application\Entity\Db\FonctionReferentiel; use Application\Entity\Db\Intervenant; use Application\Entity\Db\Structure; use Application\Entity\Db\TypeVolumeHoraire; use Application\Entity\Db\VolumeHoraire; use Laminas\View\Helper\AbstractHtmlElement; use Plafond\Entity\PlafondControle; use Plafond\Service\PlafondServiceAwareTrait; /** * Description of PlafondsViewHelper * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class PlafondsViewHelper extends AbstractHtmlElement { use PlafondServiceAwareTrait; private Structure|Intervenant|ElementPedagogique|VolumeHoraire|FonctionReferentiel $entity; private TypeVolumeHoraire $typeVolumeHoraire; /** * @var PlafondControle[] */ private array $plafonds; /** * * @return self */ public function __invoke(Structure|Intervenant|ElementPedagogique|VolumeHoraire|FonctionReferentiel $entity, TypeVolumeHoraire $typeVolumeHoraire) { $this->entity = $entity; $this->typeVolumeHoraire = $typeVolumeHoraire; $this->plafonds = $this->getServicePlafond()->controle($entity, $typeVolumeHoraire); return $this; } /** * Retourne le code HTML. * * @return string Code HTML */ public function __toString(): string { return $this->render(); } public function render(): string { $params = [ 'perimetre' => $this->getServicePlafond()->entityToPerimetreCode($this->entity), 'id' => $this->entity->getId(), 'typeVolumeHoraire' => $this->typeVolumeHoraire->getId(), ]; $attrs = [ 'class' => 'plafonds alert alert-info', 'data-url' => $this->getView()->url('plafond/plafonds', $params), ]; return $this->getView()->tag('div', $attrs)->html($this->affichage()); } public function affichage(): string { if (empty($this->plafonds)) { return ''; } $html = $this->getView()->tag('h4')->text('Plafonds'); foreach ($this->plafonds as $plafond) { $html .= $this->affichagePlafond($plafond); } return $html; } protected function affichagePlafond(PlafondControle $plafond) { $t = $this->getView()->tag(); $labAttrs = ['class' => ['label']]; if ($plafond->isBloquant()) { $labAttrs['class'][] = 'label-danger'; $labAttrs['title'] = 'Plafond bloquant'; } else { $labAttrs['class'][] = 'label-info'; $labAttrs['title'] = 'Plafond informatif'; } $text = ''; $max = $plafond->getPlafond() + $plafond->getDerogation(); if ($plafond->getHeures() >= $max) { $max = $plafond->getHeures(); if ($plafond->getHeures() > 0) { if ($plafond->getPlafond() == 0) { $text = floatToString($plafond->getHeures()) . 'h pour aucune autorisée'; } else { $text = floatToString($plafond->getHeures()) . 'h pour ' . floatToString($plafond->getPlafond()) . ' max.'; } } if ($plafond->isBloquant()) { $color = 'danger'; } else { $color = 'warning'; } } else { if ($plafond->isBloquant()) { $color = 'info'; } else { $color = 'success'; } } if ($max > 0) { $progression = ceil($plafond->getHeures() * 100 / $max); } else { $progression = 0; } if (!$text) { if ($progression > 49) { $text = floatToString($plafond->getHeures()) . 'h, ' . floatToString($max - $plafond->getHeures()) . ' dispo.'; } elseif ($progression > 10) { $text = floatToString($plafond->getHeures()) . 'h'; } } $html = ''; $html .= $t('div', ['class' => 'col-md-4'])->html( $t('div', [ 'class' => 'progress', ])->html( $t('div', [ 'class' => 'progress-bar progress-bar-striped progress-bar-' . $color, 'role' => 'progressbar', 'aria-valuenow' => $progression, 'aria-valuemin' => 0, 'aria-valuemax' => 100, 'style' => 'width:' . $progression . '%', ])->text($text) ) ); $html .= $t('div', ['class' => 'col-md-8'])->html( $plafond->getMessage() . ' ' . $t('span', $labAttrs)->text('n° ' . $plafond->getNumero()) ); return $t('div', ['class' => 'row plafond'])->html($html); } } No newline at end of file module/Plafond/src/View/Helper/PlafondsViewHelperFactory.php 0 → 100755 +31 −0 Changes for module/Plafond/src/View/Helper/PlafondsViewHelperFactory.php: 31 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\View\Helper; use Psr\Container\ContainerInterface; /** * Description of PlafondsViewHelperFactory * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class PlafondsViewHelperFactory { /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * * @return PlafondsViewHelper */ public function __invoke(ContainerInterface $container, $requestedName, $options = null): PlafondsViewHelper { $viewHelper = new PlafondsViewHelper; /* Injectez vos dépendances ICI */ return $viewHelper; } } No newline at end of file Loading
module/Plafond/src/Service/IndicateurService.php 0 → 100755 +163 −0 Changes for module/Plafond/src/Service/IndicateurService.php: 163 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\Service; use Application\Service\Traits\TypeVolumeHoraireServiceAwareTrait; use Indicateur\Entity\Db\Indicateur; use Plafond\Entity\Db\PlafondPerimetre; /** * Description of IndicateurService * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class IndicateurService { use PlafondServiceAwareTrait; use TypeVolumeHoraireServiceAwareTrait; public function makeQuery(Indicateur $indicateur): string { switch ($indicateur->getTypeIndicateur()->getPlafondPerimetreCode()) { case PlafondPerimetre::INTERVENANT: return $this->makeQueryIntervenant($indicateur); case PlafondPerimetre::STRUCTURE: return $this->makeQueryStructure($indicateur); case PlafondPerimetre::REFERENTIEL: return $this->makeQueryReferentiel($indicateur); case PlafondPerimetre::ELEMENT: return $this->makeQueryElement($indicateur); case PlafondPerimetre::VOLUME_HORAIRE: return $this->makeQueryVolumeHoraire($indicateur); } throw new \Exception('La requête n\'a pas pu être construite : le périmètre de plafond n\'a pas été identifié'); } protected function makeQueryIntervenant(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_INTERVENANT v WHERE v.numero = $numero "; } protected function makeQueryStructure(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_STRUCTURE v WHERE v.numero = $numero "; } protected function makeQueryReferentiel(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", v.fonction \"Fonction\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_REFERENTIEL v WHERE v.numero = $numero "; } protected function makeQueryElement(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", v.element \"Élément pédagogique\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_ELEMENT v WHERE v.numero = $numero "; } protected function makeQueryVolumeHoraire(Indicateur $indicateur): string { $numero = $indicateur->getNumero(); return " SELECT v.intervenant_id, v.structure_id, v.etat \"État\", v.element \"Élément pédagogique\", v.type_intervention \"Type d'intervention\", replace(to_char(v.heures),'.',',') \"Heures\", replace(to_char(v.plafond),'.',',') \"Plafond\", replace(to_char(v.derogation),'.',',') \"Derogation\" FROM V_INDICATEUR_P_VOLUME_HORAIRE v WHERE v.numero = $numero "; } public function getIndicateursData() { $typesVolumesHoraires = $this->getServiceTypeVolumeHoraire()->getList(); var_dump($typesVolumesHoraires); $plafondConfigs = $this->getServicePlafond()->getPlafondsConfig(); foreach ($plafondConfigs as $plafondConfig) { $plafond = $plafondConfig->getPlafond(); varDump($plafond->getNumero()); } } } No newline at end of file
module/Plafond/src/Service/IndicateurServiceAwareTrait.php 0 → 100755 +39 −0 Changes for module/Plafond/src/Service/IndicateurServiceAwareTrait.php: 39 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\Service; /** * Description of IndicateurServiceAwareTrait * * @author UnicaenCode */ trait IndicateurServiceAwareTrait { protected ?IndicateurService $serviceIndicateur = null; /** * @param IndicateurService $serviceIndicateur * * @return self */ public function setServiceIndicateur(?IndicateurService $serviceIndicateur) { $this->serviceIndicateur = $serviceIndicateur; return $this; } public function getServiceIndicateur(): ?IndicateurService { if (empty($this->serviceIndicateur)) { $this->serviceIndicateur = \Application::$container->get(IndicateurService::class); } return $this->serviceIndicateur; } } No newline at end of file
module/Plafond/src/Service/IndicateurServiceFactory.php 0 → 100755 +31 −0 Changes for module/Plafond/src/Service/IndicateurServiceFactory.php: 31 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\Service; use Psr\Container\ContainerInterface; /** * Description of IndicateurServiceFactory * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class IndicateurServiceFactory { /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * * @return IndicateurService */ public function __invoke(ContainerInterface $container, $requestedName, $options = null): IndicateurService { $service = new IndicateurService; /* Injectez vos dépendances ICI */ return $service; } } No newline at end of file
module/Plafond/src/View/Helper/PlafondsViewHelper.php 0 → 100755 +177 −0 Changes for module/Plafond/src/View/Helper/PlafondsViewHelper.php: 177 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\View\Helper; use Application\Entity\Db\ElementPedagogique; use Application\Entity\Db\FonctionReferentiel; use Application\Entity\Db\Intervenant; use Application\Entity\Db\Structure; use Application\Entity\Db\TypeVolumeHoraire; use Application\Entity\Db\VolumeHoraire; use Laminas\View\Helper\AbstractHtmlElement; use Plafond\Entity\PlafondControle; use Plafond\Service\PlafondServiceAwareTrait; /** * Description of PlafondsViewHelper * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class PlafondsViewHelper extends AbstractHtmlElement { use PlafondServiceAwareTrait; private Structure|Intervenant|ElementPedagogique|VolumeHoraire|FonctionReferentiel $entity; private TypeVolumeHoraire $typeVolumeHoraire; /** * @var PlafondControle[] */ private array $plafonds; /** * * @return self */ public function __invoke(Structure|Intervenant|ElementPedagogique|VolumeHoraire|FonctionReferentiel $entity, TypeVolumeHoraire $typeVolumeHoraire) { $this->entity = $entity; $this->typeVolumeHoraire = $typeVolumeHoraire; $this->plafonds = $this->getServicePlafond()->controle($entity, $typeVolumeHoraire); return $this; } /** * Retourne le code HTML. * * @return string Code HTML */ public function __toString(): string { return $this->render(); } public function render(): string { $params = [ 'perimetre' => $this->getServicePlafond()->entityToPerimetreCode($this->entity), 'id' => $this->entity->getId(), 'typeVolumeHoraire' => $this->typeVolumeHoraire->getId(), ]; $attrs = [ 'class' => 'plafonds alert alert-info', 'data-url' => $this->getView()->url('plafond/plafonds', $params), ]; return $this->getView()->tag('div', $attrs)->html($this->affichage()); } public function affichage(): string { if (empty($this->plafonds)) { return ''; } $html = $this->getView()->tag('h4')->text('Plafonds'); foreach ($this->plafonds as $plafond) { $html .= $this->affichagePlafond($plafond); } return $html; } protected function affichagePlafond(PlafondControle $plafond) { $t = $this->getView()->tag(); $labAttrs = ['class' => ['label']]; if ($plafond->isBloquant()) { $labAttrs['class'][] = 'label-danger'; $labAttrs['title'] = 'Plafond bloquant'; } else { $labAttrs['class'][] = 'label-info'; $labAttrs['title'] = 'Plafond informatif'; } $text = ''; $max = $plafond->getPlafond() + $plafond->getDerogation(); if ($plafond->getHeures() >= $max) { $max = $plafond->getHeures(); if ($plafond->getHeures() > 0) { if ($plafond->getPlafond() == 0) { $text = floatToString($plafond->getHeures()) . 'h pour aucune autorisée'; } else { $text = floatToString($plafond->getHeures()) . 'h pour ' . floatToString($plafond->getPlafond()) . ' max.'; } } if ($plafond->isBloquant()) { $color = 'danger'; } else { $color = 'warning'; } } else { if ($plafond->isBloquant()) { $color = 'info'; } else { $color = 'success'; } } if ($max > 0) { $progression = ceil($plafond->getHeures() * 100 / $max); } else { $progression = 0; } if (!$text) { if ($progression > 49) { $text = floatToString($plafond->getHeures()) . 'h, ' . floatToString($max - $plafond->getHeures()) . ' dispo.'; } elseif ($progression > 10) { $text = floatToString($plafond->getHeures()) . 'h'; } } $html = ''; $html .= $t('div', ['class' => 'col-md-4'])->html( $t('div', [ 'class' => 'progress', ])->html( $t('div', [ 'class' => 'progress-bar progress-bar-striped progress-bar-' . $color, 'role' => 'progressbar', 'aria-valuenow' => $progression, 'aria-valuemin' => 0, 'aria-valuemax' => 100, 'style' => 'width:' . $progression . '%', ])->text($text) ) ); $html .= $t('div', ['class' => 'col-md-8'])->html( $plafond->getMessage() . ' ' . $t('span', $labAttrs)->text('n° ' . $plafond->getNumero()) ); return $t('div', ['class' => 'row plafond'])->html($html); } } No newline at end of file
module/Plafond/src/View/Helper/PlafondsViewHelperFactory.php 0 → 100755 +31 −0 Changes for module/Plafond/src/View/Helper/PlafondsViewHelperFactory.php: 31 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Plafond\View\Helper; use Psr\Container\ContainerInterface; /** * Description of PlafondsViewHelperFactory * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class PlafondsViewHelperFactory { /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * * @return PlafondsViewHelper */ public function __invoke(ContainerInterface $container, $requestedName, $options = null): PlafondsViewHelper { $viewHelper = new PlafondsViewHelper; /* Injectez vos dépendances ICI */ return $viewHelper; } } No newline at end of file