Beispiel #1
0
 public function configure()
 {
     $nbSalles = count(SalleTable::getInstance()->getAllSalles()->execute()) * 20;
     $this->setWidgets(array('date' => new sfWidgetFormInputText(array(), array('class' => 'date')), 'salles' => new sfWidgetFormDoctrineChoice(array('model' => 'Salle', 'multiple' => true), array('style' => 'height : ' . $nbSalles . 'px'))));
     $this->setValidators(array('date' => new sfValidatorString(array('required' => true)), 'salles' => new sfValidatorDoctrineChoice(array('model' => 'Salle', 'required' => true))));
     $this->widgetSchema->setNameFormat('CreneauDay[%s]');
 }
Beispiel #2
0
 public function configure()
 {
     $nbSalles = count(SalleTable::getInstance()->getAllSalles()->execute()) * 20;
     $this->setWidgets(array('date' => new sfWidgetFormInputText(array(), array('class' => 'date')), 'debut' => new sfWidgetFormTime(array(), array('style' => 'width : 100px')), 'fin' => new sfWidgetFormTime(array(), array('style' => 'width : 100px')), 'salles' => new sfWidgetFormDoctrineChoice(array('model' => 'salle', 'multiple' => true), array('style' => 'height : ' . $nbSalles . 'px'))));
     $this->setValidators(array('date' => new sfValidatorString(array('required' => true)), 'debut' => new sfValidatorTime(array('required' => true)), 'fin' => new sfValidatorTime(array('required' => true)), 'salles' => new sfValidatorDoctrineChoice(array('model' => 'salle', 'required' => true))));
     $hours = [sprintf("%02d", 8), sprintf("%02d", 9), 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
     $minutes = [sprintf("%02d", 0), 30];
     $this->getWidget('debut')->addOption('minutes', array_combine($minutes, $minutes));
     $this->getWidget('fin')->addOption('minutes', array_combine($minutes, $minutes));
     $this->getWidget('debut')->addOption('hours', array_combine($hours, $hours));
     $this->getWidget('fin')->addOption('hours', array_combine($hours, $hours));
     $this->widgetSchema->setNameFormat('CreneauHour[%s]');
 }
Beispiel #3
0
 public function executeFormNew(sfWebRequest $request)
 {
     $this->idSalle = $request->getUrlParameter("id", -1);
     $this->userIdentified = false;
     if ($this->getUser()->isAuthenticated()) {
         $this->userIdentified = true;
         $this->UserID = $this->getUser()->getGuardUser()->getId();
         // création du tableua à passer au constructeur du formulaire de réservation
         $values = array('UserID' => $this->UserID, 'idSalle' => $this->idSalle);
         $this->form = new ReservationForm(array(), $values);
         // TO DO : Voir si la salle appartient au BDE ou non et en fonction donner possiblité de rentrer une asso ou non.
         $PoleId = SalleTable::getInstance()->getSalleById($this->idSalle)->fetchOne()->getIdPole();
         if ($PoleId == 1) {
             $this->form->getWidget('id_asso')->setOption('add_empty', true);
         }
         // valeur par défaut pour les champs cachés.
         $this->form->setDefault('id_salle', $this->idSalle);
         $this->form->setDefault('id_user_reserve', $this->getUser()->getGuardUser()->getId());
         $this->form->setDefault('estvalide', 0);
         // A VOIR si 2 semaines avant ou pas
         $this->ok = false;
         $this->afficherErreur = false;
     }
 }
 public function configure()
 {
     if ($this->getOption('PoleId') != 1) {
         // salle spécifique à un pôle.
         // préparation du tableau associatif regroupant les id et les noms des assos de l'utilisateur pour le pôle de la salle concernée
         $choices = array();
         $c = AssoTable::getInstance()->getMyAssosNameByIdSalle($this->getOption('UserID'), $this->getOption('idSalle'))->execute();
         foreach ($c as $asso) {
             $choices = $choices + array($asso->getId() => $asso->getName());
         }
         // Préparation des données pour la suite de l'algo
         $Salle = SalleTable::getInstance()->getSalleById($this->getOption('idSalle'))->fetchOne();
         $PoleLogin = $Salle->getPole()->getAssoId();
         $PoleName = AssoTable::getInstance()->getOneById($PoleLogin)->fetchOne()->getName();
         $PoleId = AssoTable::getInstance()->getOneById($PoleLogin)->fetchOne()->getId();
         $myAssos = AssoTable::getInstance()->getMyAssos($this->getOption('UserID'))->execute();
         // Constitution du tableau d'ID des assos de l'utilisateur.
         $ma = array();
         foreach ($myAssos as $a) {
             $ma = $ma + array($a->getId() => $a->getName());
         }
         // Si l'utilisateur appartient au pôle, on ajoute le pôle aux choix possibles.
         if (in_array($PoleName, $ma)) {
             $choices = $choices + array($PoleId => $PoleName);
         }
         $this->widgetSchema['id_asso'] = new sfWidgetFormChoice(array('choices' => $choices));
     } else {
         $choices = array();
         $myAssos = AssoTable::getInstance()->getMyAssos($this->getOption('UserID'))->execute();
         // Constitution du tableau d'ID des assos de l'utilisateur.
         $ma = array();
         foreach ($myAssos as $a) {
             $ma = $ma + array($a->getId() => $a->getName());
         }
         $ma = $ma + array("" => "");
         $this->widgetSchema['id_asso'] = new sfWidgetFormChoice(array('choices' => $ma));
     }
     $this->widgetSchema['id_user_valid'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['id_salle'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['id_user_reserve'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['estvalide'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['date'] = new sfWidgetFormDate(array('format' => '%day%/%month%/%year%', 'can_be_empty' => false));
     $this->widgetSchema['heuredebut'] = new sfWidgetFormTime(array('can_be_empty' => false));
     $this->setValidators(array('id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)), 'id_user_valid' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UserValide'), 'required' => false)), 'id_user_reserve' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UserReserve'))), 'id_asso' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Asso')), array('required' => 'Veuillez rentrer une association.')), 'id_salle' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Salle'))), 'date' => new sfValidatorDate(), 'heuredebut' => new sfValidatorTime(array('required' => false)), 'heurefin' => new sfValidatorTime(array('required' => false)), 'allday' => new sfValidatorBoolean(), 'activite' => new sfValidatorString(array('max_length' => 255)), 'estvalide' => new sfValidatorBoolean(), 'commentaire' => new sfValidatorString(array('required' => false))));
     $types = array('Réunion' => 'Réunion', 'Logistique' => 'Logistique', 'Autre' => 'Autre');
     $this->widgetSchema['activite'] = new sfWidgetFormChoice(array('choices' => $types));
     $years = range(date('Y'), date('Y') + 2);
     $this->getWidget('date')->addOption('years', array_combine($years, $years));
     $lminutes = array(0, 30);
     $minutes = array(sprintf("%02d", 0), 30);
     $hours = array(sprintf("%02d", 8), sprintf("%02d", 9), 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);
     $this->getWidget('heuredebut')->addOption('minutes', array_combine($lminutes, $minutes));
     $this->getWidget('heuredebut')->addOption('hours', array_combine(range(8, 23), $hours));
     $this->getWidget('heurefin')->addOption('minutes', array_combine($lminutes, $minutes));
     $this->getWidget('heurefin')->addOption('hours', array_combine(range(8, 23), $hours));
     $this->getWidget('date')->setLabel('Date:');
     $this->getWidget('heuredebut')->setLabel('Créneau:');
     $this->getWidget('activite')->setLabel('Activité:');
     $this->getWidget('id_asso')->setLabel('Association:');
     $this->getWidget('allday')->setLabel('Jour entier:');
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorCallback(array('callback' => array($this, 'checkTempsMinDeReservation'))), new sfValidatorCallback(array('callback' => array($this, 'checkPeutReserver'))), new sfValidatorCallback(array('callback' => array($this, 'checkCreneauDansLePasse'))), new sfValidatorCallback(array('callback' => array($this, 'checkCreneauLibre'))), new sfValidatorCallback(array('callback' => array($this, 'checkLimiteMax'))), new sfValidatorCallback(array('callback' => array($this, 'checkJourLibre'))), new sfValidatorCallback(array('callback' => array($this, 'checkHeureDebutAvantHeureFin'))))));
 }
Beispiel #5
0
 public function executeFormUpdate(sfWebRequest $request)
 {
     if (!$request->isXmlHttpRequest()) {
         $this->forward404Unless(false);
     }
     $idSalle = $request->getParameter("idSalle", -1);
     $UserID = $request->getParameter("UserID", -1);
     $idResa = intval($request->getParameter("idResa", -1));
     $reservation = ReservationTable::getInstance()->getReservationById($idResa)->fetchOne();
     // On a pas l'id de la salle
     // Donc on va la chercher via la reservation
     if ($idSalle == -1) {
         $idSalle = $reservation->getSalle()->getId();
     }
     $PoleId = SalleTable::getInstance()->getSalleById($idSalle)->fetchOne()->getIdPole();
     $SalleName = SalleTable::getInstance()->getSalleById($idSalle)->fetchOne()->getName();
     // création du tableau à passer au constructeur du formulaire de réservation
     $values = array('UserID' => $UserID, 'idSalle' => $idSalle, 'PoleId' => $PoleId, 'SalleName' => $SalleName);
     $this->form = new ReservationForm($reservation, $values);
     //$PoleId= SalleTable::getInstance()->getSalleById($idSalle)->fetchOne()->getIdPole();
     $this->form->setDefault('estvalide', 0);
     $this->ok = false;
     $this->afficherErreur = false;
     return $this->renderPartial('reservation/formUpdate', array('form' => $this->form, 'idSalle' => $idSalle, 'PoleId' => $PoleId, 'SalleName' => $SalleName));
 }
Beispiel #6
0
 public function executeStatSalle(sfWebRequest $request)
 {
     $this->salles = SalleTable::getInstance()->getAllSalles()->execute();
     $this->statSalles = SalleTable::getInstance()->getStatSalle()->execute();
 }