瀏覽代碼

modificaciones menores para obtener la lat. y lng. de los NAPs

Luciano Andrade 7 年之前
父節點
當前提交
763c905131

+ 4 - 4
composer.lock

@@ -1464,7 +1464,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "0d5dd5c5e784f5a58d6a3bf8fdce11a83de1d71a"
+                "reference": "394ee26731b2f6f777b1be6ccc48f18e599dd04f"
             },
             "type": "library",
             "autoload": {
@@ -1479,7 +1479,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2017-11-14T13:06:37+00:00"
+            "time": "2017-11-22T15:29:25+00:00"
         },
         {
             "name": "ik/device-bundle",
@@ -1510,7 +1510,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/ExtraDataBundle.git",
-                "reference": "486ba1f40fd3c00d1ca0e84843e1fd02d1830dd9"
+                "reference": "66a998f00904ca9c18e8b02b8861c11f4e24989a"
             },
             "type": "library",
             "autoload": {
@@ -1525,7 +1525,7 @@
                 "bundle",
                 "extra-data"
             ],
-            "time": "2017-11-17T11:58:02+00:00"
+            "time": "2017-11-17T18:25:46+00:00"
         },
         {
             "name": "ik/leaflet-bundle",

+ 8 - 1
src/FTTHBundle/Controller/ONUController.php

@@ -252,6 +252,13 @@ class ONUController extends Controller
      */
     public function orderDistances($a, $b)
     {
-        return $b["distance"] - $a["distance"];
+	$a = (float)$a["distance"];
+	$b = (float)$b["distance"];
+
+	if ($a == $b) {
+		return 0;
+			        }
+	return ($a < $b) ? -1 : 1;
+        //return (float)$a["distance"] - (float)$b["distance"];
     }
 }

+ 22 - 0
src/FTTHBundle/Entity/NAP.php

@@ -253,4 +253,26 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
         return $this;
     }
 
+    public function getlat(){
+	   // if($this->location->lat) return $this->location->lat;
+	if($l = $this->getLocation()){
+		$le = $l->jsonExtraData();
+		if(isset($le["lat"])){
+			return $le["lat"];
+		}
+	}
+	return $this->lat;
+    }
+
+    public function getlng(){
+	    //if($this->location->lng) return $this->location->lng;
+	    if($l = $this->getLocation()){
+		    $le = $l->jsonExtraData();
+		    if(isset($le["lng"])){
+			    return $le["lng"];
+		    }
+	    }
+	    return $this->lng;
+    }
+
 }

+ 4 - 5
src/FTTHBundle/Resources/views/ONU/form.html.twig

@@ -13,6 +13,8 @@
                 callbackClientId(objSelectClient.val());
             } else {
                 drawMap(-32.030232, -61.220883); // galvez
+                $("div[id*='_nap']").find(".select2-chosen").html("");
+                $("select[id*='_nap']").val(0);
             }
         });
 
@@ -56,13 +58,10 @@
                 url: "http://maps.googleapis.com/maps/api/geocode/json?address='" + address + "'",
                 type: "POST"
             }).done(function (res) {
-                if (res != undefined) {
-                    if (res.status == google.maps.GeocoderStatus.OK) {
+                if (res != undefined && res.status == google.maps.GeocoderStatus.OK) {
                         drawMap(res.results[0].geometry.location.lat, res.results[0].geometry.location.lng);
-                    } else {
-                        alert(res.status);
-                    }
                 } else {
+                    console.log(res.status);
                     alert("{{ 'error.address_not_found'|trans({}, 'FTTHBundle') }}");
                 }
             }).error(function (res) {