Distances Matrix GAPI : ps
This commit is contained in:
parent
3ad20665db
commit
7c3460bd52
@ -130,6 +130,7 @@ else if(ENVIRONMENT == 'testing')
|
||||
defined('SALESPD_CUSTOMER_IMG_URL') OR define('SALESPD_CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/salespd_images/');
|
||||
defined('CUSTOMER_IMG_URL') OR define('CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/pd-images/');
|
||||
defined('PDF_ATTACHEMENT_URL') OR define('PDF_ATTACHEMENT_URL','https://apitest.pdgenie.com/sparqtest/api/short?dat=');
|
||||
defined('GOOGLE_DISTANCE_MATRIX_API_KEY') OR define('GOOGLE_DISTANCE_MATRIX_API_KEY',getenv('GOOGLE_DISTANCE_MATRIX_API_KEY'));
|
||||
}
|
||||
else if(ENVIRONMENT == 'production')
|
||||
{
|
||||
@ -144,6 +145,7 @@ else if(ENVIRONMENT == 'production')
|
||||
defined('SALESPD_CUSTOMER_IMG_URL') OR define('SALESPD_CUSTOMER_IMG_URL','https://pdgenie.com/customer/#/salespd_images/');
|
||||
defined('CUSTOMER_IMG_URL') OR define('CUSTOMER_IMG_URL','https://pdgenie.com/customer/#/pd-images/');
|
||||
defined('PDF_ATTACHEMENT_URL') OR define('PDF_ATTACHEMENT_URL','https://api.pdgenie.com/sparqprod/api/short?dat=');
|
||||
defined('GOOGLE_DISTANCE_MATRIX_API_KEY') OR define('GOOGLE_DISTANCE_MATRIX_API_KEY',getenv('GOOGLE_DISTANCE_MATRIX_API_KEY'));
|
||||
}
|
||||
|
||||
/*********************END of AWS resources Constants*************************************************/
|
||||
|
||||
@ -194,10 +194,13 @@ class Dash_Board_Controller extends REST_Controller {
|
||||
$title_arr = explode(",",$field_mapping[$a]['column_title']);
|
||||
}
|
||||
$array = json_decode(json_encode($res), true);
|
||||
|
||||
for($i=0;$i<count($array);$i++){
|
||||
for($j=0;$j<count($column);$j++){
|
||||
$final[$i][$column[$j]] = $array[$i][$column[$j]];
|
||||
for($j=0;$j<count($title_arr);$j++){
|
||||
if($column[$j] == "address_visited"){
|
||||
$final[$i]["address_visited"] = nl2br($array[$i]['address_visited'].", \n".$array[$i]['state'].", \n".$array[$i]['city'].",".$array[$i]['pincode'].".");
|
||||
}else{
|
||||
$final[$i][$column[$j]] = $array[$i][$column[$j]];
|
||||
}
|
||||
}
|
||||
}
|
||||
for($k=0;$k<count($column);$k++){
|
||||
@ -214,4 +217,5 @@ class Dash_Board_Controller extends REST_Controller {
|
||||
$data['header']= $title;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
@ -6266,8 +6266,14 @@ public function getPDFormDetailsJSON_post()
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
//echo 'NOR';
|
||||
$pd_type = $data['pd_master_details'][0]['fk_pd_type'] == 3 ? 3 : 1;
|
||||
// echo 'NOR';
|
||||
// print_r($data['pd_master_details']);die();
|
||||
if($data['pd_master_details'][0]['lender_short_name'] == 'CSLFL'){
|
||||
$entity_geo_location = $this->PD_Model->getEntityAddr($data['pd_master_details'][0]['fk_lender_id']);
|
||||
$pd_location = $data['pd_master_details'][0]['start_location'];
|
||||
$data['distances'] = satellite_image::getdistancematrix($entity_geo_location,$pd_location);
|
||||
}
|
||||
$pd_type = $data['pd_master_details'][0]['fk_pd_type'] == 3 ? 3 : 1;
|
||||
$data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => ($data['pd_master_details'][0]['sub_entity_id'] ? $data['pd_master_details'][0]['sub_entity_id'] : $data['pd_master_details'][0]['fk_lender_id']),'fk_pd_type' => $pd_type));
|
||||
//}
|
||||
//print_r($data['lender_disclaimer']);die();
|
||||
@ -6393,7 +6399,6 @@ public function getPDFormDetailsJSON_post()
|
||||
if(!count($add_on_pd))
|
||||
{
|
||||
|
||||
|
||||
if($data['pd_master_details'][0]['fk_pd_type'] == 1 )
|
||||
{
|
||||
|
||||
@ -9774,7 +9779,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string);
|
||||
// print_r($pd_master_details);die();
|
||||
$result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
|
||||
exit();
|
||||
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
@ -11236,7 +11241,13 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
$records = array('file_id' => $pd_id,'addressline' => $addresses[0]['addressline1'],'city' => $addresses[0]['fk_city'],'state' => $addresses[0]['fk_state'],'pincode' => $addresses[0]['pincode']);
|
||||
$this->PD_Model->saveRecords($records,SMC_TEMP_ADDRESS);
|
||||
}
|
||||
|
||||
|
||||
function distancematrix_get(){
|
||||
$pd_loc = $this->get('loc');
|
||||
$lender = $this->get('lender');
|
||||
$entity_loc = $this->PD_Model->getEntityAddr($lender);
|
||||
$this->response(satellite_image::getdistancematrix($entity_loc,$pd_loc),REST_Controller::HTTP_OK,true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -117,5 +117,31 @@ class satellite_image
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function getdistancematrix($from_addr,$to_addr){
|
||||
if((int)$from_addr != 0){
|
||||
// $apikey = GOOGLE_DISTANCE_MATRIX_API_KEY;
|
||||
$apikey = "AIzaSyA1QV-A3t_3RwlozdlwgxlXnLNb_3WqxfY"; // now hardcoded
|
||||
$url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$from_addr."&destinations=".$to_addr."&mode=driving&key=".$apikey;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$response_a = json_decode($response, true);
|
||||
if($response_a['rows'][0]['elements'][0]['status'] != "ZERO_RESULTS"){
|
||||
$dist = $response_a['rows'][0]['elements'][0]['distance']['text'];
|
||||
$time = $response_a['rows'][0]['elements'][0]['duration']['text'];
|
||||
return array('status'=>true,'distance' => $dist, 'time' => $time,'url'=>$url);
|
||||
}else{
|
||||
return array('status'=>false,'distance' => '0 km', 'time' => '0 days','url'=>$url);
|
||||
}
|
||||
}else{
|
||||
return array('status'=>false,'distance' => '0 km', 'time' => '0 days','url'=>"");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -2254,5 +2254,19 @@ class PD_Model extends SPARQ_Model {
|
||||
// print_r($this->db->last_query());exit();
|
||||
}
|
||||
|
||||
function getEntityAddr($Eid){
|
||||
$this->db->select('geo_loc');
|
||||
$this->db->from(ENTITYBILLING.' as ENTITYBILLING');
|
||||
$this->db->where('fk_entity_id',$Eid);
|
||||
$this->db->where('isactive',1);
|
||||
$this->db->where('is_dist_cal_enable',1);
|
||||
$query = $this->db->get();
|
||||
if ($query->num_rows() > 0) {
|
||||
$result = $query->row()->geo_loc;
|
||||
}else{ $result = 0; }
|
||||
return $result;
|
||||
}
|
||||
// SELECT as full_address FROM sineedgedemo.m_entity_billing where fk_entity_id = 43 and isactive = 1 and is_dist_cal_enable = 1;
|
||||
|
||||
|
||||
}
|
||||
@ -1056,7 +1056,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -1062,7 +1062,9 @@ font-weight: bolder;;
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -1080,7 +1080,9 @@ if ( isset($pdf) ) {
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -1304,7 +1304,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -1073,7 +1073,9 @@ if ( isset($pdf) ) {
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -851,7 +851,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -851,7 +851,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -854,7 +854,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
@ -861,7 +861,9 @@ font-weight: bolder;;
|
||||
|
||||
echo '<b>PD Location Address : </b>'.$pd_address['address'].', '.$pd_address['city_master'].', '.$pd_address['state_master'].' - '.$pincode.'.';
|
||||
}
|
||||
|
||||
if($pd_master_details[0]['lender_short_name'] == 'CSLFL'){
|
||||
echo '<br><br><b> Total distances of Entity location and PD Visit location : </b>'.$distances['distance'].' and '. $distances['time'];
|
||||
}
|
||||
echo '<br><br><b> GPS Coordinates of location where PD Visit was done : </b>'.$pd_master_details[0]['start_location'];
|
||||
echo '<br><br>';
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user