forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_asset.php
132 lines (103 loc) · 4.03 KB
/
report_asset.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
<?php
require_once( 'db.inc.php' );
require_once( 'facilities.inc.php' );
define('FPDF_FONTPATH','font/');
require('fpdf.php');
class PDF extends FPDF {
var $outlines=array();
var $OutlineRoot;
var $pdfconfig;
var $pdfDB;
function PDF(){
parent::FPDF();
}
function Header() {
$this->pdfconfig = new Config();
$this->Image( 'images/' . $this->pdfconfig->ParameterArray['PDFLogoFile'],10,8,100);
$this->SetFont($this->pdfconfig->ParameterArray['PDFfont'],'B',12);
$this->Cell(120);
$this->Cell(30,20,'Information Technology Services',0,0,'C');
$this->Ln(20);
$this->SetFont( $this->pdfconfig->ParameterArray['PDFfont'],'',10 );
$this->Cell( 50, 6, 'Data Center Asset Report', 0, 1, 'L' );
$this->Cell( 50, 6, 'Date: ' . date( 'm/d/y' ), 0, 1, 'L' );
$this->Ln(10);
}
function Footer() {
$this->SetY(-15);
$this->SetFont($this->pdfconfig->ParameterArray['PDFfont'],'I',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$Owner = @$_REQUEST['owner'];
$DataCenterID = @$_REQUEST['datacenterid'];
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont($config->ParameterArray['PDFfont'],'',8);
$pdf->SetFillColor( 0, 0, 0 );
$pdf->SetTextColor( 255 );
$pdf->SetDrawColor( 128, 0, 0 );
$pdf->SetLineWidth( .3 );
$headerTags = array( 'Room', 'Rack', 'Position', 'Label', 'Serial Number', 'Asset Tag' );
$cellWidths = array( 15, 15, 15, 70, 30, 30 );
$maxval = count( $headerTags );
for ( $col = 0; $col < $maxval; $col++ )
$pdf->Cell( $cellWidths[$col], 7, $headerTags[$col], 1, 0, 'C', 1 );
$pdf->Ln();
$pdf->SetfillColor( 224, 235, 255 );
$pdf->SetTextColor( 0 );
$fill = 0;
$Criteria = '';
if ( $Owner > 0 )
$Criteria .= 'c.Owner=\'' . intval( $Owner ) . '\' and ';
if ( $DataCenterID > 0 )
$Criteria .= 'b.DataCenterID=\'' . intval( $DataCenterID ) . '\' and ';
$searchSQL = 'select a.Name,b.Location,c.Position,c.Height,c.Label,c.SerialNo,c.AssetTag,c.DeviceID,c.DeviceType from fac_DataCenter a, fac_Cabinet b, fac_Device c where ' . $Criteria . 'c.Cabinet=b.CabinetID and b.DataCenterID=a.DataCenterID and c.Reservation=false order by a.Name,b.Location,c.Position';
$lastDC = '';
$lastCab = '';
foreach($dbh->query($searchSQL) as $reportRow){
$DataCenter = $reportRow['Name'];
$Location = $reportRow['Location'];
if ( $reportRow["Height"] > 1 )
$Position = '[' . $reportRow['Position'] . '-' . intval($reportRow['Position']+$reportRow['Height']) . ']';
else
$Position = $reportRow['Position'];
$Label = $reportRow['Label'];
$SerialNo = $reportRow['SerialNo'];
$AssetTag = $reportRow['AssetTag'];
if ( $lastDC != $DataCenter )
$pdf->Cell( $cellWidths[0], 6, $DataCenter, 'LR', 0, 'L', $fill );
else
$pdf->Cell( $cellWidths[0], 6, '', 'LR', 0, 'L', $fill );
if ( $lastCab != $Location )
$pdf->Cell( $cellWidths[1], 6, $Location, 'LR', 0, 'L', $fill );
else
$pdf->Cell( $cellWidths[1], 6, '', 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[2], 6, $Position, 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[3], 6, $Label, 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[4], 6, $SerialNo, 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[5], 6, $AssetTag, 'LR', 0, 'L', $fill );
$pdf->Ln();
$fill =! $fill;
if ( $reportRow["DeviceType"] == "Chassis" ) {
$chDev = new Device();
$chDev->DeviceID = $reportRow["DeviceID"];
$chList = $chDev->GetDeviceChildren();
foreach ( $chList as $chRow ) {
$pdf->Cell( $cellWidths[0], 6, '', 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[1], 6, '', 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[2], 6, '(blade)', 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[3], 6, $chRow->Label, 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[4], 6, $chRow->SerialNo, 'LR', 0, 'L', $fill );
$pdf->Cell( $cellWidths[5], 6, $chRow->AssetTag, 'LR', 0, 'L', $fill );
$pdf->Ln();
$fill =! $fill;
}
}
$lastDC = $DataCenter;
$lastCab = $Location;
}
$pdf->Cell( array_sum( $cellWidths ), 0, '', 'T' );
$pdf->Output();
?>