$st->setFetchMode(PDO::FETCH_CLASS, "Device");
 $devList = array();
 while ($row = $st->fetch()) {
     $devList[] = $row;
 }
 if (sizeof($devList) > 0) {
     foreach ($devList as $devRow) {
         $downPanels = "";
         $outageStatus = __("Down");
         // If there is not a circuit to the cabinet that is unaffected, no need to even check
         if ($diversity) {
             // If a circuit was entered with no panel ID, or a device has no connections documented, mark it as unknown
             // The only way to be sure a device will stay up is if we have a connection to an unaffected circuit,
             // or to a failsafe switch (ATS) connected to at least one unaffected circuit.
             $outageStatus = __("Down");
             $connList = PowerPorts::getConnectedPortList($devRow->DeviceID);
             $devPDUList = array();
             $fsDiverse = false;
             if (count($connList) == 0) {
                 $outageStatus = __("Undocumented");
             }
             foreach ($connList as $connection) {
                 // If the connection is to a PDU that is NOT in the affected PDU list, and is not already in the diversity list, add it
                 if (!in_array($connection->ConnectedDeviceID, $pduArray)) {
                     if (!in_array($connection->ConnectedDeviceID, $devPDUList)) {
                         array_push($devPDUList, $connection->ConnectedDeviceID);
                     }
                 }
                 if (in_array($connection->ConnectedDeviceID, $fsArray)) {
                     $fsDiverse = true;
                 }
Exemple #2
0
 *
 *		API DELETE Methods go here
 *
 *		DELETE Methods are for removing records 
 *
 **/
//
//	URL:	/api/v1/powerport/:deviceid
//	Method:	DELETE
//	Params:
//		required: DeviceID, PortNumber
//		optional: Label, ConnectedDeviceID, ConnectedPort, Notes
//	Returns:  true/false on update operation
//
$app->delete('/powerport/:deviceid', function ($deviceid) use($app, $person) {
    $pp = new PowerPorts();
    $pp->DeviceID = $deviceid;
    foreach ($app->request->delete() as $prop => $val) {
        $pp->{$prop} = $val;
    }
    function updatedevice($deviceid)
    {
        $dev = new Device();
        $dev->DeviceID = $deviceid;
        $dev->GetDevice();
        $dev->PowerSupplyCount = $dev->PowerSupplyCount - 1;
        $dev->UpdateDevice();
    }
    // If this port isn't the last port then we're gonna shuffle ports to keep the ids in orderish
    $lastport = end($pp->getPorts());
    if ($lastport->PortNumber != $pp->PortNumber) {
Exemple #3
0
 function DeleteDevice()
 {
     global $dbh;
     // Can't delete something that doesn't exist
     if (!$this->GetDevice()) {
         return false;
     }
     // First, see if this is a chassis that has children, if so, delete all of the children first
     if ($this->ChassisSlots > 0) {
         $childList = $this->GetDeviceChildren();
         foreach ($childList as $tmpDev) {
             $tmpDev->DeleteDevice();
         }
     }
     // If this is a CDU then remove it from the other table
     if ($this->DeviceType == "CDU") {
         $pdu = new PowerDistribution();
         $pdu->PDUID = $this->DeviceID;
         $pdu->DeletePDU();
     }
     // Delete all network connections first
     DevicePorts::removePorts($this->DeviceID);
     // Delete power connections next
     PowerPorts::removePorts($this->DeviceID);
     // Remove custom values
     $this->DeleteCustomValues();
     // Now delete the device itself
     $sql = "DELETE FROM fac_Device WHERE DeviceID={$this->DeviceID};";
     if (!$dbh->exec($sql)) {
         $info = $dbh->errorInfo();
         error_log("PDO Error: {$info[2]} SQL={$sql}");
         return false;
     }
     class_exists('LogActions') ? LogActions::LogThis($this) : '';
     return;
 }
Exemple #4
0
 function Search($indexedbyid = false, $loose = false)
 {
     global $dbh;
     // Store any values that have been added before we make them safe
     foreach ($this as $prop => $val) {
         if (isset($val)) {
             $o[$prop] = $val;
         }
     }
     // Make everything safe for us to search with
     $this->MakeSafe();
     // This will store all our extended sql
     $sqlextend = "";
     foreach ($o as $prop => $val) {
         extendsql($prop, $this->{$prop}, $sqlextend, $loose);
     }
     $sql = "SELECT * FROM fac_PowerPorts {$sqlextend} ORDER BY DeviceID, PortNumber ASC;";
     $portList = array();
     foreach ($dbh->query($sql) as $portRow) {
         if ($indexedbyid) {
             $portList[$portRow["DeviceID"] . $portRow["PortNumber"]] = PowerPorts::RowToObject($portRow);
         } else {
             $portList[] = PowerPorts::RowToObject($portRow);
         }
     }
     return $portList;
 }
Exemple #5
0
    print "\t\t\t<div><div><button type=\"button\">Add note</button><div><input /></div></div></div>\n";
    print "\t\t  </div></div>\n\t\t</div>\n";
    print "\t\t<!-- Spacer --><div><div>&nbsp;</div><div></div></div><!-- END Spacer -->\n";
    // spacer row
}
//HTML content condensed for PHP logic clarity.
// If $pwrCords is null then we're creating a device record. Skip power checking.
if (!is_null($pwrCords) && (isset($_POST['action']) && $_POST['action'] != 'Child' || !isset($_POST['action'])) && !in_array($dev->DeviceType, array('Physical Infrastructure', 'Patch Panel'))) {
    print "\t\t<div>\n\t\t\t<div><a id=\"power\">{$chassis} " . __("Power Connections") . "</a></div>\r\n\t\t\t<div><div class=\"table border power\">\r\n\t\t\t\t<div>\r\n\t\t\t\t\t<div class=\"delete\" style=\"display: none;\"></div>\r\n\t\t\t\t\t<div>#</div>\r\n\t\t\t\t\t<div id=\"ppcn\">" . __("Port Name") . "</div>\r\n\t\t\t\t\t<div>" . __("Device") . "</div>\r\n\t\t\t\t\t<div>" . __("Device Port") . "</div>\r\n\t\t\t\t\t<div>" . __("Notes") . "</div>\r\n<!--\t\t\t\t<div>" . __("Panel") . "</div> -->\r\n\t\t\t\t</div>\n";
    foreach ($pwrCords as $i => $cord) {
        $tmppdu = new Device();
        $tmppdu->DeviceID = $cord->ConnectedDeviceID;
        $tmppdu->GetDevice();
        //				$panel->PanelID=$pdu->PanelID;
        //				$panel->getPanel();
        $tmpcord = new PowerPorts();
        if ($cord->ConnectedDeviceID > 0 && !is_null($cord->ConnectedDeviceID)) {
            $tmpcord->DeviceID = $cord->ConnectedDeviceID;
            $tmpcord->PortNumber = $cord->ConnectedPort;
            $tmpcord->getPort();
        } else {
            $cord->ConnectedDeviceID = 0;
            $cord->ConnectedPort = 0;
        }
        print "\t\t\t\t<div data-port={$i}>\r\n\t\t\t\t\t<div>{$i}</div>\r\n\t\t\t\t\t<div data-default=\"{$cord->Label}\">{$cord->Label}</div>\r\n\t\t\t\t\t<div data-default={$cord->ConnectedDeviceID}><a href=\"devices.php?DeviceID={$cord->ConnectedDeviceID}\">{$tmppdu->Label}</a></div>\r\n\t\t\t\t\t<div data-default={$cord->ConnectedPort}>{$tmpcord->Label}</div>\r\n\t\t\t\t\t<div data-default=\"{$cord->Notes}\">{$cord->Notes}</div>\r\n\t\t\t\t</div>\n";
    }
    $connectioncontrols = $dev->DeviceID > 0 && !empty($portList) ? '
<span style="display: inline-block; vertical-align: super;">' . __("Limit device selection to") . ':</span>
<div id="connection-limiter" data-role="controlgroup" data-type="horizontal">
	<input type="radio" name="connection-limiter" id="radio-choice-1" value="row" />
	<label for="radio-choice-1">Row</label>
Exemple #6
0
 static function getConnectedPortList($DeviceID)
 {
     global $dbh;
     $dev = new Device();
     $dev->DeviceID = $DeviceID;
     if (!$dev->GetDevice()) {
         return false;
         // This device doesn't exist
     }
     $sql = "SELECT * FROM fac_PowerPorts WHERE DeviceID={$dev->DeviceID} and ConnectedDeviceID>0";
     $portList = array();
     foreach ($dbh->query($sql) as $row) {
         $portList[$row['PortNumber']] = PowerPorts::RowToObject($row);
     }
     if (sizeof($portList) == 0 && $dev->DeviceType != "Physical Infrastructure") {
         // somehow this device doesn't have ports so make them now
         $portList = PowerPorts::createPorts($dev->DeviceID);
     }
     return $portList;
 }
 }
 foreach (range('A', 'B') as $columnID) {
     $sheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
 }
 $sheet->setActiveSheetIndex(0);
 $port = new DevicePorts();
 $port->DeviceID = $dev->DeviceID;
 $portList = $port->getPorts();
 /*	
 	if ( sizeof( $portList ) < 1 ) {
 		// No ports for this device
 		header('Location: '.redirect());
 		exit;
 	}	
 */
 $pport = new PowerPorts();
 $pport->DeviceID = $dev->DeviceID;
 $pportList = $pport->getPorts();
 // Make power cable labels based on the number of power supplies
 foreach ($pportList as $powerPort) {
     $sheet->getActiveSheet()->SetCellValue('A' . $row, $dev->Label);
     $sheet->getActiveSheet()->SetCellValue('B' . $row, $powerPort->Label);
     if ($powerPort->ConnectedDeviceID > 0) {
         $targetDev = new Device();
         $targetPort = new PowerPorts();
         $targetDev->DeviceID = $powerPort->ConnectedDeviceID;
         $targetDev->GetDevice();
         $targetPort->DeviceID = $targetDev->DeviceID;
         $targetPort->PortNumber = $powerPort->ConnectedPort;
         $targetPort->getPort();
         $sheet->getActiveSheet()->SetCellValue('C' . $row, $targetDev->Label);