0.3.14 after cleanup

This commit is contained in:
Garrett K 2021-03-16 04:43:12 +00:00
parent 2588822258
commit aad2c4da9a
12 changed files with 267 additions and 909 deletions

View File

@ -68,7 +68,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
break;
case 'connectionScan':
require_once '../includes/path_functions.php';
$validate->returnData['success'] = array();
$value = $data['value'];
if($value == 'clear') {
@ -224,7 +223,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
break;
case 'connectionExplore':
require_once '../includes/path_functions.php';
$validate->returnData['success'] = array();
$value = $data['value'];
$clear = $value == 'clear' ? true : false;

View File

@ -2,7 +2,6 @@
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('administrator.php');
require_once '../includes/path_functions.php';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once '../includes/Validate.class.php';

View File

@ -2,7 +2,7 @@
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('user.php');
require_once '../includes/path_functions.php';
//require_once '../includes/path_functions.php';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once '../includes/Validate.class.php';

View File

@ -2,7 +2,6 @@
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('administrator.php');
require_once '../includes/path_functions.php';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once '../includes/Validate.class.php';

487
backend/retrieve_connector_data.php Executable file → Normal file
View File

@ -1,244 +1,243 @@
<?php
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('operator.php');
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once('../includes/Validate.class.php');
$validate = new Validate($qls);
$validate->returnData['success'] = array();
if ($validate->returnData['active'] == 'inactive') {
echo json_encode($validate->returnData);
return;
}
$data = json_decode($_POST['data'], true);
validate($data, $validate);
if (!count($validate->returnData['error'])){
require_once '../includes/path_functions.php';
$connectorCode39 = strtoupper($data['connectorCode39']);
$connectorID = base_convert($connectorCode39, 36, 10);
$mediaTypeArray = $qls->App->mediaTypeArray;
$cableMediaTypeValueTable = $qls->App->mediaTypeValueArray;
$cableMediaCategoryTypeTable = $qls->App->mediaCategoryTypeArray;
// Does cable exist?
if($cable = $qls->App->inventoryByIDArray[$connectorID]) {
$validate->returnData['success'] = array();
$validate->returnData['success']['connectorTypeInfo'] = $qls->App->connectorTypeArray;
$validate->returnData['success']['cableMediaTypeInfo'] = getCableMediaTypeInfo($mediaTypeArray);
$validate->returnData['success']['cable'] = $cable;
$localAttrPrefix = $cable['localAttrPrefix'];
$remoteAttrPrefix = $cable['remoteAttrPrefix'];
// Retrieve local connector path
$localObjID = $cable['local_object_id'];
$localObjFace = $cable['local_object_face'];
$localObjDepth = $cable['local_object_depth'];
$localObjPort = $cable['local_object_port'];
$localConnectorFlatPath = $qls->App->generateObjectPortName($localObjID, $localObjFace, $localObjDepth, $localObjPort);
$validate->returnData['success']['localConnectorFlatPath'] = $localConnectorFlatPath;
// Retrieve unit of length
$mediaTypeID = $cable['mediaType'];
if($mediaTypeID != 0) {
$unitOfLength = $qls->App->getCableUnitOfLength($mediaTypeID);
} else {
$unitOfLength = 'm./ft.';
}
$length = calculateCableLength($cableMediaTypeValueTable, $cableMediaCategoryTypeTable, $cable, false);
$validate->returnData['success']['cable']['length'] = $length;
$validate->returnData['success']['cable']['unitOfLength'] = $unitOfLength;
// Is the remote end initialized?
if($cable['remoteEndID'] > 0) {
//Verify remote connector
if(isset($data['verifyCode39'])) {
$verifyCode39 = strtoupper($data['verifyCode39']);
if ($verifyCode39 == $cable['remoteEndCode39']) {
$validate->returnData['success']['verified'] = 'yes';
} else {
$validate->returnData['success']['verified'] = 'no';
}
} else {
$validate->returnData['success']['verified'] = 'unknown';
}
// Retrieve remote connector path
$remoteObjID = $cable['remote_object_id'];
$remoteObjFace = $cable['remote_object_face'];
$remoteObjDepth = $cable['remote_object_depth'];
$remoteObjPort = $cable['remote_object_port'];
$remoteConnectorFlatPath = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
$validate->returnData['success']['remoteConnectorFlatPath'] = $remoteConnectorFlatPath;
// Has the remote end been scanned for initialization?
} else if(isset($data['initializeCode39'])){
$initializeCode39 = strtoupper($data['initializeCode39']);
$initializeID = base_convert($initializeCode39, 36, 10);
if($initializeCode39 != $connectorCode39) {
// Is initializeID already initialized?
if($initializedExisting = $qls->App->inventoryByIDArray[$initializeID]) {
$initializedExisting = $qls->SQL->fetch_assoc($query);
if($initializedExisting['localEndID'] == 0 or $initializedExisting['remoteEndID'] == 0) {
$qls->SQL->update(
'app_inventory',
array(
$remoteAttrPrefix.'_id' => $initializedExisting['localEndID'],
$remoteAttrPrefix.'_code39' => $initializedExisting['localEndCode39'],
$remoteAttrPrefix.'_connector' => $initializedExisting['localConnector'],
$remoteAttrPrefix.'_object_id' => $initializedExisting['local_object_id'],
$remoteAttrPrefix.'_port_id' => $initializedExisting['local_object_port'],
$remoteAttrPrefix.'_object_face' => $initializedExisting['local_object_face'],
$remoteAttrPrefix.'_object_depth' => $initializedExisting['local_object_depth']
),
array(
$localAttrPrefix.'_id' => array('=', $connectorID)
)
);
$qls->SQL->delete('app_inventory', array('id' => array('=', $initializedExisting['rowID'])));
// Update cable object
$qls->App->inventoryByIDArray[$connectorID]['remoteEndID'] = $initializedExisting['localEndID'];
$qls->App->inventoryByIDArray[$connectorID]['remoteEndCode39'] = $initializedExisting['localEndCode39'];
$qls->App->inventoryByIDArray[$connectorID]['remoteConnector'] = $initializedExisting['localConnector'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_id'] = $initializedExisting['local_object_id'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_port'] = $initializedExisting['local_object_port'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_face'] = $initializedExisting['local_object_face'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_depth'] = $initializedExisting['local_object_depth'];
$cable = $qls->App->inventoryByIDArray[$connectorID];
$validate->returnData['success']['cable'] = $cable;
// Retrieve initialized remote connector path
$remoteObjID = $cable['remote_object_id'];
$remoteObjFace = $cable['remote_object_face'];
$remoteObjDepth = $cable['remote_object_depth'];
$remoteObjPort = $cable['remote_object_port'];
$remoteConnectorFlatPath = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
$validate->returnData['success']['remoteConnectorFlatPath'] = $remoteConnectorFlatPath;
} else {
$errorMsg = 'Invalid connector ID: '.$initializeID;
array_push($qls->App->returnData['error'], $errorMsg);
}
} else {
$qls->SQL->update(
'app_inventory',
array(
$remoteAttrPrefix.'_id' => $initializeID,
$remoteAttrPrefix.'_code39' => $initializeCode39,
),
array(
$localAttrPrefix.'_id' => array('=', $connectorID)
)
);
// Update cable object
$qls->App->inventoryByIDArray[$connectorID]['remoteEndID'] = $initializeID;
$qls->App->inventoryByIDArray[$connectorID]['remoteEndCode39'] = $initializeCode39;
$cable = $qls->App->inventoryByIDArray[$connectorID];
$validate->returnData['success']['cable'] = $cable;
// Reset length stuff... this is a hack
$validate->returnData['success']['cable']['length'] = $length;
$validate->returnData['success']['cable']['unitOfLength'] = $unitOfLength;
$validate->returnData['success']['remoteConnectorFlatPath'] = 'None';
}
} else {
$errMsg = 'Cannot initialize remote end with same ID as local end.';
array_push($validate->returnData['error'], $errMsg);
}
}
// Cable doesn't exist
} else {
$qls->SQL->insert(
'app_inventory',
array(
'a_id',
'a_code39'
),
array(
$connectorID,
$connectorCode39
)
);
$rowID = $qls->SQL->insert_id();
$validate->returnData['success']['connectorTypeInfo'] = $qls->App->connectorTypeArray;
$validate->returnData['success']['cableMediaTypeInfo'] = getCableMediaTypeInfo($mediaTypeArray);
$qls->App->inventoryByIDArray[$connectorID] = array(
'rowID' => $rowID,
'local_object_id' => 0,
'local_object_face' => 0,
'local_object_depth' => 0,
'local_object_port' => 0,
'remote_object_id' => 0,
'remote_object_face' => 0,
'remote_object_depth' => 0,
'remote_object_port' => 0,
'localEndID' => $connectorID,
'localEndCode39' => $connectorCode39,
'localConnector' => 0,
'localAttrPrefix' => 'a',
'remoteEndID' => 0,
'remoteEndCode39' => 0,
'remoteConnector' => 0,
'remoteAttrPrefix' => 'b',
'mediaType' => 0,
'length' => 1,
'editable' => 1
);
$cable = $validate->returnData['success']['cable'] = $qls->App->inventoryByIDArray[$connectorID];
$mediaTypeID = $validate->returnData['success']['cable']['mediaType'];
if($mediaTypeID != 0) {
$unitOfLength = $qls->App->getCableUnitOfLength($mediaTypeID);
} else {
$unitOfLength = 'm./ft.';
}
$length = calculateCableLength($cableMediaTypeValueTable, $cableMediaCategoryTypeTable, $cable, false);
$validate->returnData['success']['cable']['length'] = $length;
$validate->returnData['success']['cable']['unitOfLength'] = $unitOfLength;
$validate->returnData['success']['localConnectorFlatPath'] = 'None';
}
}
echo json_encode($validate->returnData);
return;
}
function validate($data, &$validate){
//Validate scanned Code39
$validate->validateCode39($data['connectorCode39'], 'scanned Code39');
//Validate verify Code39
if (isset($data['verifyCode39'])){
$validate->validateCode39($data['verifyCode39'], 'verifying Code39');
}
//Validate initialize Code39
if (isset($data['initializeCode39'])){
$validate->validateCode39($data['initializeCode39'], 'initializing Code39');
}
return;
}
function getCableMediaTypeInfo($cableMediaTypeTable){
$cableMediaTypeInfo = array();
foreach($cableMediaTypeTable as $row) {
$cableMediaTypeInfo[$row['value']] = $row['name'];
}
return $cableMediaTypeInfo;
}
?>
<?php
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('operator.php');
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once('../includes/Validate.class.php');
$validate = new Validate($qls);
$validate->returnData['success'] = array();
if ($validate->returnData['active'] == 'inactive') {
echo json_encode($validate->returnData);
return;
}
$data = json_decode($_POST['data'], true);
validate($data, $validate);
if (!count($validate->returnData['error'])){
require_once '../includes/path_functions.php';
$connectorCode39 = strtoupper($data['connectorCode39']);
$connectorID = base_convert($connectorCode39, 36, 10);
$mediaTypeArray = $qls->App->mediaTypeArray;
$cableMediaTypeValueTable = $qls->App->mediaTypeValueArray;
$cableMediaCategoryTypeTable = $qls->App->mediaCategoryTypeArray;
// Does cable exist?
if($cable = $qls->App->inventoryByIDArray[$connectorID]) {
$validate->returnData['success'] = array();
$validate->returnData['success']['connectorTypeInfo'] = $qls->App->connectorTypeArray;
$validate->returnData['success']['cableMediaTypeInfo'] = getCableMediaTypeInfo($mediaTypeArray);
$validate->returnData['success']['cable'] = $cable;
$localAttrPrefix = $cable['localAttrPrefix'];
$remoteAttrPrefix = $cable['remoteAttrPrefix'];
// Retrieve local connector path
$localObjID = $cable['local_object_id'];
$localObjFace = $cable['local_object_face'];
$localObjDepth = $cable['local_object_depth'];
$localObjPort = $cable['local_object_port'];
$localConnectorFlatPath = $qls->App->generateObjectPortName($localObjID, $localObjFace, $localObjDepth, $localObjPort);
$validate->returnData['success']['localConnectorFlatPath'] = $localConnectorFlatPath;
// Retrieve unit of length
$mediaTypeID = $cable['mediaType'];
if($mediaTypeID != 0) {
$unitOfLength = $qls->App->getCableUnitOfLength($mediaTypeID);
} else {
$unitOfLength = 'm./ft.';
}
$length = calculateCableLength($cableMediaTypeValueTable, $cableMediaCategoryTypeTable, $cable, false);
$validate->returnData['success']['cable']['length'] = $length;
$validate->returnData['success']['cable']['unitOfLength'] = $unitOfLength;
// Is the remote end initialized?
if($cable['remoteEndID'] > 0) {
//Verify remote connector
if(isset($data['verifyCode39'])) {
$verifyCode39 = strtoupper($data['verifyCode39']);
if ($verifyCode39 == $cable['remoteEndCode39']) {
$validate->returnData['success']['verified'] = 'yes';
} else {
$validate->returnData['success']['verified'] = 'no';
}
} else {
$validate->returnData['success']['verified'] = 'unknown';
}
// Retrieve remote connector path
$remoteObjID = $cable['remote_object_id'];
$remoteObjFace = $cable['remote_object_face'];
$remoteObjDepth = $cable['remote_object_depth'];
$remoteObjPort = $cable['remote_object_port'];
$remoteConnectorFlatPath = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
$validate->returnData['success']['remoteConnectorFlatPath'] = $remoteConnectorFlatPath;
// Has the remote end been scanned for initialization?
} else if(isset($data['initializeCode39'])){
$initializeCode39 = strtoupper($data['initializeCode39']);
$initializeID = base_convert($initializeCode39, 36, 10);
if($initializeCode39 != $connectorCode39) {
// Is initializeID already initialized?
if($initializedExisting = $qls->App->inventoryByIDArray[$initializeID]) {
$initializedExisting = $qls->SQL->fetch_assoc($query);
if($initializedExisting['localEndID'] == 0 or $initializedExisting['remoteEndID'] == 0) {
$qls->SQL->update(
'app_inventory',
array(
$remoteAttrPrefix.'_id' => $initializedExisting['localEndID'],
$remoteAttrPrefix.'_code39' => $initializedExisting['localEndCode39'],
$remoteAttrPrefix.'_connector' => $initializedExisting['localConnector'],
$remoteAttrPrefix.'_object_id' => $initializedExisting['local_object_id'],
$remoteAttrPrefix.'_port_id' => $initializedExisting['local_object_port'],
$remoteAttrPrefix.'_object_face' => $initializedExisting['local_object_face'],
$remoteAttrPrefix.'_object_depth' => $initializedExisting['local_object_depth']
),
array(
$localAttrPrefix.'_id' => array('=', $connectorID)
)
);
$qls->SQL->delete('app_inventory', array('id' => array('=', $initializedExisting['rowID'])));
// Update cable object
$qls->App->inventoryByIDArray[$connectorID]['remoteEndID'] = $initializedExisting['localEndID'];
$qls->App->inventoryByIDArray[$connectorID]['remoteEndCode39'] = $initializedExisting['localEndCode39'];
$qls->App->inventoryByIDArray[$connectorID]['remoteConnector'] = $initializedExisting['localConnector'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_id'] = $initializedExisting['local_object_id'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_port'] = $initializedExisting['local_object_port'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_face'] = $initializedExisting['local_object_face'];
$qls->App->inventoryByIDArray[$connectorID]['remote_object_depth'] = $initializedExisting['local_object_depth'];
$cable = $qls->App->inventoryByIDArray[$connectorID];
$validate->returnData['success']['cable'] = $cable;
// Retrieve initialized remote connector path
$remoteObjID = $cable['remote_object_id'];
$remoteObjFace = $cable['remote_object_face'];
$remoteObjDepth = $cable['remote_object_depth'];
$remoteObjPort = $cable['remote_object_port'];
$remoteConnectorFlatPath = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
$validate->returnData['success']['remoteConnectorFlatPath'] = $remoteConnectorFlatPath;
} else {
$errorMsg = 'Invalid connector ID: '.$initializeID;
array_push($qls->App->returnData['error'], $errorMsg);
}
} else {
$qls->SQL->update(
'app_inventory',
array(
$remoteAttrPrefix.'_id' => $initializeID,
$remoteAttrPrefix.'_code39' => $initializeCode39,
),
array(
$localAttrPrefix.'_id' => array('=', $connectorID)
)
);
// Update cable object
$qls->App->inventoryByIDArray[$connectorID]['remoteEndID'] = $initializeID;
$qls->App->inventoryByIDArray[$connectorID]['remoteEndCode39'] = $initializeCode39;
$cable = $qls->App->inventoryByIDArray[$connectorID];
$validate->returnData['success']['cable'] = $cable;
// Reset length stuff... this is a hack
$validate->returnData['success']['cable']['length'] = $length;
$validate->returnData['success']['cable']['unitOfLength'] = $unitOfLength;
$validate->returnData['success']['remoteConnectorFlatPath'] = 'None';
}
} else {
$errMsg = 'Cannot initialize remote end with same ID as local end.';
array_push($validate->returnData['error'], $errMsg);
}
}
// Cable doesn't exist
} else {
$qls->SQL->insert(
'app_inventory',
array(
'a_id',
'a_code39'
),
array(
$connectorID,
$connectorCode39
)
);
$rowID = $qls->SQL->insert_id();
$validate->returnData['success']['connectorTypeInfo'] = $qls->App->connectorTypeArray;
$validate->returnData['success']['cableMediaTypeInfo'] = getCableMediaTypeInfo($mediaTypeArray);
$qls->App->inventoryByIDArray[$connectorID] = array(
'rowID' => $rowID,
'local_object_id' => 0,
'local_object_face' => 0,
'local_object_depth' => 0,
'local_object_port' => 0,
'remote_object_id' => 0,
'remote_object_face' => 0,
'remote_object_depth' => 0,
'remote_object_port' => 0,
'localEndID' => $connectorID,
'localEndCode39' => $connectorCode39,
'localConnector' => 0,
'localAttrPrefix' => 'a',
'remoteEndID' => 0,
'remoteEndCode39' => 0,
'remoteConnector' => 0,
'remoteAttrPrefix' => 'b',
'mediaType' => 0,
'length' => 1,
'editable' => 1
);
$cable = $validate->returnData['success']['cable'] = $qls->App->inventoryByIDArray[$connectorID];
$mediaTypeID = $validate->returnData['success']['cable']['mediaType'];
if($mediaTypeID != 0) {
$unitOfLength = $qls->App->getCableUnitOfLength($mediaTypeID);
} else {
$unitOfLength = 'm./ft.';
}
$length = calculateCableLength($cableMediaTypeValueTable, $cableMediaCategoryTypeTable, $cable, false);
$validate->returnData['success']['cable']['length'] = $length;
$validate->returnData['success']['cable']['unitOfLength'] = $unitOfLength;
$validate->returnData['success']['localConnectorFlatPath'] = 'None';
}
}
echo json_encode($validate->returnData);
return;
}
function validate($data, &$validate){
//Validate scanned Code39
$validate->validateCode39($data['connectorCode39'], 'scanned Code39');
//Validate verify Code39
if (isset($data['verifyCode39'])){
$validate->validateCode39($data['verifyCode39'], 'verifying Code39');
}
//Validate initialize Code39
if (isset($data['initializeCode39'])){
$validate->validateCode39($data['initializeCode39'], 'initializing Code39');
}
return;
}
function getCableMediaTypeInfo($cableMediaTypeTable){
$cableMediaTypeInfo = array();
foreach($cableMediaTypeTable as $row) {
$cableMediaTypeInfo[$row['value']] = $row['name'];
}
return $cableMediaTypeInfo;
}

View File

@ -1,7 +1,6 @@
<?php
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
//require_once '../includes/path_functions.php';
$qls->Security->check_auth_page('user.php');
if($_SERVER['REQUEST_METHOD'] == 'POST'){

View File

@ -1,189 +0,0 @@
<?php
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('operator.php');
require_once '../includes/path_functions.php';
//[0] = element type
//[1] = element ID
//[2] = element face
//[3] = element depth
//[4] = port index
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$return = array(
'error' => '',
'result' => array()
);
$data = $_POST;
$return['error'] = validate($data, $qls);
if (count($return['error']) == 0){
$children = array();
$selected = '';
$valueArray = explode('-', $data['value']);
$elementType = $valueArray[0];
$elementID = $valueArray[1];
$elementFace = $valueArray[2];
$elementDepth = $valueArray[3];
$elementPortIndex = $valueArray[4];
$connectorID = $data['connectorID'];
$cableEnd = $data['cableEnd'];
$connectorPathAttribute = $cableEnd == 'a' ? 'a_path' : 'b_path';
$connectorAttributePrefix = $cableEnd == 'a' ? 'a' : 'b';
$connectorIDAttribute = $cableEnd == 'a' ? 'a_id' : 'b_id';
$connectorObjectIDAttribute = $cableEnd == 'a' ? 'a_object_id' : 'b_object_id';
$connectorPortIDAttribute = $cableEnd == 'a' ? 'a_port_id' : 'b_port_id';
$connectorRootIDAttribute = $cableEnd == 'a' ? 'a_root_id' : 'b_root_id';
$connectorFaceAttribute = $cableEnd == 'a' ? 'a_object_face' : 'b_object_face';
$connectorDepthAttribute = $cableEnd == 'a' ? 'a_object_depth' : 'b_object_depth';
$action = $data['action'];
$query = $qls->SQL->select('*', 'app_inventory', array($connectorIDAttribute => array('=', $connectorID)));
$cable = $qls->SQL->fetch_assoc($query);
if($action == 'SELECT'){
// Clear path
if($elementID == 0) {
$qls->SQL->update(
'app_inventory',
array(
$connectorAttributePrefix.'_object_id' => 0,
$connectorAttributePrefix.'_port_id' => 0,
$connectorAttributePrefix.'_object_face' => 0,
$connectorAttributePrefix.'_object_depth' => 0
),
array(
$connectorIDAttribute => array('=', $cable[$connectorIDAttribute])
)
);
$children = buildLocation('#', $qls);
$resultData = array('selected' => 'clear', 'children' => $children);
array_push($return['result'], $resultData);
// Location selected
} else if($elementType == 0) {
$children = buildLocation($elementID, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($return['result'], $resultData);
// Cabinet selected
} else if($elementType == 1) {
$children = buildObjectsConnector($elementID, $cable, $connectorAttributePrefix, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($return['result'], $resultData);
// Object selected
} else if($elementType == 2) {
$children = buildPorts($elementID, $elementFace, $cable, $connectorAttributePrefix, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($return['result'], $resultData);
// Port selected
} else if($elementType == 4) {
$inverseConnectorAttributePrefix = $connectorAttributePrefix == 'a' ? 'b' : 'a';
// 'b', cable(17), 34, 0, 1, 0
$peerID = $cable[$inverseConnectorAttributePrefix.'_object_id'];
$peerFace = $cable[$inverseConnectorAttributePrefix.'_object_face'];
$peerDepth = $cable[$inverseConnectorAttributePrefix.'_object_depth'];
$peerPort = $cable[$inverseConnectorAttributePrefix.'_port_id'];
if($qls->App->loopDetected2($peerID, $peerFace, $peerDepth, $peerPort, $elementID, $elementFace, $elementDepth, $elementPortIndex)) {
array_push($return['error'], 'Loop detected.');
} else {
$qls->SQL->update(
'app_inventory',
array(
$connectorAttributePrefix.'_object_id' => $elementID,
$connectorAttributePrefix.'_port_id' => $elementPortIndex,
$connectorAttributePrefix.'_object_face' => $elementFace,
$connectorAttributePrefix.'_object_depth' => $elementDepth
),
array(
$connectorAttributePrefix.'_id' => array('=', $cable[$connectorIDAttribute])
)
);
$qls->SQL->delete(
'app_populated_port',
array(
'object_id' => array('=', $elementID),
'AND',
'object_face' => array('=', $elementFace),
'AND',
'object_depth' => array('=', $elementDepth),
'AND',
'port_id' => array('=', $elementPortIndex)
)
);
array_push($return['result'], 'FIN');
}
}
} else if($action == 'GET') {
if($cable[$connectorObjectIDAttribute] == 0) {
$children = buildLocation($elementID, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($return['result'], $resultData);
} else {
$path = buildConnectorPath($cable, $connectorAttributePrefix, $qls);
$return['result'] = $path;
}
}
}
echo json_encode($return);
}
function validate($data, &$qls){
$elementTypeArray = array('initial', 'location', 'cabinet', 'Connectable', 'Enclosure', 'Insert', 'port');
$error = [];
//Validate elementType
if (!isset($data['value'])){
array_push($error, array('alert' => 'Error: Element data is required.'));
} else {
$dataValue = explode('-', $data['value']);
if (count($dataValue) != 5){
array_push($error, array('alert' => 'Error: Invalid data value.'));
} else {
if (!preg_match('/^[0-9]+$/', $dataValue[0])){
array_push($error, array('alert' => 'Error: Invalid element type.'));
}
if (!preg_match('/^[#0-9]+$/', $dataValue[1])){
array_push($error, array('alert' => 'Error: Invalid element ID.'));
}
if (!preg_match('/^[01]$/', $dataValue[2])){
array_push($error, array('alert' => 'Error: Invalid element face.'));
}
if (!preg_match('/^[0-9]+$/', $dataValue[3])){
array_push($error, array('alert' => 'Error: Invalid partition ID.'));
}
if (!preg_match('/^[0-9]+$/', $dataValue[4])){
array_push($error, array('alert' => 'Error: Invalid port ID.'));
}
}
}
//Validate cableEnd
if (!isset($data['cableEnd'])){
array_push($error, array('alert' => 'Error: Cable end value is required.'));
} else {
if (!preg_match('/^[ab]$/', $data['cableEnd'])){
array_push($error, array('alert' => 'Error: Invalid cable end value.'));
}
}
//Validate cableID
if (!isset($data['connectorID'])){
array_push($error, array('alert' => 'Error: Connector ID is required.'));
} else {
if (!preg_match('/^[0-9]+$/', $data['connectorID'])){
array_push($error, array('alert' => 'Error: Invalid connector ID.'));
}
}
return $error;
}
?>

View File

@ -1,98 +0,0 @@
<?php
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('user.php');
require_once '../includes/path_functions.php';
//[0] = element type
//[1] = element ID
//[2] = element face
//[3] = element depth
//[4] = port index
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once '../includes/Validate.class.php';
$validate = new Validate($qls);
$validate->returnData['success'] = array();
if ($validate->returnData['active'] == 'inactive') {
echo json_encode($validate->returnData);
return;
}
$data = json_decode($_POST['data'], true);
validate($data, $validate, $qls);
if (!count($validate->returnData['error'])){
$children = array();
$selected = '';
$valueArray = explode('-', $data['value']);
$elementType = $valueArray[0];
$elementID = $valueArray[1];
$elementFace = $valueArray[2];
$elementDepth = $valueArray[3];
$elementPortIndex = $valueArray[4];
// Clear path
if($elementID == 0) {
$children = buildLocation('#', $qls);
$resultData = array('selected' => 'clear', 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Location selected
} else if($elementType == 0) {
$children = buildLocation($elementID, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Cabinet selected
} else if($elementType == 1) {
$clickedObjID = $data['clickedObjID'];
$clickedObjFace = $data['clickedObjFace'];
$clickedObjDepth = $data['clickedObjDepth'];
$children = buildObjectsPathFinder($elementID, $clickedObjID, $clickedObjFace, $clickedObjDepth, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Object selected
} else if($elementType == 2) {
$clickedObjID = $data['clickedObjID'];
$clickedObjFace = $data['clickedObjFace'];
$clickedObjDepth = $data['clickedObjDepth'];
$clickedObjPortID = $data['clickedObjPortID'];
$children = buildPortsPathFinder($elementID, $elementFace, $clickedObjID, $clickedObjFace, $clickedObjDepth, $clickedObjPortID, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Port selected
} else if($elementType == 4) {
$selectedObjID = $elementID;
$selectedObjFace = $elementFace;
$selectedObjDepth = $elementDepth;
$selectedObjPortID = $elementPortIndex;
$validate->returnData['success'] = array('FIN', $selectedObjID, $selectedObjFace, $selectedObjDepth, $selectedObjPortID);
}
}
echo json_encode($validate->returnData);
}
function validate($data, &$qls){
$error = [];
//Validate elementType
if (!isset($data['value'])){
array_push($error, array('alert' => 'Error: Element data is required.'));
} else {
$dataValue = explode('-', $data['value']);
if (count($dataValue) != 5){
array_push($error, array('alert' => 'Error: Invalid data value.'));
} else {
$x=true;
}
}
return $error;
}
?>

View File

@ -26,6 +26,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Create $path
include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path2.php';
$validate->returnData['success'] = $qls->App->buildPathFull2($pathArray);
error_log('Debug (pathArray): '.json_encode($pathArray));
}
echo json_encode($validate->returnData);
}

View File

@ -1,159 +0,0 @@
<?php
define('QUADODO_IN_SYSTEM', true);
require_once '../includes/header.php';
$qls->Security->check_auth_page('user.php');
require_once '../includes/path_functions.php';
//[0] = element type
//[1] = element ID
//[2] = element face
//[3] = element depth
//[4] = port index
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require_once('../includes/Validate.class.php');
$validate = new Validate($qls);
$validate->returnData['success'] = array();
if ($validate->returnData['active'] == 'inactive') {
echo json_encode($validate->returnData);
return;
}
$data = json_decode($_POST['data'], true);
validate($data, $validate);
if (!count($validate->returnData['error'])){
$children = array();
$selected = '';
$valueArray = explode('-', $data['value']);
$elementType = $valueArray[0];
$elementID = $valueArray[1];
$elementFace = $valueArray[2];
$elementDepth = $valueArray[3];
$elementPortIndex = $valueArray[4];
$objectID = $data['objID'];
$objectFace = $data['objFace'];
$partitionDepth = $data['partitionDepth'];
$action = $data['action'];
$query = $qls->SQL->select('*', 'app_object', array('id' => array('=', $objectID)));
$object = $qls->SQL->fetch_assoc($query);
if($action == 'SELECT'){
// Clear path
if($elementID == 0) {
$query = $qls->SQL->select('*', 'app_object_peer', array('a_id' => array('=', $objectID), 'OR', 'b_id' => array('=', $objectID)));
$qls->SQL->delete('app_object_peer', array('a_id' => array('=', $objectID), 'OR', 'b_id' => array('=', $objectID)));
$children = buildLocation('#', $qls);
$resultData = array('selected' => 'clear', 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Location selected
} else if($elementType == 0) {
$children = buildLocation($elementID, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Cabinet selected
} else if($elementType == 1) {
$children = buildObjects($elementID, $object, $objectFace, $partitionDepth, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Object selected
} else if($elementType == 2) {
$children = buildPartitions($elementID, $elementFace, $object, $objectFace, $partitionDepth, $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
// Partition selected
} else if($elementType == 3) {
$query = $qls->SQL->select('partitionFunction', 'app_object_compatibility', array('template_id' => array('=', $object['template_id'])));
$partitionFunction = $qls->SQL->fetch_assoc($query);
$objectEndpoint = $partitionFunction['partitionFunction'] == 'Endpoint' ? 1 : 0;
$query = $qls->SQL->select('*', 'app_object', array('id' => array('=', $elementID)));
$element = $qls->SQL->fetch_assoc($query);
$query = $qls->SQL->select('partitionFunction', 'app_object_compatibility', array('template_id' => array('=', $element['template_id'])));
$partitionFunction = $qls->SQL->fetch_assoc($query);
$elementEndpoint = $partitionFunction['partitionFunction'] == 'Endpoint' ? 1 : 0;
$qls->SQL->delete('app_object_peer', array('a_id' => array('=', $objectID), 'AND', 'a_face' => array('=', $objectFace), 'AND', 'a_depth' => array('=', $partitionDepth)));
$qls->SQL->delete('app_object_peer', array('b_id' => array('=', $objectID), 'AND', 'b_face' => array('=', $objectFace), 'AND', 'b_depth' => array('=', $partitionDepth)));
$qls->SQL->delete('app_object_peer', array('a_id' => array('=', $elementID), 'AND', 'a_face' => array('=', $elementFace), 'AND', 'a_depth' => array('=', $elementDepth)));
$qls->SQL->delete('app_object_peer', array('b_id' => array('=', $elementID), 'AND', 'b_face' => array('=', $elementFace), 'AND', 'b_depth' => array('=', $elementDepth)));
$qls->SQL->insert(
'app_object_peer',
array(
'a_id',
'a_face',
'a_depth',
'a_endpoint',
'b_id',
'b_face',
'b_depth',
'b_endpoint'
),
array(
$objectID,
$objectFace,
$partitionDepth,
$objectEndpoint,
$elementID,
$elementFace,
$elementDepth,
$elementEndpoint
)
);
array_push($validate->returnData['success'], 'FIN');
}
} else if($action == 'GET') {
$queryString = '(a_id = '.$objectID.' AND a_face = '.$objectFace.' AND a_depth = '.$partitionDepth.') OR (b_id = '.$objectID.' AND b_face = '.$objectFace.' AND b_depth = '.$partitionDepth.')';
//$query = $qls->SQL->select('*', 'app_object_peer', array('a_id' => array('=', $objectID), 'OR', 'b_id' => array('=', $objectID)));
$query = $qls->SQL->select('*', 'app_object_peer', $queryString);
$peerRecord = $qls->SQL->fetch_assoc($query);
if(!count($peerRecord)) {
$children = buildLocation('#', $qls);
$resultData = array('selected' => $selected, 'children' => $children);
array_push($validate->returnData['success'], $resultData);
} else {
$peerPrefix = $peerRecord['a_id'] == $objectID ? 'b' : 'a';
$objectPrefix = $peerRecord['a_id'] == $objectID ? 'a' : 'b';
$peerID = $peerRecord[$peerPrefix.'_id'];
$peerFace = $peerRecord[$peerPrefix.'_face'];
$peerDepth = $peerRecord[$peerPrefix.'_depth'];
$objectFace = $peerRecord[$objectPrefix.'_face'];
$objectDepth = $peerRecord[$objectPrefix.'_depth'];
$query = $qls->SQL->select('*', 'app_object', array('id' => array('=', $peerID)));
$peer = $qls->SQL->fetch_assoc($query);
$path = buildPath($peer, $peerFace, $peerDepth, $object, $objectFace, $objectDepth, $qls);
$validate->returnData['success'] = $path;
}
$validate->returnData['pathArray'] = buildPathArray($validate->returnData['success']);
}
}
//echo json_encode($return);
echo json_encode($validate->returnData);
return;
}
function validate($data, &$validate){
if($data['action'] != 'GET') {
//Validate elementType
$validate->validateElementValue($data['value']);
}
//Validate objectID
$validate->validateObjectID($data['objID']);
return;
}
?>

View File

@ -3232,7 +3232,7 @@ var $qls;
return str_replace('&#8209;', '-', $string);
}
function crawlPath2($objID, $objFace, $objDepth, $objPort, $detectDivergence=false, &$pathArray=array(array(array(),array())), &$visitedArray=array(), $pathArrayIndex=0, $outerDirection=0, $innerDirection=0, $initial=true){
function crawlPath2($objID, $objFace, $objDepth, $objPort, $detectDivergence=false, $portDiverges=false, &$pathArray=array(array(array(),array())), &$visitedArray=array(), $pathArrayIndex=0, $outerDirection=0, $innerDirection=0, $initial=true){
// $outerDirection - 0=up 1=down
// $innerDirection - 0=near 1=far
@ -3266,6 +3266,7 @@ var $qls;
'objDepth' => $objDepth,
'objPort' => $objPort,
'selected' => $initial,
'portDiverges' => $portDiverges,
'length' => $length,
'mediaTypeID' => $mediaTypeID,
'connectorTypeID' => $connectorTypeID
@ -3291,6 +3292,7 @@ var $qls;
// Loop over each local port connection
$inventoryEntry = $this->inventoryArray[$objID][$objFace][$objDepth][$objPort];
$organicPathObjParentID = $this->getParentObjID($inventoryEntry[0]['id']);
foreach($inventoryEntry as $connection) {
// Collect remote object data
@ -3299,6 +3301,14 @@ var $qls;
$remoteObjDepth = $connection['depth'];
$remoteObjPort = $connection['port'];
$newPortDiverges = $portDiverges;
if(!$newPortDiverges) {
$remoteObjParentID = $this->getParentObjID($remoteObjID);
if($remoteObjParentID != $organicPathObjParentID) {
$newPortDiverges = true;
}
}
// Generate remote port hash
$remotePortAddressString = $remoteObjID.'_'.$remoteObjFace.'_'.$remoteObjDepth.'_'.$remoteObjPort;
$remotePortAddressMD5 = md5($remotePortAddressString);
@ -3308,7 +3318,7 @@ var $qls;
// Get path array index... it could change during recursion
$pathArrayIndex = $this->getCurrentPathIndex($pathArray, $portAddressMD5);
$this->crawlPath2($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $detectDivergence, $pathArray, $visitedArray, $pathArrayIndex, $outerDirection, $newInnerDirection, false);
$this->crawlPath2($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $detectDivergence, $newPortDiverges, $pathArray, $visitedArray, $pathArrayIndex, $outerDirection, $newInnerDirection, false);
}
}
}
@ -3373,7 +3383,7 @@ var $qls;
}
$innerDirection = 0;
$this->crawlPath2($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $detectDivergence, $pathArray, $visitedArray, $pathArrayIndex, $outerDirection, $innerDirection, false);
$this->crawlPath2($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $detectDivergence, $portDiverges, $pathArray, $visitedArray, $pathArrayIndex, $outerDirection, $innerDirection, false);
}
}
@ -3404,216 +3414,16 @@ var $qls;
return false;
}
function crawlPath($objID, $objFace, $objDepth, $objPort, $detectDivergence=false){
// pathArray contains all necessary path data
$pathArray = array();
// Retrieve initial connection set
$selected = true;
$connSet = $this->crawlConn($selected, $objID, $objFace, $objDepth, $objPort);
$selected = false;
if($detectDivergence) {
$this->detectDivergence($connSet[0]);
$this->detectDivergence($connSet[1]);
}
array_push($pathArray, $connSet);
for($direction=0; $direction<2; $direction++) {
do {
// Set path array pointer
// 0 for up, -1 for down
$pathArrayPointer = ($direction == 0) ? 0 : count($pathArray)-1;
// Get port trunk peer
$trunkSet = $this->crawlTrunk($pathArray[$pathArrayPointer][$direction]);
if($detectDivergence) {
$this->detectDivergence($trunkSet);
}
$trunkSetCount = count($trunkSet);
$trunkFound = ($trunkSetCount) ? true : false;
// Find connections for each trunked port
$workingConnSet = array(array(),array());
foreach($trunkSet as $port) {
// Store port info
$remoteObjID = $port['objID'];
$remoteObjFace = $port['objFace'];
$remoteObjDepth = $port['objDepth'];
$remoteObjPort = $port['objPort'];
// Find connections
$connSet = $this->crawlConn($selected, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort);
if($detectDivergence) {
$this->detectDivergence($connSet[0]);
$this->detectDivergence($connSet[1]);
}
// Determine where in workingConnSet ports should be added
$connSetIndexArray = array(0,1);
if($direction == 0) {
$workingConnSetIndexMappingArray = array(1,0);
} else {
$workingConnSetIndexMappingArray = array(0,1);
}
// Add ports to workingConnSet
foreach($connSetIndexArray as $connSetIndexID => $connSetIndex) {
foreach($connSet[$connSetIndex] as $port) {
// Determine if duplicate exists
$dupFound = false;
foreach($workingConnSet[$workingConnSetIndexMappingArray[$connSetIndexID]] as $existingPort) {
if($port['objID'] == $existingPort['objID'] and $port['objFace'] == $existingPort['objFace'] and $port['objDepth'] == $existingPort['objDepth'] and $port['objPort'] == $existingPort['objPort']) {
$dupFound = true;
}
}
// Append port to workingConnSet
if(!$dupFound) {
array_push($workingConnSet[$workingConnSetIndexMappingArray[$connSetIndexID]], $port);
}
}
}
foreach($connSet[0] as $localFoundPort) {
$isInitial = false;
foreach($trunkSet as $localInitialPort) {
if($localFoundPort['objID'] == $localInitialPort['objID'] and $localFoundPort['objFace'] == $localInitialPort['objFace'] and $localFoundPort['objDepth'] == $localInitialPort['objDepth'] and $localFoundPort['objPort'] == $localInitialPort['objPort']) {
$isInitial = true;
}
}
}
}
// Add connection set to appropriate end of pathArray
if($trunkFound) {
if($direction == 0) {
array_unshift($pathArray, $workingConnSet);
} else {
array_push($pathArray, $workingConnSet);
}
}
} while($trunkFound);
}
return $pathArray;
}
function crawlTrunk($portSet) {
$trunkSet = array();
// Loop over each port of $conn
foreach($portSet as $portSetID => $port) {
// Gather port data
$objID = $port['objID'];
$objFace = $port['objFace'];
$objDepth = $port['objDepth'];
$objPort = $port['objPort'];
// Gather trunk peer data
if(isset($this->peerArray[$objID][$objFace][$objDepth])) {
// Gather trunk peer object
$peer = $this->peerArray[$objID][$objFace][$objDepth];
// Gather trunk peer data
$peerObjID = $peer['peerID'];
$peerObjFace = $peer['peerFace'];
$peerObjDepth = $peer['peerDepth'];
$peerObjPort = $objPort;
// Create a working array for cleanliness
$workingArray = array(
'objID' => $peerObjID,
'objFace' => $peerObjFace,
'objDepth' => $peerObjDepth,
'objPort' => $peerObjPort
);
// Store trunk data
$trunkSet[$portSetID] = $workingArray;
}
function getParentObjID($objID) {
while($this->objectArray[$objID]['parent_id'] != 0) {
$objID = $this->objectArray[$objID]['parent_id'];
}
return $trunkSet;
return $objID;
}
function crawlConn($selected, $objID, $objFace, $objDepth, $objPort, &$connSet=array(array(),array()), $connSetID=0) {
// Store cable details
$managedCableID = (isset($this->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $this->inventoryArray[$objID][$objFace][$objDepth][$objPort][0]['localEndID'] : 0;
if($managedCableID != 0) {
$managedCable = $this->inventoryByIDArray[$managedCableID];
$managedCableMediaTypeID = $managedCable['mediaType'];
$managedCableLength = $managedCable['length'];
$includeUnit = true;
$length = $this->calculateCableLength($managedCableMediaTypeID, $managedCableLength, $includeUnit);
$mediaTypeID = $managedCable['mediaType'];
$connectorTypeID = $managedCable['localConnector'];
} else {
$length = 'Unk. Length';
$mediaTypeID = false;
$connectorTypeID = false;
}
// Store port details
$workingArray = array(
'objID' => $objID,
'objFace' => $objFace,
'objDepth' => $objDepth,
'objPort' => $objPort,
'selected' => $selected,
'length' => $length,
'mediaTypeID' => $mediaTypeID,
'connectorTypeID' => $connectorTypeID
);
// Add port info to connection set
array_push($connSet[$connSetID], $workingArray);
// Is local port connected?
if(isset($this->inventoryArray[$objID][$objFace][$objDepth][$objPort])) {
// Flip the connection set ID
$connSetID = ($connSetID == 0) ? 1 : 0;
// Loop over each local port connection
$inventoryEntry = $this->inventoryArray[$objID][$objFace][$objDepth][$objPort];
foreach($inventoryEntry as $connection) {
// Collect remote object data
$remoteObjID = $connection['id'];
$remoteObjFace = $connection['face'];
$remoteObjDepth = $connection['depth'];
$remoteObjPort = $connection['port'];
// Verify this node has not been visited already
$alreadySeen = false;
foreach($connSet as $conn) {
foreach($conn as $port) {
if($port['objID'] == $remoteObjID and $port['objFace'] == $remoteObjFace and $port['objDepth'] == $remoteObjDepth and $port['objPort'] == $remoteObjPort) {
$alreadySeen = true;
}
}
}
if(!$alreadySeen) {
$selected = false;
$this->crawlConn($selected, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSet, $connSetID);
}
}
}
return $connSet;
}
function detectDivergence(&$dataSet) {
$pathDiverges = false;
@ -3652,8 +3462,8 @@ var $qls;
$visitedArray = array();
$loopDetected = false;
$pathArrayA = $this->crawlPath($aID, $aFace, $aDepth, $aPort);
$pathArrayB = $this->crawlPath($bID, $bFace, $bDepth, $bPort);
$pathArrayA = $this->crawlPath2($aID, $aFace, $aDepth, $aPort);
$pathArrayB = $this->crawlPath2($bID, $bFace, $bDepth, $bPort);
$pathArray = array($pathArrayA, $pathArrayB);
foreach($pathArray as $path) {

View File

@ -1,6 +1,5 @@
<?php
require_once './includes/shared_tables.php';
require_once './includes/path_functions.php';
$pillYes = '<span class="label label-pill label-success">Yes</span>';
$pillNo = '<span class="label label-pill label-danger">No</span>';
@ -28,8 +27,8 @@
$query = $qls->SQL->select('*', 'app_inventory', array('active' => array('=', 1)));
while($row = $qls->SQL->fetch_assoc($query)) {
$mediaTypeID = $row['mediaType'];
$categoryTypeID = $mediaTypeTable[$mediaTypeID]['category_type_id'];
$length = calculateCableLength($mediaTypeTable, $mediaCategoryTypeTable, $row);
$lengthValue = $row['length'];
$length = $qls->App->calculateCableLength($mediaTypeID, $lengthValue);
echo '<tr>';
echo '<td data-connectorID="'.$row['a_code39'].'"><a class="linkScan" href="#">'.$row['a_code39'].'</a><button class="displayBarcode pull-right btn btn-sm waves-effect waves-light btn-primary"><i class="fa fa-barcode"></i></button></td>';