|
@@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use FTTHBundle\Entity\ONU;
|
|
use FTTHBundle\Entity\ONU;
|
|
use FTTHBundle\Entity\PreSale;
|
|
use FTTHBundle\Entity\PreSale;
|
|
|
|
+use MapBundle\Entity\Location;
|
|
use WebserviceBundle\Form\Type\RemoteClientType;
|
|
use WebserviceBundle\Form\Type\RemoteClientType;
|
|
use MapBundle\Form\Type\RemoteMapType;
|
|
use MapBundle\Form\Type\RemoteMapType;
|
|
use FOS\RestBundle\Controller\Annotations\RouteResource;
|
|
use FOS\RestBundle\Controller\Annotations\RouteResource;
|
|
@@ -48,8 +49,8 @@ class CaptivePortalController extends Controller
|
|
|
|
|
|
if($onu->getClientId() == $sale->getClientId() && $onu->getProfile() == $sale->getProfile()) {
|
|
if($onu->getClientId() == $sale->getClientId() && $onu->getProfile() == $sale->getProfile()) {
|
|
$result = true;
|
|
$result = true;
|
|
- $em->remove($sale);
|
|
|
|
- $em->flush();
|
|
|
|
|
|
+ //$em->remove($sale);
|
|
|
|
+ //$em->flush();
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -67,6 +68,34 @@ class CaptivePortalController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
private function updateOnu($clientId, $profile, $onu, $address, $em) {
|
|
private function updateOnu($clientId, $profile, $onu, $address, $em) {
|
|
|
|
+
|
|
|
|
+ if(!is_null($address) && $this->getParameter('googlemaps_api_key')) {
|
|
|
|
+ $key = $this->getParameter('googlemaps_api_key');
|
|
|
|
+ $addr = urlencode($address);
|
|
|
|
+ $data = $this->getSslPage("https://maps.googleapis.com/maps/api/geocode/json?address={$addr}&key={$key}");
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ $data = json_decode($data,true);
|
|
|
|
+ } catch(\Exception $e) {
|
|
|
|
+ $data = array();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($data['status'] == 'OK') {
|
|
|
|
+ $geoInformation = $data['results'][0];
|
|
|
|
+ $extraData = array();
|
|
|
|
+ $extraData['formatted_address'] = $geoInformation['formatted_address'];
|
|
|
|
+ $extraData['lat'] = $geoInformation['geometry']['location']['lat'];
|
|
|
|
+ $extraData['lng'] = $geoInformation['geometry']['location']['lng'];
|
|
|
|
+ $extraData['zoom'] = 18;
|
|
|
|
+
|
|
|
|
+ $location = new Location();
|
|
|
|
+ $location->setJsonExtraData($extraData);
|
|
|
|
+
|
|
|
|
+ $onu->setLocation($location);
|
|
|
|
+ $onu->setJsonExtraData($extraData);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
$onu->setClientId($clientId);
|
|
$onu->setClientId($clientId);
|
|
$onu->setProfile($profile);
|
|
$onu->setProfile($profile);
|
|
|
|
|
|
@@ -74,4 +103,13 @@ class CaptivePortalController extends Controller
|
|
$em->flush();
|
|
$em->flush();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function getSslPage($url) {
|
|
|
|
+ $ch = curl_init();
|
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
+ $result = curl_exec($ch);
|
|
|
|
+ curl_close($ch);
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|