Skip to content
Snippets Groups Projects
Commit 0e9733c1 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Type de session

parent 9ddeefd8
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,7 @@ return [
'pages' => [
'gestion' => [
'pages' => [
'session' => [
'session-type' => [
'label' => 'Types de sessions',
'route' => 'session/type',
'resource' => PrivilegeController::getResourceId(SessionTypeController::class, 'index'),
......
......@@ -219,7 +219,7 @@ class Session implements
/**
* @return ?SessionType
*/
public function getType(): ?string
public function getType(): ?SessionType
{
return $this->type;
}
......
......@@ -3,6 +3,7 @@
namespace Formation\Form\Session;
use Formation\Entity\Db\Session;
use Formation\Service\SessionType\SessionTypeServiceAwareTrait;
use Laminas\Form\Element\Button;
use Laminas\Form\Element\Date;
use Laminas\Form\Element\Number;
......@@ -15,6 +16,7 @@ use Laminas\Validator\Regex;
class SessionForm extends Form
{
use SessionTypeServiceAwareTrait;
public function init(): void
{
......@@ -75,11 +77,7 @@ class SessionForm extends Form
'options' => [
'label' => "Type de formation :",
'empty_option' => "Sélectionner un type ...",
'value_options' => [
Session::TYPE_INTERNE => 'Formation interne',
Session::TYPE_EXTERNE => 'Formation externe',
Session::TYPE_REGIONALE => 'Formation régionale',
],
'value_options' => $this->getSessionTypeService()->getSessionsTypesAsOptions(),
],
'attributes' => [
'id' => 'type',
......
......@@ -2,6 +2,7 @@
namespace Formation\Form\Session;
use Formation\Service\SessionType\SessionTypeService;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
......@@ -9,16 +10,22 @@ use Psr\Container\NotFoundExceptionInterface;
class SessionFormFactory
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container): SessionForm
{
/** @var SessionHydrator $hydrator */
/**
* @var SessionTypeService $sessionTypeService
* @var SessionHydrator $hydrator
*/
$sessionTypeService = $container->get(SessionTypeService::class);
$hydrator = $container->get('HydratorManager')->get(SessionHydrator::class);
$form = new SessionForm();
$form->setSessionTypeService($sessionTypeService);
$form->setHydrator($hydrator);
return $form;
}
......
......@@ -4,10 +4,12 @@ namespace Formation\Form\Session;
use DateTime;
use Formation\Entity\Db\Session;
use Formation\Service\SessionType\SessionTypeServiceAwareTrait;
use Laminas\Hydrator\HydratorInterface;
class SessionHydrator implements HydratorInterface
{
use SessionTypeServiceAwareTrait;
public function extract(object $object) : array
{
......@@ -36,7 +38,7 @@ class SessionHydrator implements HydratorInterface
$principale = (isset($data['principale'])) ? ((int)$data['principale']) : 0;
$complementaire = (isset($data['complementaire'])) ? ((int)$data['complementaire']) : 0;
$lieu = (isset($data['lieu']) and trim($data['lieu']) !== "") ? trim($data['lieu']) : null;
$type = (isset($data['type']) and trim($data['type']) !== "") ? trim($data['type']) : null;
$type = (isset($data['type'])) ? $this->getSessionTypeService()->getSessionType($data['type']) : null;
$inscription = (isset($data['inscription']))?$data['inscription'] : false;
$coutHt = (isset($data['cout_ht']) and trim($data['cout_ht']) !== "") ? trim($data['cout_ht']) : null;
$coutTtc = (isset($data['cout_ttc']) and trim($data['cout_ttc']) !== "") ? trim($data['cout_ttc']) : null;
......
......@@ -2,13 +2,24 @@
namespace Formation\Form\Session;
use Formation\Service\SessionType\SessionTypeService;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class SessionHydratorFactory
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container): SessionHydrator
{
/** @var SessionTypeService $sessionTypeService */
$sessionTypeService = $container->get(SessionTypeService::class);
$hydrator = new SessionHydrator();
$hydrator->setSessionTypeService($sessionTypeService);
return $hydrator;
}
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ $canSupprimer = $this->isAllowed(SessiontypePrivileges::getResourceId(Sessiontyp
</thead>
<tbody>
<?php foreach ($sessionsTypes as $sessionType): ?>
<tr>
<tr class=" <?php if($sessionType->estHistorise()) echo ' historise '; ?> ">
<td>
<?php echo $sessionType->getLibelle(); ?>
<?php if ($sessionType->getDescription()) : ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment