Files
GEOVizor_PHP/observation/index.php
2023-11-07 19:51:49 +06:00

1947 lines
74 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
header('Cache-Control: no-store, no-cache, must-revalidate');
header("Expires: 0");
header('Pragma: no-cache');
@session_start();
if(!isset($_SESSION['USER_ID']))
$_SESSION['USER_ID'] = null;
if(!isset($_SESSION['COMPANY_ID']))
$_SESSION['COMPANY_ID'] = null;
if(isset($_REQUEST["company_id"]))
$_SESSION['COMPANY_ID'] = $_REQUEST["company_id"];
if(isset($_REQUEST["lng"]))
$_SESSION["LNG"]=$_REQUEST["lng"];
if(!isset($_SESSION["LNG"]))
$_SESSION["LNG"]=2;//'ru';
require_once("./config.php");
require_once("../resources/metadata/include/tools.php");
$db=connectToDB();
//Проверяю не подсунули ли id левой компании и выставляю в какой компании по умолчанию
if($_SESSION['COMPANY_ID']!=null && $_SESSION['USER_ID'])
{
$sql="select company_id from main.companies_users where del=false and user_id=".$_SESSION['USER_ID'];
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
$exists=false;
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
if($_SESSION['COMPANY_ID']==$row['company_id'])
{
$sql="update main.companies_users set last=false where last=true and user_id=".$_SESSION['USER_ID'];
$res = $db->query($sql);
$sql="update main.companies_users set last=true where company_id=".$_SESSION['COMPANY_ID']." and user_id=".$_SESSION['USER_ID'];
$res = $db->query($sql);
$exists=true;
break;
}
}
}
if(!$exists)
$_SESSION['COMPANY_ID']=null;
}
$userName = ''; //Фамилия Имя Отчество
$roleName = ''; //Роли доступа
$timezone='';
if(isset($_SESSION['USER_ID']) && $_SESSION['USER_ID']!='' && $_SESSION['USER_ID']!='null')
{
$sql="
select
Coalesce(u.name,'') as name, --concat(Coalesce(u.surname,''),' ',Coalesce(u.name,''),' ',Coalesce(u.patronymic,'')) as name,
t.role,
main.getcompanyid(u.id) company_id,
u.timezone
from
main._Users u
left join (select ug.user_id, array_to_string(array_agg(main._(".$_SESSION['USER_ID'].",g.name)), ', ') as role from main._Groups g, main._UsersGroups ug where ug.del=false and g.id=ug.group_id group by ug.user_id) t on u.id=t.user_id
where u.id=".$_SESSION['USER_ID'].";";
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
$userName=$row['name'];
$roleName=trt($row['role']);
if($_SESSION['COMPANY_ID']==null)
$_SESSION['COMPANY_ID']=$row['company_id'];
$timezone=$row['timezone'];
}
}
}
//Типа версия скрипта (Задавать пути от корня сайта)
/*function getScript($path)
{
if (file_exists($_SERVER['DOCUMENT_ROOT'].$path))
{
return '<script type="text/javascript" src="'.$path.'?v='. filectime($_SERVER['DOCUMENT_ROOT'].$path).'"></script>'."\n";
}
return '';
}*/
?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache">
<link rel="shortcut icon" href="../resources/favicon.ico" />
<title>GEOVizor</title>
<meta property="description" content="Телеметрия и GPS/ГЛОНАСС трекинг, контроль расхода топлива, пройденного пути, скорости и работы механизмов Алматы и весь Казахстан" />
<link rel="stylesheet" href="../resources/normalize.css">
<link rel="stylesheet" href="./setup.css"/>
<script type="text/javascript" src="../resources/metadata/include/jscalendar/src/js/jscal2.js"></script>
<script type="text/javascript" src="../resources/metadata/include/jscalendar/src/js/lang/ru.js"></script>
<link rel="stylesheet" type="text/css" href="../resources/metadata/include/jscalendar/src/css/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="../resources/metadata/include/jscalendar/src/css/border-radius.css"/>
<link rel="stylesheet" type="text/css" href="../resources/metadata/include/jscalendar/src/css/steel/steel.css"/>
<script src="../resources/ol.js"></script>
<link rel="stylesheet" href="../resources/ol.css" type="text/css">
<script src="../resources/proj4.js"></script>
<script type="text/javascript" src="../resources/metadata/jquery.js"></script>
<script type="text/javascript" src="../resources/metadata/sprintf.js"></script>
<script src="../resources/moment.min.js"></script>
<script src="../resources/chartjs/Chart.min.js"></script>
<!--link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script-->
<link rel="stylesheet" type="text/css" href="../resources/metadata/dbms/dbms.css"/>
<script type="text/javascript" src="../resources/metadata/dbms/BrowserDetect.js"></script>
<? echo getScript('/monitoring/setup.js'); ?>
<? echo getScript('/resources/metadata/dbms/tools.js'); ?>
<? echo getScript('/resources/metadata/dbms/editrecord.js'); ?>
<? echo getScript('/resources/metadata/dbms/showrecord.js'); ?>
<? echo getScript('/resources/metadata/dbms/tabs.js'); ?>
<? echo getScript('/resources/metadata/tree/tree.js'); ?>
<script type="text/javascript" src="index.js"></script>
<? echo getScript('/monitoring/jscripts/geofences.js'); ?>
<? echo getScript('/monitoring/jscripts/routes.js'); ?>
<? echo getScript('/monitoring/jscripts/detours.js'); ?>
<? echo getScript('/monitoring/jscripts/objects.js'); ?>
<? echo getScript('/monitoring/jscripts/trips.js'); ?>
<? echo getScript('/monitoring/jscripts/messages.js'); ?>
<? echo getScript('/monitoring/jscripts/events.js'); ?>
<? echo getScript('/monitoring/jscripts/user.js'); ?>
<link rel="stylesheet" href="/resources/buttons.css">
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="./css/ol-popup.css">
<script type="text/javascript" src="translation.php"></script>
<style>
html,
body {
height: 100%;
margin:0;
padding:0;
background:#ffffff;
}
select{
box-sizing : border-box;
}
.api {
height: 768px;
border: 1px solid #ddd;
border-radius: 4px;
}
.split p {
padding: 20px;
}
.split {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
}
.gutter {
background-color: #eee;
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-horizontal {
background-image: url('vertical.png');
cursor: ew-resize;
}
.gutter.gutter-vertical {
background-image: url('horizontal.png');
cursor: ns-resize;
}
.split.split-horizontal, .gutter.gutter-horizontal {
height: 100%;
float: left;
}
.ol-scale-line {
left: 50%;
transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0)
}
.ol-full-screen{
left: .5em;
bottom: .5em;
right:inherit;
top:inherit
}
.ol-zoom {
left: unset;
right: 8px;
}
.ol-zoomslider {
left: unset;
right: 8px;
}
</style>
<script>
var ScriptName='records.php';
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|| window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}());
var g_feature=null; //Перемещаемый элемент (точка)
var g_map=null;
var m_winPP=null;
//var g_Login=null; //Form and authorization mechanism.
var g_user=null;
//var g_WinLegend1 = null;
//var m_FrmLocust=null;
//var m_FrmLocustDel=null;
//Decode URL parameters.
var GET = {};
var query = window.location.search.substring(1).split("&");
for (var i = 0, max = query.length; i < max; i++)
{
if (query[i] === "") // check for trailing & with no param
continue;
var param = query[i].split("=");
GET[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || "");
}
function myFunction(TypeName,settings)
{
rec=new SRec();
rec.create(null);
//rec.win.setSize("400px","100px");
rec.win.setHeight(500);
//rec.win.setLeftTop(300,40);
rec.win.setCenter();
//rec.request.callServer(ScriptName,'<metadata fn="0"><type n="'+rec.f_TypeName+'"></type></metadata>');
if(TypeName=='Objects')
{
if(g_user.getAccess('Carrier')) //Если перевозчик то только своими терминалами может оперировать
{
settings='<type n="Objects"><properties><prop n="company_id" visible="0"/></properties><objects-list><filter><column n="company_id" visible="0"><![CDATA['+g_user.company_id+']]\></column></filter></objects-list></type>';
}else
{
settings='<type n="Objects"><objects-list><filter><column n="company_id"><![CDATA['+g_user.company_id+']]\></column></filter></objects-list></type>';
}
}else
if(TypeName=='Terminals')
{
if(g_user.getAccess('Carrier')) //Если перевозчик то только своими терминалами может оперировать
{
settings='<type n="Terminals"><properties><prop n="company_id" visible="0"/></properties><objects-list><filter><column n="company_id" visible="0"><![CDATA['+g_user.company_id+']]\></column></filter></objects-list></type>';
}else
{
settings='<type n="Terminals"><objects-list><filter><column n="company_id"><![CDATA['+g_user.company_id+']]\></column></filter></objects-list></type>';
}
}else
if(TypeName=='SensorsValues')
{
settings='<type n="SensorsValues"><objects-list><filter><column n="date_start"><![CDATA['+Math.floor(Date.now() / 1000-(60*60))+']]\></column></filter></objects-list></type>';
}else
if(TypeName=='TerminalsLocations')
{
settings='<type n="TerminalsLocations"><objects-list><filter><column n="date_start"><![CDATA['+Math.floor(Date.now() / 1000-(60*60))+']]\></column></filter></objects-list></type>';
}
rec.callData(TypeName,settings);
return rec;
}
/*function showIFrameWindow(title,url)
{
var win=new TWin();
win.BuildGUI(10,10);
win.setCaption(title);
win.setContent('<iframe src="'+url+'" frameborder="0" width="100%" height="100%"></iframe>');
win.setSize("550px","250px");
win.setCenter();
win.shadow=true;
win.hide(false);
}*/
function showHelpWindow(){
let win=new TWin();
win.BuildGUI(10,10);
win.setCaption(trt('Help'));
win.setSize("550px","250px");
let html='<h2 style="text-align: center">'+trt('Instructions')+'</h2><ul><li><a href="/resources/help/connection.php" target="_blank">'+trt('Instructions_for_connecting_trackers')+'</a></li></ul><br><br>';
win.setContent(html);
win.setCenter();
win.shadow=true;
win.hide(false);
}
/*function showFrmLocust()
{
rec=new SRec();
rec.create(document.getElementById("FrmLocust"));
rec.f_TypeName="FrmLocust";
rec.f_Settings='';
rec.request.callServer(ScriptName,'<metadata fn="0"><type n="FrmLocust"></type></metadata>');
m_FrmLocust=rec;
}*/
/*function showFrmLocustDel()
{
//this.create=function(htmlElement)
rec=new SRec();
rec.create(document.getElementById("FrmLocustDel"));
rec.f_TypeName="FrmLocustDel";
rec.f_Settings='';
rec.f_Settings+="<metadata><type n=\"FrmLocustDel\">";
rec.f_Settings+=" <objects-list>";
rec.f_Settings+=" <filter height=\"1\">";
rec.f_Settings+=" <column n=\"user_id\" visible=\"0\"></column>";
//rec.f_Settings+=" <column n=\"date_start\"><![CDATA["+ (new Date(Date.now() - 7776000000)).toString() + "]]\></column>";
//rec.f_Settings+=" <column n=\"date_end\"><![CDATA[" + (new Date(Date.now() + 86400000)).toString() + "]]\></column>";
rec.f_Settings+=" </filter>";
rec.f_Settings+=" <column n=\"lon\" visible=\"0\"/>";
rec.f_Settings+=" <column n=\"lat\" visible=\"0\"/>";
rec.f_Settings+=" <column n=\"changed\" visible=\"0\"/>";
rec.f_Settings+=" <column n=\"photo\" visible=\"0\"/>";
//rec.f_Settings+=" <column n=\"region\" visible=\"0\"/>";
//rec.f_Settings+=" <column n=\"area\" visible=\"0\"/>";
rec.f_Settings+=" </objects-list>";
rec.f_Settings+="</type></metadata>";
rec.request.callServer(ScriptName,'<metadata fn="0"><type n="FrmLocustDel"></type></metadata>');
m_FrmLocustDel=rec;
}*/
function onLoadPage()
{
//document.body.appendChild( this.divsh );
//document.body.appendChild( divsh );
g_user = new TUser();
g_user.isLogined();
g_user.timezone='<?php echo $timezone; ?>';
//g_Login=new TLogin();
//g_Login.win.shadow=false;
//g_Login.create('../metadata/dbms/form/');
//g_Login.addListener(this);
//g_Login.Logined();
//Check whether the user is logged in.
//g_Login=new TLogin();
//g_Login.addListener(this);
//showFrmLocust();
//showFrmLocustDel();
}
</script>
</head>
<body style="padding: 0px;">
<!-- Для кнопки раскрытия карты на весь экран -->
<div id="scale-line" class="scale-line"></div>
<!-- Для всплывающего окна -->
<div id="popup" class="ol-popup">
<a href="#" id="popup-closer" class="ol-popup-closer"></a>
<div id="popup-content"></div>
</div>
<!--datalist id="declaration"><?php
$sql='select REPLACE(declaration, \'"\', \'&quot;\') as name from main.objects where del=false GROUP BY declaration order by declaration;';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_NUM))
{
echo "<option value=\"$row[0]\"></option>";
}
}
?></datalist-->
<!--div id="shadow" style="position: fixed; z-index: 1; top:0; left:0; height: 100%; width: 100%; background: rgba(0,0,0,0.3);"></div-->
<table border="0" style="width:100%;height:100%;">
<tr style="background-color: #4a4d55;">
<td style="width:100%; height:60px; border-bottom: 1px solid black;" colspan="2">
<table style="width:100%;height:100%;color: rgb(255, 255, 255);">
<tr>
<td style="padding-left:5px;white-space: nowrap;"><img src="../resources/images/observer.svg" height="50" alt="User"></td>
<td style="padding-left:5px;white-space: nowrap;"><img src="../resources/images/user.svg" width="50" height="50" alt="User"></td>
<td style="padding-left:5px;white-space: nowrap;"><?php echo $userName;?> </td>
<td style="padding-left: 6px;"><b><?php echo trt('Company').': ';?></b></td>
<td>
<select id="company_id_m" onchange="location.href = './?company_id='+this.value;">
<?php
//Выбираю список компаний в которых данный пользователь присутствует
$sql='select
id,
name,
(select count(*) from main.companies_objects where del=false and company_id=c.id) as count
from
main.companies c
where
del=false
and c.id in (select cu.company_id from main.companies_users cu where cu.del=false and cu.user_id='.$_SESSION['USER_ID'].')';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
if($_SESSION['COMPANY_ID']==$row['id'])
{
echo '<option value="'.$row['id'].'" selected="selected">'.$row['name'].' ('.$row['count'].')</option>';
}else
{
echo '<option value="'.$row['id'].'">'.$row['name'].' ('.$row['count'].')</option>';
}
}
}
?>
</select>
</td>
<td style="padding-left: 6px;"><b><?php echo trt('Role').':';?></b></td>
<td style="padding-left: 6px;"><?php echo $roleName;?></td>
<td style="padding-left: 5px; width: 90%; text-align: right;"><?php echo trt("Language"); ?></td>
<td style="padding-left:5px;"><div style="display:block; width:100px; height:21px; position: relative;">
<select id="lang" onchange="location.href = './?lng='+this.value;" style="width: 100%; position: absolute; z-index: 10000;">
<?php
$sql="select id,name from main._languages where del=false order by name;";
try {
$res = $db->query($sql);
} catch (Exception $ex) {
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
print '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
}
?>
</select>
</div></td>
<td style="padding-left:5px;"><img src="../resources/images/config.png" onclick="showConfigWidget()" alt="<?php echo trt('Settings'); ?>" style="cursor: pointer;"></td>
<td style="padding-left:5px;"><img src="../resources/images/help.png" onclick="showHelpWindow();" alt="<?php echo trt('Help'); ?>" style="cursor: pointer;"></td>
<td style="padding-left:5px;"><img src="../resources/images/exit.png" alt="Выход" title="<?php echo trt('Logout'); ?>" onclick="g_user.Logout();" style="cursor: pointer;"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" style="width:100%;height:100%;overflow:hidden;">
<div id="Tabs2" style="width:100%; height: 100%;"></div>
<div id="cnt_mapdiv" style="width:100%; height:100%; background-color: Gray; overflow: hidden; position: relative;"><div id="mapdiv" style="position: absolute;width:800px; height:800px;"></div></div>
<div id="tab_charts" style="width:100%; height:100%; background-color: #3a3a3a; color: #ffffff;">
<table style="width:100%; height:100%;">
<tr><td><canvas id="canvas"></canvas></td></tr>
</table>
</div>
<script>
var g_tab2=new tcTabs(document.getElementById('Tabs2'));
tb=g_tab2.addTab({caption:trt('Diagrams'),float:'right'});
tb.setConObj(document.getElementById("tab_charts"));
tb=g_tab2.addTab({caption:trt('Map'),float:'right'});
tb.setConObj(document.getElementById("cnt_mapdiv"));
tb.setSel();
var timeFormat = 'DD/MM/YYYY';
var config = {
type: 'line',
data: {
datasets: [
{
label: "Вольт на аккумуляторе",
data: [],
fill: false,
borderColor: 'red'
},
{
label: "Вольт на камерах",
data: [],
fill: false,
borderColor: 'blue'
},
{
label: "Температура °C",
data: [],
fill: false,
borderColor: 'gold'
},
{
label: "Очередь файлов",
data: [],
fill: false,
borderColor: 'magenta'
},
{
label: "Версия ПО",
data: [],
fill: false,
borderColor: 'darkkhaki'
},
{
label: "WIFI точки",
data: [],
fill: false,
borderColor: 'lightsalmon'
},
{
label: "Коды ошибок",
data: [],
fill: false,
borderColor: 'forestgreen'
}
]
},
options: {
responsive: true,
title: {
display: true,
text: "Показания датчиков"
},
scales: {
xAxes: [{
type: "time",
time: {
//format: timeFormat,
//round: 'hour',
tooltipFormat: "YYYY-MM-DD HH:mm:ss",
displayFormats: {
millisecond:'YYYY-MM-DD HH',
second: 'YYYY-MM-DD HH',
minute: 'YYYY-MM-DD HH',
hour: 'YYYY-MM-DD HH',
day: 'YYYY-MM-DD HH',
week: 'YYYY-MM-DD HH',
month: 'YYYY-MM-DD HH',
quarter: 'YYYY-MM-DD HH',
year: 'YYYY-MM-DD HH',
}
},
scaleLabel: {
display: true,
labelString: 'Дата'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Значение'
}
}]
}
}
};
window.onload = function() {
let ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx, config);
};
</script>
<script>
//Так как яндекс карты в другой проекции
proj4.defs('EPSG:3395', '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
ol.proj.get('EPSG:3395').setExtent([-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]);
//Создаю массив cо слоями пользователя
var g_Layouts = new Object();
g_Layouts["OpenStreetMap"] = new ol.source.OSM();
g_Layouts["BingAerial"] = new ol.source.BingMaps({
key: 'AkPePzQAUoC7qKlVTNT4nw0Ykq2EJ4nLE9Iq8-7NZY4wI2Owxebqqur_4zMiboZh',
imagerySet: "AerialWithLabels"
});
g_Layouts["yandex"] = new ol.source.XYZ({
url: 'http://vec0{1-4}.maps.yandex.net/tiles?l=map&x={x}&y={y}&z={z}',
projection: 'EPSG:3395',
tileGrid: ol.tilegrid.createXYZ({
extent: [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]
})
});
g_Layouts["StamenTerrain"] = new ol.source.Stamen({
layer: 'terrain'
});
g_Layouts["GoogleMaps"] = new ol.source.XYZ({
url: '/monitoring/get.php?hl=ru-RU&lyrs=m&x={x}&y={y}&z={z}&s='
});
g_Layouts["GoogleMapsHybrid"] = new ol.source.XYZ({
url: '/monitoring/get.php?hl=en-US&lyrs=y&x={x}&y={y}&z={z}&s='
});
var g_Tile = new ol.layer.Tile({source:g_Layouts["GoogleMapsHybrid"]});
var g_vectorSource = new ol.source.Vector({});
var vectorLayer = new ol.layer.Vector({source: g_vectorSource,zIndex: 100});
var g_vectorSourceGeofences = new ol.source.Vector({}); //Для отображения геозон
var g_vectorSourceRoute = new ol.source.Vector({}); //Для отображения маршрута
var g_vectorSourceDetours = new ol.source.Vector({}); //Для отображения объездов
var g_vectorSourceEdit = new ol.source.Vector({}); //Для редактирования по точкам
//Elements that make up the popup.
var container = document.getElementById('popup');
var content = document.getElementById('popup-content');
var closer = document.getElementById('popup-closer');
// Create an overlay to anchor the popup to the map.
var g_overlay = new ol.Overlay({
element: container,
autoPan: true,
autoPanAnimation: {
duration: 250
}
});
// Add a click handler to hide the popup. @return {boolean} Don't follow the href.
closer.onclick = function() {
g_overlay.setPosition(undefined);
closer.blur();
return false;
};
//var vectorSourceV = new ol.source.Vector({});
//var vectorSourceDel = new ol.source.Vector({});
//var vectorSourceDelV = new ol.source.Vector({});
//var vectorSourceArea = new ol.source.Vector({});
var wms_layer = new ol.layer.Tile({
//source: wms_source
});
//Change substrate layer
function changeMap()
{
var layer="";
var input;
input = document.getElementById('SubstrateID');
if(input!=null) layer=input.value;
g_Tile.setSource(g_Layouts[layer]);
}
//Включаем редактирование
function enableEditPoints(feature)
{
disableEditPoints(); //Удаляю старое
if(feature==null) return;
var coord;
var length;
if(feature.getGeometry().getType()=='LineString')
{
coord=feature.getGeometry().getCoordinates();
}else{
coord=feature.getGeometry().getCoordinates()[0];
}
for(var i=0;i<coord.length;i++)
{
var point = coord[i];
if(!(i==coord.length-1 && feature.getGeometry().getType()!='LineString'))
{
var point = new ol.Feature({geometry: new ol.geom.Point(point)});
point.userType="point"; //Тип точки
point.userState=0; //В данный момент не перемещается
point.userPos=i; //С какой точкой по номеру связан
point.userFeature=feature; //Что редактируем в данный момент
point.setStyle(new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 0.5],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
opacity: 1,
src: '../resources/images/point.png'
}))
}));
g_vectorSourceEdit.addFeature(point);
}
//Создаю + для добавления новой точки
if(i<coord.length-1)
{
var point = [((coord[i+1][0]+coord[i][0])/2),((coord[i+1][1]+coord[i][1])/2)];
var point = new ol.Feature({geometry: new ol.geom.Point(point)});
point.userType="plus"; //Тип точки
point.userState=0; //В данный момент не перемещается
point.userPos=i; //С какой точкой по номеру связан
point.userFeature=feature; //Что редактируем в данный момент
point.setStyle(new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 0.5],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
opacity: 1,
src: '../resources/images/plus.png'
}))
}));
g_vectorSourceEdit.addFeature(point);
}
}
}
//Выключаем редактирование координат
function disableEditPoints()
{
g_vectorSourceEdit.clear();
}
//Сохраняю точки на сервер
function sevePoints(feature)
{
//Завершили редактироание отправляем координаты на сервер
//id записи, тип данных, и сами координаты
var json='{';
json+='"id":'+feature.userData.id+',\n';
json+='"name":"'+feature.userData.constructor.name+'",\n';
json+='"points":"';
var coords;
if(feature.getGeometry().getType()=='LineString')
{
coords=feature.getGeometry().getCoordinates();
}else{
coords=feature.getGeometry().getCoordinates()[0];
}
for(var i=0;i<coords.length;i++)
{
var point = coords[i];
point = ol.proj.transform(point, 'EPSG:3857', 'EPSG:4326');
json+=point[0]+" "+point[1]+",";
}
json=json.substring(0,json.length-1);
json+='"}';
//Отправляем данные на сервер и меняем курсор на ожидание
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);
return;
}
//Востанавливаю курсор
hideProgressBarIco();
}
};
}
}(this);
req.open("POST", '/monitoring/pscripts/points.php?fn=1', true); //Так как
req.setRequestHeader("Content-type", "text/plain");
req.send(json);
//Курсор ожидание со стрелочкой
showProgressBarIco();
}
var projection = ol.proj.get('EPSG:3857');
var projectionExtent = projection.getExtent();
var size = ol.extent.getWidth(projectionExtent) / 256;
var resolutions = new Array(14);
var matrixIds = new Array(14);
for (var z = 0; z < 14; ++z) {
// generate resolutions and matrixIds arrays for this WMTS
resolutions[z] = size / Math.pow(2, z);
matrixIds[z] = z;
}
//Код для создания своей кнопки которая сворачивает левое меню
window.app = {};
var app = window.app;
/**
* @constructor
* @extends {ol.control.Control}
* @param {Object=} opt_options Control options.
*/
app.generateGeoJSONControl = function(opt_options) {
var options = opt_options || {};
var anchor = document.createElement('a');
anchor.href = '#export-geojson';
anchor.innerHTML = 'G';
var this_ = this;
var getGeoJSON = function(e) {
/*e.preventDefault();
var source = options.source;
var format = new ol.format.GeoJSON();
var features = source.getFeatures();
var featuresGeoJSON = format.writeFeatures(features);
download('export.geojson', JSON.stringify(featuresGeoJSON));*/
};
anchor.addEventListener('click', getGeoJSON, false);
anchor.addEventListener('touchstart', getGeoJSON, false);
var element = document.createElement('div');
element.className = 'export-geojson ol-unselectable';
element.appendChild(anchor);
ol.control.Control.call(this, {
element: element,
target: options.target
});
};
ol.inherits(app.generateGeoJSONControl, ol.control.Control);
//var source = new ol.source.GeoJSON();
g_map = new ol.Map({
interactions: ol.interaction.defaults({ doubleClickZoom: false }),
target: 'mapdiv',
controls: ol.control.defaults().extend([
new ol.control.ScaleLine(),
new ol.control.ZoomSlider(),
new ol.control.FullScreen()
]),
layers: [
g_Tile,
wms_layer,
/*new ol.layer.Tile({
opacity: 0.7,
source: new ol.source.WMTS({
attributions: 'Tiles © <a href="https://services.arcgisonline.com/arcgis/rest/' +
'services/Demographics/USA_Population_Density/MapServer/">ArcGIS</a>',
url: 'https://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_Density/MapServer/WMTS/',
layer: '0',
matrixSet: 'EPSG:3857',
format: 'image/png',
projection: projection,
tileGrid: new ol.tilegrid.WMTS({
origin: ol.extent.getTopLeft(projectionExtent),
resolutions: resolutions,
matrixIds: matrixIds
}),
style: 'default',
wrapX: true
})
}),*/
vectorLayer,
new ol.layer.Vector({
source: g_vectorSourceRoute,
zIndex: 50
}),
new ol.layer.Vector({
source: g_vectorSourceDetours,
zIndex: 50
}),
new ol.layer.Vector({
source: g_vectorSourceGeofences,
zIndex: 50
}),
new ol.layer.Vector({
source: g_vectorSourceEdit,
zIndex: 50
})
/*,
new ol.layer.Vector({
source: vectorSourceV,
zIndex: 50
}),*/
/*new ol.layer.Vector({
source: vectorSourceDel,
zIndex: 100
}),*/
/*new ol.layer.Vector({
source: vectorSourceDelV,
zIndex: 50
}),*/
/*new ol.layer.Vector({
source: vectorSourceArea,
zIndex: 50
})*//*,
new ol.layer.Vector({
title: 'added Layer',
source: new ol.source.Vector({
url: 'http://localhost:8081/ASDC/engine/geo_json.jsp?table=countriesregions&id=10',
format: new ol.format.GeoJSON(),
}),
style: new ol.style.Style({
fill: new ol.style.Fill({color: 'rgba(76, 181, 248, 0.2)'}),
stroke: new ol.style.Stroke({color: 'rgba(0, 0, 255, 0.5)', width: 1})
})
})*/
],
view: new ol.View({
center: ol.proj.fromLonLat([44.673221, 43.030350]),
zoom: 4
}),
overlays: [g_overlay]
});
/*var nav = new ol.Control.NavigationHistory();
g_map.addControl(nav);*/
/*
var districtLayer = new ol.layer.Tile({
opacity: 0.7,
source: new ol.source.WMTS({
attributions: 'Tiles © <a href="https://services.arcgisonline.com/arcgis/rest/' +
'services/Demographics/USA_Population_Density/MapServer/">ArcGIS</a>',
url: 'https://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_Density/MapServer/WMTS/',
layer: '0',
matrixSet: 'EPSG:3857',
format: 'image/png',
projection: projection,
tileGrid: new ol.tilegrid.WMTS({
origin: ol.extent.getTopLeft(projectionExtent),
resolutions: resolutions,
matrixIds: matrixIds
}),
style: 'default',
wrapX: true
})
});
g_map.addLayer(districtLayer);
*/
//-------------------------------------------------------------------------------------------------------------
//var popup = new ol.Overlay({element: document.getElementById('popup')});
//g_map.addOverlay(popup);
// display popup on click
g_map.on('singleclick', function(evt){
g_feature=null; //Обнуляем перемещение объекта
var elm=g_map.getTargetElement();
if(elm!=null)
{
var coordinate = evt.coordinate;
//var hdms = ol.coordinate.toStringHDMS(ol.proj.transform( coordinate, 'EPSG:3857', 'EPSG:4326'));
//$(element).popover('destroy');
//popup.setPosition(coordinate);
//$(popup.getElement()).show();
var feature = g_map.forEachFeatureAtPixel(evt.pixel,function(feature) {return feature;});
if(feature)
{
if(feature.userType=="TObject")
{
g_objects.getObjectByID(feature.userID).showDetailedInformation();
//Запрашиваем информацию о объекте и отображаем в отдельном всплывающем окне
/*if(m_winPP!=null) m_winPP.Close();
m_winPP=new TWin();
m_winPP.BuildGUI(pageX-100,pageY-100);
m_winPP.setSize(300,200);
m_winPP.setCaption(feature.get('name'));
m_winPP.showProgressBar();
callObjectData(feature.userID);*/
}else
if(feature.userType=="point")
{
//При первом щёлчке меняем статус на "перемещение"
//console.log('Кликнули на точку');
if(feature.userState!=1)
{
elm.style.cursor = 'move';
feature.userState=1;
g_feature=feature;
}else
{
elm.style.cursor = 'pointer';
feature.userState=0;
sevePoints(feature.userFeature)
enableEditPoints(feature.userFeature); //Обновляю маркеры для редактирования
}
}else if(feature.userType=="plus") //Добавляю новую точку
{
var f=feature.userFeature;
var coords=f.getGeometry().getCoordinates();
if(f.getGeometry().getType()=='LineString')
{
coords = ([]).concat(coords.slice(0,feature.userPos+1),[g_map.getCoordinateFromPixel(evt.pixel)],coords.slice(feature.userPos+1));
}else{
coords[0] = ([]).concat(coords[0].slice(0,feature.userPos+1),[g_map.getCoordinateFromPixel(evt.pixel)],coords[0].slice(feature.userPos+1));
}
f.getGeometry().setCoordinates(coords);
enableEditPoints(f); //Обновляю маркеры для редактирования
sevePoints(f); //Сохраняю точки
}else
if(feature.userType=="TTrackPoint")
{
var coordinate = feature.getGeometry().getCoordinates();
content.innerHTML = feature.userHTML;
g_overlay.setPosition(coordinate);
}
}
}
});
//При двойном щелчке на карте
g_map.on('dblclick', function(evt)
{
//console.log("dblclick");
var feature = g_map.forEachFeatureAtPixel(evt.pixel,function(feature) {return feature;});
if(feature)
{
if(feature.userType=="point") //Удаляю точку при двойном щелчке
{
var f=feature.userFeature;
var coords=f.getGeometry().getCoordinates();
if(f.getGeometry().getType()=='LineString')
{
if(coords.length<=2) {
alert(trt('Points_can_not_be_less_than_two')+'!');
return false;
}
coords = ([]).concat(coords.slice(0,feature.userPos),coords.slice(feature.userPos+1));
}else{
if(coords[0].length<=4) {
alert(trt('Points_can_not_be_less_than_three')+'!');
return false;
}
coords[0] = ([]).concat(coords[0].slice(0,feature.userPos),coords[0].slice(feature.userPos+1));
}
f.getGeometry().setCoordinates(coords);
enableEditPoints(f); //Обновляю маркеры для редактирования
sevePoints(f); //Сохраняю точки
}
}
});
//При нажатии на карту
/*g_map.on('mousedown', function(evt)
{
console.log("mousedown");
});*/
// Меняем вид курсора когда он над иконкой объекта
g_map.on('pointermove', function(evt)
{
var elm=g_map.getTargetElement();
if(elm!=null)
{
var feature = g_map.forEachFeatureAtPixel(evt.pixel,function(feature) {return feature;});
if (feature)
{
//console.log('feature.userType='+feature.userType);
if(feature.userType=="TObject" || feature.userType=="TTrackPoint")
{
elm.style.cursor = 'pointer';
}else
if(feature.userType=="point")
{
elm.style.cursor = 'pointer';
if(feature.userState==1) //Если в режиме перемещёния
{
elm.style.cursor = 'move';
var coord = g_map.getCoordinateFromPixel(evt.pixel);
elm.style.cursor = 'move';
feature.getGeometry().setCoordinates(coord);
//console.log(coord);
//Обновляю коордионаты в геозоне
var f=feature.userFeature;
var coords=f.getGeometry().getCoordinates();
if(f.getGeometry().getType()=='LineString')
{
coords[feature.userPos]=coord;
}else{
//Если это первая точка то нужно двигать и последнюю так как область должна быть закрытой
if(feature.userPos==0){
coords[0][feature.userPos]=coord;
coords[0][coords[0].length-1]=coord;
}else{
coords[0][feature.userPos]=coord;
}
}
f.getGeometry().setCoordinates(coords);
}
//elm.style.cursor = 'progress';
}else if(feature.userType=="plus")
{
elm.style.cursor = 'pointer';
}else
{
elm.style.cursor = '';
}
}else
{ elm.style.cursor = '';
}
}
if(g_feature!=null)
{
var coord = g_map.getCoordinateFromPixel(evt.pixel);
g_feature.getGeometry().setCoordinates(coord);
}
});
var g_routes = new TRoutes(g_map);
var g_detours = new TDetours(g_map);
var g_geofences = new TGeofences(g_map);
var g_objects = new TObjects(g_map);
var g_events = new TEvents(g_map);
var g_trips = new TTrips();
function updateSize()
{
//Сдвоеное Split окно расположено в ячейки таблицы
/*tSplit=document.getElementById('tSplit'); //Ячейка таблицы td
dSplit=document.getElementById('dSplit'); //Контейнер сплита div
if(tSplit!=null && dSplit!=null)
{
dSplit.style.width = (tSplit.offsetWidth-2)+"px";
dSplit.style.height = (tSplit.offsetHeight-2)+"px";
}*/
//Таб мониторинга
var cdiv=null; //Контейнер
var tdiv=null; //Сам объект для задания размера
//Таб администрирования (при изменении размеров окна и при перемещении Split)
var tab_admin=document.getElementById('tab_admin');
tab_admin.style.height = (g_tab1.ctt.offsetHeight)+"px";
tab_admin.style.width = (g_tab1.ctt.offsetWidth)+"px";
//Изменяю высоту DIV в зависемости от родителя для полос прокрутки
cdiv=document.getElementById('div_tbl0');
tdiv=document.getElementById('div_tbl_trips');
tdiv.style.height = (cdiv.offsetHeight)+"px";
tdiv.style.width = (cdiv.offsetWidth)+"px";
//Изменяю высоту DIV в зависемости от родителя для полос прокрутки во вкладке события
cdiv=document.getElementById('div_tbl_e_c');
tdiv=document.getElementById('div_tbl_e');
tdiv.style.height = (cdiv.offsetHeight)+"px";
tdiv.style.width = (cdiv.offsetWidth)+"px";
//Регулирую высоту карты так как она не правильно работает если задать 100%
cdiv=document.getElementById('cnt_mapdiv');
tdiv=document.getElementById('mapdiv');
tdiv.style.height = (cdiv.offsetHeight)+"px";
tdiv.style.width = (cdiv.offsetWidth)+"px";
//Изменяю высоту DIV для мониторинга в зависемости от родителя
cdiv=document.getElementById('div_tbl_monitoring_c');
tdiv=document.getElementById('div_tbl_monitoring');
tdiv.style.height = (cdiv.offsetHeight)+"px";
tdiv.style.width = (cdiv.offsetWidth)+"px";
//<div id="div_tbl_monitoring_c" style="width:100%;height:100%; position: relative;overflow:hidden;">
//<div id="div_tbl_monitoring" style="position: absolute; width:100%; height:100%; padding:3px; overflow:scroll;"></div>
}
/*window.onresize = function()
{
setTimeout( function()
{
updateSize();
if(g_map!=null) g_map.updateSize();
}, 100);
}
onresize();*/
//начать повторы с интервалом
var timerId = setInterval(function() {
updateSize();
if(g_map!=null) g_map.updateSize();
}, 500);
onLoadPage();
</script>
</td>
<!-- Меню -->
<td valign="top" style="min-width:650px;width:650px;height:100%;border-right: 1px solid black;">
<div id="Tabs1" style="width:100%; height: 100%;"></div>
<div id="tab_monitoring" style="width:100%; height:100%; background-color: #3a3a3a; color: #ffffff;">
<table style="width:100%; height:100%;" border="0">
<tr style="height:1%;">
<td>
<div style="position: relative; padding-top:2px; padding-left:2px; padding-right:2px; padding-bottom:5px;">
<table id="FrmLocustData" style="border: 0px solid rgb(99, 99, 99); table-layout: auto; width:100%; padding: 10px;" cellspacing="2" cellpadding="0">
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Named'); ?></td>
<td style="padding: 1px; width: 100%;"><input type="text" id="cnumber_m" maxlength="100" style="width: 100%;"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0">
<tr>
<td style="padding: 1px; white-space: nowrap;" width="1%"></td>
<td style="padding: 1px;" align="right"><button class="button-secondary" onclick="g_objects.filtering();"><img src="/resources/images/find.svg" width="16" height="16" alt="" style="vertical-align: middle"><?php echo trt('Filtering'); ?></button></td>
</tr>
</table>
<td>
</tr>
</table>
</div>
</td>
</tr>
<tr style="height:100%;">
<td style="height:100%;">
<div id="div_tbl_monitoring_c" style="width:100%;height:100%; position: relative;overflow:hidden;">
<div id="div_tbl_monitoring" style="position: absolute; width:100%; height:100%; padding:3px; overflow:scroll;"></div>
</div>
</td>
</tr>
<tr>
<td valign="middle" style="height:21px;text-align:right;padding-right:30px;">
<?php echo trt('Number_of_records'); ?>: <div id="count_m" style="display:inline;">0</div><br>
</td>
</tr>
</table>
</div>
<!-- Геозоны -->
<div id="tab_geofences" style="width:100%; height:100%; background-color: #3a3a3a; color: #ffffff;">
<table style="width:100%; height:100%;" border="0">
<tr style="height:1%;">
<td>
<div style="position: relative; padding-top:2px; padding-left:2px; padding-right:2px; padding-bottom:5px;">
<table id="id1_geofences" style="border: 0px solid rgb(99, 99, 99); table-layout: auto; width:100%; padding: 10px;" cellspacing="2" cellpadding="0">
<tr>
<td style="padding: 1px; white-space: nowrap;">Тип геозоны</td>
<td style="padding: 1px; width: 100%;">
<select style="width: 100%;" id="geofence_type_id_id0">
<option selected="selected" value=""></option>
<?php
$sql='select id,main.trt('.$_SESSION['USER_ID'].',name) from main.geofences_types where del=false order by name,id';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_NUM))
{
echo "<option value=\"$row[0]\">$row[1]</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Named');?></td>
<td style="padding: 1px; width: 100%;"><input type="text" id="filter_name_geofences" maxlength="100" style="width: 100%;"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0">
<tr>
<td style="padding: 1px; white-space: nowrap;" width="1%"><button class="button-secondary" onclick="g_geofences.createDetour();"><img src="/resources/images/rplus16.png" alt="" style="vertical-align: middle"> <?php echo trt('Create_geofence'); ?></button></td>
<td style="padding: 1px;" align="right"><button class="button-secondary" onclick="g_geofences.filtering();"><img src="/resources/images/find.svg" width="16" height="16" alt="" style="vertical-align: middle"><?php echo trt('Filtering'); ?></button></td>
</tr>
</table>
<td>
</tr>
</table>
</div>
</td>
</tr>
<tr style="height:100%;">
<td style="height:100%;">
<div id="id4_geofences" style="width:100%;height:100%;position:relative;overflow:hidden;">
<div style="position: absolute; width:100%; height:100%; padding:3px; overflow:scroll;" id="id5_geofences"></div>
</div>
</td>
</tr>
<tr>
<td valign="middle" style="height:21px;text-align:right;padding-right:30px;">
<?php echo trt('Number_of_records'); ?>: <div id="count_geofences" style="display:inline;">0</div><br>
</td>
</tr>
</table>
</div>
<div id="tab_flights" style="width:100%; height:100%; background-color: #3a3a3a; color: #ffffff;">
<table style="width:100%; height:100%;" border="0"><tr style="height:1%;"><td>
<div style="position: relative; padding-top:2px; padding-left:2px; padding-right:2px; padding-bottom:5px;">
<table id="FrmLocustData" style="border: 0px solid rgb(99, 99, 99); table-layout: auto; width:100%; padding: 10px;" cellspacing="2" cellpadding="0">
<thead></thead>
<tbody>
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Route'); ?></td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="trip_route_id">
<option selected="selected" value=""></option>
<?php
$sql='select r.id,r.name from main.routes r where r.del=false order by name;';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
}
?>
</select></td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Carrier'); ?></td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="trip_carrier_id">
<option selected="selected" value=""></option>
<?php
$sql='select c.id,c.name from main.companies c where c.del=false and c.id in
(select
rc.company_id
from
main.routes_companies rc
join main.companies c on rc.company_id=c.id
where
c.del=false
and rc.del=false
and c.company_type_id=1
and rc.route_id in (select route_id from main.routes_companies where company_id='.$_SESSION['COMPANY_ID'].' )
union
select company_id from main.trips_schedules where route_id in (select route_id from main.routes_companies where company_id='.$_SESSION['COMPANY_ID'].'))
order by name;';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
}
?>
</select></td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Bus_station'); ?></td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="trip_company_id">
<option selected="selected" value=""></option>
<?php
$sql='select
*
from
main.companies c
where
c.del=false
and c.company_type_id=2
order by name;';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
}
?>
</select></td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;">Статус рейса</td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="trip_status"><option value=""></option><option selected="selected" value="1">Активный</option><option value="0">Завершенный</option></select></td>
</tr>
<!--tr>
<td style="padding: 1px; white-space: nowrap;">Гос. номер</td>
<td style="padding: 1px; width: 100%;"><input type="text" id="cnumber" maxlength="100" style="width: 100%;"></td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;">Начало рейса </td>
<td style="padding: 1px; width: 100%;">
<table width="100%" border="0">
<tr>
<td style="padding: 1px;">c</td>
<td style="padding: 1px;">
<table style="width: 100%; table-layout: fixed; border-spacing: 0px; border-collapse: collapse;" border="0">
<tr>
<td style="width: 100%;"><input style="width: 100%;" name="date_start" value="" id="filter_X1_date_start4" type="text"></td>
<td style="width: 25px;"><img id="filter_X1_date_start_trigger4" src="../resources/images/datepicker.jpg" style="margin-left: 1px; cursor: pointer;"></td>
</tr>
</table>
</td>
<td style="padding: 1px; white-space: nowrap;" width="1%">по</td>
<td style="padding: 1px;">
<table style="width: 100%; table-layout: fixed; border-spacing: 0px; border-collapse: collapse;" border="0">
<tr>
<td style="width: 100%;"><input style="width: 100%;" name="date_end" value="" id="filter_X1_date_end5" type="text"></td>
<td style="width: 25px;"><img id="filter_X1_date_end_trigger5" src="../resources/images/datepicker.jpg" style="cursor: pointer; margin-left: 1px;"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;">Завершение рейса, </td>
<td style="padding: 1px; width: 100%;">
<table width="100%" border="0">
<tr>
<td style="padding: 1px;">c</td>
<td style="padding: 1px;">
<table style="width: 100%; table-layout: fixed; border-spacing: 0px; border-collapse: collapse;" border="0">
<tr>
<td style="width: 100%;"><input style="width: 100%;" name="date_start" value="" id="filter_X1_date_start111" type="text"></td>
<td style="width: 25px;"><img id="filter_X1_date_start_trigger111" src="../resources/images/datepicker.jpg" style="margin-left: 1px; cursor: pointer;"></td>
</tr>
</table>
</td>
<td style="padding: 1px; white-space: nowrap;" width="1%">по</td>
<td style="padding: 1px;">
<table style="width: 100%; table-layout: fixed; border-spacing: 0px; border-collapse: collapse;" border="0">
<tr>
<td style="width: 100%;"><input style="width: 100%;" name="date_end" value="" id="filter_X1_date_end222" type="text"></td>
<td style="width: 25px;"><img id="filter_X1_date_end_trigger222" src="../resources/images/datepicker.jpg" style="cursor: pointer; margin-left: 1px;"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr-->
<!--tr>
<td style="padding: 1px; white-space: nowrap;">Дата активности, </td>
<td style="padding: 1px; width: 100%;">
<table width="100%" border="0">
<tr>
<td style="padding: 1px;">c</td>
<td style="padding: 1px;">
<table style="width: 100%; table-layout: fixed; border-spacing: 0px; border-collapse: collapse;" border="0">
<tr>
<td style="width: 100%;"><input style="width: 100%;" name="date_start" value="" id="filter_X1_date_start" type="text"></td>
<td style="width: 25px;"><img id="filter_X1_date_start_trigger3" src="../resources/images/datepicker.jpg" style="margin-left: 1px; cursor: pointer;"></td>
</tr>
</table>
</td>
<td style="padding: 1px; white-space: nowrap;" width="1%">по</td>
<td style="padding: 1px;">
<table style="width: 100%; table-layout: fixed; border-spacing: 0px; border-collapse: collapse;" border="0">
<tr>
<td style="width: 100%;"><input style="width: 100%;" name="date_end" value="" id="filter_X1_date_end" type="text"></td>
<td style="width: 25px;"><img id="filter_X1_date_end_trigger" src="../resources/images/datepicker.jpg" style="cursor: pointer; margin-left: 1px;"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr-->
<!--tr>
<td style="padding: 1px; white-space: nowrap;">Тип рейса</td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="active"><option selected="selected" value=""></option></select></td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;">Перевозчик рейса</td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="active"><option selected="selected" value=""></option></select></td>
</tr-->
<tr>
<td colspan="2">
<table width="100%" border="0">
<tr>
<td style="padding: 1px; white-space: nowrap;" width="1%"><button class="button-secondary" onclick="g_trips.createTrip();"><img src="/resources/images/rplus16.png" alt="" style="vertical-align: middle"> <?php echo trt('Create').' '.trt('trip'); ?></button></td>
<td style="padding: 1px;" align="right">
<button class="button-secondary" onclick="g_trips.filtering();"><img src="/resources/images/find.svg" width="16" height="16" alt="" style="vertical-align: middle"><?php echo trt('Filtering'); ?></button>
</td>
</tr>
</table>
<td>
</tr>
</tbody>
</table>
</div>
</td></tr><tr style="height:100%;"><td style="height:100%;">
<div id="div_tbl0" style="width:100%;height:100%; position: relative;overflow:hidden;">
<div id="div_tbl_trips" style="position: absolute; width:100%; height:100%; padding:3px; overflow:scroll; "></div>
</div></td></tr>
<tr>
<td valign="middle" style="height:21px;text-align:right;padding-right:30px;">
<?php echo trt('Number_of_records'); ?>: <div id="count_trips" style="display:inline;">0</div><br>
</td>
</tr>
</table>
</div>
<script>
var lng = "<?php echo $_SESSION["LNG"]; ?>";
var field=document.getElementById("lang");
if(field!=null)
{ field.value=lng;
}
var country_id="5";
var field=document.getElementById("filter_X1_country_id");
if(field!=null) field.value=country_id;
/*var d = new Date();
d.setDate(d.getDate()-90);
var field=document.getElementById("filter_X1_date_start");
if(field!=null) field.value=d.toString();
var field=document.getElementById("filter_X1_date_end");
if(field!=null) field.value=(new Date).toString();*/
setCalendar('filter_X1_date_start4','filter_X1_date_start_trigger4');
setCalendar('filter_X1_date_end5','filter_X1_date_end_trigger5');
setCalendar('filter_X1_date_start111','filter_X1_date_start_trigger111');
setCalendar('filter_X1_date_end222','filter_X1_date_end_trigger222');
</script>
<div id="tab_events" style="width:100%; height:100%; background-color: #3a3a3a; color: #ffffff;">
<table style="width:100%; height:100%;" border="0">
<tr style="height:1%;">
<td>
<div style="position: relative; padding-top:2px; padding-left:2px; padding-right:2px; padding-bottom:5px;">
<table id="FrmLocustData" style="border: 0px solid rgb(99, 99, 99); table-layout: auto; width:100%; padding: 10px;" cellspacing="2" cellpadding="0">
<?php
//Если это перевозчик то может видеть только себя
if(!getAccess('Carrier'))
{
?>
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Company'); ?></td>
<td style="padding: 1px; width: 100%;">
<select style="width: 100%;" id="company_id_route">
<option selected="selected" value=""></option>
<?php
//
$sql='select id,name,coalesce((select count(*) from main.routes_companies where del=false and company_id=c.id),0)+coalesce((select count(*) from main.trips_schedules where del=false and company_id=c.id group by route_id),0) as count from main.companies c where del=false;';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
if($_SESSION['COMPANY_ID']==$row['id'])
{
echo '<option value="'.$row['id'].'" selected="selected">'.$row['name'].' ('.$row['count'].')</option>';
}else
{
echo '<option value="'.$row['id'].'">'.$row['name'].' ('.$row['count'].')</option>';
}
}
}
?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Named');?></td>
<td style="padding: 1px; width: 100%;"><input type="text" id="cnumber_e" maxlength="100" style="width: 100%;"></td>
</tr>
<tr>
<td style="padding: 1px; white-space: nowrap;">Тип маршрута</td>
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="active_e"><option selected="selected" value="">Все</option></select></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0">
<tr>
<td style="padding: 1px; white-space: nowrap;" width="1%"><button class="button-secondary" onclick="g_routes.createRoute();"><img src="/resources/images/rplus16.png" alt="" style="vertical-align: middle"> <?php echo trt('Create').' '.trt('route'); ?></button></td>
<td style="padding: 1px;" align="right"><button class="button-secondary" onclick="g_routes.filtering();"><img src="/resources/images/find.svg" width="16" height="16" alt="" style="vertical-align: middle"><?php echo trt('Filtering'); ?></button></td>
</tr>
</table>
<td>
</tr>
</table>
</div>
</td>
</tr>
<tr style="height:100%;">
<td style="height:100%;">
<div id="div_tbl_e_c" style="width:100%;height:100%; position: relative;overflow:hidden;">
<div style="position: absolute; width:100%; height:100%; padding:3px; overflow:scroll;" id="div_tbl_e"></div>
</div>
</td>
</tr>
<tr>
<td valign="middle" style="height:21px;text-align:right;padding-right:30px;">
<?php echo trt('Number_of_records'); ?>: <div id="count_e" style="display:inline;">0</div><br>
</td>
</tr>
</table>
</div>
<script>
var d = new Date();
d.setDate(d.getDate()-1);
var field=document.getElementById("filter_X1_date_start_e");
if(field!=null) field.value=d.toString();
setCalendar('filter_X1_date_start_e','filter_X1_date_start_trigger_e');
setCalendar('filter_X1_date_end_e','filter_X1_date_end_trigger_e');
</script>
<!-- объезды -->
<div id="tab_detours" style="width:100%; height:100%; background-color: #3a3a3a; color: #ffffff;">
<table style="width:100%; height:100%;" border="0">
<tr style="height:1%;">
<td>
<div style="position: relative; padding-top:2px; padding-left:2px; padding-right:2px; padding-bottom:5px;">
<table id="id1_detours" style="border: 0px solid rgb(99, 99, 99); table-layout: auto; width:100%; padding: 10px;" cellspacing="2" cellpadding="0">
<tr>
<td style="padding: 1px; white-space: nowrap;"><?php echo trt('Named');?></td>
<td style="padding: 1px; width: 100%;"><input type="text" id="filter_name_detours" maxlength="100" style="width: 100%;"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0">
<tr>
<td style="padding: 1px; white-space: nowrap;" width="1%"><button class="button-secondary" onclick="g_detours.createDetour();"><img src="/resources/images/rplus16.png" alt="" style="vertical-align: middle"> <?php echo trt('Create').' '.trt('detour'); ?></button></td>
<td style="padding: 1px;" align="right"><button class="button-secondary" onclick="g_detours.filtering();"><img src="/resources/images/find.svg" width="16" height="16" alt="" style="vertical-align: middle"><?php echo trt('Filtering'); ?></button></td>
</tr>
</table>
<td>
</tr>
</table>
</div>
</td>
</tr>
<tr style="height:100%;">
<td style="height:100%;">
<div id="id4_detours" style="width:100%;height:100%;position:relative;overflow:hidden;">
<div style="position: absolute; width:100%; height:100%; padding:3px; overflow:scroll;" id="id5_detours"></div>
</div>
</td>
</tr>
<tr>
<td valign="middle" style="height:21px;text-align:right;padding-right:30px;">
<?php echo trt('Number_of_records'); ?>: <div id="count_detours" style="display:inline;">0</div><br>
</td>
</tr>
</table>
</div>
<div id="tab_reports" style="width:100%; height:100%;"><div style="padding: 3px; height:100%; background-color: #3a3a3a; color: #ffffff;">
<button class="button-secondary" style="width:100%;" onclick="myFunction('ReportRoutesRegister','')">Реестр регулярных международных автобусных маршрутов</button><br>
</div></div>
<div id="tab_admin" style="position: absolute; width:100px; height:100px; padding:3px; overflow:scroll; background-color: #3a3a3a; color: #ffffff;">
<div id="lblDevices"><?php echo trt("Devices"); ?></div>
<button class="button-secondary" id="btnTerminals" style="width:100%;margin:1px;" onclick="myFunction('Terminals','')"><?php echo trt("Terminals"); ?></button>
<button class="button-secondary" id="btnTerminalsModels" style="width:100%;margin:1px;" onclick="myFunction('TerminalsModels','')"><?php echo trt("Models_of_terminals"); ?></button>
<button class="button-secondary" id="btnSensorsTypes" style="width:100%;margin:1px;" onclick="myFunction('SensorsTypes','')"><?php echo trt("Models_of_sensors"); ?></button>
<button class="button-secondary" id="btnTerminalsModelsSettings" style="width:100%;margin:1px;" onclick="myFunction('TerminalsModelsSettings','')"><?php echo trt("Models_of_terminals_settings"); ?></button>
<div id="lblObjects"><?php echo trt("Objects"); ?></div>
<!--button class="button-secondary" id="btnObjectsGroups" style="width:100%;margin:1px;" onclick="myFunction('ObjectsGroups','')"><?php echo trt("Groups_of_objects"); ?></button-->
<button class="button-secondary" id="btnObjects" style="width:100%;margin:1px;" onclick="myFunction('Objects','')"><?php echo trt("Objects_of_observation"); ?></button>
<button class="button-secondary" id="btnObjectsBrands" style="width:100%;margin:1px;" onclick="myFunction('ObjectsBrands','')"><?php echo trt("Brands_of_objects"); ?></button>
<!--button class="button-secondary" id="btnGeoFences" style="width:100%;margin:1px;" onclick="myFunction('GeoFences','')"><?php echo trt("Geofences"); ?></button-->
<!--button class="button-secondary" id="btnObjectsReadings" style="width:100%;margin:1px;" onclick="myFunction('ObjectsReadings','')"><?php echo trt("Sensor_values"); ?></button-->
<button class="button-secondary" id="btnRoutesCompanies" style="width:100%;margin:1px;" onclick="myFunction('RoutesCompanies','')"><?php echo trt("Routes").' -> '.trt("Companies"); ?></button>
<button class="button-secondary" id="btnTrips" style="width:100%;margin:1px;" onclick="myFunction('Trips','')"><?php echo trt("Trips"); ?></button>
<button class="button-secondary" id="btnTripsTypes" style="width:100%;margin:1px;" onclick="myFunction('TripsTypes','')"><?php echo trt("Types_of_trips"); ?></button>
<button class="button-secondary" id="btnTripsSchedules" style="width:100%;margin:1px;" onclick="myFunction('TripsSchedules','')"><?php echo trt("Schedules_of_trips"); ?></button>
<div id="lblObjects"><?php echo trt("Routes"); ?></div>
<button class="button-secondary" id="btnRoutes" style="width:100%;margin:1px;" onclick="myFunction('Routes','')"><?php echo trt("Routes"); ?></button>
<button class="button-secondary" id="btnRoutes" style="width:100%;margin:1px;" onclick="myFunction('RoutesCheckpoints','')"><?php echo trt("Checkpoints_of_routes"); ?></button>
<button class="button-secondary" id="btnDetours" style="width:100%;margin:1px;" onclick="myFunction('Detours','')"><?php echo trt("Detours"); ?></button>
<div id="lblMessages"><?php echo trt("Messages"); ?></div>
<button class="button-secondary" id="btnMessages" style="width:100%;margin:1px;" onclick="myFunction('Messages','')"><?php echo trt("Messages"); ?></button>
<!--button class="button-secondary" id="btnMessagesTypes" style="width:100%;margin:1px;" onclick="myFunction('MessagesTypes','')"><?php echo trt("Types_of_messages"); ?></button-->
<button class="button-secondary" id="btnMessagesUsers" style="width:100%;margin:1px;" onclick="myFunction('MessagesUsers','')"><?php echo trt("Messages_users"); ?></button>
<!--button class="button-secondary" id="btnObjectsSensorsLimits" style="width:100%;margin:1px;" onclick="myFunction('ObjectsSensorsLimits','')"><?php echo trt("The_boundary_values_of_the_sensors"); ?></button-->
<!--button class="button-secondary" id="btnObjectsGeoFences" style="width:100%;margin:1px;" onclick="myFunction('ObjectsGeoFences','')"><?php echo trt("Boundary_values_geozones"); ?></button-->
<button class="button-secondary" id="btnSensorsValues" style="width:100%;margin:1px;" onclick="myFunction('SensorsValues','')"><?php echo trt("Sensors_values"); ?></button>
<button class="button-secondary" id="btnObjectsLocations" style="width:100%;margin:1px;" onclick="myFunction('TerminalsLocations','')"><?php echo trt("Locations"); ?></button>
<div id="lblCompanies"><?php echo trt("Companies"); ?></div>
<button class="button-secondary" id="btnCompanies" style="width:100%;margin:1px;" onclick="myFunction('Companies','')"><?php echo trt("Companies"); ?></button>
<button class="button-secondary" id="btnCompaniesTypes" style="width:100%;margin:1px;" onclick="myFunction('CompaniesTypes','')"><?php echo trt("Types_of_companies"); ?></button>
<div id="lblAdministration"><?php echo trt("Administration"); ?></div>
<button class="button-secondary" id="btnActions" style="width:100%;margin:1px;" onclick="myFunction('_Actions','')"><?php echo trt("Actions"); ?></button>
<button class="button-secondary" id="btnAccess" style="width:100%;margin:1px;" onclick="myFunction('_Access','')"><?php echo trt("Access"); ?></button>
<button class="button-secondary" id="btnGroups" style="width:100%;margin:1px;" onclick="myFunction('_Groups','')"><?php echo trt("Access_role"); ?></button>
<button class="button-secondary" id="btnUsers" style="width:100%;margin:1px;" onclick="myFunction('_Users','')"><?php echo trt("Users"); ?></button>
<button class="button-secondary" id="btnHistory" style="width:100%;margin:1px;" onclick="myFunction('_History','')"><?php echo trt("History"); ?></button>
<button class="button-secondary" id="btnMetadata" style="width:100%;margin:1px;" onclick="myFunction('_Metadata','')"><?php echo trt("Metadata"); ?></button>
<div id="lblLanguage"><?php echo trt("Language"); ?></div>
<button class="button-secondary" id="btnLanguage" style="width:100%;margin:1px;" onclick="myFunction('_Languages','')"><?php echo trt("Language"); ?></button>
<button class="button-secondary" id="btnTranslation" style="width:100%;margin:1px;" onclick="myFunction('_Translations','')"><?php echo trt("Translation"); ?></button>
<div id="lblOther"><?php echo trt("Language"); ?></div>
<button class="button-secondary" id="btnIcons" style="width:100%;margin:1px;" onclick="myFunction('Icons','')"><?php echo trt("Icons"); ?></button>
</div>
<script>
var g_tab1=new tcTabs(document.getElementById('Tabs1'));
var g_tb_monitoring=g_tab1.addTab({caption:trt('Monitoring')});
g_tb_monitoring.setConObj(document.getElementById("tab_monitoring"));
g_tb_monitoring.setSel();
var g_tb_monitoring=g_tab1.addTab({caption:trt('Geofences')});
g_tb_monitoring.setConObj(document.getElementById("tab_geofences"));
tb=g_tab1.addTab({caption:trt('Trips')});
tb.setConObj(document.getElementById("tab_flights"));
tb=g_tab1.addTab({caption:trt('Routes')});
tb.setConObj(document.getElementById("tab_events"));
tb=g_tab1.addTab({caption:trt('Detours')});
tb.setConObj(document.getElementById("tab_detours"));
tb=g_tab1.addTab({caption:trt('Reports')});
tb.setConObj(document.getElementById("tab_reports"));
tb=g_tab1.addTab({caption:trt('Administration')});
tb.setConObj(document.getElementById("tab_admin"));
</script>
</td>
</tr>
</table>
</body>
</html>