//Объезды class TGeofences //Current user with role name and access { constructor(map){ this.geofences = []; } //Получаем список объектов //Фильтруем объекты для заполнения в таблицу filtering() { showProgressBar(document.getElementById('id5_geofences')); let data = { geofence_type_id: document.getElementById("geofence_type_id_id0").value, name: document.getElementById("filter_name_geofences").value }; let req=createRequestObject(); req.onreadystatechange = function(thiz) { return function(){ if(req.readyState === 4){ var data=null; try { data = JSON.parse(req.responseText); } catch (e) { alert(e.message); return; } if(data!=null) { if(data.errorMessage !== undefined && data.errorMessage!='') { alert2(trt('Error'),data.errorMessage); return; } thiz.clear(); //Приходит JSON уже в объектах //let features = []; for(i=0;i'+trt('Geofence_name')+''+trt('Points')+''; var theTable = document.getElementById('thetable_geofences'); let type_name=''; for(i=0;i'; tr.appendChild(td); td = document.createElement('td'); td.style.cssText="text-align: center;"; td.innerHTML=''; tr.appendChild(td); td = document.createElement('td'); td.style.cursor='pointer'; td.innerHTML=this.geofences[i].name; td.onclick=function(detour){ return function(){ detour.goToCenter(); } }(this.geofences[i]); tr.appendChild(td); /*td = document.createElement('td'); td.style.cssText='cursor:pointer;text-align:right;'; td.innerHTML=this.geofences[i].date_start; td.onclick=function(detour){ return function(){ detour.goToCenter(); } }(this.geofences[i]); tr.appendChild(td); td = document.createElement('td'); td.style.cssText='cursor:pointer;text-align:right;'; td.innerHTML=this.geofences[i].date_end; td.onclick=function(detour){ return function(){ detour.goToCenter(); } }(this.geofences[i]); tr.appendChild(td);*/ td = document.createElement('td'); td.style.cssText='cursor:pointer;text-align:right;'; td.innerHTML=this.geofences[i].count; td.onclick=function(detour){ return function(){ detour.goToCenter(); } }(this.geofences[i]); tr.appendChild(td); theTable.tBodies[0].appendChild(tr); //Формирую раскрывающийся список var tr = document.createElement('tr'); tr.id=this.geofences[i].id; tr.style.cssText="background-color:var(--back-color-3);display:none"; td = document.createElement('td'); td.colSpan=4; let html='
'; if(this.geofences[i].geofence_type_name!=null) html+='Тип геозоны'+trt('')+': '+this.geofences[i].geofence_type_name+'
'; html+='
'+trt('Delete')+''+trt('Edit')+'
'; td.innerHTML=html; tr.appendChild(td); theTable.tBodies[0].appendChild(tr); var cell=document.getElementById("geofences_ch_"+this.geofences[i].id); cell.onclick=function(route){ return function(){ var chb=document.getElementById("geofences_ch_"+route.id); route.setVisibility(chb.checked); } }(this.geofences[i]); //Кнопка разсрыть список var btn=document.getElementById('geofences_down_btn_'+this.geofences[i].id); btn.onclick=function(tr,thiz,id){ return function(){ var btn=document.getElementById('geofences_down_btn_'+id); if(btn.src.indexOf("right.png")!=-1) { btn.src = '/resources/images/down.png'; tr.style.display = 'table-row'; }else if(btn.src.indexOf("down.png")!=-1) { btn.src = '/resources/images/right.png'; tr.style.display = 'none'; } }; }(tr,this,this.geofences[i].id); /* //При щелчке по иконке календаря отображаем календарь выбора //setCalendar("filter_date_route_start_"+this.geofences[i].id,"filter_date_route_start_trigger_"+this.geofences[i].id,-2); //setCalendar("filter_date_route_end_"+this.geofences[i].id,"filter_date_route_end_trigger_"+this.geofences[i].id); this.geofences[i].getGeoJSON(); */ //Кнопка удалить btn=document.getElementById('detour_del_'+this.geofences[i].id) btn.onclick=function(thiz,id){ return function(){ thiz.deleteDetour({id:id}); }; }(this,this.geofences[i].id); //Кнопка редактировать btn=document.getElementById('detour_edit_'+this.geofences[i].id) btn.onclick=function(thiz,id){ return function(){ thiz.editDetour({id:id}); }; }(this,this.geofences[i].id); } //Количество элементов в дереве var divCnt = document.getElementById("count_geofences"); delChild(divCnt); divCnt.appendChild(document.createTextNode(this.geofences.length)); //По нажатию на заголовок инвертируем чекбуксы divCnt = document.getElementById("cell_ch_D"); divCnt.onclick=function(thiz){ return function(){ thiz.hide(); } }(this); } createDetour() { //В настройках передаю центр карты let center=ol.proj.transform(g_map.getView().getCenter(), 'EPSG:3857','EPSG:4326'); let eRec = new EdtRec(""); eRec.eRecNa("Geofences",-1,''); eRec.win.onClose=function(thiz){ return function(){ thiz.filtering();};}(this); } //Удалить объезд deleteDetour(settings) { if (typeof settings === 'string' || settings instanceof String) { try { settings = JSON.parse(settings); } catch (e) { alert(e.message); return; } } if (confirm(trt("Do_you_really_want_to_delete_the_record")+'?')) { var req=createRequestObject(); req.onreadystatechange = function(thiz) { return function(){ if(req.readyState === 4){ var data=null; try { data = JSON.parse(req.responseText); } catch (e) { alert(e.message); return; } if(data!=null) { if(data.errorMessage !== undefined && data.errorMessage!='') { alert(data.errorMessage); thiz.win.hideProgressBar(); }else { } } //Фильтрую список заново thiz.filtering(); } }; }(this); req.open("POST", '/monitoring/pscripts/geofences.php?fn=3', true); req.setRequestHeader("Content-type", "text/plain"); req.send(JSON.stringify(settings)); this.filtering(); } return true; } editDetour(settings) { if (typeof settings === 'string' || settings instanceof String) { try { settings = JSON.parse(settings); } catch (e) { alert(e.message); return; } } var detour=this.getDetourByID(settings.id); let eRec = new EdtRec(""); eRec.eRecNa("Geofences",settings.id); eRec.win.onClose=function(thiz,detour){ return function(){ detour.showPoints(false); //thiz.filtering(); };}(this,detour); if(detour!=null) { detour.showPoints(true); detour.setVisibility(true); } } //Вернуть объект TDetour по идентификатору getDetourByID(id) { for(var i=0;i