src.dualinventive.com/mtinfo/dist/webroot/main/scripts/page/menu_system_info.php

264 lines
12 KiB
PHP

<?php
/** \file scripts\page\menu_system_info.php
* \brief DI webinterface menu system maintenance script.
* \author Rob Schalken, Core|Vision
* \version 1.0
* \date 17-10-2008
*
* This file contains the menu system maintenance
*
*/
//== Required settings ======================
if (is_valid_action("system_motd")) {
$_PAGE_INFO['page_title'] = "message of the day menu";
$_PAGE_INFO['history_menu_buttons'] = array("Project overview", $_PAGE_INFO['HIST_MAIN'], "System maintenance");
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_system&action=system_overview");
$menu = "menu:systeemonderhoud:motd";
$rights = "menu:systeemonderhoud";
$title = "Message of the day";
}
if (is_valid_action("help")) {
$_PAGE_INFO['page_title'] = "help maintenance menu";
$_PAGE_INFO['history_menu_buttons'] = array("Project overview", $_PAGE_INFO['HIST_MAIN'], "System maintenance");
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_system&action=system_overview");
$menu = "menu:systeemonderhoud:help";
$rights = "menu:systeemonderhoud";
$title = "Help maintenance";
}
else if (is_valid_action("equipment_new")) {
$_PAGE_INFO['page_title'] = "new equipment type menu";
$_PAGE_INFO['history_menu_buttons'] = array("Project overview", $_PAGE_INFO['HIST_MAIN'], "System maintenance", "Equipment type maintenance");
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_system&action=system_overview", "page/menu_system&action=equipment_overview");
$menu = "menu:systeemonderhoud:materieel_type:nieuw";
$rights = "menu:systeemonderhoud";
$title = "Add equipment type";
}
else if (is_valid_action("equipment_info")) {
$_PAGE_INFO['page_title'] = "equipment type info menu";
$_PAGE_INFO['history_menu_buttons'] = array("Project overview", $_PAGE_INFO['HIST_MAIN'], "System maintenance", "Equipment type maintenance", "Equipment type search (info)");
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_system&action=system_overview", "page/menu_system&action=equipment_overview","page/menu_system_search");
$menu = "menu:systeemonderhoud:materieel_type:overzicht";
$rights = "menu:systeemonderhoud";
$title = "View equipment type";
}
else if (is_valid_action("equipment_change")) {
$_PAGE_INFO['page_title'] = "equipment change menu";
$_PAGE_INFO['history_menu_buttons'] = array("Project overview", $_PAGE_INFO['HIST_MAIN'], "System maintenance", "Equipment type maintenance", "Equipment type search (change)");
$_PAGE_INFO['history_menu_links'] = array("page/project", "page/menu", "page/menu_system&action=system_overview", "page/menu_system&action=equipment_overview","page/menu_system_search");
$menu = "menu:systeemonderhoud:materieel_type:wijzigen";
$rights = "menu:systeemonderhoud";
$title = "Change equipment type";
}
//===========================================
// Verify project/rights and log
if (Ver_Rights_Project_Log($rights, $menu)) {
// Clear old values
if (is_valid_action("equipment_new")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
unset($_SESSION[$_PAGE_INFO['id']]['system_info']);
}
}
else if (is_valid_action("equipment_info","equipment_change")) {
// Check if this is a recall action
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
if (isset($_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'])) {
// Retrieve equipment data
$row_equipment = db_fetch_system_devices("", $_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device']);
if (is_array($row_equipment)) {
$_SESSION[$_PAGE_INFO['id']]['system_info'] = $row_equipment[0];
if (is_valid_action("equipment_change")) {
// Fetch all equipment from this type
$equipment = db_fetch_project_lances("", $_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'], "", 0, array("actief"), array("actief"));
if (is_array($equipment)) {
foreach($equipment as $item) {
// Released project?
if (is_array(db_fetch_lance_released_projects($item['id']))) {
// Alert!
$_SESSION[$_PAGE_INFO['id']]['errormsg']['text'] = "It is not possible to change safety critical information because this equipment type is been used on a released project";
$_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] = "alert";
}
}
}
}
// get temperature thresholds
$keys = array("threshold:t_ext1","threshold:t_ext2");
foreach( $keys as $item ) {
// translate POST item name to database key
$key_parts = explode(':', $item);
$key = strtoupper($key_parts[0] . "[" . $key_parts[1] . "]");
$value = db_fetch_config(NULL, $_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'], $key);
// set the page items
if( $value ) {
// value is an array; only one item expected and supported
list($max,$min) = explode(',', $value[0]);
$_SESSION[$_PAGE_INFO['id']]['system_info']['config:' . $item . ':min'] = $min;
$_SESSION[$_PAGE_INFO['id']]['system_info']['config:' . $item . ':max'] = $max;
}
}
}
else {
// ID not valid!!! => Redirect back to search menu
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_system_search");
}
}
else {
// ID not selected
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_system_search");
}
}
}
// Locked equipment type?
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
$_SESSION[$_PAGE_INFO['id']]['locked'] = $_SESSION[$_PAGE_INFO['id']]['system_info']['locked'];
}
// Fetch all languages
$i18n_languages = db_fetch_system_lang();
/************************************/
/* Name (all languages) */
/************************************/
if (is_valid_action("equipment_new","equipment_info", "equipment_change")) {
// Only first time
if (is_valid_action("equipment_info","equipment_change")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
if (is_array($i18n_languages)) {
foreach ($i18n_languages as $i18n => $lang) {
$_SESSION[$_PAGE_INFO['id']]['system_info']["naam_" . $i18n] = db_fetch_system_device_name($i18n,$_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device']);
}
}
}
}
}
/************************************/
/* Equipment capabilities */
/************************************/
if (is_valid_action("equipment_new","equipment_info", "equipment_change")) {
// Only first time
if (is_valid_action("equipment_info","equipment_change")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
$capabilities = split(",", $_SESSION[$_PAGE_INFO['id']]['system_info']['capabilities']);
if (is_array($capabilities)) {
foreach ($capabilities as $item) {
$_SESSION[$_PAGE_INFO['id']]['system_info']['cap_' . str_replace(" " , "_", $item)] = 1;
}
}
}
}
}
/************************************/
/* Detection status */
/************************************/
$options = db_fetch_set("device_status_weergave","status");
if (is_valid_action("equipment_new","equipment_info","equipment_change")) {
// Only first time
if (is_valid_action("equipment_info","equipment_change")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
for ($i=0; $i<4; $i++) {
$status = db_fetch_system_device_status($_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'], $_SESSION[$_PAGE_INFO['id']]['i18n'], $i);
$_SESSION[$_PAGE_INFO['id']]['system_info']["status_" . $i] = $status['status'];
}
}
}
}
/************************************/
/* RT status/Track & trace states */
/************************************/
if (is_valid_action("equipment_new","equipment_info","equipment_change")) {
// Only first time
if (is_valid_action("equipment_info","equipment_change")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
if ((is_array($i18n_languages)) && (is_array($options))) {
foreach ($i18n_languages as $i18n => $lang) {
foreach ($options as $option) {
$status = db_fetch_system_device_status($_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'], $i18n, "", $option);
$_SESSION[$_PAGE_INFO['id']]['system_info'][$option . "_value_" . $i18n] = $status['display'];
}
}
}
}
}
}
/************************************/
/* RT status state icons */
/************************************/
if (is_valid_action("equipment_new","equipment_info","equipment_change")) {
// Only display when GPS & GSM/GPRS are available
if (isset($_SESSION[$_PAGE_INFO['id']]['system_info']['cap_gps']) || isset($_SESSION[$_PAGE_INFO['id']]['system_info']['cap_gps-fixed'])) {
// Retrieve all blob type
$icons = db_fetch_fields("device", "blob");
// Only first time
if (is_valid_action("equipment_info","equipment_change")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
if (is_array($icons)) {
foreach($icons as $icon) {
$icon_info = db_fetch_system_device_icon($_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'], substr($icon, strlen("icon_")));
$_SESSION[$_PAGE_INFO['id']]['system_info'][$icon] = $icon_info['icon'];
$_SESSION[$_PAGE_INFO['id']]['system_info'][$icon . "_mimetype"] = $icon_info['mimetype'];
$_SESSION[$_PAGE_INFO['id']]['system_info'][$icon . "_width"] = $icon_info['width'];
$_SESSION[$_PAGE_INFO['id']]['system_info'][$icon . "_height"] = $icon_info['height'];
}
}
}
}
}
}
/************************************/
/* RT status balloon */
/************************************/
if (is_valid_action("equipment_new","equipment_info", "equipment_change")) {
// Only display when GPS & GSM/GPRS are available
if (isset($_SESSION[$_PAGE_INFO['id']]['system_info']['cap_gps']) || isset($_SESSION[$_PAGE_INFO['id']]['system_info']['cap_gps-fixed'])) {
// Only first time
if (is_valid_action("equipment_info","equipment_change")) {
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
$rt_status = split(",", $_SESSION[$_PAGE_INFO['id']]['system_info']['realtime_status']);
if (is_array($rt_status)) {
foreach ($rt_status as $item) {
$_SESSION[$_PAGE_INFO['id']]['system_info']["rt_" . str_replace(" " , "_", $item)] = 1;
}
}
}
}
}
}
// Store title
$_SESSION[$_PAGE_INFO['id']]['title'] = $title;
// Show page header
$y_position = (isset($_SESSION[$_PAGE_INFO['id']]['system_info']['y_position'])) ? ($_SESSION[$_PAGE_INFO['id']]['system_info']['y_position']) : 0;
print_xml_header($y_position);
// Include info content
include("menu_system_info_content.php");
// Show page footer
print_page_footer();
}
?>