예제 #1
0
 public function isValid()
 {
     global $systemConfiguration;
     $this->errors = array();
     if (strlen(trim($this->dateFormat)) == 0) {
         $this->setError(SEARCH_CRITERIA_DATE_FORMAT_INVALID);
         return false;
     }
     if (strlen(trim($this->checkInDate)) == 0) {
         $this->setError(SEARCH_CRITERIA_CHECK_IN_REQ);
         return false;
     } else {
         if (!DateUtils::isValidDate($this->checkInDate, $systemConfiguration->getDateFormat())) {
             $this->setError(SEARCH_CRITERIA_CHECK_IN_INVALID);
             return false;
         }
     }
     $currentDate = getdate();
     if (!DateUtils::getNumericDate($this->checkInDate, $systemConfiguration->getDateFormat()) < intval($currentDate['year'] . $currentDate['mon'] . $currentDate['mday'])) {
         $this->setError(SEARCH_CRITERIA_CHECK_IN_BEFORE_TODAY);
         return false;
     }
     if (strlen(trim($this->checkOutDate)) == 0) {
         $this->setError(SEARCH_CRITERIA_CHECK_OUT_REQ);
         return false;
     } else {
         if (!DateUtils::isValidDate($this->checkOutDate, $systemConfiguration->getDateFormat())) {
             $this->setError(SEARCH_CRITERIA_CHECK_OUT_INVALID);
             return false;
         }
     }
     if (intval(DateUtils::getNumericDate($this->checkInDate)) > intval(DateUtils::getNumericDate($this->checkOutDate))) {
         $this->setError(SEARCH_CRITERIA_IN_BEFORE_OUT);
         return false;
     } else {
         if ($this->getNightCountPrivate(true) < $systemConfiguration->getMinimumNightCount()) {
             $this->setError(SEARCH_CRITERIA_MIN_BOOKING_PART_1 . $systemConfiguration->getMinimumNightCount() . SEARCH_CRITERIA_MIN_BOOKING_PART_2);
             return false;
         }
     }
     if (strlen(trim($this->adultsCount)) == 0) {
         $this->setError(SEARCH_CRITERIA_ADULTS_REQ);
         return false;
     } else {
         if (!is_int($this->adultsCount)) {
             $this->setError(SEARCH_CRITERIA_ADULTS_INVALID);
             return false;
         } else {
             if (intval($this->adultsCount) <= 0) {
                 $this->setError(SEARCH_CRITERIA_ADULTS_INVALID);
                 return false;
             }
         }
     }
     if (strlen(trim($this->childrenCount)) == 0) {
         $this->setError(SEARCH_CRITERIA_ADULTS_REQ);
         return false;
     } else {
         if (!is_int($this->childrenCount)) {
             $this->setError(SEARCH_CRITERIA_ADULTS_INVALID);
             return false;
         }
     }
     return sizeof($this->errors) == 0;
 }