246 lines
13 KiB
PHP
246 lines
13 KiB
PHP
<?php
|
|
/** \file scripts\page\menu_lance_info.php
|
|
* \brief DI webinterface menu lance 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 lance info script. This file displays lance info.
|
|
*/
|
|
|
|
//== Required settings ======================
|
|
if(
|
|
!is_valid_action(
|
|
"lance_info","lance_new","lance_change",
|
|
"lance_change_status","lance_change_status_di",
|
|
"lance_calibration","lance_endcontrol",
|
|
"lance_main_report","lance_doc","lance_doc_change",
|
|
"lance_alarmnr","lance_alarmnr_change"
|
|
)
|
|
) {
|
|
// Possible abuse: redirect page back to login page
|
|
force_logout(_("No valid rights"), "Invalid action: " . current_action(TRUE));
|
|
}
|
|
|
|
$page = new MTinfoPage();
|
|
|
|
//===========================================
|
|
|
|
// Verify project/rights and log
|
|
if( $page->user_has_rights() ) {
|
|
// Check action
|
|
if (is_valid_action("lance_info", "lance_change", "lance_change_status", "lance_change_status_di", "lance_alarmnr", "lance_calibration", "lance_endcontrol","lance_main_report","lance_doc")) {
|
|
// Check if this is a recall action
|
|
// Do not load the lance info when this page is called from another "lance" action
|
|
if( !$_SESSION[$_PAGE_INFO['id']]['recall_counter'] ) {
|
|
if (isset($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id'])) {
|
|
// Retrieve lance data
|
|
$row_lance = db_fetch_lance($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id'],"", 1);
|
|
|
|
if (is_array($row_lance)) {
|
|
if( is_valid_call("lance_*") && $_SESSION[$_PAGE_INFO['id']]['lance_info'] ) {
|
|
// Retrieve lance data and merge missing information into the session
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info'] = array_merge($row_lance, $_SESSION[$_PAGE_INFO['id']]['lance_info']);
|
|
}
|
|
else $_SESSION[$_PAGE_INFO['id']]['lance_info'] = $row_lance;
|
|
|
|
// Write info => needed for shortcut to rt
|
|
$_SESSION[$_PAGE_INFO['id']]['search']['lances']['id'] = $_SESSION[$_PAGE_INFO['id']]['search']['lance']['id'];
|
|
|
|
if (is_valid_action("lance_change","lance_change_status","lance_change_status_di")) {
|
|
// Released project?
|
|
if (is_array(db_fetch_lance_released_projects($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id']))) {
|
|
// Alert!
|
|
$_SESSION[$_PAGE_INFO['id']]['errormsg']['text'] = "It is not possible to change safety critical information because this equipment is been used on a released project";
|
|
$_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] = "alert";
|
|
}
|
|
}
|
|
// check if we can allow an electronics or functional test
|
|
if( is_valid_action("lance_calibration","lance_endcontrol") ) {
|
|
if(
|
|
(is_valid_action("lance_calibration") && count($wo_list = db_fetch_lance_workorders($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id'], "gereedgemeld|elek. test")) == 0) ||
|
|
(is_valid_action("lance_endcontrol") && count($wo_list = db_fetch_lance_workorders($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id'], "elek. test")) == 0)
|
|
) {
|
|
error_log("Lance " . $row_lance['idcode'] . " has no open workorders");
|
|
$_SESSION[$_PAGE_INFO['id']]['errormsg']['text'] = _("This equipment doesn't have an open workorder");
|
|
$_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] = "alert";
|
|
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_lance_search&action=" . current_action());
|
|
exit(0);
|
|
}
|
|
else {
|
|
// save identifier of "the" workorder
|
|
$wo = array_shift($wo_list);
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info']['wo_id'] = $wo['id'];
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info']['wo_lans_status'] = $wo['lans_status'];
|
|
}
|
|
}
|
|
// unset service status when performing the functional test
|
|
if(
|
|
is_valid_action("lance_endcontrol") &&
|
|
(
|
|
($row_lance['lans_status'] == "nieuw") ||
|
|
($row_lance['lans_status'] == "productie") ||
|
|
($row_lance['lans_status'] == "service")
|
|
)
|
|
) unset($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status']);
|
|
}
|
|
else {
|
|
// ID not valid!!! => Redirect back to search menu
|
|
error_log("Lance id not valid");
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_lance_search&action=" . current_action());
|
|
exit(0);
|
|
}
|
|
}
|
|
else {
|
|
// ID not selected
|
|
error_log("Lance id not set");
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=page/menu_lance_search&action=" . current_action());
|
|
exit(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Log action
|
|
if (!is_valid_action("lance_new")) {
|
|
// Check if this is a recall action
|
|
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
|
|
if (isset($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id'])) {
|
|
// Log user-lance action (use log entry from Ver_Rights_Project_Log function)
|
|
db_log_user_lance($_SESSION[$_PAGE_INFO['id']]['search']['lance']['id']);
|
|
}
|
|
}
|
|
}
|
|
|
|
/************************************/
|
|
/* Device capabilities */
|
|
/************************************/
|
|
if (is_valid_action("lance_new","lance_info", "lance_change", "lance_change_status", "lance_change_status_di")) {
|
|
// cache capabilities and other information about the device type
|
|
if (is_valid_action("lance_new")) {
|
|
unset($_SESSION[$_PAGE_INFO['id']]['lance_info']['system_info']);
|
|
}
|
|
else {
|
|
$row_equipment = db_fetch_system_devices("", $_SESSION[$_PAGE_INFO['id']]['lance_info']['device']);
|
|
if (is_array($row_equipment)) $_SESSION[$_PAGE_INFO['id']]['lance_info']['system_info'] = $row_equipment[0];
|
|
}
|
|
|
|
// get information about the parent when this device is behind a gateway
|
|
if( $_SESSION[$_PAGE_INFO['id']]['lance_info']['parent'] ) {
|
|
$_SESSION[$_PAGE_INFO['id']]['parent_info'] = db_fetch_lance($_SESSION[$_PAGE_INFO['id']]['lance_info']['parent'],"", 1);
|
|
}
|
|
else {
|
|
unset($_SESSION[$_PAGE_INFO['id']]['parent_info']);
|
|
}
|
|
|
|
// 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($_SESSION[$_PAGE_INFO['id']]['lance_info']['id'], $_SESSION[$_PAGE_INFO['id']]['lance_info']['device'], $key);
|
|
// set the page items
|
|
if( $value !== FALSE ) {
|
|
// value is an array; only one item expected and supported
|
|
list($max,$min) = explode(',', $value[0]);
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info']['config:' . $item . ':min'] = $min;
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info']['config:' . $item . ':max'] = $max;
|
|
}
|
|
else {
|
|
// temperature threshold not set; clear them in the 'lance_info' to be sure
|
|
unset($_SESSION[$_PAGE_INFO['id']]['lance_info']['config:' . $item . ':min']);
|
|
unset($_SESSION[$_PAGE_INFO['id']]['lance_info']['config:' . $item . ':max']);
|
|
}
|
|
}
|
|
|
|
if (is_valid_action("lance_info","lance_change")) {
|
|
if(!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
|
|
$capabilities = split(",", $_SESSION[$_PAGE_INFO['id']]['lance_info']['capabilities']);
|
|
if (is_array($capabilities)) {
|
|
foreach ($capabilities as $item) {
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info']['cap_' . str_replace(" " , "_", $item)] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if( !$_SESSION[$_PAGE_INFO['id']]['recall_counter'] ) {
|
|
// new device; first time invokation: set "rtstatus" capability (and other defaults)
|
|
$_SESSION[$_PAGE_INFO['id']]['lance_info']['cap_rtstatus'] = 1;
|
|
}
|
|
}
|
|
|
|
// Check shortcuts
|
|
if (is_valid_action("lance_info")) {
|
|
$_PAGE_INFO['shortcut_menu_buttons']= array(_("Realtime status"), _("Maintenance report"), _("Alarm numbers"));
|
|
// Check status
|
|
$_PAGE_INFO['shortcut_menu_links'] = array();
|
|
// Realtime status
|
|
if ((db_check_lance_capabilities($_SESSION[$_PAGE_INFO['id']]['lance_info'], "rtstatus")) &&
|
|
((db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:realtime_status") &&
|
|
($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'] == "actief")) ||
|
|
(db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:realtime_status&productie") &&
|
|
(in_array($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'], array("service","productie","winkel","actief")))))) {
|
|
array_push($_PAGE_INFO['shortcut_menu_links'], "page/menu_rt&action=lance_rt");
|
|
}
|
|
else {
|
|
array_push($_PAGE_INFO['shortcut_menu_links'], "");
|
|
}
|
|
// Maintenance report
|
|
if ((db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:lansen:root,menu:lansen&productie") &&
|
|
(in_array($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'], array("productie","service","winkel","actief","afgeschreven","verloren")))) ||
|
|
(db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:lansen&menu:lansen:onderhoudsrapporten") &&
|
|
($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'] == "actief"))) {
|
|
array_push($_PAGE_INFO['shortcut_menu_links'], "page/menu_lance_info&action=lance_main_report");
|
|
}
|
|
else {
|
|
array_push($_PAGE_INFO['shortcut_menu_links'], "");
|
|
}
|
|
// Alarm numbers
|
|
if ((db_check_system_device_capabilities($_SESSION[$_PAGE_INFO['id']]['lance_info']['device'],array(array("gprs","gsm")))) &&
|
|
((db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:lansen:root") &&
|
|
(in_array($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'], array("productie","service","winkel","actief","afgeschreven","verloren")))) ||
|
|
(db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:lansen&productie") &&
|
|
(in_array($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'], array("productie","service","winkel")))) ||
|
|
(db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:lansen&menu:lansen:alarmnummers") &&
|
|
($_SESSION[$_PAGE_INFO['id']]['lance_info']['lans_status'] == "actief")))) {
|
|
array_push($_PAGE_INFO['shortcut_menu_links'],"page/menu_lance_info&action=lance_alarmnr");
|
|
}
|
|
else {
|
|
array_push($_PAGE_INFO['shortcut_menu_links'], "");
|
|
}
|
|
// Add reset button (SMS/GPRS command)
|
|
if (db_check_system_device_capabilities($_SESSION[$_PAGE_INFO['id']]['lance_info']['device'],array(array("gprs","gsm")))) {
|
|
if (db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:lansen&productie")) {
|
|
array_push($_PAGE_INFO['shortcut_menu_buttons'], _("Reset materieel"));
|
|
array_push($_PAGE_INFO['shortcut_menu_links'] , "javascript:onSubmit('reset', '', 1,'busy');");
|
|
}
|
|
}
|
|
|
|
$_PAGE_INFO['shortcut_menu_rights'] = array("menu:realtime_status", "menu:lansen&menu:lansen:onderhoudsrapporten,menu:lansen:root,menu:lansen&productie", "menu:lansen&menu:lansen:alarmnummers,menu:lansen:root,menu:lansen&productie");
|
|
}
|
|
else if( is_valid_action("lance_calibration") ) {
|
|
// shortcut to "change equipment"
|
|
if( db_ver_rights("menu:lansen:root,menu:service:productie") ) {
|
|
// Shortcuts
|
|
$_PAGE_INFO['shortcut_menu_links'] = array("page/menu_lance_info&action=lance_change&call_action=" . current_action());
|
|
$_PAGE_INFO['shortcut_menu_buttons']= array(_("Change equipment"));
|
|
$_PAGE_INFO['shortcut_menu_rights'] = array("menu:lansen:root,menu:service:productie");
|
|
}
|
|
|
|
}
|
|
|
|
// Add calendar to header
|
|
$extra_header_HTML = "<script type=\"text/javascript\" src=\"" . JAVA_DIR . "calender.js\"></script>\n";
|
|
|
|
// Show page header
|
|
$y_position = (isset($_SESSION[$_PAGE_INFO['id']]['lance_info']['y_position'])) ? ($_SESSION[$_PAGE_INFO['id']]['lance_info']['y_position']) : 0;
|
|
print_xml_header($y_position, $extra_header_HTML);
|
|
|
|
// Include lance info content
|
|
include("menu_lance_info_content.php");
|
|
|
|
// Show page footer
|
|
print_page_footer();
|
|
}
|
|
?>
|