1/** 2 * CLASS FunctionSpecific 3 * @author Baltazar,G.S.F. 4 */ 5var FunctionSpecific = (function() 6 { 7 var FunctionSpecific = function(){}; 8 FunctionSpecific.prototype = 9 { 10 11 pollThematics:{avancado:[],espatial:[]}, 12 13 14 pointsLayerCQ : null, 15 16 17 fieldsSpecificGroundHeight : [ 18 { 19 fields:[[{apelido:'Modelo de Terreno ' ,functtion:'functionSpecific.getAllThemes()',claass:'form-control', type:'comboBox',style:'',id:'terrenoDeclividade1'},{apelido:'m' ,functtion:'',claass:'form-control',type:'inputText',style:'',id:'metro1'}]], 20 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 21 style:"background-color: white;border: 1px solid;border-color: #1d1d18;margin-bottom: 2px;", 22 id:"div1" 23 }, 24 { 25 fields:[[{apelido:'Modelo de Superficie' ,functtion:'functionSpecific.getAllThemes()',claass:'form-control',type:'comboBox',style:'',id:'superficieDeclividade2'},{apelido:'m' ,functtion:'',type:'inputText',style:'',claass:'form-control',id:'metro2'}]], 26 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 27 style:"background-color: white;border: 1px solid;border-color: #1d1d18;margin-bottom: 2px;", 28 id:"div2" 29 }, 30 {fields:[[{apelido:'Altura total :' ,functtion:'',type:'',style:'',id:''},{apelido:'' ,claass:'form-control',functtion:'',type:'inputText',style:'',id:'htotal'}]], 31 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 32 style:"background-color: white;border: 1px solid;border-color: #1d1d18;margin-bottom: 2px;", 33 id:"div2" 34 } 35 ], 36 37 fieldsSpecificControlCQ : [ 38 { 39 fields:[[{apelido:'Tema :' ,functtion:'',type:'',claass:'form-control',style:'',id:''},{apelido:'' ,functtion:'functionSpecific.getAllThemesCQ()',type:'comboBox',claass:'form-control',style:'',id:'temaSelect'}]], 40 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 41 style:"", 42 id:"div1" 43 }, 44 { 45 fields:[[{apelido:"Selecionar Ãrea: " ,type:'',functtion:'',style:'',id:'',claass:'',img:''},{apelido:"" ,type:'button',functtion:'editorInfoTools.startEventSelectArea();',style:'',id:'btnSelectArea',claass:'',img:'image/glyphicons/glyphicons/png/glyphicons-98-vector-path-line.png'}]], 46 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 47 style:"", 48 id:"div2" 49 }, 50 { 51 fields:[[{apelido:"Apagar Seleção: " ,type:'',functtion:'',style:'',id:'',claass:'',img:''},{apelido:"" ,type:'button',functtion:'cleanMap()',style:'',id:'btnCleanArea',claass:'',img:'image/rubber.png'}]], 52 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 53 style:"", 54 id:"div3" 55 }, 56 { 57 fields:[[{apelido:"Número Gerados: " ,type:'',functtion:'',style:'',id:'',claass:'',img:''},{apelido:"" ,type:'inputNumber',id:'quantidadeNumbers',claass:'form-control'}]], 58 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 59 style:"", 60 id:"div3" 61 }, 62 { 63 fields:[[{apelido:"" ,type:'',functtion:'',style:'',id:'',claass:'',img:''}, 64 {apelido:"Gerar CQ" ,type:'button',functtion:'functionSpecific.generatePointsCQ()',style:'',id:'btnGerarPoints',claass:'btn btn-info'}]], 65 styleFields:"display: flex;justify-content: space-between;margin-bottom: 4px;margin-top: 4px;margin-right: 4px;margin-left: 4px;", 66 style:"", 67 id:"div3" 68 }, 69 ], 70 71 72 73 74 /** 75 * function to use for compare one specific character of bettwee two themes. 76 * @author Baltazar,G.S.F. 77 * @author Gusmão,L.S. 78 */ 79 compareBetweenThemes : function(tma_id_1,tma_id_1_collun_1,tma_id_2,tma_id_2_collun){ 80 try{ 81 var centroid=undefined; 82 try{centroid=editor.editingLayer.features[0].geometry.getCentroid().toString();}catch(e){centroid=functionEdition.oldSelectGeom.geometry.getCentroid().toString();} 83 var url_server = serverURLs.getRestServer(); 84 var URLLL =url_server+"rest/json"+ "/compareBetweenThemes?tmaOrigin="+tma_id_1+"&columnOrigin="+tma_id_1_collun_1+"&tmaDesteny="+tma_id_2+"&columndesteny="+tma_id_2_collun+"¢roid="+centroid; 85 URLLL+="&key="+getKey(); 86 var datas=true; 87 $.ajax({ 88 url: URLLL, 89 type: 'get', 90 async: false, 91 success: function(data) { 92 try{if(data.msg==undefined){ datas=data.result} 93 else{return true;}}catch(e){datas= true;} 94 95 } 96 }); 97 if(!datas){ 98 var comparator='vm2_ajustado'; 99 var URLLL =url_server+"rest/json"+ "/updateBetweenThemesSpacial?tmaOrigin="+tma_id_1+"&columnOrigin="+tma_id_1_collun_1+"&tmaDesteny="+tma_id_2+"&columndesteny="+tma_id_2_collun+"¢roid="+centroid+"&comparator="+comparator; 100 var datas=true; 101 URLLL+="&key="+getKey(); 102 datas=$.ajax({ 103 url: URLLL, 104 type: 'get', 105 async: false, 106 success: function(data) { 107 try{if(data.msg==undefined){data.result} 108 else{console.log(data.msg)}
108}catch(e){} 109 } 110 }); 111 } 112 }catch(e){ 113 114 } 115 }, 116 117 cutGeometry : function(){ 118 try{ 119 var gid=functionEdition.oldSelectGeom.attributes.gid; 120 var tma_id=editor.attributesSesion.theme.tma_id; 121 var usr_id=editor.attributesSesion.userId; 122 var prf_id=editor.attributesSesion.perfilId; 123 124 var url_server = serverURLs.getRestServer(); 125 var URLLL =url_server+"rest/json"+ "/cutgeometry?gid="+gid+"&tma_id="+tma_id+"&user_id="+usr_id+"&prf_id="+prf_id; 126 var datas=true; 127 URLLL+="&key="+getKey(); 128 $.ajax({ 129 url: URLLL, 130 type: 'get', 131 async: false, 132 success: function(data) { 133 try{if(data.msg==undefined){ datas=data.result} 134 else{datas=true;}}catch(e){datas= true;} 135 136 } 137 }); 138 return datas; 139 }catch(e){ 140 141 } 142 }, 143 compareValuerMobiliarioMobileSantana : function(){ 144 var fieldList=[ 145 'Razão Social','RazaoSocial', 146 'CEP do Imóvel','cep', 147 'Nº do Imóvel','Numero', 148 'IRTU Nº','InscricaoImovel', 149 'Ãrea Ocupada','AreaOcupada', 150 'Logradouro do Imóvel','Endereco', 151 'Bairro do Imóvel','Bairro', 152 'Complemento do Imóvel','complemento', 153 'CNPJ','CNPJ_CPJ', 154 'Nome Fantasia','NomeFantasia', 155 'Descrição da Atividade','Atividades', 156 'Telefone da Empresa','telefone', 157 'Email da Empresa','email', 158 'Logradouro de Entrega','enderecoEntrega', 159 'Nº de Entrega','NumeroEntrega', 160 'Bairro de Entrega','BairroEntrega', 161 'Complemento de Entrega','ComplementoEntrega', 162 'Cidade de Entrega','CidadeEntrega', 163 'UF Entrega','EstadoEntrega', 164 'CEP de Entrega','CepEntrega' 165 ]; 166 167 for(var i=0;i<fieldList.length;i=i+2){ 168 var a=infoProperty.getpopupvalue(fieldList[i]); 169 var b=infoProperty.appendNoThemedata('VIEW_GEO_MOBILIARIO;Razão Social',fieldList[i+1],'InscricaoMuniciapl','ccm',undefined,undefined,true)[0];//infoProperty.getpopupvalue("Ãrea Construida 2018 (sem beiral)"); 170 if(a!= undefined && a.trim().toLocaleLowerCase()!=b.trim().toLocaleLowerCase()){ 171 infoProperty.showpopupvaluecompared(fieldList[i],b); 172 } 173 } 174 175 176 177 }, 178 trecoCacapava : function(){ 179 var infoModal1=""; 180 var aumento_bruto=0; 181 var aumento_relativo=0; 182 var area_total_cadastro = infoProperty.appendNoThemedata('tab_pref_imovel;Ãrea total (Cadastro) [m²]','area_ocupada','inscric_padrao','inscric_padrao',undefined,undefined,true); 183 infoProperty.appendNoThemedata('tab_pref_imovel;Ãrea total (Cadastro) [m²]','area_ocupada','inscric_padrao','inscric_padrao',undefined,undefined,false); 184 infoProperty.appendNoThemedata('tab_pref_imovel;Ãrea principal (Cadastro) [m²]','area_construida','inscric_padrao','inscric_padrao',undefined,undefined,false); 185 infoProperty.appendNoThemedata('tab_pref_imovel;Ãrea edÃcula (Cadastro) [m²]','area_edicula','inscric_padrao','inscric_padrao',undefined,undefined,false); 186 187 188 var val=infoProperty.appendNoThemedata('tbl_atendimentos;Ãrea Construida Atendimento','sum(area_const_plan_principal%2Barea_const_plan_secundaria)','inscricao','inscric_padrao',undefined,undefined,true)[0];//infoProperty.getpopupvalue("Ãrea Construida Atendimento") 189 var status=""; 190 try{status=infoProperty.appendNoThemedata('tbl_atendimentos;Ãrea Construida Atendimento','status','inscricao','inscric_padrao',undefined,undefined,true)[0];}catch(e){} 191 if (val!='null' && val!='0' && val!=0 && status.toLowerCase().includes('altera')){ 192 infoModal1=infoModal1+ 193 '<div class="form-group">'+ 194 '</h6><strong>Ãrea total (Constatada) [m²]: </strong>'+ val +'</h6><br />'+ 195 '</div>'; 196 infoModal1=infoModal1+ 197 '<div class="form-group">'+ 198 '</h6><strong>Ãrea principal (Constatada) [m²]: </strong>'+ infoProperty.appendNoThemedata('tbl_atendimentos;Ãrea Principal Atendimento','sum(area_const_plan_principal)','inscricao','inscric_padrao',undefined,undefined,true)[0].replace('null','0.00') +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Principal Atendimento").replace('null','0') 199 '</div>'; 200 infoModal1=infoModal1+ 201 '<div class="form-group">'+ 202 '</h6><strong>Ãrea edÃcula (Constatada) [m²]: </strong>'+ infoProperty.appendNoThemedata('tbl_atendimentos;Ãrea Edicula Atendimento','sum(area_const_plan_secundaria)','inscricao','inscric_padrao',undefined,undefined,true)[0].replace('null','0.00') +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 203 '</div>'; 204 /* 205 //Aumento Bruto 206 try{
207 aumento_bruto = area_total_cadastro - val; 208 }catch(e){ 209 210 } 211 infoModal1=infoModal1+ 212 '<div class="form-group">'+ 213 '</h6><strong>Aumento bruto [m²]: </strong>'+ aumento_bruto +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 214 '</div>'; 215 216 //Aumento Relativo 217 try{ 218 aumento_relativo = ((1-(val/area_total_cadastro))*100).toFixed(2); 219 }catch(e){ 220 221 } 222 infoModal1=infoModal1+ 223 '<div class="form-group">'+ 224 '</h6><strong>Aumento relativo [%]: </strong>'+ aumento_bruto +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 225 '</div>';*/ 226 227 228 infoModal1=infoModal1+ 229 '<div class="form-group">'+ 230 '</h6><strong>Origem da Informação: </strong>Atendimento</h6><br />'+ 231 '</div>'; 232 233 }else{ 234 var a=infoProperty.appendNoThemedata('gpx_vet_cadastral_edificacao;Ãrea Construida 2018 (sem beiral)','sum(area_m2_sem_beiral)','carac_edif not ilike (\'%piscina%\') and cod_geo_i','inscric_padrao',undefined,undefined,true)[0];//infoProperty.getpopupvalue("Ãrea Construida 2018 (sem beiral)"); 235 //Comentado por Alexandre - *Ãrea Total Cadastro agora vem do código. 236 //var b=infoProperty.getpopupvalue("Ãrea total (Cadastro) [m²]") 237 var b = area_total_cadastro; 238 a=Number(a); 239 b=Number(b); 240 if(a>b*1.15 && !isNaN(a) && !isNaN(b)){ 241 infoModal1=infoModal1+ 242 '<div class="form-group">'+ 243 '</h6><strong>Ãrea total (Constatada) [m²]: </strong>'+ a +'</h6><br />'+ 244 '</div>'; 245 infoModal1=infoModal1+ 246 '<div class="form-group">'+ 247 '</h6><strong>Ãrea principal (Constatada) [m²]: </strong>'+ infoProperty.appendNoThemedata('gpx_vet_cadastral_edificacao;Ãrea Principal 2018 (sem beiral)','sum(area_m2_sem_beiral)','carac_edif ilike (\'%principal%\') and cod_geo_i','inscric_padrao',undefined,undefined,true)[0].replace('null','0.00') +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Principal 2018 (sem beiral)").replace('null','0') 248 '</div>'; 249 infoModal1=infoModal1+ 250 '<div class="form-group">'+ 251 '</h6><strong>Ãrea edÃcula (Constatada) [m²]: </strong>'+ infoProperty.appendNoThemedata('gpx_vet_cadastral_edificacao;Ãrea Edicula 2018 (sem beiral)','sum(area_m2_sem_beiral)','carac_edif ilike (\'%cula%\') and cod_geo_i','inscric_padrao',undefined,undefined,true)[0].replace('null','0.00') +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula 2018 (sem beiral)").replace('null','0') 252 '</div>'; 253 254 //Aumento Bruto 255 try{ 256 aumento_bruto = a - area_total_cadastro; 257 if(aumento_bruto<0){ 258 aumento_bruto = 0; 259 } 260 infoModal1=infoModal1+ 261 '<div class="form-group">'+ 262 '</h6><strong>Aumento bruto [m²]: </strong>'+ aumento_bruto.toFixed(2) +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 263 '</div>'; 264 265 }catch(e){ 266 infoModal1=infoModal1+ 267 '<div class="form-group">'+ 268 '</h6><strong>Aumento bruto [m²]: </strong> Inválido </h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 269 '</div>'; 270 } 271 272 273 //Aumento Relativo 274 try{ 275 if (area_total_cadastro>0){ 276 aumento_relativo = (((a/area_total_cadastro)-1)*100).toFixed(2); 277 278 if(aumento_relativo<0){ 279 aumento_relativo=0; 280 } 281 282 infoModal1=infoModal1+ 283 '<div class="form-group">'+ 284 '</h6><strong>Aumento relativo [%]: </strong>'+ aumento_relativo +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 285 '</div>'; 286 287 }else{ 288 infoModal1=infoModal1+ 289 '<div class="form-group">'+ 290 '</h6><strong>Aumento relativo [%]: </strong> Novo </h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 291 '</div>'; 292 } 293 294 }catch(e){ 295 infoModal1=infoModal1+ 296 '<div class="form-group">'+ 297 '</h6><strong>Aumento relativo [%]: </strong> Inválido </h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 298 '</div>'; 299 } 300 301 302 303 infoModal1=infoModal1+ 304 '<div class="form-group">'+ 305 '</h6><strong>Origem da Informação: </strong>Geometria-Atualização 2018</h6><br />'+ 306 '</div>'; 307 }else{ 308 infoModal1=infoModal1+ 309 '<div class="form-group">'+ 310 '</h6><strong>Ãrea total (Constatada) [m²]: </strong>'+ infoProperty.getpopupvalue("Ãrea total (Cadastro) [m²]").replace('null','0.00') +'</h6><br />'+ 311 '</div>'; 312 infoModal1=infoModal1+ 313 '<div class="form-group">'+ 314 '</h6><strong>Ãrea principal (Constatada) [m²]: </strong>'+ infoProperty.getpopupvalue("Ãrea principal (Cadastro) [m²]").replace('null','0.00') +'</h6><br />'+ 315 '</div>'; 316 infoModal1=infoModal1+ 317 '<div class="form-group">'+ 318 '</h6><strong>Ãrea edÃcula (Constatada) [m²]: </strong>'+ infoProperty.getpopupvalue("Ãrea edÃcula (Cadastro) [m²]").replace('null','0.00') +'</h6><br />'+ 319 '</div>'; 320 321 //Aumento Bruto - 0 devido < que 15% 322 /*try{
323 aumento_bruto = a - area_total_cadastro; 324 325 if(aumento_bruto<0){ 326 aumento_bruto = 0; 327 } 328 329 infoModal1=infoModal1+ 330 '<div class="form-group">'+ 331 '</h6><strong>Aumento bruto [m²]: </strong>'+ aumento_bruto.toFixed(2) +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 332 '</div>'; 333 334 }catch(e){ 335 infoModal1=infoModal1+ 336 '<div class="form-group">'+ 337 '</h6><strong>Aumento bruto [m²]: </strong> Inválido </h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 338 '</div>'; 339 }*/ 340 341 aumento_bruto = 0; 342 infoModal1=infoModal1+ 343 '<div class="form-group">'+ 344 '</h6><strong>Aumento bruto [m²]: </strong>'+ aumento_bruto.toFixed(2) +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 345 '</div>'; 346 347 348 //Aumento Relativo 349 /*try{ 350 if (area_total_cadastro>0){ 351 aumento_relativo = (((a/area_total_cadastro)-1)*100).toFixed(2); 352 353 if(aumento_relativo<0){ 354 aumento_relativo=0; 355 } 356 357 infoModal1=infoModal1+ 358 '<div class="form-group">'+ 359 '</h6><strong>Aumento relativo [%]: </strong>'+ aumento_relativo +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 360 '</div>'; 361 362 }else{ 363 infoModal1=infoModal1+ 364 '<div class="form-group">'+ 365 '</h6><strong>Aumento relativo [%]: </strong> Novo </h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 366 '</div>'; 367 } 368 369 }catch(e){ 370 infoModal1=infoModal1+ 371 '<div class="form-group">'+ 372 '</h6><strong>Aumento relativo [%]: </strong> Inválido </h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 373 '</div>'; 374 }*/ 375 376 aumento_relativo=0; 377 378 infoModal1=infoModal1+ 379 '<div class="form-group">'+ 380 '</h6><strong>Aumento relativo [%]: </strong>'+ aumento_relativo +'</h6><br />'+//infoProperty.getpopupvalue("Ãrea Edicula Atendimento").replace('null','0') 381 '</div>'; 382 383 infoModal1=infoModal1+ 384 '<div class="form-group">'+ 385 '</h6><strong>Origem da Informação: </strong>Cadastro</h6><br />'+ 386 '</div>'; 387 } 388 389 390 391 } 392 document.getElementById("modal-popup").innerHTML+=infoModal1; 393 }, 394 395 /*** 396 * Loads all the information about edifs without beiral 397 * lotTblName table name of layer lote "gpx_vet_cadastral_lote" 398 * cadKeyName key name of the imob table "inscric_padrao" 399 * edifTblName table name of layer lote "gpx_vet_cadastral_edificacao" 400 * substringRangeLtoE range of substring from lot to edif "8" 401 * areaColumn name of the column area in edif table "area" 402 * gidColumn name of the column gid in edif table "gid" 403 * geomColumn name of the column geom in edif table "geom" 404 * lotKeyName key name of the lot table "cod_geo_l" 405 * projection projection of the map to return wkt as text "4326" 406 * typeEdifColumn name of the column that contains the type edif in edif table "carac_edif" 407 * utm value of the utm to calculate area "31983" 408 * floorColumn name of the column floor in edif table "piso" 409 * edifKeyName key name of the edif table "cod_geo_i" 410 * dataPopup global variable of popup 411 * idModal popup ID to append info about edif 412 * wkt geometry lot in wkt to highlight 413 * restrict_area true if area restrict false if area visible 414 * @author Alexandre Penteado 415 */ 416 loadGenericEdif : function(lotTblName,cadKeyName,edifTblName,substringRangeLtoE,areaColumn, gidColumn, geomColumn,lotKeyName,projection,typeEdifColumn,utm,floorColumn,edifKeyName,dataPopup, idModal,wkt,restrict_area,keySearchTarget=undefined) 417 { 418 419 var infoModalEdif=''; 420 var infoModalEdifSecond=''; 421 var keySearch = ''; 422 if(keySearchTarget==undefined){ 423 if (substringRangeLtoE!=0){ 424 keySearch = infoProperty.dataPopup[0][cadKeyName].substring(0,substringRangeLtoE); 425 } 426 }else{ 427 keySearch=keySearchTarget; 428 } 429 430 //lote 431 infoProperty.getEdif(lotTblName,keySearch,""+gidColumn+", st_astext(ST_transform("+geomColumn+","+projection+"))",lotKeyName,undefined); 432 var dataEdif = infoProperty.getdataObjEdif(); 433 434 if (!(dataEdif==null)&&!(dataEdif=='undefined')){ 435 infoProperty.wkt=dataEdif[0].st_astext; 436 } 437 if(keySearchTarget==undefined){ 438 infoProperty.getEdif(edifTblName,dataPopup[0].pesquisa_default,""+typeEdifColumn+", "+gidColumn+", "+areaColumn+", "+floorColumn+", st_area(ST_transform(st_transform("+geomColumn+",3857),"+utm+"))",edifKeyName,floorColumn); 439 }else{ 440 infoProperty.getEdif(edifTblName,keySearch,""+typeEdifColumn+", "+gidColumn+", "+areaColumn+", "+floorColumn+", st_area(ST_transform(st_transform("+geomColumn+",3857),"+utm+"))",edifKeyName,floorColumn); 441 } 442 dataEdif = infoProperty.getdataObjEdif(); 443 444 var area_m2_sem_beiral =0.0; 445 446 if (!(dataEdif==null)&&!(dataEdif=='undefined')){ 447 448 449 var areatotaltrecocacapava=0; 450 for (var i=0; i<dataEdif.length;i++) 451 { 452 453 if (i==0){ 454 infoModalEdif = infoModalEdif+'<label><input class="edfs" id="wktedf" onclick="infoProperty.showEdf();" type="checkbox" name="optradio"> </label> Terreno';; 455 } 456 var piso = ""; 457 if(parseInt(dataEdif[i][floorColumn])==0){ 458 piso = " Térreo"; 459 }else if (parseInt(dataEdif[i][floorColumn]) > 0){ 460 piso = " Piso "+ dataEdif[i][floorColumn]; 461 }else{ 462 //piso = "Piscina/Quadra"; 463 piso = " Piso -1"; 464 } 465//TODO PAREI AQUI 466 var areaBeiral=parseFloat(dataEdif[i][areaColumn]).toFixed(2); 467 468 if(!dataEdif[i][typeEdifColumn].includes('iscina')){ 469 infoModalEdif = infoModalEdif+ 470 '<p><strong>'+ 471 '<label><input class="edfs" id="'+dataEdif[i][gidColumn]+'" onclick="infoProperty.showEdf(\''+ edifTblName +'\');" type="checkbox" name="optradio"> </label>'; 472 infoModalEdif+='</strong> '+piso; 473 474 if (restrict_area == false){ 475 infoModalEdif += ' - Ãrea ConstruÃda: '+areaBeiral+'m²'; 476 } 477 478 infoModalEdif += ' - '+dataEdif[i][typeEdifColumn]+'</h6></p>'; 479 if(areaBeiral==null || areaBeiral==undefined || areaBeiral==''){ 480 //areatotaltrecocacapava+=Number(parseFloat(dataEdif[i].st_area).toFixed(2)); 481 }else{ 482 areatotaltrecocacapava+=Number(areaBeiral); 483 } 484 }else{ 485 infoModalEdifSecond = infoModalEdifSecond+ 486 '<p><strong>'+ 487 '<label><input class="edfs" id="'+dataEdif[i][gidColumn]+'" onclick="infoProperty.showEdf(\''+ edifTblName +'\');" type="checkbox" name="optradio"> </label>'; 488 infoModalEdifSecond+='</strong> '+piso; 489 490 if (restrict_area == false){ 491 infoModalEdif += ' - Ãrea ConstruÃda: '+areaBeiral+'m²' 492 } 493 infoModalEdif += ' - '+dataEdif[i][typeEdifColumn]+'</h6></p>'; 494 } 495 496 } 497 } 498 499 if (restrict_area == false){ 500 infoModalEdif = infoModalEdif + '<p></h6><strong>Total: </strong>'+parseFloat(areatotaltrecocacapava).toFixed(2)+' m²</h6></p><p>'+infoModalEdifSecond+'</p>'; 501 }else{ 502 infoModalEdif = infoModalEdif + '<p>'+infoModalEdifSecond+'</p>'; 503 } 504 505 $(idModal).append(infoModalEdif); 506 507 }, 508 509 makeTela : function(txt,titulo){ 510 if(titulo==undefined){titulo="";} 511 var textPopUp1=newpublish.makeFields(newpublish.fields); 512 if(document.getElementById('pointwindow-modal-txt')!=undefined){ 513 document.getElementById('pointwindow-modal-txt').remove(); 514 } 515 var modal= '<div class="modal-drag fade" id="pointwindow-modal-txt" role="dialog" style="width:30%;margin:0; position:absolute; top:100px;height:auto;"> '+ 516 '<div class="modal-dialog modal-lgthematic" style="width: auto;height: auto;margin: 0px;"> '+ 517 '<div class="modal-content" id="modal-content" > '+ 518 '<div class="modal-header drag">'+ 519 '<button type="button" onclick="document.getElementById(\'pointwindow-modal-txt\').remove();editorInfoTools.previousValeu=undefined;editor.infoPop = false;" class="close" >×</button>'+ 520 '</div>'+ 521 '<div class="modal-body" id="modal-body" style="widith:100%;overflow:auto;height:auto;max-height: 477px;"> '+ 522 '<div class="form-group"><center><h3>'+titulo+'</h3></center>'+ 523 txt+ 524 '</div>'+//colum 525 '</div>'+//body 526 '<div class="modal-footer" id="pointwindow-modal-txt-Footer"> '+ 527 '<button class="btn btn-danger " onclick="(function(){editorInfoTools.historyLayer.destroyFeatures();editor.infoPop = false;document.getElementById(\'pointwindow-modal-txt\').remove();editorInfoTools.previousValeu=undefined;if(editor.typeTool!=\'point\'){var point = new OpenLayers.Geometry.Point(editor.lonlat.lon,editor.lonlat.lat);
527/**editor.saveChange(point);*/editor.typeText=\'padrao\';}})()">Fechar</button>'+ 528 '</div> '+ 529 '</div> '+//content 530 '</div> '+//dialog 531 '</div> ';//fade 532 $(modal).appendTo('body'); 533 $('#pointwindow-modal-txt').modal('show'); 534 // $('#lonlatx').prop('readonly',true);$('#lonlaty').prop('readonly',true); 535 $('#utmx').prop('readonly',true);$('#utmy').prop('readonly',true); 536 $('#azimuteAngulo').prop('readonly',true);$('#azimuteDistance').prop('readonly',true); 537 538 $('#pointwindow-modal-txt').draggable({ 539 handle: ".drag", 540 cursor: "move" 541 });smartChanger.activateDragPopUp('pointwindow-modal-txt'); 542 $('#pointwindow-modal-txt-Footer').draggable({ 543 handle: ".drag", 544 cursor: "move" 545 });smartChanger.activateDragPopUp('pointwindow-modal-txt-Footer'); 546 }, 547 548 getAllThemes : function(){ 549 try{var lst='';var resp=''; 550 var url = serverURLs.getRestServer()+"rest/json/GroundHeightTheme?prf_id="+getProfileIDInSession(); 551 $.ajax({ 552 url: url, 553 type: 'post', 554 async: false, 555 success: function(data) { 556 resp=data; 557 558 }, 559 failure: function(data) { 560 } 561 }); 562 if(resp.length>0){ 563 for(var x=0;x<resp.length;x++){ 564 lst+='<option value="'+resp[x].titulo_tema+'">'+resp[x].titulo_tema+'</option>'; 565 } 566 newpublish.opst=lst; 567 } 568 }catch(e){} 569 570 }, 571 572 getAllThemesCQ : function(){ 573 try{var lst=''; 574 for(var x=0;x<window.editor.listThemesEdition.length;x++){ 575 lst+='<option value="'+window.editor.listThemesEdition[x].edittheme+'">'+window.editor.listThemesEdition[x].edittheme+'</option>'; 576 } 577 newpublish.opst=lst;}catch(e){} 578 }, 579 580 generatePointsCQ : function(){ 581 var geomBK=editor.breakPointer(editor.savedLayer.features[0].geometry).geometry; 582 var numbers=document.getElementById('quantidadeNumbers').value; 583 if(functionSpecific.pointsLayerCQ==null){ 584 functionSpecific.pointsLayerCQ=new OpenLayers.Layer.Vector("Pontos Controle de Qualidade",{styleMap: new OpenLayers.StyleMap({ // variable Guide Layer transversal.Stores label EDGE 585 "default": new OpenLayers.Style({ 586 strokeColor: "#ff0000", 587 strokeOpacity: 1, 588 strokeWidth: 4, 589 graphicName: "cross", 590 fillOpacity: 0.0, 591 graphic:true, 592 pointRadius:6}) 593 })}) 594 } 595 map.addLayers([functionSpecific.pointsLayerCQ]); 596 editor.destroyLayer(functionSpecific.pointsLayerCQ) 597 var resp=editor.getAttributesSesion(document.getElementById('temaSelect').value,false,'',true); 598 var table=resp.themeAttributes.table; 599 var geomIntersect="POLYGON(("; 600 for(var x=0;x<editor.savedLayer.features[0].geometry.components.length;x++){ 601 geomIntersect+=editor.savedLayer.features[0].geometry.components[x].toString().replace("POINT(","").replace(")",''); 602 if(x<editor.savedLayer.features[0].geometry.components.length-1){geomIntersect+=","} 603 }geomIntersect+="))"; 604 var url = serverURLs.getRestServer()+"rest/json/getPointsCQ?table="+table+"&numbers="+numbers; 605 $.ajax({ 606 url: url, 607 type: 'post', 608 data:{geom:geomIntersect}, 609 async: false, 610 success: function(data) { 611 var ff=new OpenLayers.Feature.Vector(geomBK); 612 functionSpecific.pointsLayerCQ.addFeatures([ff]); 613 for(var x=0;x<data.length;x++){ 614 var x1=data[x].st_astext.replace('POINT(','').replace(')','').split(' ')[0]; 615 var y1=data[x].st_astext.replace('POINT(','').replace(')','').split(' ')[1]; 616 var point=new OpenLayers.Geometry.Point(x1,y1) 617 var ff=new OpenLayers.Feature.Vector(point); 618 functionSpecific.pointsLayerCQ.addFeatures([ff]); 619 } 620 621 }, 622 failure: function(data) { 623 } 624 }); 625 }, 626 627 functionDeclivity : function(){ 628 functionSpecific.makeTela(newpublish.makeFields(functionSpecific.fieldsSpecificGroundHeight),'Declividade'); 629 removeEvents("onClickSpacial,loadI,loadInfoPopup");// REMOVE O CONFLITO DO POPUP 630 try{mapService.organize();tree.reorganize();}catch(e){} // REORGANIZE LAYERS ON THE MAP 631 632 editor.clean(editor.onMoveObserver); 633 editor.clean(editor.onLeftClickObservers); 634 editor.clean(editor.onRigthClickObservers); 635 editor.cleanObjects(); 636 editor.cleanEditingLayer(); 637 editor.attach(editor.onLeftClickObservers,functionSpecific.getPointedDeclivity); 638 }, 639 640 getPointedDeclivity : function (point){ 641 var proj='EPSG:3857'; 642 var values=['terrenoDeclividade1','superficieDeclividade2']; 643 644 var datas=[]; 645 var resp=[]; 646 for(var t=0;t<values.length;t++){ 647 var layer=document.getElementById(values[t]).value 648 var url_server = serverURLs.getRestServer(); 649 var url =url_server+ "rest/json/getRasterCoordInfo?LAYERS="+layer+"&X="+point.x+"&Y="+point.y+"&SRS="+proj; 650 $.ajax({ 651 url: url, 652 type: 'get', 653 async: false, 654 success: function(data) { 655 datas.push(data) 656 console.log(data); 657 }, 658 failure: function(data) { 659 } 660 }); 661 } 662 try{document.getElementById('metro1').value=datas[0].band0.toFixed(2);}catch(e){document.getElementById('metro1').value='(VAZIO)';} 663 try{document.getElementById('metro2').value=datas[1].band0.toFixed(2);}catch(e){document.getElementById('metro2').value='(VAZIO)';} 664 try{document.getElementById('htotal').value=(datas[0].band0-datas[1].band0).toFixed(2);}catch(e){document.getElementById('htotal').value='(VAZIO)';} 665 }, 666 667 UpdateCacapavaSQL : function(tma_id_1,tma_id_1_collun_1,tma_id_2,tma_id_2_collun){
668 try{ 669 670 var url_server = serverURLs.getRestServer(); 671 var URLLL =url_server+"rest/json"+ "/UpdateCacapavaSQL?tmaOrigin="+tma_id_1+"&columnOrigin="+tma_id_1_collun_1+"&tmaDesteny="+tma_id_2+"&columndesteny="+tma_id_2_collun+"¢roid="+centroid; 672 var datas=true; 673 $.ajax({ 674 url: URLLL, 675 type: 'get', 676 async: false, 677 success: function(data) { 678 try{ 679 if(data.msg==undefined){ 680 console.log(data.result) 681 }else{ 682 editorInfoTools.createPopUpInfomative('<h4><center>'+data.msg+' </center></h4>','waring',5000); 683 } 684 }catch(e){} 685 686 } 687 }); 688 }catch(e){ 689 690 } 691 }, 692 693 getPhotoGenercGoogleByPoint : function(coordx,coordy){ 694 editor.typeTool="streeatPhoto"; 695 window.functionSpecific.point={coordx:coordx,coordy:coordy} 696 streetViewPanorama.initialize(); 697 setTimeout(function(){ 698 var p1Copy=new OpenLayers.Geometry.Point(window.functionSpecific.point.coordx,window.functionSpecific.point.coordy); 699 var wgs = new OpenLayers.Projection("EPSG:4326"); 700 var mercator = new OpenLayers.Projection("EPSG:3857"); 701 var utmsirgas = new OpenLayers.Projection("EPSG:"+serverURLs.getUtmsirgas()); 702 p1Copy=p1Copy.transform(wgs,mercator); 703 editor.show(editor.editingLayer,editor.breakPointer(p1Copy).geometry); 704 streetViewPanorama.getPointStrearView(p1Copy); 705 },500); 706 }, 707 708 updateTabDocumentMobileTask : function(oldid=undefined,newdid=undefined,tma_id=undefined){ 709 var gidOld1=0;var gidNew1=0;var tma_id1; 710 try{ gidOld1=window.editor.oldIDGeom;}catch(e){}if(oldid!=undefined){gidOld1=oldid;} 711 try{gidNew1=window.editor.newIDGeom;}catch(e){}if(newdid!=undefined){gidNew1=newdid;} 712 try{ tma_id1=editor.attributesSesion.theme.tma_id;}catch(e){}if(tma_id!=undefined){tma_id1=tma_id;} 713 var url_server = serverURLs.getRestServer(); 714 var URLLL =url_server+"rest/json"+ "/updateTabCode"; 715 var datas=true; 716 if(gidOld1!=0 && gidNew1!=0){ 717 $.ajax({ 718 url: URLLL, 719 type: 'POST', 720 async: false, 721 data :{gidOld:gidOld1,gidNew:gidNew1,tma_id:tma_id1,key:getKey()}, 722 complete: function(data) { 723 try{ 724 if(data.responseJSON.msg=="Feito"){ 725 editorInfoTools.createPopUpInfomative('Atualização de documentos com sucesso!','success',5000); 726 }else{ 727 editorInfoTools.createPopUpInfomative('Erro ao atualizar documentos! Contate o suporte!','waring',10000); 728 } 729 }catch(e){ 730 editorInfoTools.createPopUpInfomative('Erro ao atualizar documentos! Contate o suporte!','waring',10000); 731 } 732 } 733 }); 734 } 735 }, 736 737 updateAngleTabDocument : function(angle,idTabDoc){ 738 var URLLL =serverURLs.getRestServer()+"rest/json"+ "/updateAngleTabDocument"; 739 var datas=true; 740 angle=Math.abs(angle)>360?90:Math.abs(angle); 741 $.ajax({ 742 url: URLLL, 743 type: 'POST', 744 async: false, 745 data :{angle:angle,id:idTabDoc}, 746 complete: function(data) { 747 console.log('atualizado tabDoc id='+idTabDoc); 748 } 749 }); 750 }, 751 752 getAngleTabDocument : function(idTabDoc){ 753 var URLLL =serverURLs.getRestServer()+"rest/json"+ "/getAngleTabDocument"; 754 var ang=0; 755 $.ajax({ 756 url: URLLL, 757 type: 'POST', 758 async: false, 759 data :{id:idTabDoc}, 760 complete: function(data) { 761 try{ang=Number(data.responseJSON.msg);}catch(e){ang=0;} 762 } 763 }); 764 return ang; 765 }, 766 createNewObjectByPoint : undefined, 767 768 creteSomePoint : function(point,tma){ 769 if(point!=undefined){ 770 infoProperty.save(functionSpecific.createNewObjectByPoint,undefined,true); 771 editor.clean(editor.onMoveObserver); 772 editor.clean(editor.onLeftClickObservers); 773 editor.clean(editor.onRigthClickObservers); 774 editor.destroyLayer(editor.savedLayer); 775 editor.cleanObjects(); 776 editor.savedLayer = editor.resetLayersEditor('savedLayer'); 777 editor.setObservers('popup'); 778 functionSpecific.createNewObjectByPoint=undefined; 779 } 780 else{ 781 if(tma==undefined){tma=resume.getTheme();} 782 functionSpecific.createNewObjectByPoint=tma; 783 removeEvents("onClickSpacial,loadI,loadInfoPopup"); 784 editorInfoTools.createPopUpInfomative('<h4><center>Selecione um local </center></h4>','alert',5000); 785 editor.clean(editor.onMoveObserver); 786 editor.clean(editor.onLeftClickObservers); 787 editor.clean(editor.onRigthClickObservers); 788 editor.attach(editor.onLeftClickObservers,editor.drawPoint); 789 editor.attach(editor.onLeftClickObservers,functionSpecific.creteSomePoint); 790 } 791 792 }, 793 794 updateGeoLocation : function(point,tma,cancel){ 795 if(cancel!=undefined){ 796 editor.clean(editor.onMoveObserver); 797 editor.clean(editor.onLeftClickObservers); 798 editor.clean(editor.onRigthClickObservers); 799 editor.destroyLayer(editor.savedLayer); 800 editor.destroyLayer(editor.editingLayer); 801 editor.cleanObjects(); 802 editor.savedLayer = editor.resetLayersEditor('savedLayer'); 803 editor.setObservers('popup'); 804 functionSpecific.createNewObjectByPoint=undefined; 805 }else{ 806 if(point!=undefined){ 807 var tmaid=functionSpecific.createNewObjectByPoint; 808 if(window.infoProperty.samePoints!=undefined){ 809 /*editorInfoTools.createPopUp('<div style="width:470px;">'+ 810 '<div class="col-md-8 col-xs-12 col-sm-12 mb-3"><div><h5>Deseja salvar nova coordenada?</h5></div>'+ 811 '<div><button class="btn btn-warning" onclick="infoProperty.save('+tmaid+',true,true,true);document.getElementById(\'pointwindow-modal\').remove();functionSpecific.updateGeoLocation(undefined,undefined,true);">Sim,para todos</button>'+ 812 '<button class="btn btn-success" onclick="window.infoProperty.samePoints=undefined;functionSpecific.updateGeoLocation(true,'+tmaid+');document.getElementById(\'pointwindow-modal\').remove();functionSpecific.updateGeoLocation(undefined,undefined,true);">Somente este</button>'+ 813 '<button class="btn btn-danger" onclick="window.infoProperty.samePoints=undefined;functionSpecific.updateGeoLocation(undefined,undefined,true);document.getElementById(\'pointwindow-modal\').remove();">Cancelar</button>'+ 814 '</div></div></div>'); 815 document.getElementById('pointwindow-modal').style.left=window.innerWidth/2*0.8+'px';*/ 816 817 var dialog = $('<p>Deseja salvar nova coordenada?</p>').dialog({ 818 buttons: { 819 "Sim,para todos": function() {infoProperty.save(tmaid,true,true,true);functionSpecific.updateGeoLocation(undefined,undefined,true);dialog.dialog('close');}, 820 "Somente este": function() {window.infoProperty.samePoints=undefined;functionSpecific.updateGeoLocation(true,tmaid);functionSpecific.updateGeoLocation(undefined,undefined,true);dialog.dialog('close');}, 821 "Cancelar": function() { 822 window.infoProperty.samePoints=undefined;functionSpecific.updateGeoLocation(undefined,undefined,true); 823 dialog.dialog('close'); 824 } 825 } 826 }); 827 828 } 829 else{ 830 infoProperty.save(tmaid,true,true,true); 831 editor.clean(editor.onMoveObserver); 832 editor.clean(editor.onLeftClickObservers); 833 editor.clean(editor.onRigthClickObservers); 834 editor.destroyLayer(editor.savedLayer); 835 editor.destroyLayer(editor.editingLayer); 836 editor.cleanObjects(); 837 editor.savedLayer = editor.resetLayersEditor('savedLayer'); 838 editor.setObservers('popup'); 839 functionSpecific.createNewObjectByPoint=undefined; 840 } 841 } 842 else{ 843 if(tma==undefined){tma=resume.getTheme();} 844 functionSpecific.createNewObjectByPoint=tma; 845 removeEvents("onClickSpacial,loadI,loadInfoPopup"); 846 editorInfoTools.createPopUpInfomative('<h4><center>Selecione um local </center></h4>','alert',5000); 847 editor.clean(editor.onMoveObserver); 848 editor.clean(editor.onLeftClickObservers); 849 editor.clean(editor.onRigthClickObservers); 850 editor.attach(editor.onLeftClickObservers,editor.drawPoint); 851 editor.attach(editor.onLeftClickObservers,functionSpecific.updateGeoLocation); 852 document.getElementById(infoProperty.idModalNome).style.display='none'; 853 } 854 } 855 856 }, 857 858 creteSomePointByPopUp : function(){
859 try{ 860 editor.resetLayersEditor() 861 var wgs = new OpenLayers.Projection("EPSG:4326"); 862 var mercator = new OpenLayers.Projection("EPSG:3857"); 863 var xyLonLat = map.getLonLatFromPixel(infoProperty.lastX.xy); 864 var point = new OpenLayers.Geometry.Point(xyLonLat.lon,xyLonLat.lat); 865 editor.drawPoint(point); 866 editor.show(editor.editingLayer,point); 867 }catch(e){} 868 }, 869 870 createNewObjectByResume : function(tma_id,createGeom,typeGeom,buttonsv1Test=true,attributesOtputs=false){ 871 functionSpecific.createNewObjectByResumeTma_id=tma_id; 872 if(createGeom){if(typeGeom==undefined || typeGeom==''){ 873 //pega o geom pelo editor 874 infoProperty.loadInfoPopupEdit(functionSpecific.createNewObjectByResumeTma_id,'new',buttonsv1Test); 875 }else{ 876 //pega o geom do popUp 877 try{ 878 functionSpecific.creteSomePointByPopUp(); 879 infoProperty.loadInfoPopupEdit(functionSpecific.createNewObjectByResumeTma_id,'newPointByPopup',buttonsv1Test); 880 }catch(e){} 881 } 882 } 883 else{infoProperty.loadInfoPopupEdit(functionSpecific.createNewObjectByResumeTma_id,'save');} 884 if(attributesOtputs!=false){ 885 for(var x=0;x<attributesOtputs.length;x++){ 886 try{ 887 document.getElementById(attributesOtputs[x].key).value=attributesOtputs[x].value; 888 }catch(e){} 889 } 890 } 891 }, 892 893 createTelaGrapich : function(fild,title,tela){ 894 if(tela.contains('resu')){ 895 if($('#resume-table').bootstrapTable('getSelections').length>0 && $('#resume-table').bootstrapTable('getSelections').length<2){ 896 thematicmap.createObraSchedule($('#resume-table').bootstrapTable('getSelections')[0][fild],title); 897 }else if($('#resume-table').bootstrapTable('getSelections').length==0){ 898 if(infoProperty.dataPopup[0][fild]!=undefined){ 899 thematicmap.createObraSchedule(infoProperty.dataPopup[0][fild],title); 900 }else{ 901 editorInfoTools.createPopUpInfomative('<h4><center>Selecione um Registro </center></h4>','waring',5000); 902 } 903 904 }else{editorInfoTools.createPopUpInfomative('<h4><center>Selecione apenas 1 Registro </center></h4>','waring',5000);} 905 }else if (tela.contains('pop')){ 906 if(infoProperty.dataPopup!=undefined){thematicmap.createObraSchedule(infoProperty.dataPopup[0][fild],title);} 907 else{editorInfoTools.createPopUpInfomative('<h4><center>Nada Consta!</center></h4>','waring',5000);} 908 }else{ 909 editorInfoTools.createPopUpInfomative('<h4><center>Funcionalidade indisponivel! \n Contate o suporte </center></h4>','waring',5000); 910 } 911 912 }, 913 914 getUserByName : function(tma_id,collum,idDocument){ 915 var keyName=collum; 916 var keyValue=document.getElementById(idDocument).value; 917 if(keyValue==""){ 918 editorInfoTools.createPopUpInfomative('<h4><center>Não Encontrado</center></h4>','waring',3000); 919 return false; 920 }else{ 921 if(keyName.toLowerCase().contains('cpf')){return resume.callMe(tma_id,'',keyValue);} 922 else{ 923 var result=resume.loadData(tma_id,"*",'',keyValue,'',''); 924 if(result.length>0){ 925 resume.showModal(); 926 $("#cbo-infotable option[tma_id="+tma_id+"]").prop('selected', true); 927 resume.loadColumns(tma_id); 928 resume.setChangeTheme("",false); 929 resume.loadData(tma_id,"*",'',keyValue,'',''); 930 resume.loadButtons(tma_id,'resume'); 931 }else{ 932 editorInfoTools.createPopUpInfomative('<h4><center>Nenhum resultado encontrado</center></h4>','waring',3000); 933 } 934 //resume.callMe(tma_id,keyName,keyValue); 935 } 936 } 937 }, 938 939 copyValueById : function(element,idSource){ 940 try{ 941 var valor=document.getElementById(idSource).value; 942 if(valor!=undefined && valor!=null && valor!=''){ 943 element.value=valor; 944 } 945 }catch(e){} 946 }, 947 948 /** 949 * function used to duplicate theme blocks inside json form 950 * @param tma_source {int} target theme block inside json form that will be duplicated 951 * @param form_id {String} optional variable. if null will use default last form was that generated 952 * @param object {String} optional param. if different of false will be append HTML on this child 953 * @author Baltazar,G.S.F. 954 * OBS: encapsulated call in "functionsForm.duplicateBlockThemeForm" 955 * documented by Gabriel.Baltazar 956 */ 957 duplicateFieldsByTheme : function(tma_source,form_id,object=false){
958 try{ 959 var elementOfForm; 960 961 if(window.functionSpecific.buttons==undefined){ 962 window.functionSpecific.buttons=0; 963 }else{ 964 window.functionSpecific.buttons+=1; 965 } 966 if(form_id==undefined){ 967 elementOfForm=document.getElementById(interpreter.storage.formID); 968 }else{ 969 elementOfForm=document.getElementById(form_id); 970 } 971 972 var element=document.getElementById('theme-'+tma_source).cloneNode(true); 973 let buttons=element.getElementsByTagName('button'); 974 975 for(let a=0;a<buttons.length;a++){ 976 buttons[a].id+="_"+window.functionSpecific.buttons; 977 } 978 if(object!=false){ 979 $('#theme-'+tma_source).after($(element.outerHTML)); 980 }else{ 981 try{ 982 elementOfForm.firstChild.appendChild(element); 983 }catch(e){ 984 elementOfForm.appendChild(element); 985 } 986 } 987 988 //===============clear components================== 989 var x=$('[id=theme-'+tma_source+']').length-1; 990 var fakeImages = $('[id=theme-'+tma_source+']')[x].querySelectorAll('input'); 991 var fakeImages2 = $('[id=theme-'+tma_source+']')[x].querySelectorAll('textarea'); 992 var fakeImages3 = $('[id=theme-'+tma_source+']')[x].querySelectorAll('select'); 993 for (var i = 0; i < fakeImages.length; i++){ 994 try{ 995 if($(fakeImages[i]).attr('disabled') == undefined){ 996 $(fakeImages[i]).val(''); 997 } 998 }catch(e){} 999 } 1000 for (var i = 0; i < fakeImages2.length; i++){ 1001 try{ 1002 if($(fakeImages[i]).attr('disabled') == undefined){ 1003 $(fakeImages[i]).val(''); 1004 } 1005 }catch(e){} 1006 } 1007 for (var i = 0; i < fakeImages3.length; i++){ 1008 try{ 1009 if($(fakeImages[i]).attr('disabled') == undefined){ 1010 $(fakeImages[i]).val(''); 1011 } 1012 }catch(e){} 1013 } 1014 //================================= 1015 functionSpecific.callMaksByForm(tma_source); 1016 }catch(e){} 1017 }, 1018 1019 selectFieldsHideAndShowByTheme : function(element,list_value,list_tma_source, tma_target){ 1020 try{ 1021 var pass=false; 1022 list_value=list_value.split(';'); 1023 for(var x=0;x<list_value.length;x++){ 1024 if(element.value.toString().toLowerCase()==list_value[x].toLowerCase()){ 1025 functionSpecific.hideFieldsByTheme(list_tma_source); 1026 pass=true; 1027 } 1028 }if(!pass){ 1029 functionSpecific.showFieldsByTheme(list_tma_source, tma_target); 1030 //window.functionSpecific.cloneElement=[]; 1031 } 1032 }catch(e){} 1033 }, 1034 1035 hideFieldsByTheme : function(list_tma_source){ 1036 try{ 1037 list_tma_source=list_tma_source.split(';'); 1038 for(var x=0;x<list_tma_source.length;x++){ 1039 if(window.functionSpecific.cloneElement==undefined){window.functionSpecific.cloneElement=[];} 1040 window.functionSpecific.cloneElement.push({chave:list_tma_source[x],valor:document.getElementById(''+list_tma_source[x]).cloneNode(true)}); 1041 document.getElementById(''+list_tma_source[x]).remove() 1042 } 1043 1044 }catch(e){} 1045 }, 1046 showFieldsByTheme : function(list_tma_source, tma_target){ 1047 try{ 1048 list_tma_source=list_tma_source.split(';'); 1049 var teste=document.getElementById(interpreter.storage.formID); 1050 for(var y=0;y<list_tma_source.length;y++){ 1051 for(var x=0;x<window.functionSpecific.cloneElement.length;x++){ 1052 if(window.functionSpecific.cloneElement[x].chave==list_tma_source[y]){ 1053 if(tma_target != undefined){ 1054 $(`#${tma_target}`).insertAfter(window.functionSpecific.cloneElement[x].valor); 1055 } else { 1056 teste.appendChild(window.functionSpecific.cloneElement[x].valor); 1057 } 1058 window.functionSpecific.cloneElement.splice(x, 1); 1059 x=-1; 1060 } 1061 } 1062 } 1063 }catch(e){} 1064 }, 1065 1066 getInformation : function(type,field,fieldDestiny,value){ 1067 if(type=='attr'){ 1068 var teste=document.getElementById('modal-popup'); 1069 var element=document.createElement('input'); 1070 element.setAttribute('type','text'); 1071 element.setAttribute('id',field); 1072 element.setAttribute('value',value); 1073 element.style.display='none'; 1074 teste.appendChild(element); 1075 } 1076 }, 1077 1078 /** 1079 * Applies masks to form fields 1080 * 1081 */ 1082 applyFormMasks: function(){ 1083 const result=interpreter.getMasks(); 1084 for(let x=0;x<result.length;x++){ 1085 const elements=document.querySelectorAll('[id='+result[x].element+']'); 1086 for(let t=0;t<elements.length;t++){ 1087 1088 let resultMask; 1089 try{ 1090 resultMask=result[x].mask; 1091 1092 }catch(e){ 1093 console.log(e); 1094 } 1095 try{ 1096 const mask = new IMask( 1097 elements[t], { 1098 mask: resultMask 1099 }) 1100 }catch(e){ 1101 console.log(e) 1102 } 1103 1104 } 1105 } 1106 }, 1107 1108 callMaksByForm : function(tma_id){ 1109 var testJson=registerus.checkFormJson(tma_id); 1110 if(testJson!=false) 1111 { 1112 var result=interpreter.getMasks(); 1113 for(var x=0;x<result.length;x++){ 1114 var elements=document.querySelectorAll('[id='+result[x].element+']'); 1115 for(var t=0;t<elements.length;t++){ 1116 1117 var resultMask; 1118 try{ 1119 resultMask=result[x].mask; 1120 1121 }catch(e){ 1122 console.log(e); 1123 } 1124 try{ 1125 var mask = new IMask( 1126 elements[t], { 1127 mask: resultMask 1128 }) 1129 }catch(e){ 1130 console.log(e) 1131 } 1132 1133 } 1134 } 1135 } 1136 }, 1137 1138 /** function to use for error message 1139 * @param element Tag of input 1140 * @param showError check error true or false 1141 * @param msg Error msg 1142 * @return Style in input with message 1143 * @author Santos,R.M. 1144 */ 1145 showFieldErrorMessage: function(element,showError,msg){ 1146 if(showError){ 1147 const textErrorMsg = document.getElementById('msg-incorrect-'+element.i
1147d); 1148 if(textErrorMsg != null){ 1149 element.style.cssText = 'border:1px solid #ced4da'; 1150 textErrorMsg.remove() 1151 } 1152 }else{ 1153 if(!(document.body.contains(document.getElementById('msg-incorrect-'+element.id)))){ 1154 element.style.border="1px solid red"; 1155 check=false; 1156 const divInput = element.parentElement; 1157 const errorMsg = document.createElement('span'); 1158 errorMsg.id = 'msg-incorrect-'+element.id; 1159 errorMsg.innerHTML = msg; 1160 divInput.appendChild(errorMsg); 1161 document.getElementById('msg-incorrect-'+element.id).style.color = 'red'; 1162 document.getElementById('msg-incorrect-'+element.id).style.fontSize = '12px'; 1163 } 1164 } 1165 }, 1166 1167 1168 validadeField : function(element,typeCompare,valorCompare,msg){ 1169 var check=true; 1170 switch(element.type){ 1171 case 'date': 1172 console.log('date'); 1173 break; 1174 case 'text': 1175 if(typeCompare=='diferente'){ 1176 if(element.value.toString()!=valorCompare.toString()){element.style.backgroundColor="";}else{element.style.backgroundColor="#f3606073";editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000);check=false;} 1177 } 1178 else if(typeCompare=='igual'){ 1179 if(element.value.toString()==valorCompare.toString()){element.style.backgroundColor="";}else{element.style.backgroundColor="#f3606073";editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000);check=false;} 1180 } 1181 else if(typeCompare=='maior'){ 1182 if(element.value.toString()>valorCompare.toString()){element.style.backgroundColor="";}else{element.style.backgroundColor="#f3606073";editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000);check=false;} 1183 } 1184 else if(typeCompare=='menor'){ 1185 if(element.value.toString()<valorCompare.toString()){element.style.backgroundColor="";}else{element.style.backgroundColor="#f3606073";editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000);check=false;} 1186 } 1187 else if(typeCompare.toLocaleLowerCase()=='cpf'){ 1188 if(functionSpecific.checkCPF(element.value.toString())){element.style.backgroundColor="";}else{element.value='';element.style.backgroundColor="#f3606073";editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000);check=false;} 1189 } 1190 break; 1191 default: 1192 console.log('entrou'); 1193 break; 1194 } 1195 return check; 1196 }, 1197 1198 /** function to use for validade CNPJ (numeric or alphanumeric), return true or false 1199 *@param value(String) value of CNPJ 1200 *@return Boolean 1201 * @author Baltazar,G.S.F. 1202 */ 1203 1204 /** 1205 * Validates numeric or alphanumeric CNPJ by checking format and verifying check digits 1206 * Supports both old (numeric) and new (alphanumeric) formats per IN RFB nº 2.119/2022 1207 * Rejects known invalid numeric patterns (all repeated digits) 1208 * 1209 * @param {string} value - CNPJ with or without formatting 1210 * @returns {boolean} True if valid CNPJ, false otherwise 1211 */ 1212 checkCNPJ : function(value) { 1213 const cnpj = String(value).toUpperCase().replace(/[^0-9A-Z]+/g, ''); 1214 1215 if (cnpj === '' || cnpj.length !== 14) { 1216 return false; 1217 } 1218 1219 if (/^[0-9]+$/.test(cnpj)) { 1220 const invalidPatterns = ['00000000000000', '11111111111111', '22222222222222', '33333333333333', '44444444444444', '55555555555555', '66666666666666', '77777777777777', '88888888888888', '99999999999999']; 1221 if (invalidPatterns.includes(cnpj)) { 1222 return false; 1223 } 1224 } 1225 1226 let size = cnpj.length - 2; 1227 let chars = cnpj.substring(0, size); 1228 const digits = cnpj.substring(size); 1229 let sum = 0; 1230 let position = size - 7; 1231 1232 for (let i = size; i >= 1; i--) { 1233 const charValue = this.charToNumeric(chars.charAt(size - i)); 1234 sum += charValue * position--; 1235 if (position < 2) { 1236 position = 9; 1237 } 1238 } 1239 1240 let remainder = sum % 11; 1241 let verifyDigit = remainder < 2 ? 0 : 11 - remainder; 1242 if (String(verifyDigit) !== digits.charAt(0)) { 1243 return false;
1244 } 1245 1246 size = size + 1; 1247 chars = cnpj.substring(0, size); 1248 sum = 0; 1249 position = size - 7; 1250 1251 for (let i = size; i >= 1; i--) { 1252 const charValue = this.charToNumeric(chars.charAt(size - i)); 1253 sum += charValue * position--; 1254 if (position < 2) { 1255 position = 9; 1256 } 1257 } 1258 1259 remainder = sum % 11; 1260 verifyDigit = remainder < 2 ? 0 : 11 - remainder; 1261 if (String(verifyDigit) !== digits.charAt(1)) { 1262 return false; 1263 } 1264 1265 return true; 1266 }, 1267 1268 /** 1269 * Converts alphanumeric character to numeric value via ASCII - 48 1270 * Conforms to IN RFB nº 2.119/2022 (alphanumeric CNPJ specification) 1271 * 0-9 (ASCII 48-57) => 0-9 1272 * A-Z (ASCII 65-90) => 17-42 1273 * 1274 * @param {string} char - Single character ('0'-'9' or 'A'-'Z') 1275 * @returns {number} Numeric value 0-42 1276 * @throws {Error} If character is not 0-9 or A-Z 1277 */ 1278 charToNumeric: function(char) { 1279 const upperChar = String(char).toUpperCase(); 1280 const code = upperChar.charCodeAt(0); 1281 const value = code - 48; 1282 1283 if ((value >= 0 && value <= 9) || (value >= 17 && value <= 42)) { 1284 return value; 1285 } 1286 throw new Error('Invalid character for alphanumeric CNPJ: ' + char); 1287 }, 1288 1289 1290 checkCPF: function(value) 1291 { 1292 const cleanCPF = String(value).replace(/\.|-|\s|\//g, '') 1293 const firstNineDigits = cleanCPF.substring(0, 9) 1294 const checker = cleanCPF.substring(9, 11) 1295 if (cleanCPF.length !== 11) { 1296 return false 1297 } 1298 // Checking if all digits are equal 1299 for (let i = 0; i < 10; i++) { 1300 if (`${firstNineDigits}${checker}` === Array(12).join(String(i))) { 1301 return false 1302 } 1303 } 1304 const checker1 = (() => { 1305 let sum = 0 1306 for (let j = 0; j < 9; ++j) { 1307 sum += Number(firstNineDigits.toString().charAt(j)) * (10 - j) 1308 } 1309 const lastSumChecker1 = sum % 11 1310 const checker1 = lastSumChecker1 < 2 ? 0 : 11 - lastSumChecker1 1311 return checker1 1312 })() 1313 const checker2 = (() => { 1314 const cpfWithChecker1 = `${firstNineDigits}${checker1}` 1315 let sum = 0 1316 for (let k = 0; k < 10; ++k) { 1317 sum += Number(cpfWithChecker1.toString().charAt(k)) * (11 - k) 1318 } 1319 const lastSumChecker2 = sum % 11 1320 const checker2 = lastSumChecker2 < 2 ? 0 : 11 - lastSumChecker2 1321 return checker2 1322 })() 1323 return checker.toString() === checker1.toString() + checker2.toString(); 1324 }, 1325 1326 validadeFieldRequired : function(idForm){ 1327 var retorno=true; var id; 1328 try{if(idForm!=null && idForm!=undefined){id=idForm;}else{id=interpreter.storage.formID;}}catch(e){} 1329 var elements=document.querySelectorAll('[id='+id+']'); 1330 if(elements.length!=0){ 1331 try{ 1332 if(! elements[0].checkValidity()) { 1333 elements[0].reportValidity(); 1334 retorno=false; 1335 } 1336 }catch(e){console.log(e);} 1337 } 1338 return retorno; 1339 }, 1340 1341 fireEvent : function(keyCode,value,funct){ 1342 if(keyCode.keyCode==value){ 1343 var codeToExecute = funct; 1344 var tmpFunc = new Function(codeToExecute.toString()); 1345 tmpFunc(); 1346 } 1347 }, 1348 1349 serchCEP : function(element,tma_id,coluns,chave,outputs,replace,msg,ilike,dropDown=false,dropDownOptionId=false,readonly=true){ 1350 var valor=element 1351 try{if(element.value!=undefined){valor=element.value;}}catch(e){} 1352 if(replace==true){try{valor=valor.replace(/[^0-9^a-z^A-Z^ÃçáaãáeéiÃoõóôuúszcçAÃÃEÃIÃOÃÃÃUÃSZCÃ,]+/g, '');}catch(e){}} 1353 var result=[]; 1354 if(valor.toString().length>0){ 1355 if(ilike){ 1356 //valor=chave+"::text ilike '%"+valor.replace(/'/g,'')+"%'"; 1357 //chave="thematics"; 1358 result=resume.loadData(tma_id,chave,'',element.value,"","") 1359 }else{ 1360 if (tma_id === 18 && chave === 'cep') { 1361 try { 1362 $.ajax({ 1363 url: urlServer + 'rest/json/getCep', 1364 type: 'post', 1365 contentType: 'application/x-www-form-urlencoded', 1366 data: { cep: valor }, 1367 async: false, 1368 success: function(data) { 1369 result = data; 1370 }, 1371 error: function() { 1372 result = []; 1373 } 1374 }); 1375 } catch (e) { 1376 result = []; 1377 } 1378 } else { 1379 try { 1380 var key = registerus.getKey(); 1381 1382 if (!key) { 1383 try { 1384 var ajaxResp = loadData(tma_id, coluns, chave, valor); 1385 if (ajaxResp && ajaxResp.responseJSON) { 1386 result = ajaxResp.responseJSON; 1387 } else { 1388 result = []; 1389 } 1390 } catch (e) { 1391 result = []; 1392 } 1393 } else { 1394 result = registerus.loadData(tma_id, coluns, chave, valor, '', ''); 1395 } 1396 } catch (e) { 1397 result = []; 1398 } 1399 } 1400 } 1401 } 1402 try{ 1403 if(result.length>0){ 1404 var chaves=outputs.split('/'); 1405 for(var x=0;x<chaves.length;x++){ 1406 var checkError=true; 1407 var input=chaves[x].split(':')[0]; 1408 var output=chaves[x].split(':')[1]; 1409 if(dropDown){ 1410 functionSpecific.changeDropDown(result,dropDownOptionId,output); 1411 return; 1412 }else{ 1413 try{ 1414 if(chave!=input && readonly){$(`#${input}`).attr('readonly',true);} 1415 }catch(e){} 1416 switch(document.getElementById(input).type){ 1417 case "input": 1418 case "text": 1419 try{document.getElementById(input).value=result[0][output];try{element.style.backgroundColor="";}catch(e){}}catch(e){checkError=false;} 1420 break; 1421 case "date": 1422 var t=result[0][output]; 1423 try{document.getElementById(input).value=t.split('/')[2]+"-"+t.split('/')[1]+"-"+t.split('/')[0];}catch(e){ 1424 try{document.getElementById(input).value=t.split('-')[2]+"-"+t.split('-')[1]+"-"+t.split('-')[0];}catch(e){ 1425 element.style.backgroundColor="#f3606073";console.log('erro no campo de data!!!!!'); 1426 checkError=false; 1427 } 1428 } 1429 break; 1430 } 1431 } 1432 if(checkError){try{document.getElementById(input).style.backgroundColor="";}catch(e){}} 1433 } 1434 element.style.border = "1px solid #ced4da"; 1435 return true; 1436 }else{ 1437 element.value=""; 1438 if(valor.toString().length == 0){ 1439 element.style.border = "1px solid #ced4da"; 1440 return true; 1441 } 1442 element.style.border = "1px solid red"; 1443 if(msg!=undefined && msg!=null && msg!=''){ 1444 if(msg === 'CEP não encontrado'){ 1445 try{
1446 toastr["error"](msg, "CEP"); 1447 }catch(e){ 1448 editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000); 1449 } 1450 }else{ 1451 editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>','waring',2000); 1452 } 1453 }else{ 1454 editorInfoTools.createPopUpInfomative('<h4><center>'+'Dado não localizado!!!'+' </center></h4>','waring',2000); 1455 } 1456 return false; 1457 } 1458 }catch(e){} 1459 1460 }, 1461 1462 deleteInfo : function(tma_id,where,expiredate){ 1463 try{ 1464 where=where.split('='); 1465 where=where[0]+"::text = '"+where[1].trim()+"'"; 1466 }catch(e){} 1467 if(expiredate){ 1468 var json={expiredate:'now()'}; 1469 $.ajax({ 1470 url: serverUrl + 'rest/json/updatedata?themeId='+tma_id, 1471 type: 'post', 1472 async: false, 1473 data:{ 1474 attributes:'JSON', 1475 values:JSON.stringify(json), 1476 wheretabular:where 1477 }, 1478 success: function(data) { 1479 editorInfoTools.createPopUpInfomative('<h4><center>'+data.msg+' </center></h4>','waring',5000); 1480 setTimeout(function(){ 1481 hideLoadModal(); 1482 resume.loadResume(document.getElementById( "cbo-infotable" ).value); 1483 }, 500); 1484 }}); 1485 } 1486 else{ 1487 $.ajax({ 1488 url: serverURLs.getDomain()+"/deletedata?themeId="+tma_id, 1489 type: "POST", 1490 async: thematicmap.requestAsync, 1491 data:{ 1492 where:where 1493 }, 1494 success: function(data) { 1495 editorInfoTools.createPopUpInfomative('<h4><center>'+data.msg+' </center></h4>','waring',5000); 1496 setTimeout(function(){ 1497 hideLoadModal(); 1498 resume.loadResume(document.getElementById( "cbo-infotable" ).value); 1499 }, 500); 1500 1501 }, 1502 failure: function(data) { 1503 showAlert("erro"); 1504 setTimeout(function(){ 1505 hideLoadModal(); 1506 }, 500); 1507 1508 1509 } 1510 1511 }); 1512 } 1513 try{map.getLayersByName(resume.getNameTheme())[0].redraw(true);}catch(e){} 1514 }, 1515 1516 1517 /** 1518 * Looks the CPF up on SERPRO and fills the name and birth-date fields of the form. 1519 * @param {String|Object} element - CPF field, or its id 1520 * @param {String} outputName - id of the field filled with the person name 1521 * @param {String} outputDataNasc - id of the field filled with the SERPRO birth date 1522 * @param {String} [birthDateFieldId] - id of the birth-date field filled with the 1523 * modal date; when omitted no modal is shown and the lookup keeps the CPF-only flow 1524 * @return {boolean|undefined} false when the lookup is skipped or fails, so a CNPJ 1525 * never reaches the CPF-only SERPRO endpoint; undefined once the fields are filled 1526 */ 1527 searchCpf : async function(element,outputName,outputDataNasc,birthDateFieldId){ 1528 var cpf="";try{ if(element.value!=undefined){cpf=element.value;}else{cpf=document.getElementById(element).value;}}catch(e){ 1529 editorInfoTools.createPopUpInfomative('<h4><center>campo CPF inválido </center></h4>','waring',2000);return false; 1530 } 1531 cpf=cpf.replace(/[\.-\/]/g, "").replace('-',''); 1532 1533 const isCnpj = cpf.length === 14; 1534 1535 if (isCnpj) { 1536 return false; 1537 } 1538 1539 const dataNascimento = birthDateFieldId ? await openModalDataNascimento() : null; 1540 1541 if(birthDateFieldId && !dataNascimento){ 1542 return false; 1543 } 1544 1545 const result=await functionSpecific.serProCPF(cpf,dataNascimento); 1546 if(result!=undefined && result.nome!=undefined && result.nascimento!=undefined){ 1547 try{ 1548 try{ 1549 try{document.getElementById(element).style.backgroundColor="";}catch(e){try{element.style.backgroundColor="";}catch(e){}} 1550 try{document.getElementById(outputName).style.backgroundColor="";}catch(e){} 1551 try{document.getElementById(outputDataNasc).style.backgroundColor="";}catch(e){} 1552 try{if(outputName!='cpf'){document.getElementById(outputName).disabled = true;}}catch(e){} 1553 try{if(outputDataNasc!='cpf'){document.getElementById(outputDataNasc).disabled = true;}}catch(e){} 1554 1555 }catch(e){} 1556 document.getElementById(outputName).value=result.nome; 1557 var nasc=result.nascimento.substring(4,8)+'-'+result.nascimento.substring(2,4)+"-"+result.nascimento.substring(0,2); 1558 document.getElementById(outputDataNasc).value=nasc; 1559 }catch(e){ 1560 1561 } 1562 1563 if(dataNascimento){ 1564 fillSerproBirthDate(birthDateFieldId, dataNascimento); 1565 } 1566 } 1567 else{ 1568 editorInfoTools.createPopUpInfomative('<h4><center>'+serproCpfErrorMessage(result, dataNascimento)+'</center></h4>
1568','waring',3000); 1569 return false; 1570 } 1571 }, 1572 1573 /** 1574 * Looks the CPF up on SERPRO, calling the birth-date endpoint when the date was collected. 1575 * @param {String} cpfs - CPF digits 1576 * @param {String} [dataNascimento] - birth date as yyyy-mm-dd, or null when not collected 1577 * @return {Object|Array} SERPRO data, or an empty array when the CPF is empty 1578 */ 1579 serProCPF : async function(cpfs, dataNascimento){ 1580 var cpf=cpfs; 1581 if(cpf.length>0){ 1582 var urlServer = serverURLs.getRestServer(); 1583 var cpfReturn = []; 1584 1585 $.ajax({ 1586 url: buildSerproCpfUrl(cpf, dataNascimento, urlServer),//+"&gri_user="+getSession().key, 1587 crossDomain: true, 1588 type: 'GET', 1589 async: false, 1590 complete: function (data) { 1591 1592 cpfReturn = data.responseJSON; 1593 }, 1594 failure: function (data) { 1595 console.log('erro 2:' + data); 1596 return false; 1597 } 1598 1599 }); 1600 return cpfReturn; 1601 } 1602 }, 1603 /** 1604 * Validate the CNPJ about characters 1605 * @param {String} element - number CNPJ 1606 * @param {String} outputOrgao - fild in form with autocomplete 1607 * @param {String} outputEntidade - fild in form with autocomplete 1608 * @return {String} - success or error 1609 */ 1610 searchCnpj : function(element,outputOrgao,outputEntidade){ 1611 var cnpj="";try{ if(element.value!=undefined){cnpj=element.value;}else{cnpj=document.getElementById(element).value;}}catch(e){ 1612 editorInfoTools.createPopUpInfomative('<h4><center>campo CNPJ inválido </center></h4>','waring',2000);return false; 1613 } 1614 const isValid = functionSpecific.checkCNPJ(element.value.toString()); 1615 if(isValid){ 1616 cnpj=cnpj.replace(/[\.-\/]/g, "").replace('-',''); 1617 var result=functionSpecific.serProCNPJ(cnpj); 1618 if(result!=undefined && result.nomeEmpresarial!=undefined && result.errorCode == undefined){ 1619 try{ 1620 try{ 1621 try{document.getElementById(element).style.backgroundColor="";}catch(e){try{element.style.backgroundColor="";}catch(e){}} 1622 try{document.getElementById(outputOrgao).style.backgroundColor="";}catch(e){} 1623 try{document.getElementById(outputEntidade).style.backgroundColor="";}catch(e){} 1624 try{if(outputEntidade!='cnpj'){document.getElementById(outputEntidade).disabled = true;}}catch(e){} 1625 }catch(e){} 1626 document.getElementById(outputEntidade).value=result.nomeEmpresarial; 1627 }catch(e){ 1628 1629 } 1630 }else if(result != undefined && result.errorCode == 204){ 1631 document.getElementById(outputName).disabled = false; 1632 document.getElementById(outputName).value = ""; 1633 }else{ 1634 document.getElementById(outputEntidade).disabled = true; 1635 document.getElementById(outputEntidade).value = ""; 1636 const msg = '*CNPJ não encontrado'; 1637 functionSpecific.showFieldErrorMessage(element, false, msg); 1638 } 1639 }else{ 1640 document.getElementById(outputEntidade).disabled = true; 1641 document.getElementById(outputEntidade).value = ""; 1642 } 1643 }, 1644 1645 /** 1646 * Find the CNPJ in SERPRO server 1647 * @param {String} cnpjs - number CNPJ 1648 * @return {String} - number CNPJ 1649 */ 1650 serProCNPJ : function(cnpjs){ 1651 var cnpj=cnpjs; 1652 if(cnpj.length>0){ 1653 var urlServer = serverURLs.getRestServer(); 1654 var cnpjReturn = []; 1655 1656 $.ajax({ 1657 url: urlServer + 'rest/json/getCnpjSerpro?cnpj='+cnpj, 1658 crossDomain: true, 1659 type: 'GET', 1660 async: false, 1661 complete: function (data) { 1662 if (data.status == 200){ 1663 cnpjReturn = data.responseJSON; 1664 }else if(data.status == 500){ 1665 cnpjReturn = data.status; 1666 }else{ 1667 cnpjReturn = data.status; 1668 } 1669 }, 1670 failure: function (data) { 1671 console.log('erro 2:' + data); 1672 return false; 1673 } 1674 1675 }); 1676 return cnpjReturn; 1677 } 1678 }, 1679 1680 appendButtonGrapichCovid : function(){ 1681 var prf_ids=serverURLs.getgraphicBarButtonPrfId() 1682 if(prf_ids.includes(parseInt(getProfileIDInSession()))){ 1683 var bar='<div style="margin-left: 10%;margin-right: 10%;"><label title="Gerar um gráfico salvo" for="graphic-saved-selection">Graficos Salvos</label>'+ 1684 '<select title="Gerar um gráfico salvo" id="graphic-saved-selection-1" onfocusout="window.selectLisOpen=false;" onfocusin="functionSpecific.changeEventOfSelectList(\'time\')"; onclick="functionSpecific.changeEventOfSelectList(\'graphic\',this.selectedIndex)" class="form-control">'+ 1685 '<option>Nenhum gráfico salvo</option>'+ 1686 '</select></div>'; 1687 bar+='<div style="margin-left: 10%;margin-right: 10%;"><label title="Filtros Espacial" for="graphic-saved-selection">Filtros Espacial</label>'+ 1688 '<select title="Ler grafico salvo" id="filter-saved-e
1688spatial" onfocusout="window.selectLisOpen=false;" onfocusin="functionSpecific.changeEventOfSelectList(\'time\')"; onclick="functionSpecific.changeEventOfSelectList(\'espatial\',this.selectedIndex)" class="form-control">'+ 1689 '<option>Nenhum filtro salvo</option>'+ 1690 '</select></div>'; 1691 bar+='<div style="margin-left: 10%;margin-right: 10%;"><label title="Filtros Tabular" for="graphic-saved-selection">Filtros Tabular</label>'+ 1692 '<select title="Ler grafico salvo" id="filter-saved-tabular" onfocusout="window.selectLisOpen=false;" onfocusin="functionSpecific.changeEventOfSelectList(\'time\')"; onclick="functionSpecific.changeEventOfSelectList(\'tabular\',this.selectedIndex)" class="form-control">'+ 1693 '<option>Nenhum filtro salvo</option>'+ 1694 '</select></div>'; 1695 // bar+='<li id="testeIframesss"><a href="javascript:editorInfoTools.createPopUpInfomative(\'\',\'testeDivIframe\')"><span></span> Teste Iframe </a></li>' 1696 1697 $(bar).appendTo("#nav-info"); 1698 1699 var session = thematicmap.getSession(); 1700 var url = serverURLs.getDomain() + "/listthematics?"; 1701 url += "key=" + session["key"]; 1702 url += "&prfId=" + session["profile_id"]; 1703 var url1 = url+"&tipo=espacial"; 1704 var url2 = url+"&tipo=avancado"; 1705 $.ajax({ 1706 url: url1, 1707 type: 'get', 1708 async: false, 1709 success: function(data) { 1710 if(data.length>0){document.getElementById('filter-saved-espatial').options[document.getElementById('filter-saved-espatial').selectedIndex].text=" SELECIONE UM CONJUNTO DE FILTROS SALVOS! "} 1711 for(var x=0;x<data.length;x++){ 1712 $('#filter-saved-espatial').append($('<option>', { 1713 value: data[x].dd_id+"%||%"+data[x].filtro_espacial, 1714 text: data[x].nome 1715 //valorFiltro: data[x].filtro_espacial 1716 })); 1717 //$("#filter-saved-espatial").append(new Option(data[x].nome, data[x].nome)); 1718 } 1719 1720 } 1721 }); 1722 $.ajax({ 1723 url: url2, 1724 type: 'get', 1725 async: false, 1726 success: function(data) { 1727 for(var x=0;x<data.length;x++){ 1728 if(data.length>0){document.getElementById('filter-saved-tabular').options[document.getElementById('filter-saved-tabular').selectedIndex].text=" SELECIONE UM CONJUNTO DE FILTROS SALVOS! "} 1729 $('#filter-saved-tabular').append($('<option>', { 1730 value: data[x].tma_id+"%||%"+data[x].tipo_tematico, 1731 text: data[x].nome 1732 //valorFiltro: data[x].filtro_tabular 1733 })); 1734 } 1735 1736 } 1737 }); 1738 1739 var session = thematicmap.getSession(); 1740 var url = serverURLs.getDomain() + "/listthematics?"; 1741 url += "key=" + session["key"]; 1742 url += "&prfId=" + session["profile_id"]; 1743 $.ajax({ 1744 url: url, 1745 type: 'get', 1746 async: false, 1747 success: function(data){ 1748 if(data.msg==undefined){ 1749 glueapi.saveds = data; 1750 }else{ 1751 editorInfoTools.createPopUpInfomative('<h4><center>'+data.msg+' </center></h4>','waring',5000); 1752 } 1753 1754 } 1755 }); 1756 1757 thematicmap.function_toReturn=functionSpecific.callFilterThematic; 1758 thematicmap.requestListGraphic('graphic-saved-selection-1'); 1759 functionSpecific.changeEventOfSelectList('graphic') 1760 } 1761 }, 1762 1763 changeEventOfSelectList : function(type,elemet){ 1764 switch(type){ 1765 case 'graphic': 1766 if(elemet!=0 && window.selectLisOpen){ 1767 thematicmap.delAllValues('graphic'); 1768 thematicmap.controlAtualTheme('graphic'); 1769 thematicmap.loadFormDatagraphic('graphic-saved-selection-1'); 1770 window.selectLisOpen=false; 1771 } 1772 else{ 1773 try{ 1774 $('#graphic-saved-selection-1').html($('#graphic-saved-selection-1').html().replace(/<option/g,'<option onclick="thematicmap.delAllValues(\'graphic\');thematicmap.controlAtualTheme(\'graphic\');thematicmap.loadFormDatagraphic()"')) 1775 }catch(e){}; 1776 } 1777 break; 1778 case 'tabular': 1779 if(elemet!=0 && window.selectLisOpen){ 1780 var text=document.getElementById('filter-saved-tabular').options[document.getElementById('filter-saved-tabular').selectedIndex].text; 1781 var tma_id=document.getElementById('filter-saved-tabular').options[document.getElementById('filter-saved-tabular').selectedIndex].value.split('%||%')[0]; 1782 var valorFiltro=document.getElementById('filter-saved-tabular').options[document.getElementById('filter-saved-tabular').selectedIndex].value.split('%||%')[1]; 1783 glueapi.loadthematic(text,!functionSpecific.pollThematics.avancado.includes(text)); 1784 resume.callMe(tma_id,'thematics',valorFiltro,'',''); 1785 if(!functionSpecific.pollThematics.avancado.includes(text)){ 1786 functionSpecific.pollThematics.avancado.push(text); 1787 thematicmap.refreshAvancado(); 1788 } 1789 window.selectLisOpen=false; 1790 } 1791 else{ 1792 1793 } 1794 break; 1795 1796 case 'espatial': 1797 if(elemet!=0 && window.selectLisOpen){
1798 var text=document.getElementById('filter-saved-espatial').options[document.getElementById('filter-saved-espatial').selectedIndex].text; 1799 var tma_id=document.getElementById('filter-saved-espatial').options[document.getElementById('filter-saved-espatial').selectedIndex].value.split('%||%')[0]; 1800 var valorFiltro=document.getElementById('filter-saved-espatial').options[document.getElementById('filter-saved-espatial').selectedIndex].value.split('%||%')[1]; 1801 window.functionSpecific.tma_id_select=tma_id; 1802 window.functionSpecific.typeFilter='spacial'; 1803 thematicmap.function_toReturn=functionSpecific.callFilterThematic; 1804 glueapi.loadthematic(text,!functionSpecific.pollThematics.espatial.includes(text)); 1805 if(!functionSpecific.pollThematics.espatial.includes(text)){ 1806 functionSpecific.pollThematics.espatial.push(text); 1807 thematicmap.refreshSpacial(); 1808 } 1809 window.selectLisOpen=false; 1810 } 1811 else{ 1812 1813 } 1814 break; 1815 1816 case 'time': 1817 setTimeout(function(){window.selectLisOpen=true},100); 1818 break; 1819 } 1820 1821 }, 1822 1823 callFilterThematic : function(param){ 1824 resume.callMe(window.functionSpecific.tma_id_select,window.functionSpecific.typeFilter,param.filtro,'',''); 1825 thematicmap.function_toReturn=undefined 1826 }, 1827 1828 searchPacienteCovid : function (tma_id){ 1829 editorInfoTools.createPopUp('<div style="width:480px;">'+ 1830 '<div class="col-md-8 col-xs-12 col-sm-12 mb-3"><label class="dark">CPF</label><input id="cpf_search" class="form-control" name="" value="" type="input" placeholder=""></div><button type="button" class="btn btn-success col-md-2 col-xs-12 col-sm-12 mb-3" style="margin-top: 5%;" onclick="(function(){if(functionSpecific.getUserByName(\''+tma_id+'\',\'cpf\',\'cpf_search\')){document.getElementById(\'pointwindow-modal\').remove();}})()">Pesquisar</button>'+ 1831 //'<div class="col-md-8 col-xs-12 col-sm-12 mb-3"><label class="dark">Data Nascimento</label><input id="data_nascimento_search" class="form-control" type="date" value="" name=""></div><button type="button" class="btn btn-success col-md-2 col-xs-12 col-sm-12 mb-3" onclick="functionSpecific.getUserByName(\'711\',\'data_nascimento\',\'data_nascimento_search\');" style="margin-top: 5%;">Pesquisar</button>'+ 1832 '<div class="col-md-8 col-xs-12 col-sm-12 mb-3"><label class="dark">Prontuário</label><input id="prontuario_search" class="form-control" type="text" value="" name=""></div><button type="button" class="btn btn-success col-md-2 col-xs-12 col-sm-12 mb-3" onclick="(function(){if(functionSpecific.getUserByName(\''+tma_id+'\',\'prontuario\',\'prontuario_search\')){document.getElementById(\'pointwindow-modal\').remove();}})()" style="margin-top: 5%;">Pesquisar</button>'+ 1833 '<div class="col-md-8 col-xs-12 col-sm-12 mb-3"><label class="dark">Nome</label><input id="nome_search" class="form-control" type="text" value="" name=""></div><button type="button" class="btn btn-success col-md-2 col-xs-12 col-sm-12 mb-3" onclick="(function(){if(functionSpecific.getUserByName(\''+tma_id+'\',\'nome\',\'nome_search\')){document.getElementById(\'pointwindow-modal\').remove();}})()" style="margin-top: 5%;">Pesquisar</button>'+ 1834 1835 '</div>',' overflow: hidden;height:auto;max-height: 477px;width: 450px;'); 1836 var element1=document.querySelectorAll('[id=cpf_search]')[0]; 1837 var element2=document.querySelectorAll('[id=prontuario_search]')[0] 1838 var mask = new IMask(element1, {mask: [{ mask: '000.000.000-00' }] }); 1839 1840 1841 }, 1842 associateMobileUser :function(themeId,json2,chave){ 1843 var testJson=infoProperty.checkFormJson(themeId); 1844 if(testJson!=false && JSON.parse(testJson).buttonAssociar==true && landmark.userId.length>0){ 1845 json2[chave]=landmark.userId; 1846 json2['done']=false; 1847 } 1848 return json2; 1849 }, 1850 copyValueByPk : function(json,themeid,allColluns=false){ 1851 try{ 1852 var integrity=' '+infoProperty.dataPopup[0].pk_name+'='+infoProperty.dataPopup[0].pk_value; 1853 var URLLL =serverURLs.getRestServer()+"rest/json"+ "/copyValueByPk?themeid="+themeid+"&pk="+integrity; 1854 $.ajax({ 1855 url: URLLL, 1856 type: 'get', 1857 async: false, 1858 success: function(data) { 1859 if(data.length>0){ 1860 var notIn=['geom','gid','id','expiredate','insertdate','locked',infoProperty.dataPopup[0].pk_name]; 1861 var keys=Object.keys(data[0]); 1862 var values=Object.values(data[0]); 1863 for(var x=0;x<keys.length;x++){ 1864 if(allColluns){ 1865 if(!notIn.includes(keys[x])){ 1866 json[keys[x]]=values[x]; 1867 } 1868 }else{ 1869 if(json[keys[x]]==undefined || json[keys[x]]==null){ 1870 if(!notIn.includes(keys[x])){ 1871 json[keys[x]]=values[x]; 1872 } 1873 } 1874 } 1875 } 1876 } 1877 } 1878 }); 1879 return json; 1880 }catch(e){ 1881 return json; 1882 } 1883 }, 1884 1885 /*** 1886 * calls soap themes to get destination key values and use to the next theme 1887 * to find the last value and populate the popup with nickname and value. 1888 * @param arr_tma_id array of theme ids ordered to search the value that will 1889 * be used to the next soap theme. 1890 * @param arr_columns array of columns names returned by soap service. 1891 * @param key_value column that has the value to use in first soap search. 1892 * @param nickname nickname to the attribute that will appear in popup. 1893 * @author Alexandre Penteado 1894 */ 1895 searchSOAPValueByCode : function(arr_tma_id,arr_columns,key_value, nickname){ 1896 var last_value = ""; 1897 arr_tma_id = arr_tma_id.split(','); 1898 arr_columns = arr_columns.split(','); 1899 for (var i=0; i<arr_tma_id.length;i++){ 1900 if (i==0){ 1901 last_value = editor.loadData(arr_tma_id[i],arr_columns[i],"",key_value,"","",false); 1902 }else{ 1903 last_value = editor.loadData(arr_tma_id[i],arr_columns[i],"",last_value[0][arr_columns[i-1]],"","",false)[0][arr_columns[i]]; 1904 } 1905 } 1906 1907 var popup_div = '<div class="form-group">'+ 1908 '</h6><strong>'+nickname+': </strong>'+ last_value +'</h6><br />'+ 1909 '</div>'; 1910 1911 document.getElementById("modal-popup").innerHTML+=popup_div; 1912 }, 1913 1914 highlightFromLoteToEdif : function(tmaId,lon,lat,buffer){ 1915 1916 var url = serverUrl + 'rest/json/getPointedGeometry?themeid=' + tmaId + '&x='+ lon +'&y='+ lat +'&buffer='+ buffer; //?? new method 1917 var chave ="", wkt="", objKey0="", objKey1="", key_name=""; 1918 var keyName=""; 1919 $.ajax({ 1920 url: url, 1921 type: 'get', 1922 async: false, 1923 success: function(data) { 1924// This is using Object.keys(data[0])[0] indexed by 0, cause just 1 row 1925 chave = Object.values(data[0])[0]; 1926 1927 if(typeof(chave)=="object"){ 1928 chave=chave[0]; 1929 //call mais.. 1930 if(data[0][data[0].key_name]==undefined){ 1931 chave=Object.values(data[0])[0][0]; 1932 }else{ 1933 var where=data[0].key_name+"::text in (\\\'"+data[0][data[0].key_name].toString().replace(/,/g,"\\\',\\\'")+"\\\')"; 1934 btnnewmais='<button type="button" id="btn-gotoresume" onclick="resume.callMe('+ themeId +',\'thematics\',\''+where+'\',\'\',\'\');" type="button" class="btn btn-success btn-md" title="Mais informações.">
1934 Geometrias ... </button>'; 1935 } 1936 1937 } 1938 wkt= Object.values(data[0])[1]; 1939 1940 parseWKTTable(wkt); 1941 } 1942 }); 1943 1944 }, 1945 1946 getDataByGeom : function(geom,tma_id,attrEntrada,attrSaida){ 1947 if(geom==undefined){try{geom=editor.editingLayer.features[0].geometry.toString();}catch(e){}} 1948 if(geom==undefined){try{ 1949 var x = infoProperty.lastX.xy.x; 1950 var y = infoProperty.lastX.xy.y; 1951 var coorddd={x:x,y:y}; 1952 var xyLonLat = map.getLonLatFromPixel(coorddd); 1953 geom='POINT('+xyLonLat.lon+' '+xyLonLat.lat+")"; 1954 }catch(e){}} 1955 if(attrEntrada==undefined){attrEntrada="*";} 1956 var url = serverURLs.getRestServer()+"rest/json/getDataByGeom?geom="+geom+"&tma_id="+tma_id+"&attrEntrada="+attrEntrada; 1957 $.ajax({ 1958 url: url, 1959 type: 'get', 1960 async: false, 1961 complete: function(data) { 1962 var resp=JSON.parse(data.responseText); 1963 var listSaida=attrSaida.split(','); 1964 for(var x=0;x<listSaida.length;x++){ 1965 //try{$('#'+listSaida).val(resp[0][listSaida[x]])}catch(e){} 1966 if($('#'+listSaida[x]).is('input')){ 1967 try{$('#'+listSaida[x]).val(Object.values(resp[0])[x])}catch(e){}} 1968 if($('#'+listSaida[x]).is('select')){ 1969 try{ 1970 var opt=Object.values(resp[0])[x] 1971 if($('#'+listSaida[x]+' option[value="'+opt+'"]').length==0){ 1972 $('#'+listSaida[x]).append(new Option(Object.values(resp[0])[x], Object.values(resp[0])[x])); 1973 }//else{ 1974 $('#'+listSaida[x]+" option:contains(" + opt + ")").attr('selected', 'selected'); 1975 // } 1976 }catch(e){} 1977 } 1978 //if() 1979 } 1980 }, 1981 failure: function(data) { 1982 1983 } 1984 }); 1985 }, 1986 1987 findOtherBeneficiario : function(typeOperation,chavePesquisa,valorPesquisa,tma_id){ 1988 var keyValue=valorPesquisa; 1989 var keyName=chavePesquisa; 1990 if(valorPesquisa==undefined){ 1991 keyValue=window.infoProperty.lastUpdateWhere.split('=')[1].replace(/'/g,"").replace(/ /g,""); 1992 } 1993 var result=editor.loadData(tma_id,' * ',keyName,keyValue); 1994 if(result.length>0){ 1995 switch(typeOperation){ 1996 case 'avancar': 1997 if(window.editorInfoTools.lastPkSearch!=keyValue){window.editorInfoTools.lastPkSearch=keyValue;window.editorInfoTools.lastPkSearchCount=-1;} 1998 1999 window.editorInfoTools.lastPkSearchCount++; 2000 if(result[window.editorInfoTools.lastPkSearchCount]!=undefined){ 2001 infoProperty.dataPopup=[result[window.editorInfoTools.lastPkSearchCount]]; 2002 infoProperty.loadInfoPopupEdit(tma_id,'save',false,'popup');//infoProperty.save(tma_id,true,false,false); 2003 }else{ 2004 window.editorInfoTools.lastPkSearchCount--; 2005 editorInfoTools.createPopUpInfomative('<br>'+'Dado nao encontrado'+"<br>",'waring',3000); 2006 } 2007 2008 break; 2009 case 'voltar': 2010 if(window.editorInfoTools.lastPkSearch!=keyValue){window.editorInfoTools.lastPkSearch=keyValue;window.editorInfoTools.lastPkSearchCount=1;} 2011 2012 window.editorInfoTools.lastPkSearchCount--; 2013 if(result[window.editorInfoTools.lastPkSearchCount]!=undefined){ 2014 infoProperty.dataPopup=[result[window.editorInfoTools.lastPkSearchCount]]; 2015 infoProperty.loadInfoPopupEdit(tma_id,'save',false,'popup');//infoProperty.save(tma_id,true,false,false); 2016 }else{ 2017 window.editorInfoTools.lastPkSearchCount++; 2018 editorInfoTools.createPopUpInfomative('<br>'+'Dado nao encontrado'+"<br>",'waring',3000); 2019 } 2020 2021 break; 2022 default: 2023 editorInfoTools.createPopUpInfomative('<br>'+'Ha definir'+"<br>",'waring',3000); 2024 break; 2025 } 2026 }else{ 2027 editorInfoTools.createPopUpInfomative('<br>'+'Dado nao encontrado'+"<br>",'waring',3000); 2028 } 2029 }, 2030 2031 auxSaveInfopropertyUpdateData : function(tma_id){ 2032 var auxWhere=window.infoProperty.lastUpdateWhere.toString(); 2033 infoProperty.save(tma_id,true,false,false); 2034 window.infoProperty.lastUpdateWhere=auxWhere; 2035 }, 2036 2037 changeDropDown : function(result,id,chave){ 2038 var HTML=""; 2039 for(var x=0;x<result.length;x++){ 2040 try{ 2041 HTML+=' <li><a onclick="'+id.firstElementChild.firstElementChild.onclick.toString().replace('function onclick(event) {','').replace('}','')+'" href="#">'+result[x][chave]+'</a></li>'; 2042 }catch(e){} 2043 } 2044 id.innerHTML=HTML; 2045 }, 2046 makeFormPGV : function(type){ 2047 window.listAttrPGV=[]; 2048 var json=""; 2049 var html=""; 2050 if(type==1){ 2051 // 2052 const form_amostras = serverURLs.getformAmostrasPgv(); 2053 json=infoProperty.checkFormJson(form_amostras); 2054 }else{ 2055 const form_inferencia = serverURLs.getformInferenciaPgv(); 2056 json=infoProperty.checkFormJson(form_inferencia); 2057 } 2058 var pageObj; 2059 function getPage(element) { 2060 pageObj = element; 2061 } 2062 2063 function generatePageObject(pageJSON) { 2064 let obj = JSON.parse(pageJSON); 2065 interpreter.win = window; 2066 interpreter.doc = window.document; 2067 interpreter.interpretJSONPage(obj, getPage); 2068 } 2069 let js = JSON.parse(json) 2070 generatePageObject(json); 2071 html+=pageObj.innerHTML; 2072 editorInfoTools.createPopUp(html,'width:'+ js.width+'px;height:'+ js.height+'px;'); 2073 2074 2075 //=========================================== 2076 var prf_id = getProfileIDInSession(); 2077 var themes = resume.loadThemes(prf_id); 2078 if(themes!=""){ 2079 $.each(themes, function(key,value) { 2080 try{$("#entrada").append(new Option(value.nome_tema, value.tma_id));}catch(e){} 2081 try{$("#saida").append(new Option(value.nome_tema, value.tma_id));}catch(e){} 2082 try{$("#amostras").append(new Option(value.nome_tema, value.tma_id));}catch(e){} 2083 }); 2084 try{ 2085 var test=$("#attribute-amostras").html() 2086 $("#attribute-estimar").html(test)} catch(e){} 2087 } 2088 }, 2089 insertDataWithSpecificConstraint2 : function(tma_id,valorPesquisa,objInsert){ 2090 var pesq=valorPesquisa.split('/'); 2091 var check=true;var lstcheck='' 2092 for(var x=0;x<pesq.length;x++){
2093 var key=pesq[x].split(':')[0]; 2094 var value=pesq[x].split(':')[1] 2095 var result=editor.loadData(tma_id,'*',key,value,'',''); 2096 if(result.length!=0){ 2097 lstcheck+='false '; 2098 }else{ 2099 lstcheck+='true'; 2100 } 2101 } 2102 if(!lstcheck.contains('false')){infoProperty.save(tma_id,false,undefined,undefined,objInsert,undefined,true);} 2103 }, 2104 2105 insertDataWithSpecificConstraint : function(tma_id,valorPesquisa,objInsert){ 2106 if(functionSpecific.checkCPF(valorPesquisa)){ 2107 var result=editor.loadData(tma_id,'*','cpf',valorPesquisa,'',''); 2108 var result2=editor.loadData(tma_id,'*','gid',infoProperty.dataPopup[0].pk_value,'',''); 2109 var check=false; 2110 if(result.length!=0){ 2111 if(result2.length==0){check=true;} 2112 }else if(result.length==0){ 2113 check=true; 2114 } 2115 if(check){infoProperty.save(tma_id,false,undefined,undefined,objInsert,undefined,true);} 2116 }else{setTimeout(function(){editorInfoTools.createPopUpInfomative('<h4><center>CPF inválido </center></h4>','waring',2000);},400);} 2117 }, 2118 2119 /** 2120 * function use to routine "functionSpecific.loadDataByMultiplyForm" 2121 * this routine assists in loading mixed-theme forms 2122 * @param valorPesquisa {String} value used in search data 2123 * @param tma_id_pesquisa {int} search theme target 2124 * @param tma_id_form {int} theme target form json 2125 * @param button put button update in form, default is true 2126 * @author Baltazar,G.S.F. 2127 * documented by Gabriel.Baltazar 2128 */ 2129 loadDataByMultiplyForm : function(valorPesquisa,tma_id_pesquisa,tma_id_form,button=true){ 2130 window.functionSpecific.listPksForms=[]; 2131 var result=editor.loadData(tma_id_pesquisa,"*","",valorPesquisa,'',''); 2132 if(result.length>0){ 2133 infoProperty.loadInfoPopupEdit(tma_id_form,"update",button,'popup'); 2134 var testJson=infoProperty.checkFormJson(tma_id_form); 2135 if(testJson!=false){ 2136 testJson=JSON.parse(testJson); 2137 for(var x=0;x<testJson.divisions.length;x++){ 2138 result=editor.loadData(testJson.divisions[x].theme,"*","",valorPesquisa,'',''); 2139 if(result.length>1){ 2140 for(var x1=0;x1<result.length-1;x1++){ 2141 functionSpecific.duplicateFieldsByTheme(testJson.divisions[x].theme) 2142 } 2143 } 2144 var resps=$('[id=theme-'+testJson.divisions[x].theme+']'); 2145 for(var x1=0;x1<result.length;x1++){ 2146 window.functionSpecific.listPksForms.push({theme:testJson.divisions[x].theme,value:result[x1][result[x1].pk_name],key:result[x1].pk_name}) 2147 var fakeImages = $('[id=theme-'+testJson.divisions[x].theme+']')[x1].querySelectorAll('input'); 2148 var fakeImages2 = $('[id=theme-'+testJson.divisions[x].theme+']')[x1].querySelectorAll('textarea') 2149 var fakeImages3 = $('[id=theme-'+testJson.divisions[x].theme+']')[x1].querySelectorAll('select') 2150 for (var i = 0; i < fakeImages.length; i++) { 2151 if($(fakeImages[i]).attr('type') === 'text'){ 2152 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2153 } 2154 else if($(fakeImages[i]).attr('type') == 'number'){ 2155 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2156 } 2157 else if($(fakeImages[i]).attr('type') == 'checkbox' ){ 2158 if(result[x1][$(fakeImages[i]).attr('id')].toString().toLowerCase().contains('t') || result[x1][$(fakeImages[i]).attr('id')].toString().toLowerCase().contains('v')){ 2159 $(fakeImages[i]).prop('checked', true); 2160 } 2161 } 2162 else if($(fakeImages[i]).attr('type') == 'date' && result[x1][$(fakeImages[i]).attr('id')]!=undefined){ 2163 var test=result[x1][$(fakeImages[i]).attr('id')].toString() 2164 if(test.contains('/')){test=test.split('/')}else{test=test.split('-')} 2165 if(test[0].length!=4){ 2166 $(fakeImages[i]).val(test[2]+"-"+test[1]+"-"+test[0]); 2167 }else{ 2168 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2169 } 2170 } 2171 else{ 2172 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2173 } 2174 } 2175 for (var i = 0; i < fakeImages2.length; i++) { 2176 $(fakeImages2[i]).val(result[x1][$(fakeImages2[i]).attr('id')]); 2177 } 2178 for (var i = 0; i < fakeImages3.length; i++) { 2179 $(fakeImages3[i]).val(result[x1][$(fakeImages3[i]).attr('id')]); 2180 } 2181 } 2182 2183 } 2184 } 2185 }else{ 2186 functionSpecific.createNewObjectByResume(tma_id_form,false); 2187 } 2188 }, 2189 changeComboPGV : function(id){ 2190 var tma_id=$("#"+id).val(); 2191 console.log(id); 2192 if(!isNaN(parseInt(tma_id))){ 2193 var url_server = serverURLs.getRestServer(); 2194 //thematicmap.requestListAttributeThemeJSON(tma_id,id,false); 2195 var prf_id = getProfileIDInSession(); 2196 var URL = url_server+"rest/json"+ "/getColumns?access="+prf_id+"&type="+"resume"+"&themeid="+tma_id; 2197 $.ajax({ 2198 url: URL, 2199 type: 'get', 2200 async: false, 2201 success: function(data) { 2202 if(id != 'saida'){ 2203 window.tbl_name = data[0].nome; 2204 } 2205 $("#attribute-"+id).empty(); 2206 $.each(data, function(key, entry){ 2207 console.log(key,entry) 2208 console.log(entry.atributo, entry.apelido); 2209 $("#attribute-"+id).append($('<option></option>').attr('value', entry.atributo).text(entry.apelido)); 2210 }); 2211 } 2212 }); 2213 } 2214 try{ 2215 var test=$("#attribute-amostras").html() 2216 $("#attribute-estimar").html(test) 2217 let options = $("#attribute-tema_vut").html(); 2218 $("#vut_proposto").html(options); 2219 } catch(e){ 2220 } 2221 }, 2222 2223 addAttrPGV : function(idInput,idOutPut){ 2224 $('#'+idOutPut).append($("#"+idInput+" option:selected" ).text()+'\n'); 2225 window.listAttrPGV.push($("#"+idInput).val()); 2226 }, 2227 2228 checKifExists : function (element,tmaId,collunsFind,colluntarget,msg){ 2229 try{ 2230 var value=element.value; 2231 var result=editor.loadData(tmaId,collunsFind,colluntarget,value,'',''); 2232 if(result.length>0){ 2233 editorInfoTools.createPopUpInfomative('<h4><center>'+msg+' </center></h4>
2233','waring',5000); 2234 setTimeout(function(){element.value="";},200); 2235 return false; 2236 }else{ 2237 try{document.getElementById('dt_nasc').disabled = false;}catch(e){} 2238 try{document.getElementById('nome').disabled = false;}catch(e){} 2239 return true; 2240 } 2241 }catch(e){console.log(e);} 2242 }, 2243 2244 putAnexar : function(element,doc_location,doc_type,path,tma_id){ 2245 try{ 2246 window.functionSpecific.anexar={doc_location:doc_location,doc_type:doc_type,path:path,tma_id:tma_id} 2247 //$('#'+interpreter.storage.formID).append('<div class="row"><div class="col-md-12 col-xs-12 col-sm-12 mb-3" style=" margin-top: 12px;margin-left: 15px;"><input type="file" multiple="" name="file_name" id="importedFiles"></div></div>'); 2248 //$('#'+element.id).prop('disabled',true); 2249 document.getElementById(element.id).outerHTML='<div class="col-md-12 col-xs-12 col-sm-12 mb-3" style=" margin-top: 30px;"><input type="file" multiple="" name="file_name" id="importedFiles"></div>'; 2250 }catch(e){} 2251 }, 2252 2253 saveAnexar : function(newFile,tma_id,chave=false){ 2254 //if(newFile){ 2255 if ($('input[name=file_name]')[0]!=undefined && $('input[name=file_name]')[0].files.length > 0) { 2256 var result=0 2257 if(chave!=false){ 2258 result=chave 2259 }else{ 2260 result=editor.loadData(window.functionSpecific.anexar.tma_id,'',"maxpk",""); 2261 result=result[0].maxpk; 2262 } 2263 for(var f=0;f<$('input[name=file_name]')[0].files.length;f++){ 2264 formData = new FormData(); 2265 window.add=0; 2266 formData.append('themeId', window.functionSpecific.anexar.tma_id); 2267 formData.append('file', $('input[name=file_name]')[0].files[f]); 2268 formData.append('obj_code', result); 2269 formData.append('user_id', resume.getSession().usr_id); 2270 formData.append('doc_type', window.functionSpecific.anexar.doc_type); 2271 formData.append('doc_location', window.functionSpecific.anexar.doc_location); 2272 formData.append('doc_info', ''); 2273 formData.append('doc_id', ''); 2274 formData.append('path', window.functionSpecific.anexar.path); 2275 var urlServer =serverURLs.getRestServer(); 2276 $.ajax({ 2277 url: urlServer + 'rest/json/uploadFile/', 2278 data: formData, 2279 type: 'POST', 2280 processData: false, 2281 contentType: false, 2282 success: function (data) { 2283 try{ 2284 editorInfoTools.createPopUpInfomative('<h4><center>'+data.msg+'</center></h4>','success',4000); 2285 }catch(e){ 2286 window.add=window.add+1; 2287 editorInfoTools.createPopUpInfomative('<h4><center>Arquivo nº'+(window.add)+' enviado </center></h4>','success',4000); 2288 } 2289 }, 2290 error: function (data) {window.add=window.add+1;editorInfoTools.createPopUpInfomative('<h4><center>Arquivo nº'+(window.add)+' falhou </center></h4>','waring',4000);} 2291 }); 2292 } 2293 } 2294 //oldid=undefined,newdid=undefined,tma_id=undefined 2295 //functionSpecific.updateTabDocumentMobileTask(infoProperty.dataPopup[0].pk_value,result[0].maxpk,tma_id); 2296 if(!newFile){//}else{ 2297 var result=0 2298 if(chave!=false){ 2299 result=chave 2300 }else{ 2301 result=editor.loadData(tma_id,'',"maxpk",""); 2302 result=result[0].maxpk; 2303 } 2304 //var result=editor.loadData(tma_id,'',"maxpk",""); 2305 try{functionSpecific.updateTabDocumentMobileTask(infoProperty.dataPopup[0].pk_value,result,tma_id);}catch(e){} 2306 } 2307 }, 2308 2309 setTemeSpecific : function(){ 2310 try{ 2311 if(getSession().profile_name=='Atendimento'){ 2312 var session = getSession(); 2313 var prf_id = session.profile_id; 2314 var themes = resume.loadThemes(prf_id); 2315 if(themes!=""){ 2316 $.each(themes, function(key,value) { 2317 if(value.nome_tema.trim().toLowerCase() == 'atendimento novo'){ 2318 themeId = value.tma_id; 2319 name_theme = value.nome_tema; 2320 chave_geo = value.chave_geo; 2321 funcao = value.funcao; 2322 resume.setTheme(themeId, name_theme, chave_geo, funcao); 2323 } 2324 }); 2325 } 2326 } 2327 }catch(e){} 2328 }, 2329 2330 callLongActions: function(callbacks){ 2331 createPopUp(); 2332 setTimeout(function () { 2333 try { 2334 for (let i = 0; i < callbacks.length; i++) { 2335 var tmpFunc = new Function(callbacks[i].toString()); 2336 tmpFunc(); 2337 } 2338 2339 } finally{ 2340 dropPopUp(); 2341 2342 } 2343 }, 200); 2344 2345 }, 2346 sendPGV : function(type){ 2347 var url_server = serverURLs.getRestServer(); 2348 var tbl_name = window.tbl_name; 2349 2350 if(type==1){ 2351 var tma_id_input=parseInt($('#entrada').val()); 2352 var list_attr_input=window.listAttrPGV; 2353 var tma_id_output=parseInt($('#saida').val()); 2354 var attr_estimativa=$('#attribute-saida').val(); 2355 var vut_max=$('#vut_max').val(); 2356 var vut_min=$('#vut_min').val(); 2357 var avg_max=$('#avg_max').val(); 2358 var avg_min=$('#avg_min').val();
2359 var file = $('#importedFiles').get(0).files[0]; 2360 var formData = new FormData(); 2361 formData.append('file', file); 2362 var URL = url_server+"rest/json"+ "/inferPGV?tma_id_input="+tma_id_input+"&list_attr_input="+list_attr_input+"&tma_id_output="+tma_id_output+"&attr_estimativa="+attr_estimativa+"&tbl_name="+ 2363 tbl_name+'&vut_max='+vut_max+'&vut_min='+vut_min+'&avg_max='+avg_max+'&avg_min='+avg_min; 2364 $.ajax({ 2365 url: URL, 2366 type: 'post', 2367 data: formData, 2368 contentType : false, 2369 processData : false, 2370 async: false, 2371 success: function(data) { 2372 console.log(data); 2373 } 2374 }); 2375 } else { 2376 var tma_id_input = parseInt($('#amostras').val()); 2377 var list_attr_input = window.listAttrPGV; 2378 var attr_estimar = $('#attribute-estimar').val(); 2379 var desvio = parseInt($('#desvio').val()) 2380 list_attr_input.push(attr_estimar) 2381 list_attr_input = [... new Set(list_attr_input)] 2382 var URL =url_server+"rest/json"+ "/trainNN?tma_id_input="+tma_id_input+"&list_attr_input="+list_attr_input+"&attr_estimar="+attr_estimar+"&tbl_name="+tbl_name + "&desvio="+desvio; 2383 $.ajax({ 2384 url: URL, 2385 type: 'post', 2386 async: false, 2387 success: function(data) { 2388 console.log(data); 2389 } 2390 }); 2391 var janela = window.open(serverURLs.getDomain()+"/getexporfile?filename=save.zip"); 2392 } 2393 }, 2394 2395 2396 setPopUp : function(){ 2397 infoProperty.idModalNome="pointwindow-modal" 2398 }, 2399 2400 makeImposto : function(){ 2401 var html=""; 2402 2403 const form_imposto = serverURLs.getformImpostoPgv(); 2404 json=infoProperty.checkFormJson(form_imposto); 2405 var pageObj; 2406 function getPage(element) { 2407 pageObj = element; 2408 } 2409 2410 function generatePageObject(pageJSON) { 2411 let obj = JSON.parse(pageJSON); 2412 interpreter.win = window; 2413 interpreter.doc = window.document; 2414 interpreter.interpretJSONPage(obj, getPage); 2415 } 2416 let js = JSON.parse(json) 2417 generatePageObject(json); 2418 html+=pageObj.innerHTML; 2419 editorInfoTools.createPopUp(html,'width:'+ js.width+'px;height:'+ js.height+'px;'); 2420 2421 2422 var prf_id = getProfileIDInSession(); 2423 var themes = resume.loadThemes(prf_id); 2424 if(themes!=""){ 2425 $.each(themes, function(key,value) { 2426 try{$("#tema_vut").append(new Option(value.nome_tema, value.tma_id));}catch(e){} 2427 try{$("#tema_simulacao").append(new Option(value.nome_tema, value.tma_id));}catch(e){} 2428 }); 2429 2430 } 2431 //=========================================== 2432 }, 2433 2434 populateDropDownThemeByPrfId : function(prf_id,idform){ 2435 var HTML=document.getElementById(idform).innerHTML; 2436 var url = serverURLs.getDomain() + "/getthemes?prfId="+prf_id; 2437 $.ajax({ 2438 url: url, 2439 type: 'get', 2440 async: false, 2441 success: function(data){ 2442 if(data.length>0){HTML="";} 2443 for(var x=0;x<data.length;x++){ 2444 try{HTML+='<option value="'+data[x].tma_id+'">'+data[x].nome_tema+'</option>';}catch(e){} 2445 } 2446 } 2447 }); 2448 document.getElementById(idform).innerHTML=HTML; 2449 }, 2450 /** 2451 * function use to routine "infoproperty.loadGenericPopup" 2452 * this routine assists in loading mixed-theme forms 2453 * @param valorPesquisa {String} value used in search data 2454 * @param tma_id_pesquisa {int} search theme target 2455 * @param tma_id_form {int} theme target form json 2456 * @param checkCpf {boolean} if true validade CPF 2457 * @param attributesOtputs {Object} Json object will be use to paste data 2458 * @param button put button update in form, default is true 2459 * @author Baltazar,G.S.F. 2460 * documented by Gabriel.Baltazar 2461 */ 2462 auxLoadDataByMultiplyForm : function (valorPesquisa,tma_id_pesquisa,tma_id_form,checkCpf=false,attributesOtputs=false,button=true,schema=undefined){ 2463 var passing=true; 2464 if(checkCpf && functionSpecific.checkCPF(valorPesquisa)==false){passing=false;} 2465 if(valorPesquisa==undefined || valorPesquisa.toString().length==0){passing=false;} 2466 if(passing){ 2467 2468 if(schema!=undefined){ 2469 var result=editor.loadData(tma_id_pesquisa,schema+".*","",valorPesquisa,'',''); 2470 }else{ 2471 var result=editor.loadData(tma_id_pesquisa,"*","inscricao",valorPesquisa,'',''); 2472 } 2473 2474 if(result.length == 0){ 2475 toastr["warning"]("Os dados procurados não existem.", "Sem Dados"); 2476 } 2477 try{if(infoProperty.dataPopup==undefined){infoProperty.dataPopup=editor.editingLayer.features[0].attributes;}}catch(e){} 2478 if(result.length>0){ 2479 infoProperty.dataPopup=result; 2480 functionSpecific.loadDataByMultiplyForm(valorPesquisa,tma_id_pesquisa,tma_id_form,button,schema); 2481 }else{ 2482 functionSpecific.createNewObjectByResume(tma_id_form,false); 2483 } 2484 2485 if(attributesOtputs!=false){ 2486 for(var x=0;x<attributesOtputs.length;x++){ 2487 try{ 2488 document.getElementById(attributesOtputs[x].key).value=attributesOtputs[x].value; 2489 }catch(e){} 2490 } 2491 } 2492 }else{ 2493 editorInfoTools.createPopUpInfomative('<h4><center>Valor inválido </center></h4>
2493','waring',2000); 2494 } 2495 }, 2496 2497 2498 /** 2499 * function use to routine "functionSpecific.loadDataByMultiplyForm" 2500 * this routine assists in loading mixed-theme forms 2501 * @param valorPesquisa {String} value used in search data 2502 * @param tma_id_pesquisa {int} search theme target 2503 * @param tma_id_form {int} theme target form json 2504 * @param button put button update in form, default is true 2505 * @author Baltazar,G.S.F. 2506 * documented by Gabriel.Baltazar 2507 */ 2508 loadDataByMultiplyForm : function(valorPesquisa,tma_id_pesquisa,tma_id_form,button=true,schema=undefined){ 2509 window.functionSpecific.listPksForms=[]; 2510 if(schema!=undefined){ 2511 var result=editor.loadData(tma_id_pesquisa,schema+".*","",valorPesquisa,'',''); 2512 }else{ 2513 var result=editor.loadData(tma_id_pesquisa,"*","inscricao",valorPesquisa,'',''); 2514 } 2515 2516 2517 if(result.length>0){ 2518 infoProperty.loadInfoPopupEdit(tma_id_form,"update",button,'popup'); 2519 var testJson=infoProperty.checkFormJson(tma_id_form); 2520 if(testJson!=false){ 2521 testJson=JSON.parse(testJson); 2522 for(var x=0;x<testJson.divisions.length;x++){ 2523 if(testJson.divisions[x].theme=='992' && serverURLs.getRestServer().contains("hortolandia")){ 2524 result=editor.loadData(testJson.divisions[x].theme,"LOTES_ANTIGOS_PROCESSOS.*","",infoProperty.dataPopup[0].LCOD,'',''); 2525 if(result.length==0){ 2526 $('[id=theme-'+testJson.divisions[x].theme+']').remove(); 2527 } 2528 } 2529 else{ 2530 2531 if(schema!=undefined){ 2532 result=editor.loadData(testJson.divisions[x].theme,schema+".*","",valorPesquisa,'',''); 2533 }else{ 2534 result=editor.loadData(testJson.divisions[x].theme,"*","",valorPesquisa,'',''); 2535 } 2536 } 2537 if(result.length>1){ 2538 for(var x1=0;x1<result.length-1;x1++){ 2539 functionSpecific.duplicateFieldsByTheme(testJson.divisions[x].theme) 2540 } 2541 } 2542 var resps=$('[id=theme-'+testJson.divisions[x].theme+']'); 2543 for(var x1=0;x1<result.length;x1++){ 2544 window.functionSpecific.listPksForms.push({theme:testJson.divisions[x].theme,value:result[x1][result[x1].pk_name],key:result[x1].pk_name}) 2545 var fakeImages = $('[id=theme-'+testJson.divisions[x].theme+']')[x1].querySelectorAll('input'); 2546 var fakeImages2 = $('[id=theme-'+testJson.divisions[x].theme+']')[x1].querySelectorAll('textarea') 2547 var fakeImages3 = $('[id=theme-'+testJson.divisions[x].theme+']')[x1].querySelectorAll('select') 2548 for (var i = 0; i < fakeImages.length; i++) { 2549 if($(fakeImages[i]).attr('type') === 'text'){ 2550 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2551 } 2552 else if($(fakeImages[i]).attr('type') == 'number'){ 2553 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2554 } 2555 else if($(fakeImages[i]).attr('type') == 'checkbox' ){ 2556 if(result[x1][$(fakeImages[i]).attr('id')].toString().toLowerCase().contains('t') || result[x1][$(fakeImages[i]).attr('id')].toString().toLowerCase().contains('v')){ 2557 $(fakeImages[i]).prop('checked', true); 2558 } 2559 } 2560 else if($(fakeImages[i]).attr('type') == 'date' && result[x1][$(fakeImages[i]).attr('id')]!=undefined){ 2561 var test=result[x1][$(fakeImages[i]).attr('id')].toString() 2562 if(test.contains('/')){test=test.split('/')}else{test=test.split('-')} 2563 if(test[0].length!=4){ 2564 $(fakeImages[i]).val(test[2]+"-"+test[1]+"-"+test[0]); 2565 }else{ 2566 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2567 } 2568 } 2569 else{ 2570 $(fakeImages[i]).val(result[x1][$(fakeImages[i]).attr('id')]); 2571 } 2572 } 2573 for (var i = 0; i < fakeImages2.length; i++) { 2574 $(fakeImages2[i]).val(result[x1][$(fakeImages2[i]).attr('id')]); 2575 } 2576 for (var i = 0; i < fakeImages3.length; i++) { 2577 $(fakeImages3[i]).val(result[x1][$(fakeImages3[i]).attr('id')]); 2578 } 2579 } 2580 2581 } 2582 } 2583 }else{ 2584 functionSpecific.createNewObjectByResume(tma_id_form,false); 2585 } 2586 }, 2587 2588 2589 /** function to append information in a form 2590 *@param tma_source tma_id will be search data 2591 *@param value value target will be used in search 2592 *@param elementApend Element HTML will be appending informations 2593 *@param elementHide Element HTML will be hide, default is false 2594 *@param keyName target collun search, default is false 2595 *@author Baltazar,G.S.F. 2596 */ 2597 appendingInformationForm : function(tma_source,value,elementApend,elementHide=false,keyName=false,schema=undefined){ 2598 let testJson=infoProperty.checkFormJson(tma_source); 2599 let pageObj; 2600 function getPage(element) {pageObj = element;} 2601 function generatePageObject(pageJSON) { 2602 let obj = JSON.parse(pageJSON); 2603 interpreter.win = window; 2604 interpreter.doc = window.document; 2605 interpreter.interpretJSONPage(obj, getPage); 2606 } 2607 let list=[]; 2608 if(keyName){ 2609 if (schema!=undefined){ 2610 list=editor.loadData(tma_source,schema+".*",keyName,value,'',''); 2611 }else{ 2612 list=editor.loadData(tma_source,"*",keyName,value,'',''); 2613 } 2614 }else{ 2615 if (schema!=undefined){ 2616 list=editor.loadData(tma_source,schema+".*","",value,'',''); 2617 }else{ 2618 list=editor.loadData(tma_source,"*","",value,'',''); 2619 } 2620 } 2621 2622 if(list.length==0){ 2623 toastr["warning"]("Os dados procurados não existem.", "Sem Dados"); 2624 return false;
2625 }else{ 2626 if(elementHide!=false){ 2627 if(typeof(elementHide)!='object'){$('#'+elementHide).hide();} 2628 else{ 2629 elementHide.attributes.style.nodeValue+='display: none;'; 2630 } 2631 } 2632 generatePageObject(testJson); 2633 for(let x=0;x<list.length;x++){ 2634 let pageObj2=pageObj.cloneNode(true); 2635 let inputs=pageObj2.getElementsByTagName('input'); 2636 let textarea=pageObj2.getElementsByTagName('textarea'); 2637 let select=pageObj2.getElementsByTagName('select'); 2638 let buttons=pageObj2.getElementsByTagName('button'); 2639 for(let a=0;a<inputs.length;a++){ 2640 if(inputs[a].type == 'text' || inputs[a].type == 'number'){if(typeof(list[x][inputs[a].id])!='undefined'){inputs[a].value=list[x][inputs[a].id];}} 2641 if(inputs[a].type == 'checkbox'){alert('não programado');} 2642 if(inputs[a].type == 'date'){if(typeof(list[x][inputs[a].id])!='undefined'){let valor=list[x][inputs[a].id];valor=valor.split('/');inputs[0].value=valor[2]+"-"+valor[1]+"-"+valor[0];}} 2643 inputs[a].id+="_"+x; 2644 } 2645 for(let a=0;a<textarea.length;a++){ if(typeof(list[x][textarea[a].id])!='undefined'){textarea[a].value=list[x][textarea[a].id];}textarea[a].id+="_"+x;} 2646 for(let a=0;a<select.length;a++){ alert('não programado');select[a].id+="_"+x;} 2647 for(let a=0;a<buttons.length;a++){buttons[a].id+="_"+x;} 2648 pageObj2.style='margin-left: 1%'; 2649 elementApend.parentElement.appendChild(pageObj2); 2650 elementApend.parentElement.style="margin-left: 3%; margin-top: 1%; border-left: 1px solid; border-bottom: 1px solid; min-width:100%;"; 2651 } 2652 } 2653 }, 2654 2655 /** 2656 * Searches a theme and replicates form groups for each result returned. 2657 * Similar to serchCEP but supports multiple returns, replicating the target theme 2658 * for each object in the result array. 2659 * 2660 * @param {string|HTMLElement} element - Value to search or HTML element containing the value 2661 * @param {number} tma_id - Theme ID in the database 2662 * @param {string} coluns - Columns to fetch (use '*' for all) 2663 * @param {string} chave - Key column name for the search 2664 * @param {string} outputs - Mapping of html_field:db_field separated by '/' 2665 * Example: 'nome:name/cpf:document/endereco:address' 2666 * @param {string} targetTheme - ID of the theme/div to replicate 2667 * @param {boolean} replace - If true, removes special characters from search value 2668 * @param {string} msg - Custom error message when no results found 2669 * @param {string} typeForm - Form type for replication function (optional) 2670 * @param {boolean} readonly - If true, sets filled fields as readonly (default: true) 2671 * @param {Object} valueMapping - Object with value transformations per db field 2672 * Example: {ehprincipal: {'S': 'Principal', 'N': 'SECUNDÃRIA'}} 2673 * @returns {boolean} true if results found and processed, false otherwise 2674 * @author Generated based on serchCEP structure 2675 */ 2676 searchThemeMultiple: function(element, tma_id, coluns, chave, outputs, targetTheme, replace, msg, typeForm, readonly = true, valueMapping = null) { 2677 var valor = element; 2678 try { 2679 if (element.value != undefined) { 2680 valor = element.value; 2681 } 2682 } catch (e) {} 2683 2684 if (replace == true) { 2685 try { 2686 valor = valor.replace(/[^0-9^a-z^A-Z^ÃçáaãáeéiÃoõóôuúszcçAÃÃEÃIÃOÃÃÃUÃSZCÃ,]+/g, ''); 2687 } catch (e) {} 2688 } 2689 2690 var result = []; 2691 if (valor.toString().length > 0) { 2692 try { 2693 var key = registerus.getKey(); 2694 2695 if (!key) { 2696 try { 2697 var ajaxResp = loadData(tma_id, coluns, chave, valor); 2698 if (ajaxResp && ajaxResp.responseJSON) { 2699 result = ajaxResp.responseJSON; 2700 } else { 2701 result = []; 2702 } 2703 } catch (e) { 2704 result = []; 2705 } 2706 } else { 2707 result = registerus.loadData(tma_id, coluns, chave, valor, '', ''); 2708 } 2709 } catch (e) { 2710 result = []; 2711 } 2712 } 2713 2714 try { 2715 if (result.length > 0) { 2716 // Clean and replicate the theme for each result 2717 functionSpecific.cleanReplicatedTheme(targetTheme); 2718 functionSpecific.replicateThemeWithData(result.length, targetTheme, typeForm); 2719 2720 var chaves = outputs.split('/'); 2721 2722 // Fill data for each replicated theme 2723 for (var r = 0; r < result.length; r++) { 2724 for (var x = 0; x < chaves.length; x++) { 2725 var input = chaves[x].split(':')[0]; 2726 var output = chaves[x].split(':')[1]; 2727 2728 // Build the replicated field ID (fieldName@index) 2729 var replicatedInputId = input + '_' + r; 2730 2731 try { 2732 var inputElement = document.getElementById(replicatedInputId); 2733 if (inputElement == null) { 2734 // Try without @ suffix for the first element or original 2735 inputElement = document.getElementById(input); 2736 } 2737 2738 if (inputElement != null) { 2739 if (chave != input && readonly) { 2740 $(inputElement).attr('readonly', true); 2741 } 2742 2743 // Get value and apply mapping if exists 2744 var rawValue = result[r][output] || ''; 2745 var finalValue = rawValue; 2746 if (valueMapping && valueMapping[output] && valueMapping[output][rawValue] !== undefined) { 2747 finalValue = valueMapping[output][rawValue]; 2748 } 2749 2750 switch (inputElement.type) { 2751 case "input": 2752 case "text": 2753 case "number": 2754 inputElement.value = finalValue; 2755 inputElement.style.backgroundColor = ""; 2756 break; 2757 case "date": 2758 var t = finalValue; 2759 if (t) { 2760 try { 2761 inputElement.value = t.split('/')[2] + "-" + t.split('/')[1] + "-" + t.split('/')[0]; 2762 } catch (e) { 2763 try { 2764 inputElement.value = t.split('-')[2] + "-" + t.split('-')[1] + "-" + t.split('-')[0]; 2765 } catch (e) { 2766 console.log('Date field error'); 2767 } 2768 } 2769 } 2770 break; 2771 case "select-one": 2772 inputElement.value = finalValue; 2773 break; 2774 default: 2775 inputElement.value = finalValue; 2776 break; 2777 } 2778 } 2779 } catch (e) { 2780 console.log('Error filling field: ' + replicatedInputId, e); 2781 } 2782 } 2783 } 2784 2785 try { 2786 element.style.border = "1px solid #ced4da"; 2787 } catch (e) {} 2788 return true; 2789 } else { 2790 try { 2791 element.value = ""; 2792 if (valor.toString().length == 0) { 2793 element.style.border = "1px solid #ced4da"; 2794 return true; 2795 } 2796 element.style.border = "1px solid red"; 2797 } catch (e) {} 2798 2799 if (msg != undefined && msg != null && msg != '') { 2800 editorInfoTools.createPopUpInfomative('<h4><center>
2800' + msg + ' </center></h4>', 'waring', 2000); 2801 } else { 2802 editorInfoTools.createPopUpInfomative('<h4><center>Nenhum dado localizado</center></h4>', 'waring', 2000); 2803 } 2804 return false; 2805 } 2806 } catch (e) { 2807 console.log('searchThemeMultiple error:', e); 2808 return false; 2809 } 2810 }, 2811 2812 /** 2813 * Cleans all replicated divs for a given theme. 2814 * Should be called before replicating to avoid duplicates. 2815 * 2816 * @param {string} targetTheme - ID of the theme/div to clean replicas 2817 */ 2818 cleanReplicatedTheme: function(targetTheme) { 2819 // Restore required attributes stripped when template was hidden 2820 $(`#${targetTheme}`).find('[data-required-stored]').each(function() { 2821 $(this).attr('required', ''); 2822 $(this).removeAttr('data-required-stored'); 2823 }); 2824 // Remove divs with name containing targetTheme_div 2825 $(`div[name*="${targetTheme}_div"]`).remove(); 2826 // Also remove divs with id like targetTheme0, targetTheme1, etc. 2827 $(`div[id^="${targetTheme}"]`).not(`#${targetTheme}`).remove(); 2828 }, 2829 2830 /** 2831 * Replicates a theme div N times for use with searchThemeMultiple. 2832 * Creates clones of the target theme with indexed IDs and field names. 2833 * 2834 * @param {number} nTimes - Number of times to replicate 2835 * @param {string} targetTheme - ID of the theme/div to replicate 2836 * @param {string} typeForm - Form type (optional, for specific handling) 2837 * @author Generated based on createFunctionConstruction structure 2838 */ 2839 replicateThemeWithData: function(nTimes, targetTheme, typeForm) { 2840 const div = $(`#${targetTheme}`); 2841 2842 if (div.length === 0) { 2843 console.log('Target theme not found: ' + targetTheme); 2844 return; 2845 } 2846 2847 const events = ["onclick", "onchange", "onkeyup", "onkeypress", "onkeydown", "onfocus", "onfocusout", "submit"]; 2848 2849 let lastInserted = div; 2850 for (let i = 0; i < nTimes; i++) { 2851 let newDiv = div.clone(true); 2852 2853 const cloned_ids = []; 2854 newDiv.find("*[id]:not(div)").each(function() { 2855 cloned_ids.push($(this).attr('id')); 2856 }); 2857 2858 newDiv.find("*[id]:not(div)").each(function() { 2859 $(this).attr('id', function(j, id) { 2860 const newId = id + "_" + i; 2861 $(this).attr('name', newId); 2862 2863 // Apply masks if configured 2864 try { 2865 const maskConfig = interpreter.getMasks().find(m => m.element === id); 2866 if (maskConfig) { 2867 interpreter.__insertMask__({ 2868 element: newId, 2869 mask: maskConfig.mask 2870 }); 2871 2872 const el = document.querySelector('input[name="' + newId + '"]'); 2873 if (el) { 2874 IMask(el, { mask: maskConfig.mask }); 2875 } 2876 } 2877 } catch (e) {} 2878 2879 // Update event handlers with new IDs 2880 events.forEach(event => { 2881 if ($(this).attr(event)) { 2882 let new_event = $(this).attr(event); 2883 cloned_ids.forEach(clonedId => { 2884 const regex = new RegExp(`(['#/\\s,{])${clonedId}([\\s':,}])`, 'g'); 2885 new_event = new_event.replace(regex, (_, prefix, suffix) => `${prefix}${clonedId}_${i}${suffix}`); 2886 }); 2887 $(this).attr(event, new_event); 2888 } 2889 }); 2890 2891 return newId; 2892 }); 2893 }); 2894 2895 $(newDiv).attr('id', targetTheme + i); 2896 $(newDiv).attr('name', targetTheme + '_div'); 2897 newDiv.insertAfter(lastInserted); 2898 lastInserted = newDiv; 2899 newDiv.show(); 2900 2901 const title = newDiv.find('h3, h4'); 2902 const removeButton = $('<i/>', { 2903 text: 'delete', 2904 class: 'btn material-icons red float-right', 2905 type: 'button', 2906 id: 'remove' + i 2907 }); 2908 removeButton.click({param: newDiv}, function(event) { 2909 $(event.data.param).remove(); 2910 }); 2911 removeButton.prependTo(title); 2912 } 2913 2914 // Hide original template 2915 div.hide(); 2916 div.find('input[required], select[required], textarea[required]').each(function() { 2917 $(this).attr('data-required-stored', 'true'); 2918 $(this).removeAttr('required'); 2919 }); 2920 }, 2921 2922 2923 }; 2924 return FunctionSpecific; 2925 })(); 2926 2927var functionSpecific= new FunctionSpecific();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.