Skip to content
Snippets Groups Projects
Commit ca7e9de4 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Début de mise en place du form de saisie calendaire

(en cours)
parent cf61bc5f
No related branches found
No related tags found
No related merge requests found
...@@ -7,27 +7,34 @@ ...@@ -7,27 +7,34 @@
* @var $sl \Zend\ServiceManager\ServiceLocatorInterface * @var $sl \Zend\ServiceManager\ServiceLocatorInterface
*/ */
use Application\Entity\VolumeHoraireListe; use Zend\Form\Form;
use Application\Hydrator\VolumeHoraire\ListeFilterHydrator;
use Application\Service\ServiceService;
/** @var ServiceService $ss */ var_dump($_POST);
$ss = $sl->get(ServiceService::class);
$service = $ss->get(24519); $horaire = isset($_POST['horaire']) ? $_POST['horaire'] : null;
$vhl = new VolumeHoraireListe($service); $hd = $horaire;
//$hd = null;//'32/05/2017';
$sl = $vhl->getSousListes([ $form = new Form();
$vhl::FILTRE_HORAIRE_DEBUT, $form->add([
$vhl::FILTRE_HORAIRE_FIN, 'type' => 'DateTime',
$vhl::FILTRE_MOTIF_NON_PAIEMENT 'name' => 'horaire',
'options' => [
'label' => 'Horaire',
'format' => 'd/m/Y à H:i',
],
]); ]);
$form->add([
'name' => 'submit',
'type' => 'Submit',
'attributes' => [
'value' => 'Enregistrer',
'title' => "Enregistrer",
'class' => 'btn btn-primary',
],
]);
$form->get('horaire')->setValue($hd);
$h = new ListeFilterHydrator(); echo $this->form($form);
foreach( $sl as $vhl ){
$d = $h->extractInts($vhl);
var_dump($d);
}
\ No newline at end of file
...@@ -137,6 +137,16 @@ class VolumeHoraireController extends AbstractController ...@@ -137,6 +137,16 @@ class VolumeHoraireController extends AbstractController
$vhlph->hydrate($this->params()->fromQuery() + $this->params()->fromPost(), $volumeHoraireListe); $vhlph->hydrate($this->params()->fromQuery() + $this->params()->fromPost(), $volumeHoraireListe);
$form = $this->getFormVolumeHoraireSaisieCalendaire(); $form = $this->getFormVolumeHoraireSaisieCalendaire();
$form->bindRequestSave($volumeHoraireListe, $this->getRequest(), function(VolumeHoraireListe $vhl){
try {
//$this->getServiceTypeDotation()->save($td);
$this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
} catch (\Exception $e) {
$e = DbException::translate($e);
$this->flashMessenger()->addErrorMessage($e->getMessage());
}
});
$title = "Modification d'une ligne de service"; $title = "Modification d'une ligne de service";
return compact('title', 'form'); return compact('title', 'form');
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
namespace Application\Form\VolumeHoraire; namespace Application\Form\VolumeHoraire;
use Application\Entity\VolumeHoraireListe;
use Application\Filter\FloatFromString; use Application\Filter\FloatFromString;
use Application\Filter\StringFromFloat;
use Application\Form\AbstractForm; use Application\Form\AbstractForm;
use Application\Hydrator\VolumeHoraire\ListeFilterHydrator;
use Application\Service\Traits\MotifNonPaiementServiceAwareTrait; use Application\Service\Traits\MotifNonPaiementServiceAwareTrait;
use UnicaenApp\Util;
use Zend\Form\Element\Hidden; use Zend\Form\Element\Hidden;
use Zend\Stdlib\Hydrator\HydratorInterface;
/** /**
* Description of Saisie * Description of Saisie
...@@ -38,15 +39,17 @@ class SaisieCalendaire extends AbstractForm ...@@ -38,15 +39,17 @@ class SaisieCalendaire extends AbstractForm
$this->setAttribute('method', 'post') $this->setAttribute('method', 'post')
->setAttribute('class', 'volume-horaire') ->setAttribute('class', 'volume-horaire')
; ;
$hydrator = new SaisieCalendaireHydrator();
$this->setHydrator($hydrator);
$this->add([ $this->add([
'type' => 'UnicaenApp\Form\Element\DateTime', 'type' => 'DateTime',
'name' => 'horaire-debut', 'name' => 'horaire-debut',
'options' => [ 'options' => [
'label' => 'Horaire de début', 'label' => 'Horaire de début',
'format' => Util::DATETIME_FORMAT,
], ],
]); ]);
$this->get('horaire-debut')->setIncludeTime(true);
$this->add([ $this->add([
'name' => 'heures', 'name' => 'heures',
...@@ -111,26 +114,6 @@ class SaisieCalendaire extends AbstractForm ...@@ -111,26 +114,6 @@ class SaisieCalendaire extends AbstractForm
/* Associe une entity VolumeHoraireList au formulaire */
public function bind($object, $flags = 17)
{
/* @var $object \Application\Entity\VolumeHoraireListe */
$vhlph = new ListeFilterHydrator();
$data = $vhlph->extract($object);
$data['service'] = $object->getService()->getId();
$data['heures'] = StringFromFloat::run($object->getHeures(), false);
if (!$this->getViewMNP()) {
$this->remove('motif-non-paiement');
} else {
$data['motif-non-paiement'] = $object->getMotifNonPaiement() ? $object->getMotifNonPaiement()->getId() : 0;
}
$this->setData($data);
}
/** /**
* Should return an array specification compatible with * Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}. * {@link Zend\InputFilter\Factory::createInputFilter()}.
...@@ -154,56 +137,49 @@ class SaisieCalendaire extends AbstractForm ...@@ -154,56 +137,49 @@ class SaisieCalendaire extends AbstractForm
], ],
]; ];
} }
/**
* @return boolean
*/
public function getViewMNP()
{
return $this->viewMNP;
} }
/** /**
* @param boolean $viewMNP
* *
* @return Saisie *
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/ */
public function setViewMNP($viewMNP) class SaisieCalendaireHydrator implements HydratorInterface
{ {
$this->viewMNP = $viewMNP;
return $this;
}
/** /**
* @return boolean * Hydrate $object with the provided $data.
*
* @param array $data
* @param VolumeHoraireListe $object
*
* @return object
*/ */
public function getEditMNP() public function hydrate(array $data, $object)
{ {
return $this->editMNP; $object->setHoraireDebut(\DateTime::createFromFormat(Util::DATETIME_FORMAT, $data['horaire-debut']) );
return $object;
} }
/** /**
* @param boolean $editMNP * Extract values from an object
*
* @param VolumeHoraireListe $object
* *
* @return Saisie * @return array
*/ */
public function setEditMNP($editMNP) public function extract($object)
{ {
$this->editMNP = $editMNP; $data = [
'horaire-debut' => $object->getHoraireDebut(),
];
if (!$editMNP && $this->has('motif-non-paiement')) { return $data;
$this->remove('motif-non-paiement');
} }
return $this;
}
} }
\ No newline at end of file
...@@ -102,6 +102,11 @@ $(function () ...@@ -102,6 +102,11 @@ $(function ()
WidgetInitializer.includeCss(Url('css/droits.css')); WidgetInitializer.includeCss(Url('css/droits.css'));
}); });
/* DateTime Picker */
WidgetInitializer.add('bootstrap-datetimepicker', 'bootstrapDatetimepicker', function(){
WidgetInitializer.includeJs(Url('vendor/unicaen/app/js/bootstrap-datetimepicker.min.js'));
WidgetInitializer.includeCss(Url('vendor/unicaen/app/css/bootstrap-datetimepicker.min.css'));
});
// installation de tooltip Bootstrap sur les icônes d'information (i) // installation de tooltip Bootstrap sur les icônes d'information (i)
$(".info-icon").tooltip(); $(".info-icon").tooltip();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment