Старт

This commit is contained in:
2023-11-07 19:51:49 +06:00
commit 86542a157f
5002 changed files with 199551 additions and 0 deletions

View File

@ -0,0 +1,94 @@
<?php
//Вернуть данные о объекте в виде HTML
@session_start();
if(isset($_GET["object_id"])){
$object_id=$_GET["object_id"];
}else{
echo "Not set ID";
exit;
}
require_once("../config.php");
require_once("../../resources/metadata/include/tools.php");
$db=connectToDB();
//$db->exec('SET NAMES utf8');
//$db->exec("SET time_zone = '+00:00'");
//Номер пломбы
$sql = '
SELECT
o.id,
COALESCE(o.name,\'\') as name,
c.name as company_name,
COALESCE(t.serial,\'\') || \' (\' || t.imei || \')\' as terminal_name
from
main.objects o
left join main.companies_objects co on co.object_id=o.id and co.del=false
left join main.companies c on c.id=co.company_id and c.del=false
left join main.terminals t on t.id=o.terminal_id and t.del=false
where
o.del=false
and o.id='.$object_id;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{ echo $e->getMessage();
$res = null;
}
$html='';
while ($row = $res->fetch(PDO::FETCH_ASSOC))
{
$html.='<table border="1" cellpadding="7" style="width:100%;">';
$html.='<tr><td style="font-weight: bold;white-space: nowrap;vertical-align:top;padding-right:4px;">Гос. номер:</td><td colspan="3">'.$row['name'].'</td></tr>';
if($row['company_name']!=''){
$html.='<tr><td style="font-weight: bold;white-space: nowrap;padding-right:4px;">Наименование перевозчика:</td><td colspan="3">'.$row['company_name'].'</td></tr>';
}
if($row['terminal_name']!=''){
$html.='<tr><td style="font-weight: bold;white-space: nowrap;padding-right:4px;">Терминал:</td><td colspan="3">'.$row['terminal_name'].'</td></tr>';
}
//выбираю показания всех датчиков для данного объекта (установки)
$sql="
select
obr.id,
obs.name,
round(obr.value::numeric,2) as value,
to_char(obr.date+(select timezone from main._users where id=".$_SESSION['USER_ID']."), 'yyyy.mm.dd HH24:MI:SS') as date,
obs.sensor_type_id,
trst.measurement as terminalsensortype_name
from
main.objects_sensors obs
left join main.sensors_values obr on obr.id=obs.sensor_value_id
left join main.terminals_sensors trs on trs.id=obs.terminal_sensor_id
left join main.sensors_types trst on trst.id=trs.sensor_type_id
where
obs.del=false
--and obs.sensor_type_id in (1,16,17)
and obs.object_id=".$row['id']."
order by obs.name";
try
{
$res2 = $db->query($sql);
}catch (Exception $e)
{ echo $e->getMessage();
$res2 = null;
}
while ($row2 = $res2->fetch(PDO::FETCH_ASSOC))
{
$html.='<tr><td style="font-weight: bold;white-space: nowrap;padding-right:4px;">'.trt($row2['name']).':</td><td>'.$row2['value'].'</td><td>'.$row2['terminalsensortype_name'].'</td><td>'.$row2['date'].'</td></tr>';
}
$html.='</table>';
}
header('Content-Type: text/html');
echo $html;