<?php
require("../../inc/lib.inc");
//This script file is executed when login in the ems
//get the alarm number of the five alarm level
if (!session_id()) session_start();

if (isset($_SESSION["userInfo"])) {
    if (!isset($userInfo)) $userInfo = $_SESSION["userInfo"];
    $selectedLanguage = $userInfo['language'];
    $language = $userInfo['language'];
    $userName = $userInfo['ID'];
    $userPwd = $userInfo['PWD'];
    $userIp = $userInfo['IP'];
    $session_id = session_id();
    $login_time = date('Y-m-d H:i:s', $userInfo['refresh_time']);
}
$dbName = 'OMC_PUB';
$defTable = 'sysAlarmConf';
$logTable = 'sysAlarmLog';
$showSql = " SELECT  t2.alarmLevel,count(*) as number
			FROM $logTable as t1,$defTable as t2
			WHERE t1.clearTime = '0000-00-00 00:00:00' 
				AND t1.sysTypeNo = t2.sysTypeNo 
				AND t1.compCode  = t2.compCode 
				AND t1.alarmCode = t2.alarmCode
			GROUP BY t2.alarmLevel
		";

if (0) echo "<br>showSql=$showSql";
$result=@mysqli_query($pubConn,$showSql);
echo mysqli_error($pubConn);
global $alarmNumArr;
while ($rows = @mysqli_fetch_array($result)) {
    $alarmNumArr[$rows['alarmLevel']]['number'] = $rows['number'];
}
//echo "alarmNumArr=$alarmNumArr<br>";
// echo "<pre>";
// echo print_r($alarmNumArr);
// echo "</pre>";

for ($i = 1; $i <= 5; $i++) {
    if (trim($alarmNumArr[$i]['number']) == "")
        $alarmNumArr[$i]['number'] = 0;
}
$retureValue = $alarmNumArr[1]['number'] . "_" . $alarmNumArr[2]['number'] . "_" . $alarmNumArr[3]['number'] . "_" . $alarmNumArr[4]['number'] . "_" . $alarmNumArr[5]['number'];
echo "$retureValue";  ///is should
?>

