javascript needed for the live report * \author Rob Schalken, Core|Vision * \version 1.0 * \date 17-10-2008 * */ // Read only => Lock as less as possible $_PAGE_INFO['session_read_only'] = TRUE; /* * Required pages */ require_once("core_xml.php"); // Extra right check if ((db_ver_right_user($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "login")) && (db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "menu:rapportages&productie"))) { // Retrieve ini file skin $ini_file = get_all_files($_PAGE_INFO['base_path'] . SKIN_DIR . $_SESSION[$_PAGE_INFO['id']]['skin'] . "/", array("ini")); $_PAGE_INFO['ini'] = parse_ini_file($ini_file[0], true); /* * Get online users */ if (isset($_POST['online_users'])) { // Initial values $sessions = array(); $user_info = array(); $valid_customers = array(); // Get all company down the pyramid $customers = db_search_customers(); // Get all ids if (is_array($customers)) { foreach($customers as $customer) { array_push($valid_customers, $customer['id']); } } // Read session file content from database $session_info = db_fetch_data("SELECT * FROM session"); if (is_array($session_info)) { foreach($session_info as $session) { // Find non-session char if (stristr($session['id'], "_") === FALSE) { // Decode session file content => Puts it in $_SESSION session_decode($session['data']); // Parse session if (is_array($_SESSION)) { foreach($_SESSION as $key => $info) { // valid customer? if (in_array($info['login']['customer']['id'], $valid_customers)) { // Session accessed last 10 seconds // Skip extended menu if (($info['last_access'] > time()-10) && (!isset($info['extended_menu']))) { // No duplicated sessions if (!in_array($key, $sessions)) { // Store session array_push($sessions, $key); // Store user array_push($user_info, array(id => $info['login']['user']['id'], customer => $info['login']['customer']['id'], page => $info['MTinfo_menu'], last_access => $info['last_access'], session => $key, session_org => (!isset($info['original_id'])) ? $key : $info['original_id'])); } } } } } } } } // Build table echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if (!empty($user_info)) { // Intial values $count = 0; $collected = array(); foreach($user_info as $user) { // Get user/customer info $c = db_fetch_customer($user['customer'], 1); $u = db_fetch_user($user['id'], "", 1); $s = db_fetch("log_gebruiker", "tijd,formdata", "gebruiker=" . $user['id'] . " AND menu='login' and session_id like '%_" . $user['session_org'] . "'"); // Get user info $ip = ""; if (is_array($s)) { $unserial_s = unserialize($s[0]['formdata']); // Get correct $_SERVER value $ip_settings = (isset($unserial_s['HTTP_X_FORWARDED_FOR'])) ? $unserial_s['HTTP_X_FORWARDED_FOR'] : $unserial_s['REMOTE_ADDR']; $ip = " (" . $ip_settings . ")"; } // Collect info array_push($collected, array(username => getUser($user['id']), customer => $c['bedrijfsnaam'], mobile_number => $u['mobielnr'], page => _("h:" . $user['page']), session => $user['session'] . $ip, start_session => ((is_array($s)) ? $s[0]['tijd'] : "-"), last_accessed => convert_datetime($user['last_access'], TRUE))); } // Order $collected = array_sort($collected, $_POST['order'], SORT_STRING, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); foreach($collected as $collected_item) { $style = ($count % 2) ? "style=\"background-color:#F2F2F2\"" : ""; // Create row echo ""; foreach($collected_item as $key => $item) { echo ""; } echo ""; // Increment counter $count++; } } echo "
" . _("Username") . "" . _("Company") . "" . _("Mobile number") . "" . _("Page menu") . "" . ucfirst(_("session")) . " " . _("id") . "" . ucfirst(_("session")) . " " . _("start") . "" . ucfirst(_("last access")) . "
" . ucfirst($item) . "
"; } /* * Get last equipment status */ if (isset($_POST['status_equipment'])) { // Initial values $session = array(); $log_rt_info = array(); $collected = array(); // Get all equipment (down the pyramid) $all_equipment = db_search_lances($_GET['device']); if (is_array($all_equipment)) { foreach($all_equipment as $equipment) { // Get log realtime info $e = db_fetch_cache($equipment['id'], "status"); // Catch exceptions if (is_array($e)) { // Store info $log_rt = array('zkl' => $equipment['id'], 't' => $e['t'], 'interpreter_status' => $e); array_push($log_rt_info, $log_rt); } } } // Build table echo ""; echo ""; echo ""; echo ""; // Device can measure? if (db_check_system_device_capabilities($_GET['device'],array("meting"))) { echo ""; } // Device can switch? if (db_check_system_device_capabilities($_GET['device'],array("kortsluiting schakelen"))) { echo ""; } // Detection? if (db_check_system_device_capabilities($_GET['device'],array("meting"))) { echo ""; } echo ""; echo ""; if (!empty($log_rt_info)) { // Intial values $count = 0; // Collect info foreach($log_rt_info as $log_rt) { $e = db_fetch_lance($log_rt['zkl'], "", 1); array_push($collected, array('idcode_di' => $e['serienr'], 'idcode_owner' => $e['idcode'], 'log_rt' => $log_rt, 'last_update' => $log_rt['t'])); } // Order switch($_POST['order']) { case "last_update": $collected = array_sort($collected, $_POST['order'], SORT_NUMERIC, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); break; default: $collected = array_sort($collected, $_POST['order'], SORT_STRING, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); break; } foreach($collected as $collected_item) { $style = ($count % 2) ? "style=\"background-color:#F2F2F2\"" : ""; // Create row echo ""; foreach($collected_item as $key => $item) { switch($key) { case "log_rt"; // Device can measure? if (db_check_system_device_capabilities($_GET['device'],array("meting"))) { if ($item['interpreter_status']['detection']['active']) { echo ""; } else { echo ""; } } // Device can switch? if (db_check_system_device_capabilities($_GET['device'],array("kortsluiting schakelen"))) { if (!$item['interpreter_status']['system']['error']['sw1w']) { if ($item['interpreter_status']['switch3000']['on']) { echo ""; } else { echo ""; } } else { echo ""; } } // Detection? if (db_check_system_device_capabilities($_GET['device'],array("meting"))) { $condition = array(); array_push($condition, array("condition" => "kortsluiting", "value" => $item['interpreter_status']['detection']['ok'])); // Check switch status if (!is_array($item['interpreter_status']['switch3000'])) { // ZKL 3000 array_push($condition, array("condition" => "relais", "value" => !$item['interpreter_status']['relay']['enabled'])); } else { // ZKL 3000 + SWITCH 3000 (Check also the communication) array_push($condition, array("condition" => "relais", "value" => ((!$item['interpreter_status']['system']['error']['sw1w']) ? $item['interpreter_status']['switch3000']['on'] : FALSE))); } // Get current status $sts = db_fetch_system_device_status($_GET['device'], 'en', $condition, ""); if ( $sts !== false && $sts['status'] == "ok") { echo ""; } else { echo ""; } } break; case "last_update"; // Timestamp to old? if ($item > time()-(15 * 60)) { echo ""; } else { echo ""; } break; default: echo ""; break; } } echo ""; // Increment counter $count++; } } else { // Create empty row echo ""; echo ""; echo ""; echo ""; // Device can measure? if (db_check_system_device_capabilities($_GET['device'],array("meting"))) { echo ""; } // Device can switch? if (db_check_system_device_capabilities($_GET['device'],array("kortsluiting schakelen"))) { echo ""; } // Detection? if (db_check_system_device_capabilities($_GET['device'],array("meting"))) { echo ""; } echo ""; } echo "
" . _("ID code") . " " . ucwords($_SESSION[$_PAGE_INFO['id']]['skin_name']) . "" . _("ID code") . " " . _("owner") . "" . _("Measurement") . "" . ucfirst(_("switch")) . "" . ucfirst(_("detection")) . "" . _("Last update") . "
ONOFFONOFFUNKOWNOKNOK" . convert_datetime($item, TRUE) . "" . convert_datetime($item, TRUE) . "" . ucfirst($item) . "
------
"; } /* * Get project status */ if (isset($_POST['projects'])) { // Initial values $session = array(); $collected = array(); // Get all unfinished projects $all_projects = db_search_projects($_GET['project_type']); // Build table echo ""; echo ""; echo ""; echo ""; if (strtolower($_GET['project_type']) == "rc") { echo ""; } echo ""; echo ""; if (strtolower($_GET['project_type']) == "rc") { echo ""; } echo ""; if (!empty($all_projects)) { // Intial values $count = 0; $collected = array(); foreach($all_projects as $project) { $next_planned = ""; $next_user = ""; // Get user if (strtoupper($project['type']) == "RC") { $project_users = db_fetch_data("SELECT project_gebruiker.* FROM project_gebruiker,project WHERE (project.id=" . $project['id'] . " or project.parent=" . $project['id'] . ") AND project_gebruiker.project=project.id AND project_gebruiker.rol='schakelen'"); if (!empty($project_users)) { foreach($project_users as $user) { if (!strlen($next_planned)) { $next_planned = convert_datetime($user['begin']); $next_user = getUser($user['gebruiker']); } else if ((convert_datetime($user['begin'])) < $next_planned) { $next_planned = convert_datetime($user['begin']); $next_user = getUser($user['gebruiker']); } } } } // Get company $project_company = db_fetch_customer($project['klant'], 1); // Skip periods array_push($collected, array(naam => $project['naam'], company => $project_company['bedrijfsnaam'], ostatus => ((strtoupper($project['type']) != "RC") ? "-" : _($project['ostatus'])), pstatus => (((strtoupper($project['type']) != "RC") && ($project['pstatus'] != "concept")) ? _("gevalideerd") : _($project['pstatus'])), sstatus => (((strtoupper($project['type']) != "RC") && ($project['pstatus'] != "concept")) ? _("vrijgegeven") : _($project['sstatus'])), next_planned => (strlen($next_planned)) ? $next_planned : "-", next_user => $next_user)); } // Order switch($_POST['order']) { case "ostatus": // Only applicable for rc projects if (strtolower($_GET['project_type']) == "rc") { $collected = array_sort($collected, $_POST['order'], SORT_STRING, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); } else { $collected = array_sort($collected, "naam", SORT_STRING, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); } break; case "next_planned": // Only applicable for rc projects if (strtolower($_GET['project_type']) == "rc") { $collected = array_sort($collected, $_POST['order'], SORT_NUMERIC, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); } else { $collected = array_sort($collected, "naam", SORT_STRING, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); } break; default: $collected = array_sort($collected, $_POST['order'], SORT_STRING, ($_POST['order_style'] == "SORT_DESC" ? SORT_DESC : SORT_ASC)); break; } foreach($collected as $project) { $style = ($count % 2) ? "style=\"background-color:#F2F2F2;\"" : ""; // Create row echo ""; foreach($project as $key => $item) { switch($key) { case "ostatus": // Only applicable for rc projects if (strtolower($_GET['project_type']) == "rc") { echo ""; } break; case "sstatus": if (strtoupper($item) == strtoupper(_("vrijgegeven"))) { echo ""; } else { echo ""; } break; case "next_planned": // Only applicable for rc projects if (strtolower($_GET['project_type']) == "rc") { echo ""; } break; case "next_user": break; default: if (strlen($item) > 20) { echo ""; } else { echo ""; } break; } } echo ""; // Increment counter $count++; } } else { // Create empty row echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
" . _("Name") . "" . _("Company") . "" . _("Design status") . "" . _("Plan status") . "" . _("Status") . "" . ucfirst(_("first user planned")) . "
" . ucfirst($item) . "" . ucfirst($item) . "" . ucfirst($item) . "" . (($item != "-") ? convert_datetime($item, TRUE) : "-") . (($item != "-") ? "
(" . $project['next_user'] . ")" : "") . "
" . ucfirst(substr($item, 0, 20)) . ".." . ucfirst($item) . "
----
"; } } else { // Display logout message $_SESSION[$_PAGE_INFO['id']]['login_info']['errormsg'] = _("No valid rights"); // Redirect page back to login page echo "\n"; } ?>