rendered paste body<?php
class MakeRate_Vhelper extends Vframe_Helper
{
public function count($iTime, $iTimeSlot, $sService, $bTimeNotice = true)
{
// 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'];
// 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' => -9,
'wed' => -1,
'thu' => 0,
'fri' => 2,
'sat' => 4,
'sun' => 2,
);
protected $aNoticePercents = array
(
'1' => 20,
'1-3' => 10,
'3-7' => 0,
'' => -5,
);
}
?>