Skip to content
Snippets Groups Projects
Commit 6a5c1d21 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Ajout date de début et de fin sur les tags

parent 4034f796
No related branches found
No related tags found
No related merge requests found
Showing
with 432 additions and 216 deletions
......@@ -129,6 +129,30 @@ return [
'position' => 4,
'commentaire' => NULL,
],
'DATE_DEBUT' => [
'name' => 'DATE_DEBUT',
'type' => 'date',
'bdd-type' => 'DATE',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 11,
'commentaire' => NULL,
],
'DATE_FIN' => [
'name' => 'DATE_FIN',
'type' => 'date',
'bdd-type' => 'DATE',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 12,
'commentaire' => NULL,
],
],
];
......
......@@ -2,6 +2,8 @@
namespace Application;
use Application\Form\Tag\TagSaisieForm;
use Application\Form\Tag\TagSaisieFormFactory;
use Application\Provider\Privilege\Privileges;
use UnicaenPrivilege\Guard\PrivilegeController;
......@@ -100,9 +102,10 @@ return [
],
'view_helpers' => [
],
'form_elements' => [
'invokables' => [
Form\Tag\TagSaisieForm::class => Form\Tag\TagSaisieForm::class,
],
'forms' => [
TagSaisieForm::class => TagSaisieFormFactory::class,
],
];
......@@ -3,7 +3,7 @@
namespace Application\Controller;
use Application\Entity\Db\Tag;
use Application\Form\Tag\Traits\TagSaisieFormAwareTrait;
use Application\Form\Tag\TagSaisieFormAwareTrait;
use Application\Service\Traits\TagServiceAwareTrait;
use UnicaenApp\View\Model\MessengerViewModel;
......@@ -25,12 +25,13 @@ class TagController extends AbstractController
}
public function saisirAction ()
{
/* @var $tag Tag */
$tag = $this->getEvent()->getParam('tag');
$form = $this->getFormTag();
$form = $this->getFormTagSaisie();
if (empty($tag)) {
$title = 'Création d\'un nouveau tag';
$tag = $this->getServiceTag()->newEntity();
......@@ -38,6 +39,7 @@ class TagController extends AbstractController
$title = 'Édition d\'un tag';
}
$form->bindRequestSave($tag, $this->getRequest(), function (Tag $tag) {
try {
$this->getServiceTag()->save($tag);
......@@ -51,6 +53,7 @@ class TagController extends AbstractController
}
public function supprimerAction ()
{
$tag = $this->getEvent()->getParam('tag');
......
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<doctrine-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\Db\Tag" table="TAG">
<indexes>
......@@ -17,6 +17,9 @@
<field name="histoModification" type="datetime" column="HISTO_MODIFICATION" nullable="false"/>
<field name="libelleCourt" type="string" column="LIBELLE_COURT" length="50" nullable="false"/>
<field name="libelleLong" type="string" column="LIBELLE_LONG" length="200" nullable="false"/>
<field name="dateDebut" type="datetime" column="DATE_DEBUT" nullable="false"/>
<field name="dateFin" type="datetime" column="DATE_FIN" nullable="false"/>
<many-to-one field="histoModificateur" target-entity="Application\Entity\Db\Utilisateur">
<join-columns>
<join-column name="HISTO_MODIFICATEUR_ID" referenced-column-name="ID"/>
......
......@@ -2,6 +2,7 @@
namespace Application\Entity\Db;
use Laminas\Validator\Date;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;
......@@ -17,6 +18,11 @@ class Tag implements HistoriqueAwareInterface
protected ?string $libelleLong = null;
private ?\DateTime $dateDebut = null;
private ?\DateTime $dateFin = null;
public function getId (): ?int
{
......@@ -24,12 +30,14 @@ class Tag implements HistoriqueAwareInterface
}
public function getCode (): ?string
{
return $this->code;
}
public function setCode (?string $code): Tag
{
$this->code = $code;
......@@ -38,12 +46,37 @@ class Tag implements HistoriqueAwareInterface
}
public function __toString (): string
{
return $this->getLibelleLong() ? : $this->getLibelleCourt();
}
public function getLibelleLong (): ?string
{
return $this->libelleLong;
}
public function setLibelleLong (?string $libelleLong): Tag
{
$this->libelleLong = $libelleLong;
return $this;
}
public function getLibelleCourt (): ?string
{
return $this->libelleCourt;
}
public function setLibelleCourt (?string $libelleCourt): Tag
{
$this->libelleCourt = $libelleCourt;
......@@ -52,22 +85,35 @@ class Tag implements HistoriqueAwareInterface
}
public function getLibelleLong(): ?string
public function getDateDebut (): ?\DateTime
{
return $this->libelleLong;
return $this->dateDebut;
}
public function setLibelleLong(?string $libelleLong): Tag
public function setDateDebut (?\DateTime $dateDebut): Tag
{
$this->libelleLong = $libelleLong;
$this->dateDebut = $dateDebut;
return $this;
}
public function __toString(): string
public function getDateFin (): ?\DateTime
{
return $this->getLibelleLong() ?: $this->getLibelleCourt();
return $this->dateFin;
}
public function setDateFin (?\DateTime $dateFin): Tag
{
$this->dateFin = $dateFin;
return $this;
}
}
......@@ -4,6 +4,7 @@ namespace Application\Form\Tag;
use Application\Entity\Db\Tag;
use Application\Form\AbstractForm;
use Application\Service\Traits\AnneeServiceAwareTrait;
/**
* Description of TagSaisieForm
......@@ -12,14 +13,22 @@ use Application\Form\AbstractForm;
*/
class TagSaisieForm extends AbstractForm
{
use AnneeServiceAwareTrait;
public function init ()
{
$this->spec(Tag::class);
$this->build();
$this->get('libelleCourt')->setLabel('Libellé court');
$this->get('libelleLong')->setLabel('Libellé long');
$this->setLabels([
'libelleCourt' => 'Libellé court',
'libelleLong' => 'Libellé long',
'dateDebut' => 'A partir de',
'dateFin' => 'jusqu\'à',
]);
$this->addSecurity();
$this->addSubmit();
......
<?php
namespace Application\Form\Tag\Traits;
namespace Application\Form\Tag;
use Application\Entity\Db\Tag;
use Application\Form\Tag\TagSaisieForm;
/**
* Description of TagSaisieFormAwareTrait
*
* @author Antony Le Courtes <antony.lecourtes at unicaen.fr>
*/
trait TagSaisieFormAwareTrait
{
protected ?TagSaisieForm $formTagSaisie = null;
protected ?TagSaisieForm $formTag = null;
/**
* @param TagSaisieForm $formTagSaisie
*
* @return self
*/
public function setFormTagSaisie(?TagSaisieForm $formTagSaisie)
public function getFormTag (): ?TagSaisieForm
{
$this->formTagSaisie = $formTagSaisie;
if (!empty($this->formTag)) {
return $this->formTag;
}
return $this;
return \Application::$container->get('FormElementManager')->get(TagSaisieForm::class);
}
public function getFormTagSaisie(): ?TagSaisieForm
/**
* @param TagSaisieForm $formTag
*
* @return self
*/
public function setFormTag (?TagSaisieForm $formTag)
{
if (!empty($this->formTagSaisie)) {
return $this->formTagSaisie;
}
$this->formTag = $formTag;
return \Application::$container->get('FormElementManager')->get(TagSaisieForm::class);
return $this;
}
}
\ No newline at end of file
<?php
namespace Application\Form\Tag;
use Psr\Container\ContainerInterface;
/**
* Description of TagSaisieFormFactory
*
* @author Antony Le Courtes <antony.lecourtes at unicaen.fr>
*/
class TagSaisieFormFactory
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
*
* @return TagSaisieForm
*/
public function __invoke (ContainerInterface $container, $requestedName, $options = null): TagSaisieForm
{
$form = new TagSaisieForm();
/* Injectez vos dépendances ICI */
return $form;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ namespace Application\Service;
use Application\Entity\Db\Tag;
use Doctrine\ORM\QueryBuilder;
use Laminas\Validator\Date;
/**
* Description of TagService
......@@ -24,6 +25,8 @@ class TagService extends AbstractEntityService
return Tag::class;
}
/**
* Retourne l'alias d'entité courante
*
......@@ -34,17 +37,33 @@ class TagService extends AbstractEntityService
return 'tag';
}
public function getListByDate (QueryBuilder $qb = null, $alias = null)
{
[$qb, $alias] = $this->initQuery($qb, $alias);
$qb->andWhere("$alias.histoDestruction is Null");
$qb->andWhere("CURRENT_TIMESTAMP() BETWEEN $alias.dateDebut AND $alias.dateFin");
$qb->addOrderBy("$alias.libelleLong");
return parent::getList($qb, $alias);
}
/**
* Retourne la liste des tags
*
* @param QueryBuilder|null $queryBuilder
*
* @return Tag[]
*/
public function getList (QueryBuilder $qb = null, $alias = null)
{
list($qb, $alias) = $this->initQuery($qb, $alias);
[$qb, $alias] = $this->initQuery($qb, $alias);
$qb->andWhere("$alias.histoDestruction is Null");
$qb->addOrderBy("$alias.libelleLong");
return parent::getList($qb, $alias);
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
/**
* @var $this \Application\View\Renderer\PhpRenderer
* @var $motifNonPaiements \Paiement\Entity\Db\MotifNonPaiement[]
* @var $fr \Application\Entity\Db\Tag
*/
use Application\Provider\Privilege\Privileges;
......@@ -20,6 +21,8 @@ $canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::MOTIF_NON_PAIE
<th style="word-wrap: break-word ; ">Code</th>
<th style="word-wrap: break-word ; ">Libelle Court</th>
<th style="word-wrap: break-word ; ">Libelle Long</th>
<th style="word-wrap: break-word ; ">A partir de</th>
<th style="word-wrap: break-word ; ">Jusqu'à</th>
<?php if ($canEdit) echo '<th>Actions</th>' ?>
</thead>
<tbody>
......@@ -28,6 +31,8 @@ $canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::MOTIF_NON_PAIE
<td style="word-wrap: break-word ; "><?= $fr->getCode() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getLibelleCourt() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getLibelleLong() ?></td>
<td style="word-wrap: break-word ; "><?= ($fr->getDateDebut() instanceof DateTime) ? $fr->getDateDebut()->format('d-m-Y') : '' ?></td>
<td style="word-wrap: break-word ; "><?= ($fr->getDateFin() instanceof DateTime) ? $fr->getDateFin()->format('d-m-Y') : '' ?></td>
<?php if ($canEdit) { ?>
<td style="text-align:center;width:1px;white-space: nowrap">
<a class="mod-ajax" data-submit-reload="true"
......
......@@ -49,40 +49,6 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
protected $editTag = false;
/**
* @return MotifNonPaiement[]
*/
protected function getMotifsNonPaiement()
{
$qb = $this->getServiceMotifNonPaiement()->finderByHistorique();
return $this->getServiceMotifNonPaiement()->getList($qb);
}
/**
* @return TypeIntervention[]
*/
protected function getTypesIntervention()
{
$qb = $this->getServiceTypeIntervention()->finderByContext();
$this->getServiceTypeIntervention()->finderByHistorique($qb);
return $this->getServiceTypeIntervention()->getList($qb);
}
/**
* @return Periode[]
*/
protected function getPeriodes()
{
$qb = $this->getServicePeriode()->finderByHistorique();
$this->getServicePeriode()->finderByEnseignement($qb);
return $this->getServicePeriode()->getList($qb);
}
public function build ()
{
......@@ -180,7 +146,7 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
'options' => [
'label' => "Tag :",
'empty_option' => "Aucun tag",
'value_options' => Util::collectionAsOptions($this->getServiceTag()->getList()),
'value_options' => Util::collectionAsOptions($this->getServiceTag()->getListByDate()),
'disable_inarray_validator' => true,
],
......@@ -228,6 +194,65 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* @return Periode[]
*/
protected function getPeriodes ()
{
$qb = $this->getServicePeriode()->finderByHistorique();
$this->getServicePeriode()->finderByEnseignement($qb);
return $this->getServicePeriode()->getList($qb);
}
/**
* @return TypeIntervention[]
*/
protected function getTypesIntervention ()
{
$qb = $this->getServiceTypeIntervention()->finderByContext();
$this->getServiceTypeIntervention()->finderByHistorique($qb);
return $this->getServiceTypeIntervention()->getList($qb);
}
/**
* @return bool
*/
public function canEditMNP (): bool
{
return $this->editMNP;
}
/**
* @return MotifNonPaiement[]
*/
protected function getMotifsNonPaiement ()
{
$qb = $this->getServiceMotifNonPaiement()->finderByHistorique();
return $this->getServiceMotifNonPaiement()->getList($qb);
}
/**
* @return bool
*/
public function canEditTag (): bool
{
return $this->editTag;
}
/**
* @return bool
*/
......@@ -237,6 +262,7 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* @param bool $viewMNP
*
......@@ -250,14 +276,6 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* @return bool
*/
public function canEditMNP(): bool
{
return $this->editMNP;
}
/**
* @return bool
......@@ -268,6 +286,7 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* @param bool $viewTag
*
......@@ -281,14 +300,6 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* @return bool
*/
public function canEditTag(): bool
{
return $this->editTag;
}
/**
* @param bool $editTag
......@@ -303,6 +314,7 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* @param bool $editMNP
*
......@@ -316,6 +328,7 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
* Should return an array specification compatible with
* {@link Laminas\InputFilter\Factory::createInputFilter()}.
......@@ -391,6 +404,9 @@ class VolumeHoraireSaisieCalendaireForm extends AbstractForm
}
/**
*
*
......@@ -406,21 +422,6 @@ class SaisieCalendaireHydrator implements HydratorInterface
private $data;
private function getVal($key)
{
if (isset($this->data[$key])) {
switch ($key) {
case 'horaire-debut':
case 'horaire-fin':
return DateTimeFromString::run($this->data[$key]);
default:
return $this->data[$key];
}
} else {
return null;
}
}
/**
* Hydrate $object with the provided $data.
......@@ -474,6 +475,24 @@ class SaisieCalendaireHydrator implements HydratorInterface
}
private function getVal ($key)
{
if (isset($this->data[$key])) {
switch ($key) {
case 'horaire-debut':
case 'horaire-fin':
return DateTimeFromString::run($this->data[$key]);
default:
return $this->data[$key];
}
} else {
return null;
}
}
/**
* Extract values from an object
*
......@@ -509,23 +528,19 @@ class SaisieCalendaireHydrator implements HydratorInterface
/* Conversion des dates en objets */
if (isset($data['horaire-debut']) && $data['horaire-debut'] > 0) {
$data['horaire-debut'] = (new \DateTime)->setTimestamp($data['horaire-debut']);
}
else{
} else {
//Pour une meilleure gestion du datetime local, si pas d'horaire de début on set à la date du jour 00:00
$now = new \DateTime();
$now->setTime(0, 0);
$data['horaire-debut'] = $now;
}
if (isset($data['horaire-fin']) && $data['horaire-fin'] > 0) {
$data['horaire-fin'] = (new \DateTime)->setTimestamp($data['horaire-fin']);
}
else{
} else {
//Pour une meilleure gestion du datetime local, si pas d'horaire de début on set à la date du jour 00:00
$now = new \DateTime();
$now->setTime(0, 0);
$data['horaire-fin'] = $now;
}
return $data;
......
......@@ -46,40 +46,6 @@ class VolumeHoraireSaisieForm extends AbstractForm
protected $editTag = false;
/**
* @return MotifNonPaiement[]
*/
protected function getMotifsNonPaiement()
{
$qb = $this->getServiceMotifNonPaiement()->finderByHistorique();
return $this->getServiceMotifNonPaiement()->getList($qb);
}
/**
* @return TypeIntervention[]
*/
protected function getTypesIntervention()
{
$qb = $this->getServiceTypeIntervention()->finderByContext();
$this->getServiceTypeIntervention()->finderByHistorique($qb);
return $this->getServiceTypeIntervention()->getList($qb);
}
/**
* @return Periode[]
*/
protected function getPeriodes()
{
$qb = $this->getServicePeriode()->finderByHistorique();
$this->getServicePeriode()->finderByEnseignement($qb);
return $this->getServicePeriode()->getList($qb);
}
public function build ()
{
......@@ -133,7 +99,7 @@ class VolumeHoraireSaisieForm extends AbstractForm
'options' => [
'label' => "Tag :",
'empty_option' => "Aucun tag",
'value_options' => Util::collectionAsOptions($this->getServiceTag()->getList()),
'value_options' => Util::collectionAsOptions($this->getServiceTag()->getListByDate()),
],
'attributes' => [
'value' => "",
......@@ -178,6 +144,39 @@ class VolumeHoraireSaisieForm extends AbstractForm
}
/**
* @return bool
*/
public function canEditMNP (): bool
{
return $this->editMNP;
}
/**
* @return MotifNonPaiement[]
*/
protected function getMotifsNonPaiement ()
{
$qb = $this->getServiceMotifNonPaiement()->finderByHistorique();
return $this->getServiceMotifNonPaiement()->getList($qb);
}
/**
* @return bool
*/
public function canEditTag (): bool
{
return $this->editTag;
}
/**
* @return bool
*/
......@@ -187,6 +186,7 @@ class VolumeHoraireSaisieForm extends AbstractForm
}
/**
* @param bool $viewMNP
*
......@@ -200,14 +200,6 @@ class VolumeHoraireSaisieForm extends AbstractForm
}
/**
* @return bool
*/
public function canEditMNP(): bool
{
return $this->editMNP;
}
/**
* @param bool $editMNP
......@@ -221,6 +213,8 @@ class VolumeHoraireSaisieForm extends AbstractForm
return $this;
}
/**
* @return bool
*/
......@@ -230,6 +224,7 @@ class VolumeHoraireSaisieForm extends AbstractForm
}
/**
* @param bool $viewTag
*
......@@ -243,14 +238,6 @@ class VolumeHoraireSaisieForm extends AbstractForm
}
/**
* @return bool
*/
public function canEditTag(): bool
{
return $this->editTag;
}
/**
* @param bool $editTag
......@@ -265,6 +252,7 @@ class VolumeHoraireSaisieForm extends AbstractForm
}
/**
* Should return an array specification compatible with
* {@link Laminas\InputFilter\Factory::createInputFilter()}.
......@@ -297,9 +285,38 @@ class VolumeHoraireSaisieForm extends AbstractForm
],
];
}
/**
* @return TypeIntervention[]
*/
protected function getTypesIntervention ()
{
$qb = $this->getServiceTypeIntervention()->finderByContext();
$this->getServiceTypeIntervention()->finderByHistorique($qb);
return $this->getServiceTypeIntervention()->getList($qb);
}
/**
* @return Periode[]
*/
protected function getPeriodes ()
{
$qb = $this->getServicePeriode()->finderByHistorique();
$this->getServicePeriode()->finderByEnseignement($qb);
return $this->getServicePeriode()->getList($qb);
}
}
/**
*
*
......@@ -315,15 +332,6 @@ class SaisieHydrator implements HydratorInterface
private $data;
private function getVal($key)
{
if (isset($this->data[$key])) {
return $this->data[$key];
} else {
return null;
}
}
/**
* Hydrate $object with the provided $data.
......@@ -365,6 +373,18 @@ class SaisieHydrator implements HydratorInterface
}
private function getVal ($key)
{
if (isset($this->data[$key])) {
return $this->data[$key];
} else {
return null;
}
}
/**
* Extract values from an object
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment