Created
November 9, 2016 02:10
-
-
Save iBasit/d33ac5f682dcf25e463887ca5458908b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @var Vehicle $vehicle | |
*/ | |
$vehicle = false; | |
foreach ($user->getVehicles() as $userVehicle) | |
{ | |
if ($userVehicle->getType() == $selectedVehicleType) | |
{ | |
$vehicle = $userVehicle; | |
break; | |
} | |
} | |
if (!$vehicle) | |
return 'invalid [VT]!'; | |
$totalPrice = 0; | |
$isWeekday = $param->isWeekday(); | |
$pricing = $user->getPricing(); | |
$miles = ($param->getMiles() >= 5) ? $param->getMiles() : 5; | |
$hours = ($vehicle->getMinHours() > $param->getHour()) ? $vehicle->getMinHours() : $param->getHour(); | |
// per hour | |
$perHour = $isWeekday ? $vehicle->getPerHourWeekday() : $vehicle->getPerHourWeekend(); | |
$perMile = $isWeekday ? $vehicle->getPerMileWeekday() : $vehicle->getPerMileWeekend(); | |
$perMen = $isWeekday ? $pricing->getPerMenWeekday() : $pricing->getPerMenWeekend(); | |
$totalPrice += ($perHour * $hours); | |
$totalPrice += ($perMile * $miles); | |
if ($param->getMen()) | |
$totalPrice += ($pricing->isDiscountDriverHelpFree() && $param->getMen() == 1) ? 0 : ($perMen * ($param->getMen() * $hours)); | |
if ($param->isCongestion() && $pricing->getFeeCongestion()) | |
$totalPrice += $pricing->getFeeCongestion(); | |
if ($param->getStair() && $param->getStair() <= 5 && $pricing->getPerStairFlight()) | |
$totalPrice += $param->getStair() * $pricing->getPerStairFlight(); | |
if ($param->getExtraStops() && $pricing->getFeeStoppingViaAddress()) | |
$totalPrice += $param->getExtraStops() * $pricing->getFeeStoppingViaAddress(); | |
if ($param->isOutOfHours() && $pricing->getFeeOutOfHours()) | |
$totalPrice += $pricing->getFeeOutOfHours(); | |
$totalPrice += $pricing->getIncreasePercentage() ? ($totalPrice / 100) * $pricing->getIncreasePercentage() : 0; | |
if ($param->getDiscount() == 'd2d' && $pricing->isDiscountWithCompany()) | |
$totalPrice -= ($param->getDiscountPercentage() * ($totalPrice/100)); | |
elseif ($param->getDiscount() == 'student' && $pricing->getDiscountStudent()) | |
$totalPrice -= ($pricing->getDiscountStudent() * ($totalPrice/100)); | |
elseif ($param->getDiscount() == 'oneItem' && $pricing->getDiscountOneItem()) | |
$totalPrice -= ($pricing->getDiscountOneItem() * ($totalPrice/100)); | |
elseif ($param->getDiscount() == 'emptyReturn' && $pricing->getDiscountEmptyReturn()) | |
$totalPrice -= ($pricing->getDiscountEmptyReturn() * ($totalPrice/100)); | |
$totalPrice = round($totalPrice, 2); | |
return $totalPrice; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment