public function doClean($values)
 {
     if (is_null($values)) {
         $values = array();
     }
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
     }
     if (is_null($values['date'])) {
         $valid = true;
     } else {
         $start = $values['date'];
         $stop = date('Y-m-d H:i:s', strtotime($start . ' +' . $values['duration'] . ' minute'));
         $roomprofileId = $values['RoomProfile_id'];
         $roomprofile = RoomprofilePeer::retrieveByPk($roomprofileId);
         if (is_null($roomprofile)) {
             $valid = true;
         } else {
             $roomId = $roomprofile->getRoomId();
             $valid = ReservationPeer::checkDayperiods($start, $stop, $roomId);
             if ($valid) {
                 $valid = ReservationPeer::checkCloseperiods($start, $stop, $roomId);
             }
         }
     }
     if (!$valid) {
         $error = new sfValidatorError($this, 'invalid', array());
         if ($this->getOption('throw_global_error')) {
             throw $error;
         }
         throw new sfValidatorErrorSchema($this, array('date' => $error));
     }
     return $values;
 }
Exemple #2
0
 public function checkDayperiods()
 {
     return ReservationPeer::checkDayperiods($this->getDate(), $this->getStopDate(), $this->getRoomprofile()->getRoomId());
 }