123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- {% extends 'SonataAdminBundle:CRUD:base_edit.html.twig' %}
- {% block javascripts %}
- {{ parent() }}
- <script type="text/javascript">
- $(function () {
- // buscar la direccion del cliente y la muestra en el mapa.
- $('select[id$="clientId"]').change(function () {
- $.ajax({
- url: '{{ path('ajax_client_data') }}',
- dataType: 'json',
- delay: 250,
- data: {
- q: $(this).val()
- }
- }).done(function (data) {
- googleSearchDirectionAndShowMaps(data.results[0].address);
- });
- });
- });
- /**
- * funcion que busca una direccion y la muestra en el mapa.
- * @param address Contiene la direccion.
- */
- function googleSearchDirectionAndShowMaps(address) {
- $('input[class="search-input"]').val(address + ", Gálvez, Santa Fe, Argentina");
- $.ajax({
- url: "http://maps.googleapis.com/maps/api/geocode/json?address='" + address + ", Gálvez, Santa Fe, Argentina'",
- type: "POST"
- }).done(function (res) {
- if (res != undefined) {
- if (res.status == google.maps.GeocoderStatus.OK) {
- loc = new L.latLng(res.results[0].geometry.location.lat, res.results[0].geometry.location.lng);
- drawMarker();
- setDataValue();
- } else {
- alert(res.status);
- }
- } else {
- alert("{{ 'error.address_not_found'|trans({}, 'FTTHBundle') }}");
- }
- }).error(function (res) {
- console.log("ERROR: ");
- console.log(res);
- alert("{{ 'error.address_not_found'|trans({}, 'FTTHBundle') }}");
- });
- }
- /**
- * Busca y calcula la distancia a los nap y la cantidad de puertos libres.
- */
- function calcularDistanciaNap() {
- var origin = JSON.parse($("input[id*='_location_extraData']").attr('value'));
- $.ajax({
- url: '{{ path('ajax_distance_nap_onu') }}',
- dataType: 'json',
- type: "GET",
- data: {
- lat: origin.lat,
- lng: origin.lng
- }
- }).done(function (res) {
- var select = $("select[id*='_nap']");
- select.find("option").remove().end();
- $.each(res, function (i, obj) {
- obj = JSON.parse(obj);
- for (var i = 0; i < obj.length; i++) {
- if (obj[i].distance != -1) {
- select.append(
- '<option value="' + obj[i].id + '">' +
- obj[i].name + " ({{ 'Free Port'|trans({}, 'FTTHBundle') }}: " + obj[i].freePort + " - " +
- "{{ 'Distance'|trans({}, 'FTTHBundle') }}: " + obj[i].distance + " KM.)" +
- '</option>'
- );
- }
- }
- for (var i = 0; i < obj.length; i++) {
- if (obj[i].distance == -1) {
- select.append(
- '<option value="' + obj[i].id + '">' +
- obj[i].name + " ({{ 'Free Port'|trans({}, 'FTTHBundle') }}: " + obj[i].freePort + ")" +
- '</option>'
- );
- }
- }
- });
- }).error(function (res) {
- console.log("ERROR: ");
- console.log(res);
- });
- }
- </script>
- {% endblock %}
|