Exemplo n.º 1
0
     break;
 case 'getQuotes':
     $td = new TripThru();
     $pickupLocation = json_decode(stripslashes($_POST["locationobj"]), true);
     $dropoffLocation = json_decode(stripslashes($_POST["destinationobj"]), true);
     $passenger_id = $_POST['passenger_id'];
     $passenger_name = $_POST['passenger_name'];
     $pickup_location = array("lat" => $pickupLocation["location"]["lat"], "lng" => $pickupLocation["location"]["lng"]);
     $dropoff_location = array("lat" => $dropoffLocation["location"]["lat"], "lng" => $dropoffLocation["location"]["lng"]);
     list($d, $m, $y) = explode('/', $_POST['date']);
     $hour = $_POST['hours'];
     $minutes = $_POST['minutes'];
     $pickup_time = "{$y}-{$m}-{$d}T{$hour[0]}{$hour[1]}:{$minutes[0]}{$minutes[1]}:00+00:00";
     $passenger = array('id' => $passenger_id, 'name' => $passenger_name);
     $trip_id = date('Y-m-dTH-i-s') . "-webquote";
     $quotes = $td->Get_quotes($trip_id, $passenger, $pickup_time, $pickup_location, $dropoff_location, $_POST['ORIGIN']);
     if ($quotes) {
         if ($quotes['result_code'] == 430) {
             $quotes = array('count' => 0, 'quotes' => array());
         }
         $response = $quotes;
         $response['status_code'] = 200;
         $response['pickup_postcode'] = $pickupLocation["postcode"];
         $response['dropoff_postcode'] = $dropoffLocation["postcode"];
         $response['pickup_location']['lat'] = $pickupLocation["location"]["lat"];
         $response['pickup_location']['lng'] = $pickupLocation["location"]["lng"];
         $response['dropoff_location']['lat'] = $dropoffLocation["location"]["lat"];
         $response['dropoff_location']['lng'] = $dropoffLocation["location"]["lng"];
     } else {
         $response = array("message" => array("text" => "Call /quotes failed"), "status_code" => 400);
     }