Beispiel #1
0
  *
  */
 // Finished updating devices or creating them.  Refresh the object with data from the DB
 $dev->GetDevice();
 // Get any tags associated with this device
 $tags = $dev->GetTags();
 if (count($tags) > 0) {
     // We have some tags so build the javascript elements we need to create the tags themselves
     $taginsert = "\t\ttags: {items: " . json_encode($tags) . "},\n";
 }
 // Since a device exists we're gonna need some additional info, but only if it's not a copy
 if (!$copy) {
     // clearing errors for now
     $LastWattage = $LastRead = $upTime = 0;
     $pwrConnection->DeviceID = $dev->ParentDevice > 0 ? $dev->GetRootDeviceID() : $dev->DeviceID;
     $pwrCords = $pwrConnection->getPorts();
     if ($dev->DeviceType == 'Switch') {
         $linkList = SwitchInfo::getPortStatus($dev->DeviceID);
     } elseif ($dev->DeviceType == 'CDU') {
         $pdu->PDUID = $dev->DeviceID;
         $pdu->GetPDU();
         $lastreading = $pdu->GetLastReading();
         $LastWattage = $lastreading ? $lastreading->Wattage : 0;
         $LastRead = $lastreading ? strftime("%c", strtotime($lastreading->LastRead)) : "Never";
     }
 }
 if ($dev->ChassisSlots > 0 || $dev->RearChassisSlots > 0) {
     $childList = $dev->GetDeviceChildren();
 }
 if ($dev->ParentDevice > 0) {
     $pDev = new Device();
Beispiel #2
0
$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) {
        foreach ($lastport as $prop => $value) {
            if ($prop != "PortNumber") {
                $pp->{$prop} = $value;
            }
        }
        if ($pp->updatePort()) {
            if ($lastport->removePort()) {
                updatedevice($pp->DeviceID);
                $response['error'] = false;
            } else {
                $response['error'] = true;
            }
        } else {
            $response['error'] = true;
     $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);
         $sheet->getActiveSheet()->SetCellValue('D' . $row, $targetPort->Label);
         $sheet->getActiveSheet()->SetCellValue('H' . $row, __("Power Connection"));