Example #1
0
 public static function calculate($fromDDD, $toDDD, $duration, $planId)
 {
     $price = @PriceBus::getByRoute($fromDDD, $toDDD);
     if ($price != null) {
         $normal_price = $price->calculateCallCost($duration);
         $plan = @PlanBus::getById($planId);
         if ($plan != null) {
             return array("normal" => $normal_price, "plan" => $plan->calculateCallCost($price, $duration));
         } else {
             return array("normal" => $normal_price, "plan" => "Plan not found");
         }
     }
     return null;
 }
Example #2
0
<?php

@header('Content-type: text/html; charset=iso-8859-1');
@(require_once "../business/PlanBus.class.php");
if ($_POST) {
    $result = PlanBus::calculate($_POST["from_ddd"], $_POST["to_ddd"], $_POST["duration"], $_POST["plan"]);
    if ($result == null) {
        $result = array("normal" => "Route from/to DDD not found", "plan" => "Route from/to DDD not found");
    } else {
        $result = array("normal" => "\$ " . number_format($result["normal"], 2, '.', ''), "plan" => "\$ " . number_format($result["plan"], 2, '.', ''));
    }
    echo json_encode($result);
}
Example #3
0
<?php

@header('Content-type: text/html; charset=iso-8859-1');
@(require_once "../business/PlanBus.class.php");
@(require_once "../to/Plan.class.php");
$plans = PlanBus::listAll();
if (is_array($plans) && count($plans) > 0) {
    $result = array();
    foreach ($plans as $p) {
        $item = array("plan_id" => $p->getPlanId(), "description" => $p->getDescription(), "minutes" => $p->getMinutes(), "fare_additional_min" => $p->getFareAdditionalMin());
        $result[] = $item;
    }
    echo json_encode(array_values($result));
} else {
    echo "[]";
}