All pastes #796750 Raw Edit

Mine

public php v1 · immutable
#796750 ·published 2007-11-25 11:02 UTC
rendered paste body
<?phpclass MakeRate_Vhelper extends Vframe_Helper{  public function count($iTime, $iTimeSlot, $sService, $bTimeNotice = true, $mLength = null)  {    // base rate for services    $oConfig = new Vframe_Config('Services');    $aConfig = $oConfig->dump();        $iPrice = $aConfig[$sService]['rate'];        // add day modifier    $iPrice += $this->aDaysModifiers[strtolower(date('D', $iTime))];        // rate by timeslots    $oConfig = new Vframe_Config('TimeSlots');    $aConfig = $oConfig->dump();        $iPrice += $aConfig[$iTimeSlot]['rate'];        // lengths    if($mLength !== null)    {      $iLengthRate = false;      $iLength = urldecode($iLength); // parse varible      $sLengthPreg = '/^(.*?)-(.*?)$/';            // load configuration      $oLengths = new Vframe_Config('Lengths');      $aLengths = $oLengths->dump();            if(preg_match($sLengthPreg, $mLength, $aLengthsParsed) && isset($aLengths[$mLength]['rate']))        $iLengthRate = $aLengths[$mLength]['rate'];      elseif(is_numeric($mLength))      {        foreach($aLengths as $sLengthKey => $aRow)        {          if(preg_match($sLengthPreg, $sLengthKey, $aLengthsParsed))          {            $iMin = $aLengthsParsed[1];            $iMax = $aLengthsParsed[2];                        if($mLength > $iMin && $mLength <= $iMax)              $iLengthRate = $aRow['rate'];          }        }      }            $iPrice += $iLengthRate;    }        // notices percents    if($bTimeNotice)    {      $iDaysLeft = floor(($iTime - time()) / 3600 / 24);            if($iDaysLeft < 1)                  $iNotifyModifier = 1.2;      elseif($this->_b($iDaysLeft, 1, 3)) $iNotifyModifier = 1.1;      elseif($this->_b($iDaysLeft, 3, 7)) $iNotifyModifier = 1;      else                                $iNotifyModifier = -1.05;            $iPrice = round($iPrice * $iNotifyModifier, 2);    }        // ok, return :)    return $iPrice;  }    protected function _b($iInt, $iA, $iB)  {    return ($iInt >= $iA && $iInt <= $iB);  }    protected $aDaysModifiers = array  (    'mon' => 0,    'tue' => -3,    'wed' => -1,    'thu' => 0,    'fri' => 2,    'sat' => 4,    'sun' => 2,  );    protected $aNoticePercents = array  (    '1' => 20,    '1-3' => 10,    '3-7' => 0,    '' => -5,  );}?>