64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
|
/** \file scripts\page\tws.php
|
|
* \brief TWS 3000 script.
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version 1.0
|
|
* \date 12-12-2012
|
|
*
|
|
* This file contains the TWS 3000 script. This is a RS 3000 based app.
|
|
*/
|
|
|
|
// Verify "login" rights!
|
|
// Verify RS3000 or other RS3000 based app
|
|
if ((Ver_Rights_Project_Log("login", "natws")) && (is_dev("RS3000"))) {
|
|
// Initial values
|
|
$equipment = "";
|
|
|
|
// Retrieve all device types
|
|
$types = db_fetch_system_devices($_SESSION[$_PAGE_INFO['id']]['i18n']);
|
|
|
|
if (is_array($types)) {
|
|
foreach($types as $type) {
|
|
// Check capabilities
|
|
if (db_check_system_device_capabilities($type['id'], array(array("gprs","gsm"),"meting"))) {
|
|
// Check device name
|
|
if (stristr($type['naam'], "DU") !== FALSE) {
|
|
// Search for equipment
|
|
$equipment = db_fetch_lances($_SESSION[$_PAGE_INFO['id']]['login']['customer']['id'], "", $type['id'], 4, array("actief"), array("actief"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((is_array($equipment)) && (!empty($equipment))) {
|
|
// Collect equipment info (id, idcode and tcp-server)
|
|
$id = array();
|
|
$idcode = array();
|
|
$tcp_server = array();
|
|
|
|
foreach($equipment as $item) {
|
|
array_push($id , $item['id']);
|
|
array_push($idcode , str_replace(",", " ", $item['idcode']));
|
|
|
|
// Retrieve tcp server
|
|
$tcp_server_info = db_fetch("server", "adres","id='" . $item['tcp_server'] . "'");
|
|
|
|
array_push($tcp_server, ((is_array($tcp_server_info)) ? $tcp_server_info[0]['adres'] : ""));
|
|
}
|
|
|
|
// TWS3000/RS3000 send message
|
|
SendMessageRS3000(array("status='0'","equipment='" . implode(",", $idcode) . "'","equipment_id='" . implode(",", $id) . "'","equipment_tcp='" . implode(",", $tcp_server) . "'"));
|
|
}
|
|
else {
|
|
// TWS3000/RS3000
|
|
SendMessageRS3000(array("status='1'","message='label_equip_no'"));
|
|
}
|
|
}
|
|
else {
|
|
// Redirect to login page (and logout)
|
|
$_SESSION[$_PAGE_INFO['id']]['login_info']['errormsg'] = "Account has been blocked";
|
|
$_SESSION[$_PAGE_INFO['id']]['login_info']['username'] = $_SESSION[$_PAGE_INFO['id']]['login']['user']['name'];
|
|
$_SESSION[$_PAGE_INFO['id']]['login_info']['customer'] = $_SESSION[$_PAGE_INFO['id']]['login']['customer']['name'];
|
|
header("Location: ?id=" . $_PAGE_INFO['id'] . "&href=" . PAGE_LOGIN . "");
|
|
}
|
|
?>
|