public function getPricePlansForDates($fromDate, $toDate) { return RoomPricePlan::fetchAllFromDbForRoomAndDates($this->id, $fromDate, $toDate); }
public function isValid() { $this->errors = array(); if (strlen(trim($this->roomId)) == 0) { $this->setError("Room id cannot be empty"); } if ($this->startDate == NULL && !$this->isDefault) { $this->setError("Start date name cannot be empty"); } if ($this->endDate == NULL && !$this->isDefault) { $this->setError("End date name cannot be empty"); } if (!is_float($this->price)) { $this->setError("Price is invalid"); } if ($this->price <= 0) { $this->setError("Price must be greater than zero"); } if (!is_float($this->extraBedPrice)) { $this->setError("Extra bed price is invalid"); } if ($this->extraBedPrice < 0) { $this->setError("Extra bed price must be greater than zero"); } if (sizeof($this->errors) == 0) { $existingPricePlans = RoomPricePlan::fetchAllFromDbForRoomAndDates($this->roomId, $this->startDate, $this->endDate); foreach ($existingPricePlans as $existingPricePlan) { if (!$existingPricePlan->isDefault && $existingPricePlan->id != $this->id) { $this->setError("Plan whose dates overlap already exists"); break; } } } return sizeof($this->errors) == 0; }