Ejemplo n.º 1
0
 /**
  * @param RM_Unit_Row $original
  * @param RM_Unit_Row $copy
  * @return void
  */
 function copyInformation(RM_Unit_Row $original, RM_Unit_Row $copy)
 {
     $unitExtrasModel = new RM_UnitExtras();
     $unitExtras = $unitExtrasModel->getByUnit($original);
     foreach ($unitExtras as $unitExtra) {
         $unitExtrasModel->insert(array('unit_id' => $copy->getId(), 'extra_id' => $unitExtra->extra_id));
     }
 }
Ejemplo n.º 2
0
 /**
  * This checks if a unit/units is available for the selected dates/time
  *
  * @param   RM_Reservation_Period      $reservationPeriod  The selected date/time periods
  * @param   RM_Unit_Row      $unitObject  the unit object
  * @return 	Zend_Db_Table_Rowset   containing only reserved units ids
  */
 private function _isAvailable(RM_Reservation_Period $reservationPeriod, RM_Unit_Row $unit = null)
 {
     $sql = "SELECT\r\n                rd.unit_id as id\r\n            FROM\r\n                rm_reservations AS r\r\n            LEFT OUTER JOIN\r\n                rm_reservation_details rd ON rd.reservation_id=r.id\r\n            WHERE\r\n                ((\r\n                    UNIX_TIMESTAMP(rd.start_datetime)<UNIX_TIMESTAMP('" . $reservationPeriod->getEnd()->toMySQL() . "')\r\n                        AND\r\n                    UNIX_TIMESTAMP(rd.start_datetime)>=UNIX_TIMESTAMP('" . $reservationPeriod->getStart()->toMySQL() . "')\r\n                ) OR (\r\n                    UNIX_TIMESTAMP(rd.end_datetime)>UNIX_TIMESTAMP('" . $reservationPeriod->getStart()->toMySQL() . "')\r\n                        AND\r\n                    UNIX_TIMESTAMP(rd.end_datetime)<=UNIX_TIMESTAMP('" . $reservationPeriod->getEnd()->toMySQL() . "')\r\n                ) OR (\r\n                    UNIX_TIMESTAMP(rd.start_datetime)<=UNIX_TIMESTAMP('" . $reservationPeriod->getStart()->toMySQL() . "')\r\n                        AND\r\n                    UNIX_TIMESTAMP(rd.end_datetime)>=UNIX_TIMESTAMP('" . $reservationPeriod->getEnd()->toMySQL() . "')\r\n                ))\r\n                AND\r\n                    r.confirmed = '1'\r\n                ";
     if ($unit !== null) {
         $unitID = $unit->getId();
         $sql .= "AND\r\n                rd.unit_id = '{$unitID}'\r\n            ";
     }
     return $this->_getBySQL($sql);
 }
Ejemplo n.º 3
0
 /**
  * Return how many reservations start (only starts) 
  * in input reservation period
  *
  * @param RM_Unit_Row $unit
  * @param RM_Reservation_Period $period
  * @return int
  */
 public function getReservationCount(RM_Unit_Row $unit, RM_Reservation_Period $period)
 {
     $sql = "\r\n            SELECT\r\n                *\r\n            FROM\r\n                rm_reservation_details\r\n            WHERE\r\n                (\r\n                UNIX_TIMESTAMP(start_datetime)<=UNIX_TIMESTAMP('" . $period->getEnd()->toMySQL() . "')\r\n                    AND\r\n                UNIX_TIMESTAMP(start_datetime)>=UNIX_TIMESTAMP('" . $period->getStart()->toMySQL() . "')\r\n                )\r\n                    AND\r\n                unit_id = '" . $unit->getId() . "'";
     $value = $this->_getBySQL($sql)->count();
     return $value;
 }
Ejemplo n.º 4
0
 /**
  * Return reservation details for one unit
  *
  * @param RM_Unit_Row $unit
  * @return RM_Reservation_Details|null
  */
 function getDetails(RM_Unit_Row $unit)
 {
     if (isset($this->_details[$unit->getId()]) == false) {
         return null;
     }
     return $this->_details[$unit->getId()];
 }