/**** SQL para los distintos tipos de mapas ****/ var app = app || {}; //VARIABLES GLOBALES var tipofiltro = ""; var param_subfiltro = ""; var sqlnuevo = ""; var filtroactual = ""; var filtro = ""; var query = ""; var estado, idactual = ''; var array, arraymenu, menus, capas_adicionales = ''; var seccion, subseccion = ''; var ttc1, ttc2, ttc3 = ''; var loteactual = ''; //FUNCIONES GLOBALES var mapa_zonas = function () { mapa = 'zona'; app.map.el.map.remove(); app.map.init(); } //muestra/oculta resumen de lote var mostrarResumen = function() { if($('#resumen').css('display') != 'none'){ $('#resumen').css({ display: 'none' }); $("#toggle_msg").html('Mostrar Resumen'); document.getElementById('print_resumen').type = 'hidden'; $("#box2").css({display: 'block', height: 'auto'}); }else{ $('#resumen').css({display: 'block'}); $("#toggle_msg").html('Ocultar Resumen'); document.getElementById('print_resumen').type = 'button'; $("#box2").css({display: 'block', height: '500px'}); } }; //funcion para limpiar el mapa cuando se elija un nuevo filtro/operacion var limpiar = function() { el = app.map.el; el.map.setView([lat, lng], zoom); $("#resumen").html(""); $("#resumen").css({display: 'none'}); $("#toggle_resumen").html(""); //document.getElementById("box").style.opacity = "0.7"; $("#box").css({ 'opacity': '0.7' } ) $('#box2').hide(); if (el.polygon) { el.map.removeLayer(el.polygon); } }; window.forceReload = function(){ if( !window.fetch)return document.location.reload( true); var els = document.getElementsByTagName( "*"); for( var i = 0; i < els.length; i++){ var src = ""; if( els[i].tagName == "A")continue; if( !src && els[i].src)src = els[i].getAttribute( "src"); if( !src && els[i].href)src = els[i].getAttribute( "href"); if( !src)continue; fetch( src, { cache: "reload"}); } return document.location.reload( true); }; var procesar = function (identificador, operacion) { console.log('identificador: ', identificador, ' operacion: ', operacion); switch (operacion){ case 'actualizar': var ccc = document.getElementById("infoModalCCC").value; var zona = document.getElementById("infoModalZona").value; var mz = document.getElementById("infoModalManzana").value; var lote = document.getElementById("infoModalLote").value; $.ajax({ url: "login/set_valores.php", type: "POST", data: {id: identificador, operacion: operacion, ccc: ccc, zona: zona, mz: mz, lote: lote}, async: false, dataType: 'json', success: function (data) { array = JSON.parse(data); alert(array[0].total_rows + ' de ' + array[1].total_rows + ' agregado'); $('#modal_editar_lotes')[0].reset(); console.log(array); }, error:function(data){console.log('ndoikoi!', data);} }); break; case 'eliminar': $.ajax({ url: "login/set_valores.php", type: "POST", data: {id: identificador, operacion: operacion}, async: false, dataType: 'json', success: function (data) { array = JSON.parse(data); alert('Se ha eliminado '+ array.total_rows + ' registro/s'); }, error:function(data){console.log('ndoikoi!', data);} }); break; case 'cancelar': map.removeLayer(polygon); $('#modal_editar_lotes')[0].reset(); break; default: alert('Operacion no valida'); } $("#infoModal").toggle(); //forceReload(); }; //Se imprime el div que contiene el informe del lote var printDiv = function() { var divToPrint=document.getElementById('resumen'); var newWin=window.open('','Print-Window'); newWin.document.open(); newWin.document.write('' + '' + ''+ ''+ ''+ ''+ ''+ ''+ ''+divToPrint.innerHTML+''); newWin.document.close(); setTimeout(function(){newWin.close();},10); }; app.conf = ( function () { //mapa = "zonas"; //MENU DINAMICO var initMenu = function() { //console.log(mapa); seccion = 'Mapas'; actualizar_navegacion(); $.ajax({ url: "login/get_valores.php", type: "POST", data: {mapa: mapa}, async: false, dataType: 'json', success: function (data) { //console.log(data); switch (mapa) { case 'morosidad': array = JSON.parse(data); //console.log(array); var estado = ''; var idactual; var actual = 0; var tipo = 0; creg = 0; cpag = 0; for (var p = 0; p < array.total_rows; p++) { var pimpuesto = array.rows[p]; if (pimpuesto.estado === 'REG') { if (creg === 0){ creg = creg + 1; estado = 'ADEUDADOS'; menus = "" + "
  • " + " IMPUESTOS " + estado + "" + "" + "
  • "+ "
  •  IMPUESTOS " + estado + "" + "" + "
  • " break; case 'zonas': array = JSON.parse(data); ///ZONAS/// menus = "" + "
  • " + " "+ mapa.toUpperCase() + "" + ""+ "
  • " ///ZONAS TRIBUTARIAS $(document).ajaxStart(function() { Pace.restart(); }); $.ajax({ url: "login/get_valores.php", type: "POST", data: {mapa: 'zonastributarias'}, async: false, dataType: 'json', success: function (zonastrib) { array = JSON.parse(zonastrib); //console.log(array); menus = menus + "
  • " + " ZONAS TRIBUTARIAS" + ""+ "
  • " }, error:function(data){console.log('ndoikoi!', data);} }); break; case 'frentes': array = JSON.parse(data); //console.log(array, array.total_rows); menus = ""+ "
  • " + " Tipos de "+ mapa.toUpperCase() + "" + ""+ "
  • " break; case 'notificacion': //NOTIFICACIONES! array = JSON.parse(data); //console.log(array, array.total_rows); menus = "" + "
  • " + " Tipos de "+ mapa.toUpperCase() + "" + ""+ "
  • " break; case 'migracion': menus = "" + "
  • " + " Lotes Actualizados " + ""+ "
  • "+ "
  • "+ " Tipo Actualizacion " + ""+ "
  • " break; case 'baldios': //console.log(data); menus = "" + "
  • " + " Situacion de LOTES" + ""+ "
  • " break; case 'sigem': array = JSON.parse(data); //console.log(array); conficha = array.rows[0].conficha; sinficha = array.rows[0].sinficha; console.log('Con ficha: ', conficha, ' sin ficha: ', sinficha); menus = "" + "
  • " + " Situacion de LOTES" + ""+ "
  • " break; case 'actualotes': case 'mejoras': //console.log(data); menus = "" break; } }, error:function(data){console.log('ndoikoi!', data);} }); switch (mapa){ case 'sigem': titulo = 'MAPA DE LOTES SIN FICHAS'; break; case 'actualotes': titulo = 'ACTUALIZACION DE LOTES'; break; default: titulo = 'MAPA DE '+ mapa; break; } if (mapa === 'zonas'){ shape_zonas = ""+ "" + "Zonas Tributarias" + "
    "; }else{ shape_zonas = ""; } //MENU DINAMICO arraymenu = "" + "
    " + "

    "+titulo.toUpperCase() + "

    "+ "
    "+ ""+ //""+ "
    "+ "
    "+ "" + "
    "+ "
    "; //CAPAS ADICIONALES capas_adicionales = "" + "
    " + "

    CAPAS ADICIONALES

    "+ "
    "+ ""+ //""+ "
    "+ "
    "+ "" + "Lotes sin CCC" + "
    " + "" + "Manzanas" + "
    " + "" + "Calles" + "
    " + shape_zonas + "
    "+ "
    "; //console.log(arraymenu); $('#accordion').html("").html(arraymenu); $('#capas_adicionales').append(capas_adicionales); $('.toggle').click(function(e) { e.preventDefault(); var $this = $(this); if ($this.next().hasClass('show')) { $this.next().removeClass('show'); $this.next().slideUp(150); $('.carets').open(); } else { $this.parent().parent().find('li .inner').removeClass('show'); $this.parent().parent().find('li .inner').slideUp(150); $this.next().toggleClass('show'); } }); } var initPage = function () { switch (mapa){ case 'zonas': //$('#contenido').html("").append(""); break; } } // get it all going! var init = function() { initPage(); initMenu(); } return {init : init} })(); var mostrarLOTE = function (cartodb_id, ccc) { $('#box2').show(); $('#tool-tip').hide(); $.ajax({ url: "api/callREAD.php", type: "POST", data: {cartodb_id: cartodb_id, type: 'lote', entidad: entidad}, dataType: 'json', success: function (geojson) { if (app.map.el.polygon) {app.map.el.map.removeLayer(app.map.el.polygon);} //Trae el poligono por ajax app.map.el.polygon = L.geoJson(geojson, { style: { color: "#000", fillColor: "#edd711", weight: 6, opacity: 0.8, fillOpacity: 0.2 } }); //Fija los limites del mapa de cuardo al poligono app.map.el.map.fitBounds(app.map.el.polygon.getBounds(), {maxZoom: 17}); //Agrega el poligono al mapa app.map.el.polygon.addTo(app.map.el.map); switch (mapa){ case 'morosidad': var deuda_todal = ccc; if (typeof impuesto !== "undefined") { //console.log(entidad, impuesto, estado); $.ajax ({ url: 'login/get_liquidacion.php', //Se parsea el numero de ccc a fin de obtener los datos del lote type: 'POST', data: {ccc: deuda_todal, entidad: entidad, impuesto: impuesto, estado: estado},//parseo de ccc dataType: "json", //text or html or json or script success:function(data) { var largo = data.length; //SE LIMPIA EL DIV DE RESULTADOS $("#resumen").html(""); $("#toggle_resumen").html(""); $('#toggle_resumen').append('Mostrar Todos'); $("#box").css({'opacity': '0.8'}); //TODO: aca podria haber sido overlowY en el "scroll" para contemplar solo el scroll vertical, preferi dejar ambos para que se "note que hay algo" //console.log(largo); if (largo > 0){ // SE CREA EL INFORME POR LOTE $('#resumen').append('' + '

    Informe Catastral

    ' + '

    Lote: '+ccc+' Ficha: '+data[0].inm_ficha+'

    '); //SE CREA LA TABLA PARA EL RESUMEN $("#resumen").append( ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''); //SE IMPRIMEN LOS DATOS DEL LOTE var sum = 0; $.each(data,function (i,item) { switch (item.liq_estado){ case 'REG': estadopago = 'PENDIENTE'; tiporesumen = 'ADEUDADO'; break; case 'PAG': tiporesumen = 'PAGADO'; estadopago = item.liq_fecpago; break; } sum += parseInt(item.liq_importe_apagar); $('#resumen_table').append( '' + '' + '' + '' + '' + '' + '' ); //console.log(sum, item); }); $('#resumen').append( '
    Ejercicio FiscalTributoEstadoImporteFecha de pago
    '+item.ejer_fisca+''+item.trb_tributo+''+item.liq_estado+''+$.number(item.liq_importe_apagar,0,',','.')+''+estadopago+'

    Total '+tiporesumen+': '+ $.number(sum,0,',','.')+' Gs.

    '); $('#toggle_resumen').append('Ocultar Resumen'); $('#toggle_resumen').append(''); }else{ $("#resumen").html(""); $("#resumen").css({display: 'block', height: 'auto', overflow: ''}); $("#box2").css({display: 'block', height: 'auto'}); $('#resumen').append('

    No se encontraron Datos

    '); } }, error:function(data) { $('#resumen').append('

    No se encontraron datos

    ') } });; }else { //alert("FAVOR ELIJA TIPO DE IMPUESTO!"); } break; } //console.log(polygon.getBounds()); } }); }; //Buscador $('#ctactastral').focus(function(){if ($(this).val()==="Ingrese Cta Catastral") {$(this).val("");}}); $('#ctactastral').on('blur',function(){if ($(this).val()!=="") {buscador();$(this).val("")}}); $(document).keyup(function (e) {if ($("#ctactastral:focus") && (e.keyCode === 13)) {buscador();$(this).val("")}}); var buscador = function () { var numficha = document.getElementById("ctactastral").value; if (numficha === null || numficha === ''){alert('Favor ingrese datos!');$('#ctactastral').value(''); }else{ $.ajax({ url: "login/buscar.php", type: "POST", data: {lote: numficha, busqueda: 'lote'}, dataType: 'json', success: function (data) { busqueda = JSON.parse(data); if (busqueda.total_rows === 0){ alert('NO SE ENCONTRARON DATOS!'); $('#ctactastral').val(""); }else{ cartoid = busqueda.rows[0].cartodb_id;mostrarLOTE(cartoid, numficha); $('#ctactastral').val(""); } } }) } } //FIN FUNCIONES GLOBALES //URL yvyape app.url = 'https://yvyape.yvaga.com.py/user/yvaga/api/v2/viz/'+basemap+'/viz.json'; //QUERY's mapas app.param = ( function(){ return { //CAPAS EXTRA manzanas: 'SELECT * FROM e'+entidad+'_manzanas', calles : 'SELECT * FROM e'+entidad+'_calles', lotesincc : 'SELECT * FROM e'+entidad+'_lotes_sinccc where borrado is not true', capazonastrib : 'SELECT * from e'+entidad+'_zonas_tributarias', ///////////////////////////// //BASE all: 'SELECT * FROM e'+entidad+'_lotes_conccc', ///////////////////////////// //MOROSIDAD morosidadtodos : 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.v_liq_entidad_totalxobjeto on ccc = inm_ctacatastral', morosidadRenSTab : 'SELECT * FROM e'+entidad+'_lotes_conccc', morosidadVacant : "SELECT * FROM bushwick_pluto14v1 WHERE landuse = '11'", ///////////////// //FRENTES/ frentetodos: 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', frentepavimento: 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', frentepavimentolb: 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'lb.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', fplbresumen: 'SELECT b.inm_tpav, count(inm_tpav) as total FROM e'+entidad+'_lotes_conccc a left join sigem'+entidad+'lb.v_inmuebles_zona_pavimento b on ccc = inm_ctacatastral where b.inm_tpav is not null and b.inm_tpav <> \'\' GROUP BY b.inm_tpav', //////////////// //ZONAS zonas : 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', zonaslb : 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'lb.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', zonastributarias: "SELECT *," + " (coalesce(inm_tipo_ur, '0')" + " || '-' || " + " coalesce(inm_zona_tributaria, '0')" + " || '-' || " + "coalesce(sub_zona_rural,'0')) as zonas_tributarias " + "FROM e"+entidad+"_lotes_conccc " + "left join sigem"+entidad+".v_inmuebles_zona_pavimento " + "on ccc = inm_ctacatastral", zonastributariaslb: "SELECT *," + " (coalesce(inm_tipo_ur, '0')" + " || '-' || " + " coalesce(inm_zona_tributaria, '0')" + " || '-' || " + "coalesce(sub_zona_rural,'0')) as zonas_tributarias " + "FROM e"+entidad+"_lotes_conccc " + "left join sigem"+entidad+"lb.v_inmuebles_zona_pavimento " + "on ccc = inm_ctacatastral", ///////////////////// ///NOTIFICACIONES//// notificaciones: 'SELECT * FROM e'+entidad+'_lotes_conccc LEFT JOIN sigem'+entidad+'.v_seguimiento_notificaciones ON ccc = obj_numero', //////////////////// ///MIGRACION//////// migracion: 'SELECT DISTINCT ON (actualizacion_proceso, obj_imponible_ficha) * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.actualizaciones on ccc = obj_imponible_id where obj_imponible_ficha is not null ORDER BY actualizacion_proceso, obj_imponible_ficha, fec_graba DESC NULLS LAST', migraciontipo: 'SELECT DISTINCT ON (actualizacion_proceso, obj_imponible_ficha) * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.actualizaciones on ccc = obj_imponible_id where obj_imponible_ficha is not null ORDER BY actualizacion_proceso, obj_imponible_ficha, fec_graba DESC NULLS LAST', /////////////////////// ///RECOLECION BASURA/// recoleccion: 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', lotes_recoleccion: 'select a.cartodb_id, a.ccc, a.ccc_guion, a.the_geom, a.the_geom_webmercator, b.ruta_id, b.name, b.ruta_descripcion from e'+entidad+'_lotes_conccc a, e'+entidad+'_cobertura_recoleccion b WHERE ST_DWithin(a.the_geom_webmercator, b.the_geom_webmercator, 20)', /////////////////////// ///ESTADO SIGEM//// sigem: 'SELECT * FROM e'+entidad+'_lotes_conccc left join sigem'+entidad+'.v_inmuebles_zona_pavimento on ccc = inm_ctacatastral', estado_mejoras: 'SELECT * FROM e'+entidad+'_mejoras where borrado is not true', estado_lotes: 'SELECT * FROM e'+entidad+'_lotes_conccc where borrado is not true' }; } )();