forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_xml_CFD.php
126 lines (101 loc) · 3.82 KB
/
report_xml_CFD.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
<?php
require_once( "db.inc.php" );
require_once( "facilities.inc.php" );
$user = new User();
$user->UserID = $_SERVER["REMOTE_USER"];
$user->GetUserRights();
if(!$user->ReadAccess){
// No soup for you.
header('Location: '.redirect());
exit;
}
$datacenter = new DataCenter();
$dcList = $datacenter->GetDCList();
$cab = new Cabinet();
$dev = new Device();
if (!isset($_REQUEST['action'])) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>openDCIM Inventory Reporting</title>
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css">
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
</head>
<body>
<div style="height: 66px;" id="header"></div>
<?php
include( 'sidebar.inc.php' );
?>
</div>
<div class="main">
<h2>openDCIM</h2>
<h3><?php __("XML Output for CFD Simulation"); ?></h3>
<form action="<?php printf( "%s", $_SERVER['PHP_SELF'] ); ?>" method="post">
<table align="center" border=0>
<?php
if ( @$_REQUEST['datacenterid'] == 0 ) {
printf( "<tr><td>%s:</td><td>\n", __("Data Center") );
printf( "<select name=\"datacenterid\" onChange=\"form.submit()\">\n" );
printf( "<option value=\"\">%s</option>\n", __("Select data center") );
foreach ( $dcList as $dc )
printf( "<option value=\"%d\">%s</option>\n", $dc->DataCenterID, $dc->Name );
printf( "</td></tr>" );
} else {
$datacenter->DataCenterID = $_REQUEST['datacenterid'];
$datacenter->GetDataCenter();
printf( "<h3>%s : %s</h3>\n", __("Data Center"), $datacenter->Name );
printf( "<input type=\"hidden\" name=\"datacenterid\" value=\"%d\">\n", $datacenter->DataCenterID );
printf( "<input type=submit name=\"action\" value=\"%s\"><br>\n", __("Generate") );
}
?>
</table>
</form>
<?php
} else {
$datacenter->DataCenterID = $_REQUEST["datacenterid"];
$datacenter->GetDataCenter();
header("Content-type: text/xml");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: attachment; filename="opendcim.xml"');
print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
print "<datacenter>\n";
printf( "\t<ID>%d</ID>\n", $datacenter->DataCenterID );
printf( "\t<Name>%s</Name>\n", $datacenter->Name );
printf( "\t<Size>%d</Size>\n", $datacenter->SquareFootage );
$cab->DataCenterID = $datacenter->DataCenterID;
$cabList = $cab->ListCabinetsByDC();
foreach ( $cabList as $cabRow ) {
print "\t<cabinet>\n";
printf( "\t\t<ID>%d</ID>\n", $cabRow->CabinetID );
printf( "\t\t<Location>%s</Location>\n", $cabRow->Location );
printf( "\t\t<Height>%d</Height>\n", $cabRow->CabinetHeight );
printf( "\t\t<FrontEdge>%s</FrontEdge>\n", $cabRow->FrontEdge );
printf( "\t\t<MapX1>%d</MapX1>\n", $cabRow->MapX1 );
printf( "\t\t<MapY1>%d</MapY1>\n", $cabRow->MapY1 );
printf( "\t\t<MapX2>%d</MapX2>\n", $cabRow->MapX2 );
printf( "\t\t<MapY2>%d</MapY2>\n", $cabRow->MapY2 );
$dev->Cabinet = $cabRow->CabinetID;
$devList = $dev->ViewDevicesByCabinet( false );
$totalWatts = 0;
foreach ( $devList as $devRow ) {
print "\t\t<Device>\n";
printf( "\t\t\t<ID>%d</ID>\n", $devRow->DeviceID );
printf( "\t\t\t<Label>%s</Label>\n", $devRow->Label );
printf( "\t\t\t<Position>%d</Position>\n", $devRow->Position );
printf( "\t\t\t<Height>%d</Height>\n", $devRow->Height );
printf( "\t\t\t<Watts>%d</Watts>\n", $devRow->GetDeviceTotalPower() );
print "\t\t</Device>\n";
$totalWatts += $devRow->GetDeviceTotalPower();
}
printf( "\t\t<TotalWatts>%d</TotalWatts>\n", $totalWatts );
print "\t</cabinet>\n";
}
print "</datacenter>\n";
print "</xml>\n";
}
?>