262 lines
11 KiB
PHP
262 lines
11 KiB
PHP
<?php
|
|
/** \file scripts\page\menu_system_info.php
|
|
* \brief DI webinterface menu system maintenance 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 system maintenance
|
|
*
|
|
*/
|
|
|
|
if(
|
|
!is_valid_action(
|
|
"system_motd",
|
|
"help",
|
|
"equipment_new", "equipment_info", "equipment_change"
|
|
)
|
|
) {
|
|
// Redirect page back to login page
|
|
force_logout(_("No valid rights"), "Invalid action: " . $_SESSION[$_PAGE_INFO['id']]['action']);
|
|
}
|
|
|
|
$page = new MTinfoPage();
|
|
|
|
//===========================================
|
|
|
|
// Verify project/rights and log
|
|
if( $page->user_has_rights() ) {
|
|
if( $_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
|
|
// Return from call
|
|
$equipment_id = $_SESSION[$_PAGE_INFO['id']]['system_info']['id'];
|
|
if( isset($_GET['syscomp_id']) ) {
|
|
// Add new system component to the selected list
|
|
if( $_SESSION[$_PAGE_INFO['id']]['system_info']['syscomp_left_ids'] )
|
|
$selected = explode(",", $_SESSION[$_PAGE_INFO['id']]['system_info']['syscomp_left_ids']);
|
|
$selected[] = decrypt($_GET['syscomp_id'], "syscomp_id_" . $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['syscomp_left_ids'] = implode(",", $selected);
|
|
}
|
|
if( isset($_GET['woitem_id']) ) {
|
|
// Add new system component to the selected list
|
|
if( $_SESSION[$_PAGE_INFO['id']]['system_info']['woitem_left_ids'] )
|
|
$selected = explode(",", $_SESSION[$_PAGE_INFO['id']]['system_info']['woitem_left_ids']);
|
|
$selected[] = decrypt($_GET['woitem_id'], "woitem_id_" . $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['woitem_left_ids'] = implode(",", $selected);
|
|
}
|
|
}
|
|
else if (is_valid_action("equipment_new")) {
|
|
unset($_SESSION[$_PAGE_INFO['id']]['system_info']);
|
|
}
|
|
else if (is_valid_action("equipment_info","equipment_change")) {
|
|
if( isset($_GET['equipment_id']) ) {
|
|
$equipment_id = decrypt($_GET['equipment_id'], "equipment_id_" . $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
|
|
}
|
|
else if( isset($_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device']) ) {
|
|
$equipment_id = $_SESSION[$_PAGE_INFO['id']]['search']['equipment']['device'];
|
|
}
|
|
if( isset($equipment_id) ) {
|
|
// Retrieve equipment data
|
|
$row_equipment = db_fetch_system_devices("", $equipment_id);
|
|
|
|
if( $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("", $equipment_id, "", 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 system components, versions, changes and workorder items linked with this equipment type
|
|
$components = db_search_system_components($_SESSION[$_PAGE_INFO['id']]['i18n'], $equipment_id);
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['syscomp'] = array();
|
|
if( $components ) foreach( $components as $syscomp ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['syscomp'][] = array('id' => $syscomp['id'], 'value' => db_printf_system_component($syscomp, FALSE));
|
|
$versions = db_search_system_versions($_SESSION[$_PAGE_INFO['id']]['i18n'], $syscomp['id'], $equipment_id);
|
|
if( $versions ) foreach( $versions as $version ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['so_enable']['version'][$version['id']] = $version['so_enable'];
|
|
$changelog = db_fetch_version_changelog($version['id']);
|
|
if( $changelog ) foreach( $changelog as $change ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['so_enable']['change'][$change['id']] = in_array($equipment_id, $change['device']);
|
|
}
|
|
}
|
|
}
|
|
$woitems = db_search_workorder_items($_SESSION[$_PAGE_INFO['id']]['i18n'], $equipment_id);
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['woitems'] = array();
|
|
if( $woitems ) foreach( $woitems as $woitem ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']['woitems'][] = array('id' => $woitem['id'], 'value' => db_printf_workorder_item($woitem, FALSE));
|
|
}
|
|
|
|
// 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, $equipment_id, $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
|
|
force_logout(_("No valid rights"), "Device type ID not valid");
|
|
}
|
|
}
|
|
else {
|
|
// ID not selected
|
|
force_logout(_("No valid rights"), "Device type ID not set");
|
|
}
|
|
}
|
|
|
|
// 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) */
|
|
/************************************/
|
|
// 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,$equipment_id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/************************************/
|
|
/* Equipment capabilities */
|
|
/************************************/
|
|
// 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");
|
|
// 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($equipment_id, $_SESSION[$_PAGE_INFO['id']]['i18n'], $i);
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']["status_" . $i] = $status['status'];
|
|
}
|
|
}
|
|
}
|
|
|
|
/************************************/
|
|
/* RT status/Track & trace states */
|
|
/************************************/
|
|
// 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($equipment_id, $i18n, "", $option);
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info'][$option . "_value_" . $i18n] = $status['display'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/************************************/
|
|
/* RT status state icons */
|
|
/************************************/
|
|
// 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($equipment_id, 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 */
|
|
/************************************/
|
|
// Only first time
|
|
if (is_valid_action("equipment_info","equipment_change")) {
|
|
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
|
|
// 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'])) {
|
|
$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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/************************************/
|
|
/* Release items */
|
|
/************************************/
|
|
if (is_valid_action("equipment_info","equipment_change")) {
|
|
$release_items = split(",", $_SESSION[$_PAGE_INFO['id']]['system_info']['release_items']);
|
|
foreach( $release_items as $item ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['system_info']["release_item_" . str_replace(" " , "_", $item)] = 1;
|
|
}
|
|
}
|
|
|
|
// 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();
|
|
}
|
|
else {
|
|
// Redirect page back to login page
|
|
force_logout(_("No valid rights"), "No rights for menu " . $menu . ": " . $rights);
|
|
}
|
|
|
|
?>
|