Beispiel #1
0
 static function followPathToEndPoint($DeviceID, $PortNumber)
 {
     $path = array();
     $n = sizeof($path);
     $dev = new Device();
     $dev->DeviceID = $DeviceID;
     $dev->getDevice();
     $path[$n] = new DevicePorts();
     $path[$n]->DeviceID = $DeviceID;
     $path[$n]->PortNumber = $dev->DeviceType == "Patch Panel" ? -$PortNumber : $PortNumber;
     $path[$n]->getPort();
     // Follow the trail until you get no more connections
     while ($path[$n]->ConnectedDeviceID > 0) {
         $path[++$n] = new DevicePorts();
         $path[$n]->DeviceID = $path[$n - 1]->ConnectedDeviceID;
         // Patch panels have +/- port numbers to designate front/rear, so as you
         // traverse the path, you have to flip
         $path[$n]->PortNumber = -$path[$n - 1]->ConnectedPort;
         $path[$n]->getPort();
     }
     // If the connected device id is null and the label is empty then the port failed to lookup
     // invert the sign and try to get the port again cause this might be a device and not a
     // patch panel
     if ($path[$n]->ConnectedDeviceID == "NULL" && $path[$n]->Label == "") {
         $path[$n]->PortNumber = $path[$n]->PortNumber * -1;
         $path[$n]->getPort();
     }
     return $path;
 }
Beispiel #2
0
         $insert = true;
     } else {
         if ($control == Controls::Update) {
             if (isset($_POST["chkStatus"])) {
                 $Device->setStatus($_POST["chkStatus"]);
             } else {
                 $Device->setStatus(0);
             }
             $Device->update();
             $update = true;
         }
     }
 } else {
     if (isset($_GET["DeviceID"]) && isset($_GET["control"])) {
         $control->setValue($_GET["control"]);
         $Device = Device::getDevice($_GET["DeviceID"]);
         if ($Device != null) {
             if ($control == Controls::Update) {
                 echo "<script> \$(function () { \$(window).load(function(){ \$('#modalDevice').modal( { backdrop: 'static', keyboard: false }, 'show');});  });</script>";
             } else {
                 if ($control == Controls::Delete) {
                     $Device->delete();
                     $delete = true;
                 }
             }
         } else {
             require_once '../helper/Utils.php';
             $url = "devices.php";
             Utils::Redirect($url);
         }
     }
Beispiel #3
0
                 // sets install date to today when a new device is being created
                 $dev->InstallDate = date("m/d/Y");
                 break;
         }
         // Can't check the device for rights because it shouldn't exist yet
         // but the user could have rights from the cabinet and it is checked above
         // when the device object is populated.
     } elseif ($write && $_POST['action'] == 'Create') {
         // Since the cabinet isn't part of the form for a child device creation
         // it's possible to create a new child that doesn't follow the new cabinet designation
         // we're creatig a device at this point so look up the parent just in case and match
         // the cabinet designations
         if ($dev->ParentDevice) {
             $pdev = new Device();
             $pdev->DeviceID = $dev->ParentDevice;
             $pdev->getDevice();
             $dev->Cabinet = $pdev->Cabinet;
         }
         if ($dev->TemplateID > 0 && intval($dev->NominalWatts == 0)) {
             $dev->UpdateWattageFromTemplate();
         }
         $dev->CreateDevice();
         $dev->SetTags($tagarray);
         updateCustomValues($dev);
         // We've, hopefully, successfully created a new device. Force them to the new device page.
         header('Location: ' . redirect("devices.php?DeviceID={$dev->DeviceID}"));
         exit;
     }
 }
 /*
  * Prepare data for display
Beispiel #4
0
$p = new Product();
$c = new Category();
$device = new Device();
$bra = new Brand();
$flag = 0;
if (isset($_GET["CatID"]) && !empty($_GET["CatID"])) {
    $catID = $_GET["CatID"];
    $c = Category::getCat($catID);
    $p->setCatPro($c);
    $flag = 1;
}
if (isset($_GET["DeviceID"]) && !empty($_GET["DeviceID"])) {
    $devID = $_GET["DeviceID"];
    $c->setDevice(new Device($devID));
    require_once 'entities/Device.php';
    $device = Device::getDevice($devID);
    $p->setCatPro($c);
    $flag = 2;
}
if (isset($_GET["BraID"]) && !empty($_GET["BraID"])) {
    $braID = $_GET["BraID"];
    $c->setBrand(new Brand($braID));
    require_once 'entities/Brand.php';
    $bra = Brand::getBrand($braID);
    $p->setCatPro($c);
    $flag = 3;
}
if ($flag != 0) {
    $ListPro = $p->loadLimit($rowsPerPage, $offset, "CatProID");
    $numberOfRows = $p->countRecords();
    ?>