forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
777 lines (710 loc) · 25.5 KB
/
install.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
<!doctype html>
<?php
/*
Generic first time installer. Makes assumption that the db.inc.php has been created
*/
// Make sure that a db.inc.php has been created
if(!file_exists("db.inc.php")){
print "Please copy db.inc.php-dist to db.inc.php.<br>\nOpen db.inc.php with a text editor and fill in the blanks for user, pass, database, and server.";
exit;
}else{
require_once("db.inc.php");
}
// Functions for upgrade / installing db objects
$successlog="";
function applyupdate ($updatefile){
//Make sure the upgrade file exists.
if(file_exists($updatefile)){
$file=fopen($updatefile, 'r');
$sql=array();
while(feof($file)===false){
$sql[]=fgets($file);
}
$sqlstring="";
foreach($sql as $key => $value){
// I really need a better way to filter out comments but this works.
if(substr($value,0,1)=='-'){
}else{
$sqlstring.=trim($value);
}
}
fclose($file);
$sql=explode(";",$sqlstring);
unset($sql[count($sql)-1]);
$result=0;
foreach($sql as $key => $value){
// uncomment to debug sql injection
// echo $value."<br>\n";
if(!mysql_query($value)){
//something broke log it
$errormsg.=mysql_error();
$errormsg.="<br>\n";
$result=1;
}
}
if($result){
if(!isset($errormsg)){
$errormsg="An error has occured while applying $updatefile. Please consult the server logs for more details.<br>\n";
}
}else{
$successlog="$updatefile: Database updates applied.<br>\n";
}
}else{
$errormsg="Seems you're at 1.0 but you're missing the db updates to goto 1.1. Are you sure that db-1.0-to-1.1.sql unpacked from the archive?";
}
$temp=array();
if(isset($errormsg)){
$temp[1]=$errormsg;
}else{
$temp[0]=$successlog;
}
return $temp;
}
$upgrade=false;
// Check to see if we are doing an upgrade or an install
$result=mysql_query("SHOW TABLES;");
if(mysql_num_rows($result)==0){ // No tables in the DB so try to install.
$results[]=applyupdate("create.sql");
$upgrade=false;
}
// New install so create a user
require_once("customers.inc.php");
$user=new User();
$user->UserID=$_SERVER['REMOTE_USER'];
$user->GetUserRights($facDB);
// Re-read the config
$config->Config($facDB);
// Check to see if we have any users in the database.
if(mysql_num_rows(mysql_query("SELECT * FROM fac_User WHERE SiteAdmin=1;"))<1){
// no users in the system or no users with site admin rights, either way we're missing the class of people we need
// put stuff here like correcting for a missing site admin
print "There are no users in the database with sufficient privileges to perform this update";
exit;
$rightserror=1;
}else{ // so we have users and at least one site admin
require_once("customers.inc.php");
$user=new User();
$user->UserID=$_SERVER['REMOTE_USER'];
$user->GetUserRights($facDB);
if(!$user->SiteAdmin){
// dolemite says you aren't an admin so you can't apply the update
print "An update has been applied to the system but the system hasn't been taken out of maintenance mode. Please contact a site Administrator to correct this issue.";
exit;
}
$rightserror=0;
}
// test for openDCIM version
$result=mysql_query("SELECT Value FROM fac_Config WHERE Parameter='Version' LIMIT 1;");
if(mysql_num_rows($result)==0){// Empty result set means this is either 1.0 or 1.1. Surely the check above caught all 1.0 instances.
$results[]=applyupdate("db-1.1-to-1.2.sql");
$upgrade=true;
$version="1.2";
}else{
$version=mysql_result($result,0);//sets version number
}
if($version=="1.2"){ // Do 1.2 to 1.3 Update
$results[]=applyupdate("db-1.2-to-1.3.sql");
$upgrade=true;
$version="1.3";
}
if($version=="1.3"){ // Do 1.3 to 1.4 Update
// Clean the configuration table of any duplicate values that might have been added.
$config->rebuild($facDB);
$results[]=applyupdate("db-1.3-to-1.4.sql");
$upgrade=true;
$version="1.4";
}
if($version=="1.4"){ // Do 1.4 to 1.5 Update
// A few of the database changes require some tests to ensure that they will be able to apply.
// Both of these need to return 0 results before we continue or the database schema update will not complete.
$conflicts=0;
$sql="SELECT PDUID, CONCAT(PDUID,'-',PDUPosition) AS KEY1, COUNT(PDUID) AS Count FROM fac_PowerConnection GROUP BY KEY1 HAVING (COUNT(KEY1)>1) ORDER BY PDUID ASC;";
$conflicts+=(mysql_num_rows(mysql_query($sql, $facDB))>0)?1:0;
$sql="SELECT DeviceID, CONCAT(DeviceID,'-',DeviceConnNumber) AS KEY2, COUNT(DeviceID) AS Count FROM fac_PowerConnection GROUP BY KEY2 HAVING (COUNT(KEY2)>1) ORDER BY DeviceID ASC;";
$conflicts+=(mysql_num_rows(mysql_query($sql, $facDB))>0)?1:0;
$sql="SELECT SwitchDeviceID, CONCAT(SwitchDeviceID,'-',SwitchPortNumber) AS KEY1, COUNT(SwitchDeviceID) AS Count FROM fac_SwitchConnection GROUP BY KEY1 HAVING (COUNT(KEY1)>1) ORDER BY SwitchDeviceID ASC;";
$conflicts+=(mysql_num_rows(mysql_query($sql, $facDB))>0)?1:0;
$sql="SELECT SwitchDeviceID, SwitchPortNumber, EndpointDeviceID, EndpointPort, CONCAT(EndpointDeviceID,'-',EndpointPort) AS KEY2, COUNT(EndpointDeviceID) AS Count FROM fac_SwitchConnection GROUP BY KEY2 HAVING (COUNT(KEY2)>1) ORDER BY EndpointDeviceID ASC;";
$conflicts+=(mysql_num_rows(mysql_query($sql, $facDB))>0)?1:0;
require_once("facilities.inc.php");
if($conflicts!=0){
header('Location: '.redirect("conflicts.php"));
exit;
}
$config->rebuild($facDB);
$results[]=applyupdate("db-1.4-to-1.5.sql");
$upgrade=true;
$version="1.5";
}
if ( $version == "1.5" ) { // Do the 1.5 to 2.0 Update
// Get a list of all Manufacturers that are duplicated
$sql = "select ManufacturerID,Name from fac_Manufacturer group by Name having count(*)>1";
$result = mysql_query( $sql, $facDB );
while ( $row = mysql_fetch_array( $result ) ) {
// Set all devices with that Manufacturer to the ID of just one
$sql = sprintf( "update fac_DeviceTemplate set ManufacturerID=%d where ManufacturerID in (select ManufacturerID from fac_Manufacturer where Name=\"%s\")", $row["ManufacturerID"], $row["Name"] );
mysql_query( $sql, $facDB );
// Delete all the duplicates other than the one you set everything to
$sql = sprintf( "delete from fac_Manufacturer where Name=\"%s\" and ManufacturerID!=%d", $row["Name"], $row["ManufacturerID"] );
mysql_query( $sql, $facDB );
}
// Repeat for Templates
$sql = "select TemplateID,ManufacturerID,Model from fac_DeviceTemplate group by ManufacturerID,Model having count(*)>1";
$result = mysql_query( $sql, $facDB );
while ( $row = mysql_fetch_array( $result ) ) {
$sql = sprintf( "update fac_Device set TemplateID=%d where TemplateID in (select TemplateID from fac_DeviceTemplate where ManufacturerID=%d and Model=\"%s\")", $row["TemplateID"], $row["ManufacturerID"], $row["Model"] );
mysql_query( $sql, $facDB );
$sql = sprintf( "delete from fac_DeviceTemplate where ManufacturerID=%d and TemplateID!=%d", $row["ManufacturerID"], $row["TemplateID"] );
mysql_query( $sql, $facDB );
}
// And finally, Departments
$sql = "select DeptID, Name from fac_Department group by Name having count(*)>1";
$result = mysql_query( $sql, $facDB );
while ( $row = mysql_fetch_array( $result ) ) {
$sql = sprintf( "update fac_Device set Owner=%d where Owner in (select DeptID from fac_Department where Name=\"%s\")", $row["DeptID"], $row["Name"] );
mysql_query( $sql, $facDB );
// Yes, I know, this may create duplicates
$sql = sprintf( "update fac_DeptContacts set DeptID=%d where DeptID in (select DeptID from fac_Department where Name=\"%s\")", $row["DeptID"], $row["Name"] );
mysql_query( $sql, $facDB );
$sql = sprintf( "delete from fac_Department where Name=\"%s\" and DeptID!=%d", $row["Name"], $row["DeptID"] );
mysql_query( $sql, $facDB );
}
// So delete the potential duplicate contact links created in the last step
$sql = "select DeptID,ContactID from fac_DeptContacts group by DeptID,ContactID having count(*)>1";
$result = mysql_query( $sql, $facDB );
while ( $row = mysql_fetch_array( $result ) ) {
$sql = sprintf( "delete from fac_DeptContacts where DeptID=%d and ContactID=%d", $row["DeptID"], $row["ContactID"] );
mysql_query( $sql, $facDB );
$sql = sprintf( "insert into fac_DeptContacts values ( %d, %d )", $row["DeptID"], $row["ContactID"] );
mysql_query( $sql, $facDB );
}
$config->rebuild( $facDB );
$results[]=applyupdate( "db-1.5-to-2.0.sql" );
$upgrade = true;
$version = "2.0";
}
if($upgrade==true){ //If we're doing an upgrade don't call the rest of the installer.
?>
<!doctype html>
<html>
<head>
<title>Upgrade</title>
<style type="text/css">
.error { color: red;}
.success { color: green;}
</style>
</head>
<body>
<?php
if(isset($results)){
foreach($results as $key => $value){
foreach($value as $status => $message){
if($status==1){$class="error";}else{$class="success";}
print "<h1 class=\"$class\">$message</h1>";
}
}
print "<p class=\"$class\">If all updates have completed. Please remove install.php to return to normal functionality.</p><p>Reload the page to try loading sql updates again or to go on to the installer</p>";
}else{
echo '<p class="success">All is well. Please remove install.php to return to normal functionality</p>';
}
?>
</body>
</html>
<?php
exit;
}
require_once( "facilities.inc.php" );
$dept=new Department();
$dc=new DataCenter();
$cab=new Cabinet();
// Configuration Form Submission
if(isset($_REQUEST["confaction"]) && $_REQUEST["confaction"]=="Update"){
foreach($config->ParameterArray as $key=>$value){
if($key=="ClassList"){
$List=explode(", ",$_REQUEST[$key]);
$config->ParameterArray[$key]=$List;
}else{
$config->ParameterArray[$key]=$_REQUEST[$key];
}
}
$config->UpdateConfig($facDB);
}
// Departments Form Submission
if(isset($_REQUEST['deptid'])&&($_REQUEST['deptid']>0)){
$dept->DeptID = $_REQUEST['deptid'];
$dept->GetDeptByID( $facDB );
}
if(isset($_REQUEST['deptaction'])&& (($_REQUEST['deptaction']=='Create') || ($_REQUEST['deptaction']=='Update'))){
$dept->DeptID = $_REQUEST['deptid'];
$dept->Name = $_REQUEST['name'];
$dept->ExecSponsor = $_REQUEST['execsponsor'];
$dept->SDM = $_REQUEST['sdm'];
$dept->Classification = $_REQUEST['classification'];
if($_REQUEST['deptaction']=='Create'){
if($dept->Name != '' && $dept->Name != null)
$dept->CreateDepartment($facDB);
}else{
$dept->UpdateDepartment($facDB);
}
}
$result=mysql_query("SELECT * FROM fac_Department LIMIT 1;");
if(mysql_num_rows($result)==0){ // No departments defined
$nodept="<h3>Create a department</h3>";
$nodeptdrop="readonly";
}else{
$nodept=$nodeptdrop="";
}
// Data Centers Form Submission
if(isset($_REQUEST['dcaction']) && (($_REQUEST['dcaction']=='Create')||($_REQUEST['dcaction']=='Update'))){
$dc->DataCenterID = $_REQUEST['datacenterid'];
$dc->Name = $_REQUEST['name'];
$dc->SquareFootage = $_REQUEST['squarefootage'];
$dc->DeliveryAddress = $_REQUEST['deliveryaddress'];
$dc->Administrator = $_REQUEST['administrator'];
$dc->DrawingFileName = $_REQUEST['drawingfilename'];
if($_REQUEST['dcaction']=='Create'){
$dc->CreateDataCenter($facDB);
}else{
$dc->UpdateDataCenter($facDB);
}
}
if(isset($_REQUEST['datacenterid']) && $_REQUEST['datacenterid'] >0){
$dc->DataCenterID=$_REQUEST['datacenterid'];
$dc->GetDataCenter($facDB);
}
$dcList=$dc->GetDCList($facDB);
$result=mysql_query("SELECT * FROM fac_DataCenter LIMIT 1;");
if(mysql_num_rows($result)==0){ // No data centers configured disable cabinets and complete options
$nodc="<h3>Define a data center</h3>";
$nodccab="<h3>You must create a Data Center before you can create cabinets in it.</h3>";
$nodcfield="disabled";
$nodcdrop="readonly";
}else{
$nodc=$nodccab=$nodcfield=$nodcdrop="";
}
//Cabinet Form Submission
if(isset($_REQUEST['cabinetid'])){
$cab->CabinetID=$_REQUEST['cabinetid'];
$cab->GetCabinet($facDB);
}
if(isset($_REQUEST['cabaction'])){
if(($cab->CabinetID >0)&&($_REQUEST['cabaction']=='Update')){
$cab->DataCenterID=$_REQUEST['datacenterid'];
$cab->Location=$_REQUEST['location'];
$cab->AssignedTo=$_REQUEST['assignedto'];
$cab->CabinetHeight=$_REQUEST['cabinetheight'];
$cab->Model=$_REQUEST['model'];
$cab->MaxKW=$_REQUEST['maxkw'];
$cab->MaxWeight=$_REQUEST['maxweight'];
$cab->InstallationDate=$_REQUEST['installationdate'];
$cab->UpdateCabinet($facDB);
}elseif($_REQUEST['cabaction']=='Create'){
$cab->DataCenterID=$_REQUEST['datacenterid'];
$cab->Location=$_REQUEST['location'];
$cab->AssignedTo=$_REQUEST['assignedto'];
$cab->CabinetHeight=$_REQUEST['cabinetheight'];
$cab->Model=$_REQUEST['model'];
$cab->MaxKW=$_REQUEST['maxkw'];
$cab->MaxWeight=$_REQUEST['maxweight'];
$cab->InstallationDate=$_REQUEST['installationdate'];
$cab->CreateCabinet($facDB);
}
}
if($nodccab==""){ // only attempt to check for racks in the db if a data center has already been created
$result=mysql_query("SELECT * FROM fac_Cabinet LIMIT 1;");
if(mysql_num_rows($result)==0){ // No racks defined disable complete option
$nodccab="<h3>Create a rack for equipment to be housed in</h3>";
$nocabdrop="readonly";
$nocab="error";
}else{
$nocab=$nocabdrop=$nodccab="";
}
}
//Installation Complete
if($nodept=="" && $nodc=="" && $nocab==""){ // All three primary sections have had at least one item created
//enable the finish menu option
$complete=true;
}
?>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>openDCIM Installer</title>
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/jquery.miniColors.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.miniColors.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$(".color-picker").miniColors({
letterCase: 'uppercase',
change: function(hex, rgb) {
logData(hex, rgb);
}
});
});
</script>
</head>
<body>
<div id="header"></div>
<?php
if((!isset($_GET["dept"])&&!isset($_GET["cab"])&&!isset($_GET["dc"])&&!isset($_GET["complete"]))||isset($_GET["conf"])){
?>
<div class="page config installer">
<div id="sidebar">
<ul>
<a><li class="active">Configuration</li></a>
<a href="?dept"><li>Departments</li></a>
<a href="?dc"><li>Data Centers</li></a>
<a href="?cab"><li>Cabinets</li></a>
<?php if(isset($complete)){ echo '<a href="?complete"><li>Complete</li></a>'; }?>
</ul>
</div>
<div class="main">
<h2><?php print $config->ParameterArray["OrgName"]; ?></h2>
<h3>Data Center Configuration</h3>
<h3>Database Version: <?php print $config->ParameterArray["Version"]; ?></h3>
<div class="center"><div>
<form action="<?php print $_SERVER["PHP_SELF"]; ?>?conf" method="POST">
<input type="hidden" name="Revert" id="Revert" value="no">
<input type="hidden" name="Single" id="Single" value = "none">
<div class="table rights">
<div><div><h3>Parameter</h3></div><div><h3>Value</h3></div></div>
<?php
foreach ($config->ParameterArray as $key=>$value){
if ( strpos( $key, "Color" ) ) {
$class='class="color-picker"';
$cssfix1='<div class="cp">';
$cssfix2='</div>';
} else {
$cssfix1=$cssfix2=$class='';
}
if ($key =="ClassList"){
$numItems=count($config->ParameterArray[$key]);
$i=0;
$valueStr="";
foreach($config->ParameterArray[$key] as $item){
$valueStr .= $item;
if($i+1 != $numItems){
$valueStr.=", ";
}
$i++;
}
print "<div>\n";
print "<div>$key:</div>\n";
print "<div><input type=\"text\" maxlength=\"200\" name=\"$key\" value=\"$valueStr\"></div>\n";
print "</div>\n";
} elseif ( $key != "Version" ) {
print "<div>\n";
print "<div>$key:</div>\n";
print "<div>$cssfix1<input type=\"text\" $class maxlength=\"200\" name=\"$key\" value=\"{$config->ParameterArray[$key]}\">$cssfix2</div>\n";
print "</div>\n";
}
}
?>
<div>
<div></div>
<div><input type="submit" name="confaction" value="Update"></div>
</div>
</div> <!-- END div.table -->
</div>
</form>
</div>
<?php
}elseif(isset($_GET["dept"])){
$deptList = $dept->GetDepartmentList( $facDB );
?>
<script type="text/javascript">
function showgroup(obj){
self.frames['groupadmin'].location.href='dept_groups.php?deptid='+obj;
document.getElementById('groupadmin').style.display = "block";
document.getElementById('deptname').readOnly = true
document.getElementById('deptsponsor').readOnly = true
document.getElementById('deptmgr').readOnly = true
document.getElementById('deptclass').disabled = true
document.getElementById('controls').id = "displaynone";
}
</script>
<div class="page installer">
<div id="sidebar">
<ul>
<a href="?conf"><li>Configuration</li></a>
<a><li class="active">Departments</li></a>
<a href="?dc"><li>Data Centers</li></a>
<a href="?cab"><li>Cabinets</li></a>
<?php if(isset($complete)){ echo '<a href="?complete"><li>Complete</li></a>'; }?>
</ul>
</div>
<div class="main">
<h2><?php echo $config->ParameterArray['OrgName']; ?></h2>
<h3>Data Center Department Detail</h3>
<?php echo $nodept; ?>
<div class="center"><div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?dept" method="POST">
<div class="table centermargin">
<div>
<div>Department</div>
<div><input type="hidden" name="deptaction" value="query"><select name="deptid" onChange="form.submit()" <?php echo $nodeptdrop;?>>
<option value=0>New Department</option>
<?php
foreach($deptList as $deptRow){
echo "<option value=\"$deptRow->DeptID\"";
if($dept->DeptID == $deptRow->DeptID){
echo ' selected';
}
echo ">$deptRow->Name</option>\n";
}
?>
</select></div>
</div>
<div>
<div><label for="deptname">Department Name</label></div>
<div><input type="text" size="50" name="name" id="deptname" value="<?php echo $dept->Name; ?>"></div>
</div>
<div>
<div><label for="deptsponsor">Executive Sponsor</label></div>
<div><input type="text" size="50" name="execsponsor" id="deptsponsor" value="<?php echo $dept->ExecSponsor; ?>"></div>
</div>
<div>
<div><label for="deptmgr">Account Manager</label></div>
<div><input type="text" size="50" name="sdm" id="deptmgr" value="<?php echo $dept->SDM; ?>"></div>
</div>
<div>
<div><label for="deptclass">Classification</label></div>
<div><select name="classification" id="deptclass">
<?php
foreach($config->ParameterArray['ClassList'] as $className){
echo "<option value=\"$className\"";
if($dept->Classification==$className){echo ' selected';}
echo ">$className</option>";
}
?>
</select>
</div>
</div>
<div class="caption" id="controls">
<input type="submit" name="deptaction" value="Create">
<?php
if($dept->DeptID > 0){
echo '<input type="submit" name="deptaction" value="Update">';
echo "<input type=\"button\" onClick=\"showgroup($dept->DeptID)\" value=\"Assign Contacts\">";
// print "<input type=\"button\" onClick=\"self.frames['groupadmin'].location.href='dept_groups.php?deptid=$dept->DeptID'\" value=\"Assign Contacts\">";
// print "<input type=\"button\" onClick=\"window.open('dept_groups.php?deptid=$dept->DeptID', 'popup')\" value=\"Assign Contacts\">";
}
?>
</div>
</div> <!-- END div.table -->
</form>
<iframe name="groupadmin" id="groupadmin" frameborder=0 scrolling="no"></iframe>
<br>
</div></div>
</div> <!-- END div.main -->
</div> <!-- END div.page -->
<?php
}elseif(isset($_GET["dc"])){
?>
<div class="page installer">
<div id="sidebar">
<ul>
<a href="?conf"><li>Configuration</li></a>
<a href="?dept"><li>Departments</li></a>
<a><li class="active">Data Centers</li></a>
<a href="?cab"><li>Cabinets</li></a>
<? if(isset($complete)){ echo '<a href="?complete"><li>Complete</li></a>'; }?>
</ul>
</div>
<div class="main">
<h2><?php echo $config->ParameterArray['OrgName']; ?></h2>
<h3>Data Center Detail</h3>
<?php echo $nodc; ?>
<div class="center"><div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?dc" method="POST">
<div class="table">
<div>
<div><label for="datacenterid">Data Center ID</label></div>
<div><select name="datacenterid" id="datacenterid" onChange="form.submit()" <?php echo $nodcdrop;?>>
<option value="0">New Data Center</option>
<?php
foreach($dcList as $dcRow){
echo "<option value=\"$dcRow->DataCenterID\"";
if($dcRow->DataCenterID == $dc->DataCenterID){
echo ' selected="selected"';
}
echo ">$dcRow->Name</option>\n";
}
?>
</select></div>
</div>
<div>
<div><label for="dcname">Name</label></div>
<div><input type="text" name="name" id="dcname" size="50" value="<?php echo $dc->Name; ?>"></div>
</div>
<div>
<div><label for="sqfootage">Square Footage</label></div>
<div><input type="text" name="squarefootage" id="sqfootage" size="10" value="<?php echo $dc->SquareFootage; ?>"></div>
</div>
<div>
<div><label for="deliveryaddress">Delivery Address</label></div>
<div><input type="text" name="deliveryaddress" id="deliveryaddress" size="60" value="<?php echo $dc->DeliveryAddress; ?>"></div>
</div>
<div>
<div><label for="administrator">Administrator</label></div>
<div><input type="text" name="administrator" id="administrator" size=60 value="<?php echo $dc->Administrator; ?>"></div>
</div>
<div>
<div><label for="drawingfilename">Drawing URL</label></div>
<div><input type="text" name="drawingfilename" id="drawingfilename" size=60 value="<?php echo $dc->DrawingFileName; ?>"></div>
</div>
<div class="caption">
<?php
if($dc->DataCenterID >0){
echo ' <input type="submit" name="dcaction" value="Update">';
}else{
echo ' <input type="submit" name="dcaction" value="Create">';
}
?>
</div>
</div> <!-- END div.table -->
</form>
</div></div>
</div><!-- END div.main -->
</div><!-- END div.page -->
<?php
}elseif(isset($_GET["cab"])){
if($cab->CabinetID >0){
$cab->GetCabinet($facDB);
}else{
$cab->CabinetID=null;
$cab->DataCenterID=null;
$cab->Location=null;
$cab->CabinetHeight=null;
$cab->Model=null;
$cab->MaxKW=null;
$cab->MaxWeight=null;
$cab->InstallationDate=date('m/d/Y');
}
$deptList=$dept->GetDepartmentList($facDB);
$cabList=$cab->ListCabinets($facDB);
?>
<div class='page installer'>
<div id="sidebar">
<ul>
<a href="?conf"><li>Configuration</li></a>
<a href="?dept"><li>Departments</li></a>
<a href="?dc"><li>Data Centers</li></a>
<a><li class="active">Cabinets</li></a>
<?php if(isset($complete)){ echo '<a href="?complete"><li>Complete</li></a>'; }?>
</ul>
</div>
<div class='main'>
<h2><?php echo $config->ParameterArray['OrgName']; ?></h2>
<h3>Data Center Cabinet Inventory</h3>
<?php echo $nodccab; ?>
<div class='center'><div>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>?cab' method='POST'>
<div class='table'>
<div>
<div>Cabinet</div>
<div><select name='cabinetid' onChange='form.submit()' <?php echo $nodcdrop; ?>>
<option value='0'>New Cabinet</option>
<?php
foreach($cabList as $cabRow){
echo '<option value=\''.$cabRow->CabinetID.'\'';
if($cabRow->CabinetID == $cab->CabinetID){
echo ' selected';
}
echo '>'.$cabRow->Location.'</option>\n';
}
?>
</select></div>
</div>
<div>
<div>Data Center</div>
<div><?php echo $cab->GetDCSelectList($facDB); ?></div>
</div>
<div>
<div>Location</div>
<div><input type='text' name='location' size='8' value='<?php echo $cab->Location; ?>' <?php echo $nodcfield;?>></div>
</div>
<div>
<div>Assigned To:</div>
<div><select name='assignedto' <?php echo $nodcdrop;?>>
<option value='0'>General Use</option>
<?php
foreach($deptList as $deptRow){
echo '<option value=\''.$deptRow->DeptID.'\'';
if($deptRow->DeptID == $cab->AssignedTo){echo ' selected=\'selected\'';}
echo '>'.$deptRow->Name.'</option>\n';
}
?>
</select>
</div>
</div>
<div>
<div>Cabinet Height (U)</div>
<div><input type='text' name='cabinetheight' size='4' value='<?php echo $cab->CabinetHeight; ?>' <?php echo $nodcfield;?>></div>
</div>
<div>
<div>Model</div>
<div><input type='text' name='model' size='30' value='<?php echo $cab->Model; ?>' <?php echo $nodcfield;?>></div>
</div>
<div>
<div>Maximum kW</div>
<div><input type='text' name='maxkw' size='30' value='<?php echo $cab->MaxKW; ?>' <?php echo $nodcfield;?>></div>
</div>
<div>
<div>Maximum Weight</div>
<div><input type='text' name='maxweight' size='30' value='<?php echo $cab->MaxWeight; ?>' <?php echo $nodcfield;?>></div>
</div>
<div>
<div>Date of Installation</div>
<div><input type='text' name='installationdate' size='15' value='<?php echo date('m/d/Y', strtotime($cab->InstallationDate)); ?>' <?php echo $nodcfield;?>></div>
</div>
<?php
if($nodcdrop==""){
echo '<div class=\'caption\'>';
if($cab->CabinetID >0){
echo ' <input type=\'submit\' name=\'cabaction\' value=\'Update\'>';
}else{
echo ' <input type=\'submit\' name=\'cabaction\' value=\'Create\'>';
}
echo '</div>';
}
?>
</div> <!-- END div.table -->
</form>
</div></div>
</div><!-- END div.main -->
</div><!-- END div.page -->
<?php
}elseif(isset($_GET["complete"])){
?>
<div class='page installer'>
<div id="sidebar">
<ul>
<a href="?conf"><li>Configuration</li></a>
<a href="?dept"><li>Departments</li></a>
<a href="?dc"><li>Data Centers</li></a>
<a href="?cab"><li>Cabinets</li></a>
<?php if(isset($complete)){ echo '<a><li class="active">Complete</li></a>'; }?>
</ul>
</div>
<div class='main'>
<h2><?php echo $config->ParameterArray['OrgName']; ?></h2>
<h3>Installation Complete</h3>
<?php echo $nodccab; ?>
<div class='center'><div>
<p>You have completed the basic configuration for openDCIM. At this time please goto the wiki for additional questions that you might have or join our mailing list at [insert link here].</p>
<p>To start normal operation of openDCIM please delete install.php from the installation directory</p>
</div></div>
</div><!-- END div.main -->
</div><!-- END div.page -->
<?php
}
?>
</body>
</html>