ontarget
Active Member
I am running joomla 3.9.0 and Fabrik 3.9
I have a calc element that calculates distance using the goolge maps distance matrix api which works fine when the account is on php5.6 as soon as I switch to php7.2 / php 7.0 the calc element no longer works and it simply returns 0
Here are the calc settings:
Here is my code - is there something in my php that is possibly deprecated?
I Appreciate any pointers!
I have a calc element that calculates distance using the goolge maps distance matrix api which works fine when the account is on php5.6 as soon as I switch to php7.2 / php 7.0 the calc element no longer works and it simply returns 0
Here are the calc settings:
Only Calc on Save = Yes
Ajax calculation = Yes
Ajax observe fields = '{aaa_participant_claim___mode_of_transport}, {aaa_participant_claim___school_eircode}'
Here is my code - is there something in my php that is possibly deprecated?
I Appreciate any pointers!
Code:
$venue_ec = '{aaa_participant_claim___venue_ec}';
$start_ec = '{aaa_participant_claim___start_eircode}';
$school_ec = '{aaa_participant_claim___school_eircode}';
$venue_ec = str_replace(' ','',$venue_ec);
$start_ec = str_replace(' ','',$start_ec);
$school_ec = str_replace(' ','',$school_ec);
$mode = '{aaa_participant_claim___mode_of_transport_raw}';
if($mode == "car_public") {
$station_ec = '{aaa_participant_claim___station_eircode}';
$station_ec = str_replace(' ','',$station_ec);
$end_ec = $station_ec;
} else if ($mode == "car") {
$end_ec = $venue_ec;
} else if ($mode == "public_only") {
return 0;
}
if($start_ec === '0') {return 0;}
elseif ($start_ec === "") {return 0;}
//if (strlen($start_ec) === 0)
//{
//return 0;
//}
//else if ($start_ec == "0")
//{
//return 0;
//}
//working for fastest route
$data1 = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?region=ie&origins=$start_ec+ire&destinations=$end_ec+ire&language=en-EN&key=xxxxxxx&sensor=false");
$data2 = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?region=ie&origins=$school_ec+ire&destinations=$end_ec+ire&language=en-EN&key=xxxxxxx&sensor=false");
$data1 = json_decode($data1);
$distance1 = 0;
$status1 = "OK";
$distance1 = $data1->rows[0]->elements[0]->distance->value;
$status1 = $data1->status;
$msg1 = $data1->error_message;
$data2 = json_decode($data2);
$distance2 = 0;
$status2 = "OK";
$distance2 = $data2->rows[0]->elements[0]->distance->value;
$status2 = $data2->status;
$msg2 = $data2->error_message;
if ($distance1 < $distance2){
return round($distance1/1000);
} else {
return round($distance2/1000);
}
Last edited: