forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
power_connection.php
110 lines (100 loc) · 3.29 KB
/
power_connection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
require_once( 'db.inc.php' );
require_once( 'facilities.inc.php' );
$user = new User();
$user->UserID = $_SERVER['REMOTE_USER'];
$user->GetUserRights( $facDB );
if(!isset($_REQUEST['pdu']) && !isset($_REQUEST['conn']) && !$user->SiteAdmin){
// No soup for you.
header('Location: '.redirect());
exit;
}
$pduID = $_REQUEST['pdu'];
$connID = $_REQUEST['conn'];
$dev=new Device();
$pdu=new PowerDistribution();
$connection=new PowerConnection();
$pdu->PDUID=$pduID;
$pdu->GetPDU($facDB);
$connection->PDUID=$pdu->PDUID;
$connection->PDUPosition=$connID;
if(isset($_REQUEST['action'])){
if($_REQUEST['action']=='Save'){
$connection->DeviceID = $_REQUEST['deviceid'];
$connection->DeviceConnNumber = $_REQUEST['inputnum'];
$connection->CreateConnection( $facDB );
$url=redirect("pduinfo.php?pduid=$connection->PDUID");
header("Location: $url");
exit;
}elseif($_REQUEST['action']=='Delete'){
$connection->RemoveConnection($facDB);
$url=redirect("pduinfo.php?pduid=$connection->PDUID");
header("Location: $url");
exit;
}
}
$connection->GetPDUConnectionByPosition($facDB);
$dev->Cabinet=$pdu->CabinetID;
$devList=$dev->ViewDevicesByCabinet($facDB);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>openDCIM Power Connection Management</title>
<link rel="stylesheet" href="css/inventory.css" type="text/css">
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css" type="text/css">
<![endif]-->
<script type="text/javascript" src="scripts/jquery.min.js"></script>
</head>
<body>
<div id="header"></div>
<div class="page">
<?php
include( 'sidebar.inc.php' );
?>
<div class="main">
<h2>openDCIM</h2>
<h3>PDU Connection</h3>
<div class="center"><div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="pdu" value="<?php echo $pduID; ?>">
<input type="hidden" name="connid" value="<?php echo $connID; ?>">
<div class="table">
<div>
<div><label for="conn">Output Number</label></div>
<div><input type="text" name="conn" id="conn" value="<?php echo $connID; ?>" size="3" readonly></div>
</div>
<div>
<div><label for="deviceid">Device Attached</label></div>
<div><select name="deviceid" id="deviceid"><option value=0>No Connection</option>
<?php
foreach($devList as $key=>$devRow){
print "<option value=\"$devRow->DeviceID\"";
if($connection->DeviceID==$devRow->DeviceID){ echo ' selected="selected"';}
print ">$devRow->Label</option>\n";
}
?>
</select></div>
</div>
<div>
<div><label for="inputnum">Power Input on Device</label></div>
<div><input type="text" name="inputnum" id="inputnum" value="<?php echo $connection->DeviceConnNumber; ?>"></div>
</div>
<div class="caption">
<?php
if($user->SiteAdmin){
echo ' <input name="action" type="submit" value="Save"><input name="action" type="submit" value="Delete">';
}
?>
<button type="reset" onclick="document.location.href='pduinfo.php?pduid=<?php echo $connection->PDUID; ?>'; return false;">Cancel</button>
</div>
</div><!-- END div.table -->
</form>
</div></div>
</div><!-- END div.main -->
</div><!-- END div.page -->
</body>
</html>