示例#1
0
 /**
  * Calculate total price for one unit
  *
  * @param RM_Prices_Information $information
  * @param bool $byStep - if true, the result will be in array (0 => array('step' => RM_Date, 'price' => float))
  */
 public function getTotalUnitPrice($information, $byStep = false)
 {
     $days = $information->getPeriod()->getDays();
     $total = 0;
     $totalDays = array();
     $daysNumber = count($days);
     foreach ($days as $day) {
         $price = $this->getDayPrice($day, $daysNumber, $information->getUnit(), $information->getPersons(), $information->getPeriod()->getStart());
         if ($byStep) {
             $totalDays[] = array('step' => clone $day, 'price' => RM_Environment::getInstance()->roundPrice($price));
         } else {
             $total += $price;
         }
     }
     if ($byStep) {
         return $totalDays;
     } else {
         return RM_Environment::getInstance()->roundPrice($total);
     }
 }
示例#2
0
 /**
  * Returns the lowest price of a unit over a given period
  *
  * @param $information RM_Prices_Information - information object,
  * contains all needed information about unit reservation:
  * unit,
  * start date,
  * end date,
  * number of persons
  * etc.
  *
  * @return float
  */
 public function getLowestUnitPrice(RM_Prices_Information $information)
 {
     $priceSystem = $this->_getPriceSystem($information->getUnit());
     if ($priceSystem == null) {
         return null;
     }
     return $priceSystem->getLowestUnitPrice($information);
 }