src.dualinventive.com/mtinfo/dist/webroot/rc-4.05/scripts/page/menu_rt.php

393 lines
24 KiB
PHP

<?php
/** \file scripts\page\menu_rt.php
* \brief DI webinterface menu realtime-status script.
* \author Rob Schalken, Core|Vision
* \version $Revision: 26247 $
* \date $Date: 2016-02-29 10:40:22 +0100 (Mon, 29 Feb 2016) $
*
* This file contains the menu realtime status script. This file contains the realtime
* status of the different ZKLs.
*/
//== Required settings ======================
if (is_valid_action("lance_rt")) {
$_PAGE_INFO['page_title'] = _("realtime status menu");
$_SESSION[$_PAGE_INFO['id']]['title'] = _("Realtime status");
if (isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
$_PAGE_INFO['shortcut_menu_buttons']= array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Realtime status"), _("Use equipment"), _("Project report"), _("GPS track"));
$_PAGE_INFO['shortcut_menu_links'] = array("page/project", "page/menu&page_project=" . $_GET['page_project'], "", "page/menu_lance_use&action=lance_use&page_project=" . $_GET['page_project'], "page/menu_report_info&action=project_report&page_project=" . $_GET['page_project'], "page/menu_report_info&action=gps_report&page_project=" . $_GET['page_project']);
$_PAGE_INFO['shortcut_menu_rights'] = array("", "", "", "menu:lans", "menu:rapportages&menu:rapportages:projecten,menu:rapportages:root", "menu:rapportages&menu:rapportages:gps,menu:rapportages:root");
}
else if (isset($_GET['project_rt_shortcut'])) {
$_PAGE_INFO['history_menu_buttons'] = array(_("Project overview"), $_PAGE_INFO['HIST_MAIN']);
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu");
switch($_GET['project_action']) {
case "project_info":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Search project"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_info");
break;
case "project_verify_design":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Verify project design"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_verify_design");
break;
case "project_validate_design":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Validate project design"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_validate_design");
break;
case "project_verify_plan":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Verify project plan"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_verify_plan");
break;
case "project_validate_plan":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Validate project plan"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_validate_plan");
break;
case "project_release":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Release project"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_release");
break;
case "project_return":
array_push($_PAGE_INFO['history_menu_buttons'], _("Project maintenance"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project");
array_push($_PAGE_INFO['history_menu_buttons'], _("Return project"));
array_push($_PAGE_INFO['history_menu_links'], "page/menu_project_info&action=project_return");
break;
case "project_design":
case "project_plan":
// No way back => New window!!
break;
default:
break;
}
}
else {
$_PAGE_INFO['history_menu_buttons'] = array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Equipment select (realtime)"));
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_lance_search&action=lance_rt");
}
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
$menu = "menu:realtime_status:extended";
$rights = "";
}
else {
$rights = "menu:realtime_status,menu:realtime_status&productie";
$menu = "menu:realtime_status";
}
}
else if (is_valid_action("lance_use_rt")) {
$_PAGE_INFO['page_title'] = _("realtime status menu");
if (isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
$_PAGE_INFO['shortcut_menu_buttons']= array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Realtime status"), _("Use equipment"), _("Project report"), _("GPS track"));
$_PAGE_INFO['shortcut_menu_links'] = array("page/project", "page/menu&page_project=" . $_GET['page_project'], "page/menu_rt&action=lance_rt&page_project=" . $_GET['page_project'], "page/menu_lance_use&action=lance_use&page_project=" . $_GET['page_project'], "page/menu_report_info&action=project_report&page_project=" . $_GET['page_project'], "page/menu_report_info&action=gps_report&page_project=" . $_GET['page_project']);
$_PAGE_INFO['shortcut_menu_rights'] = array("", "", "menu:realtime_status", "menu:lans", "menu:rapportages&menu:rapportages:projecten,menu:rapportages:root", "menu:rapportages&menu:rapportages:gps,menu:rapportages:root");
}
else {
$_PAGE_INFO['history_menu_buttons'] = array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Equipment search (use)"), _("Use") . " " . $_SESSION[$_PAGE_INFO['id']]['lance_info']['idcode']);
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_lance_search&action=lance_use", "page/menu_lance_use&action=lance_use");
}
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
$menu = "menu:realtime_status:extended";
$rights = "";
}
else {
$rights = "menu:realtime_status,menu:realtime_status&productie";
$menu = "menu:realtime_status";
}
}
else if (is_valid_action("lance_track_trace")) {
$_PAGE_INFO['page_title'] = _("track & trace menu");
if (isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
$_PAGE_INFO['shortcut_menu_buttons']= array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Realtime status"), _("Use equipment"), _("Project report"), _("GPS track"));
$_PAGE_INFO['shortcut_menu_links'] = array("page/project", "page/menu&page_project=" . $_GET['page_project'], "page/menu_rt&action=lance_rt&page_project=" . $_GET['page_project'], "page/menu_lance_use&action=lance_use&page_project=" . $_GET['page_project'], "page/menu_report_info&action=project_report&page_project=" . $_GET['page_project'], "page/menu_report_info&action=gps_report&page_project=" . $_GET['page_project']);
$_PAGE_INFO['shortcut_menu_rights'] = array("", "", "menu:realtime_status", "menu:lans", "menu:rapportages&menu:rapportages:projecten,menu:rapportages:root", "menu:rapportages&menu:rapportages:gps,menu:rapportages:root");
}
else {
$_PAGE_INFO['history_menu_buttons'] = array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Equipment search (use)"), _("Use") . " " . $_SESSION[$_PAGE_INFO['id']]['lance_info']['idcode']);
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_lance_search&action=lance_use", "page/menu_lance_use&action=lance_use");
}
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
$menu = "menu:realtime_status:extended";
$rights = "";
}
else {
$rights = "menu:lans&menu:lans:track_and_trace";
$menu = "menu:lans:track_and_trace";
}
}
//===========================================
// Verify project/rights and log
if (Ver_Rights_Project_Log($rights, $menu)) {
// Realtime status shortcuts used?
if (isset($_GET['project_rt_shortcut'])) {
$_SESSION[$_PAGE_INFO['id']]['rt_dev_shortcut'] = array();
// Retrieve all device types
$types = db_fetch_system_devices($_SESSION[$_PAGE_INFO['id']]['i18n']);
if (is_array($types)) {
foreach($types as $type) {
if (db_check_system_device_capabilities($type['id'], array(array("gps","gps-fixed")))) {
// Get selected lances
$sel_dev = explode(',', $_SESSION[$_PAGE_INFO['id']]['project_info'][$type['id'] . "_left_ids"]);
if (is_array($sel_dev)) {
foreach($sel_dev as $device) {
array_push($_SESSION[$_PAGE_INFO['id']]['rt_dev_shortcut'], db_fetch_lance($device, "", 1));
}
}
}
}
}
}
else
{
// No (project) shortcuts used => Cleanup
unset($_SESSION[$_PAGE_INFO['id']]['rt_dev_shortcut']);
}
// Extended menu? => Diplay only shortcuts
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
// Show page header
print_page_header();
// No project selected => shortcuts/history
$menu_items = array();
$menu_rights = array();
$menu_links = array();
if (is_array($_PAGE_INFO['history_menu_buttons'])) {
for ($i = 0; $i < sizeof($_PAGE_INFO['history_menu_buttons']); $i++) {
// Add item
array_push($menu_items , $_PAGE_INFO['history_menu_buttons'][$i]);
// Shortcut for the parent?
error_log($i . ": " . $_PAGE_INFO['history_menu_buttons'][$i] . (($_PAGE_INFO['history_menu_buttons'][$i] == _("Equipment select (realtime)")) ? "==" : "!=") . _("Equipment select (realtime)"));
if ($_PAGE_INFO['history_menu_buttons'][$i] != _("Equipment select (realtime)")) {
array_push($menu_links, "javascript:goParent('?id=" . $_SESSION[$_PAGE_INFO['id']]['main_id'] . "&href=" . $_PAGE_INFO['history_menu_links'][$i] . "');");
}
else {
array_push($menu_links, "javascript:location.href='?id=" . $_PAGE_INFO['id'] . "&href=" . $_PAGE_INFO['history_menu_links'][$i] . "';");
}
// Catch rights
$rights = 1;
$projects = db_fetch_user_projects($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "normaal");
$valid_project = 0;
if (is_array($projects)) {
foreach($projects as $project) {
// Check for non-closed projects
// normal project => planning status must be finished
// rc project => planning and design status must be validated
if (($project['status'] != "afgesloten") &&
((($project['type'] == "normaal") && ($project['pstatus'] == "gereed")) ||
(($project['type'] == "rc") && (($project['pstatus'] == "gevalideerd") && ($project['ostatus'] == "gevalideerd"))))) {
$valid_project = 1;
}
}
}
if ((empty($_PAGE_INFO['history_menu_links'][$i])) ||
(($_PAGE_INFO['history_menu_links'][$i] == PAGE_PROJECT) &&
((!db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:projecten:root,menu:projecten&projecten:d")))) &&
(!$valid_project)) {
$rights = 0;
}
// Add rights to array
array_push($menu_rights, $rights);
}
// Display menu
print_menu(_("Shortcuts"), $menu_items, $menu_links, $menu_rights, 0, 0, "", 30);
}
// Show page footer
print_page_footer();
}
else {
include ("include/mapview_codegen.php");
// Generate status translation table
$StatusTranslationTable['s_serialnr']='ZKL serial:'; // Serialnr
$StatusTranslationTable['s_batt1']='Battery 1 status'; // Battery 1 status (OK/ALARM/EMPTY/REMOVED)
$StatusTranslationTable['s_batt2']='Battery 2 status'; // Battery 2 status
$StatusTranslationTable['s_batt_timestamp']='Battery status timestamp'; // Battery timestamp
$StatusTranslationTable['s_rssi']='Signal strength'; // Signal string (GSM, XBee, etc)
$StatusTranslationTable['s_gps']='GPS position'; // GPS position lat,lon
$StatusTranslationTable['s_lon']='GPS position longitude'; // GPS position lon
$StatusTranslationTable['s_lat']='GPS position latitude'; // GPS position lat
$StatusTranslationTable['s_gps_timestamp']='GPS position timestamp'; // GPS position datum/tijd
$StatusTranslationTable['s_sleutelschakelaar']='Key switch'; // Key switch (switch 3000)
$StatusTranslationTable['s_detection']='Detection status'; // detection status (OK/NOK)
$StatusTranslationTable['s_switch']='Switch status'; // Switch status (On/Off)
$StatusTranslationTable['s_shortquality']='Quality of the short circuit'; // Quality of the short circuit (percentage)
$StatusTranslationTable['s_shortquality_time']= 'Quality of the short circuit timestamp'; // Quality of the short circuit timestamp (last detection ok)
$StatusTranslationTable['s_active']='Measurement on/off'; // Measurement status (active/inactive)
$StatusTranslationTable['s_remark']='Remark'; // Project remarks
$StatusTranslationTable['s_idcode']='IDCODE:'; // The ID of this device
$StatusTranslationTable['s_devname']='Device type'; // Device type
$StatusTranslationTable['s_relayactive']='Relay state'; // Relay state
$StatusTranslationTable['s_speed']='Speed'; // Speed
$StatusTranslationTable['s_temp_onboard']='temperature %s'; // Temperature on-board
$StatusTranslationTable['s_temp_extern']='temperature %s'; // Temperature external
$StatusTranslationTable['s_time']='Last update'; // Last update
$StatusTranslationTable['s_button']='Button'; // Button
$StatusTranslationTable['ok_zkl']='Ok'; // OK detection for ZKL-like devices
$StatusTranslationTable['nok_zkl']='Not ok'; // NOK detection for ZKL-like devices
$StatusTranslationTable['nodet_gateway']='Geen trein'; // No detection for gateway-like devices means: no train on rails
$StatusTranslationTable['det_gateway']='trein'; // Detection for gateway-like devices means: train on rails
$StatusTranslationTable['ACTIVE']='On'; // Active (for measurement)
$StatusTranslationTable['INACTIVE']='Off'; // inactive (for measurement)
$StatusTranslationTable['ok']='Ok'; // OK state (for battery)
$StatusTranslationTable['empty']='Battery empty'; // Empty (battery state)
$StatusTranslationTable['removed']='Battery removed'; // Removed (battery state)
$StatusTranslationTable['alarm']='Battery almost empty'; // alarm (battery state)
$StatusTranslationTable['GOOD']='Good'; // Mainly used for short circuit quality
$StatusTranslationTable['BAD']='Bad'; // Mainly used for short circuit quality
$StatusTranslationTable['INACTIVE']='Off'; // inactive (for measurement)
$StatusTranslationTable['SW_ACTIVE']='On (overruled)'; // Switch active (for key switch)
$StatusTranslationTable['SW_INACTIVE']='Off (overruled)'; // Switch inactive (for key switch)
$StatusTranslationTable['SW_OPER']='Operational'; // Switch operational (for key switch)
$StatusTranslationTable['View all']='View all'; // The text 'View all'.
$StatusTranslationTable['baseMap']='Map type'; // The text 'Map type'
$StatusTranslationTable['devTypes'] ='Shown device types'; // The text 'Shown devices'
$StatusTranslationTable['devFinder'] ='Track/Visible/Find';
$StatusTranslationTable['satellitemap'] ='Satellite Map';
$StatusTranslationTable['streetmap'] ='Street Map';
// Generate the header HTML/JS for the map viewer.
$extra_header_HTML = mapview_GenHdrCode($StatusTranslationTable);
// JS logic for the realtime status updates
$extra_header_HTML.='<script src="html/javascript/comet_statusupdates.js"></script>';
// Add event
if (Browser() != "IE") {
$extra_header_HTML .= <<< RTSTATUSJS
<script type="text/javascript">
// Clean up everything on exit
window.onbeforeunload = function (evt) {
try {
ol_Cleanup();
}
catch(err) { /* Silent exception */ }
}
</script>
RTSTATUSJS;
}
// Define map control color
$control_color = (strlen($_PAGE_INFO['ini']['rt_status']['control_color'])) ? $_PAGE_INFO['ini']['rt_status']['control_color'] : "#F28424";
$extra_header_HTML.='<script type="text/javascript">var mapviewcontrol_color="' . $control_color . '"</script>';
// Extra OpenLayers control
$extra_header_HTML.='<script src="html/javascript/mapview_control.js"></script>';
// Add onresize event when exteded view
$onresize = (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) ? "onresize=\"ContentSize();\"" : "";
// Skin image dir for openLayers
$image_dir = (strlen($_PAGE_INFO['ini']['rt_status']['images'])) ? SKIN_DIR . $_SESSION[$_PAGE_INFO['id']]['skin'] . "/" . $_PAGE_INFO['ini']['rt_status']['images'] : "";
// Print page header
print_page_header($extra_header_HTML, "<body oncontextmenu=\"return false;\" onload=\"Menu_rt_init('" . $_PAGE_INFO['id'] . "', '" . $image_dir . "', '" . (($_SESSION[$_PAGE_INFO['id']]['dbg']['mask'] & 0x04) ? "1" : "0") . "'); ol_init(); createUpdater(Comet_DataParser, Comet_NetworkError,'" . $_PAGE_INFO['id'] . "');\" onUnload=\"AbortUpdater();\" " . $onresize . ">");
echo "<div id=\"map\" onmouseup=\"mouseup();\" onmousedown=\"mousedown();\">";
// Hide rt second line info
echo "<a id=\"info_hide_href\" href=\"javascript:Extend_Info('hide');";
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) {
// Resize map
echo " ContentSize();";
}
echo "\" onClick=javascript:onclick_handler(); ";
echo "onmouseover=\"Tip('" . _("Hide realtime status info") . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\">";
echo "<!--[if lte IE 6]>";
echo "<span id=\"arrow_info_hide_span\" style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "";
echo (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) ? "arrow_bottom.png" : "arrow_top.png";
echo "');\">";
echo "<![endif]-->";
echo "<img id=\"arrow_info_hide\" src=\"" . IMAGE_DIR . "";
echo (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) ? "arrow_bottom.png" : "arrow_top.png";
echo "\" alt=\"\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
echo "</a>\n";
// Show rt second line info
echo "<a id=\"info_show_href\" href=\"javascript:Extend_Info('show');";
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) {
// Resize map
echo " ContentSize();";
}
echo "\" onClick=javascript:onclick_handler(); ";
echo "onmouseover=\"Tip('" . _("Show realtime status info") . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\">";
echo "<!--[if lte IE 6]>";
echo "<span id=\"arrow_info_show_span\" style=\"visibility:hidden;display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "";
echo (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) ? "arrow_top.png" : "arrow_bottom.png";
echo "');\">";
echo "<![endif]-->";
echo "<img id=\"arrow_info_show\" src=\"" . IMAGE_DIR . "";
echo (isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) ? "arrow_top.png" : "arrow_bottom.png";
echo "\" alt=\"\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
echo "</a>\n";
echo "</div>";
echo "<div id=\"errordiv\" class=\"nwerror_div\">";
echo "<table style=\"width:100%;height:100%\">";
echo "<tr><td style=\"text-align:center;\">";
echo "<img src='" . IMAGE_DIR . "ibox_indicator.gif' alt=\"\" width=\"50px\" height=\"50px\">";
echo "<div class=\"nwerror_p\">" . _("Connection with the server failed") . "</div>";
echo "</td></tr>";
echo "</table>";
echo "</div>";
echo "<div id=\"messagediv\" class=\"message_div\">";
echo "<table style=\"width:100%;height:100%\">";
echo "<tr><td style=\"text-align:center;\">";
echo "<img src='" . IMAGE_DIR . "ibox_indicator.gif' alt=\"\" width=\"50px\" height=\"50px\">";
echo "<div class=\"message_p\">" . _("Searching for equipment") . "..</div>";
echo "</td></tr>";
echo "</table>";
echo "</div>";
// Display second info line
echo "<iframe id=\"iframe_info\" src=\"?id=" . $_PAGE_INFO['id'] . "&href=page/menu_rt_info" . $_PAGE_INFO['page_project'] . "&extended_info=1&extended_view=" . $_SESSION[$_PAGE_INFO['id']]['extended_view'] . "\" frameborder=\"0\" height=\"0\" scrolling=\"auto\"></iframe>";
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_view'])) {
echo "<div id=\"debugwindow\" class=\"debugwindow_div\"></div>";
}
// Show page footer
print_page_footer();
}
}
?>