forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdu_templates.php
224 lines (202 loc) · 7.64 KB
/
cdu_templates.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
require_once('db.inc.php');
require_once('facilities.inc.php');
if(!$user->SiteAdmin){
// No soup for you.
header('Location: '.redirect());
exit;
}
$template=new CDUTemplate();
$manufacturer=new Manufacturer();
if(isset($_REQUEST['templateid']) && $_REQUEST['templateid'] >0){
$template->TemplateID=$_REQUEST['templateid'];
$template->GetTemplate();
}
$status='';
if(isset($_REQUEST['action'])&&(($_REQUEST['action']=='Create')||($_REQUEST['action']=='Update'))){
$template->ManufacturerID = $_REQUEST['manufacturerid'];
$template->Model = transform( $_REQUEST['model'] );
$template->Managed = isset($_REQUEST['managed'])?1:0;
$template->ATS = isset($_REQUEST['ats'])?1:0;
$template->SNMPVersion = $_REQUEST['snmpversion'];
$template->VersionOID = $_REQUEST['versionoid'];
$template->Multiplier = $_REQUEST['multiplier'];
$template->OID1 = $_REQUEST['oid1'];
$template->OID2 = $_REQUEST['oid2'];
$template->OID3 = $_REQUEST['oid3'];
$template->ATSStatusOID = $_REQUEST['atsstatusoid'];
$template->ATSDesiredResult = $_REQUEST['atsdesiredresult'];
$template->ProcessingProfile = $_REQUEST['processingprofile'];
$template->Voltage = $_REQUEST["voltage"];
$template->Amperage = $_REQUEST["amperage"];
$template->NumOutlets = $_REQUEST["numoutlets"];
if ( $_REQUEST['action']=='Create' ) {
$template->CreateTemplate();
} else {
$status=__('Updated');
$template->UpdateTemplate();
}
}
$templateList=$template->GetTemplateList();
$ManufacturerList=$manufacturer->GetManufacturerList();
$managed=($template->Managed)?" checked":"";
$ats=($template->ATS)?" checked":"";
?>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>openDCIM Cabinet Distribution Unit Templates</title>
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/jquery-ui.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>
<script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
</head>
<body>
<div id="header"></div>
<div class="page">
<?php
include( 'sidebar.inc.php' );
echo '<div class="main">
<h2>',$config->ParameterArray["OrgName"],'</h2>
<h3>',__("Data Center Cabinet Distribution Unit Templates"),'</h3>
<h3>',$status,'</h3>
<div class="center"><div>
<form action="',$_SERVER["PHP_SELF"],'" method="POST">
<div class="table">
<div>
<div><label for="templateid">',__("Template"),'</label></div>
<div><input type="hidden" name="action" value="query"><select name="templateid" id="templateid" onChange="form.submit()">
<option value=0>',__("New Template"),'</option>';
foreach($templateList as $templateRow){
$manufacturer->ManufacturerID=$templateRow->ManufacturerID;
$manufacturer->GetManufacturerByID();
$selected=($template->TemplateID==$templateRow->TemplateID)?' selected':'';
print " <option value=\"$templateRow->TemplateID\"$selected>[$manufacturer->Name] $templateRow->Model</option>\n";
}
echo ' </select></div>
</div>
<div>
<div><label for="manufacturerid">',__("Manufacturer"),'</label></div>
<div><select name="manufacturerid" id="manufacturerid">';
foreach($ManufacturerList as $ManufacturerRow){
$selected=($template->ManufacturerID==$ManufacturerRow->ManufacturerID)?' selected':'';
print " <option value=\"$ManufacturerRow->ManufacturerID\"$selected>$ManufacturerRow->Name</option>\n";
}
echo ' </select>
</div>
</div>
<div>
<div><label for="model">',__("Model"),'</label></div>
<div><input type="text" name="model" id="model" value="',$template->Model,'" size=40></div>
</div>
<div>
<div><label for="managed">',__("Managed"),'</label></div>
<div>
<input type="checkbox" name="managed" id="managed"',$managed,'>
</div>
</div>
<div>
<div><label for="ats">',__("Automatic Transfer Switch"),'</label></div>
<div>
<input type="checkbox" name="ats" id="ats"',$ats,'>
</div>
</div>
<div>
<div><label for="snmpversion">',__("SNMP Version"),'</label></div>
<div><select name="snmpversion" id="snmpversion">';
$snmpv = array( "1", "2c" );
foreach ( $snmpv as $unit ) {
$selected = ( $unit == $template->SNMPVersion ) ? 'selected':'';
print "\t\t<option value=\"$unit\" $selected>$unit</option>\n";
}
echo '</select>
</div>
</div>
<div>
<div><label for="versionoid">',__("Firmware Version OID"),'</label></div>
<div><input type="text" name="versionoid" id="versionoid" value="',$template->VersionOID,'" size=40></div>
</div>
<div>
<div><label for="multiplier">',__("Multiplier"),'</label></div>
<div><select name="multiplier" id="multiplier">';
$Multi=array("0.1", "1","10","100");
$mult = 1;
// Loop to find the template default multiplier, if any
foreach($Multi as $unit) {
//$selected = ($unit==$template->Multiplier)?' selected' : '';
if ($unit == $template->Multiplier) {
$mult = $template->Multiplier;
break;
}
}
// Set the "selected" option, using $mult as set above
foreach($Multi as $unit){
$selected = ( $unit == $mult ) ? ' selected' : '';
print "\t\t<option value=\"$unit\"$selected>$unit</option>\n";
}
echo ' </select>
</div>
</div>
<div>
<div><label for="oid1">',__("OID1"),'</label></div>
<div><input type="text" name="oid1" id="oid1" value="',$template->OID1,'" size=40></div>
</div>
<div>
<div><label for="oid2">',__("OID2"),'</label></div>
<div><input type="text" name="oid2" id="oid2" value="',$template->OID2,'" size=40></div>
</div>
<div>
<div><label for="oid3">',__("OID3"),'</label></div>
<div><input type="text" name="oid3" id="oid3" value="',$template->OID3,'" size=40></div>
</div>
<div>
<div><label for="atsstatusoid">',__("ATS Status OID"),'</label></div>
<div><input type="text" name="atsstatusoid" id="atsstatusoid" value="',$template->ATSStatusOID,'" size=40></div>
</div>
<div>
<div><label for="atsdesiredresult">',__("ATS Desired Result"),'</label></div>
<div><input type="text" name="atsdesiredresult" id="atsdesiredresult" value="',$template->ATSDesiredResult,'" size=40></div>
</div>
<div>
<div><label for="processingprofile">',__("Processing Scheme"),'</label></div>
<div><select name="processingprofile" id="processingprofile">';
$ProfileList=array("SingleOIDWatts","SingleOIDAmperes","Combine3OIDWatts","Combine3OIDAmperes","Convert3PhAmperes");
foreach($ProfileList as $prof){
$selected=($prof == $template->ProcessingProfile)?' selected':'';
print "<option value=\"$prof\"$selected>$prof</option>";
}
echo ' </select></div>
</div>
<div>
<div><label for="voltage">',__("Voltage"),'</label></div>
<div><input type="text" name="voltage" id="voltage" value="',$template->Voltage,'"></div>
</div>
<div>
<div><label for="amperage">',__("Amperage"),'</label></div>
<div><input type="text" name="amperage" id="amperage" value="',$template->Amperage,'"></div>
</div>
<div>
<div><label for="numoutlets">',__("No. of Outlets"),'</label></div>
<div><input type="text" name="numoutlets" id="numoutlets" value="',$template->NumOutlets,'"></div>
</div>
<div class="caption">';
if($template->TemplateID >0){
echo ' <button type="submit" name="action" value="Update">',__("Update"),'</button>';
}else{
echo ' <button type="submit" name="action" value="Create">',__("Create"),'</button>';
}
?>
</div>
</div><!-- END div.table -->
</form>
</div></div>
<?php echo '<a href="index.php">[ ',__("Return to Main Menu"),' ]</a>'; ?>
</div><!-- END div.main -->
</div><!-- END div.page -->
</body>
</html>