/** * Prints the data. * @param $data (array) Array containing data to print. * @public */ public function printData($data) { global $l, $db; require_once '../config/tce_config.php'; $dcn_num = 0; // for each datacenter foreach ($data['datacenter'] as $key => $dcn_value) { // new datacenter .................................................. ++$dcn_num; $sts_num = 0; $this->header_path = $dcn_value['dcn_name']; $this->AddPage(); $this->printTitle($dcn_num . '. ' . $this->l['t_datacenter'] . ': ' . $dcn_value['dcn_name'], 0); $this->printDataLine($this->l['w_description'], $dcn_value['dcn_description']); $this->printDataLine($this->l['w_website'], $dcn_value['dcn_website_url']); $this->printDataLine($this->l['w_map'], $dcn_value['dcn_map_url']); // permission if (isset($dcn_value['dcn_permissions']) and !empty($dcn_value['dcn_permissions'])) { $perms = ''; foreach ($dcn_value['dcn_permissions'] as $group_id => $perm) { $perms .= "\n• " . $perm; } $this->printDataLine($this->l['t_permissions'], $perms); } foreach ($dcn_value['suite'] as $sts_key => $sts_value) { // new suite ................................................... ++$sts_num; $rck_num = 0; $this->header_path = $dcn_value['dcn_name'] . ' > ' . $sts_value['sts_name']; $this->AddPage(); $this->printTitle($dcn_num . '.' . $sts_num . '. ' . $this->l['t_suite'] . ': ' . $sts_value['sts_name'], 1); $this->printDataLine($this->l['w_description'], $sts_value['sts_description']); $this->printDataLine($this->l['w_floor'], $sts_value['sts_floor']); $this->printDataLine($this->l['w_width'], $sts_value['sts_width']); $this->printDataLine($this->l['w_height'], $sts_value['sts_height']); // permission if (isset($sts_value['sts_permissions']) and !empty($sts_value['sts_permissions'])) { $perms = ''; foreach ($sts_value['sts_permissions'] as $group_id => $perm) { $perms .= "\n• " . $perm; } $this->printDataLine($this->l['t_permissions'], $perms); } $this->Ln(10); // get rack position info $rack_pos = array(); foreach ($sts_value['rack'] as $sts_rack) { $rack_pos[$sts_rack['rck_position_x']][$sts_rack['rck_position_y']] = $sts_rack['rck_label']; } $this->SetFont('helvetica', '', 7); $this->SetLineStyle(array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); // print suite map $rw = ($this->w - $this->lMargin - $this->rMargin) / ($sts_value['sts_width'] + 2); $rh = ($this->h - $this->y - $this->bMargin) / ($sts_value['sts_height'] + 2); $rw = min($rw, $rh, 10); $rh = $rw; for ($y = $sts_value['sts_height']; $y >= 0; --$y) { $this->SetTextColor(33, 33, 33); $this->Cell($rw, $rw, $y, 0, 0, 'C', false, '', 1, true, 'T', 'M'); for ($x = 1; $x <= $sts_value['sts_width']; ++$x) { if ($y == 0) { $this->SetTextColor(33, 33, 33); $this->Cell($rw, $rw, $x, 0, 0, 'C', false, '', 1, true, 'T', 'M'); } else { if (isset($rack_pos[$x][$y])) { $this->SetTextColor(255, 255, 255); $this->SetFillColor(0, 128, 0); $this->Cell($rw, $rw, $rack_pos[$x][$y], 1, 0, 'C', true, '', 1, true, 'T', 'M'); } else { $this->SetFillColor(200, 200, 200); $this->Cell($rw, $rw, '', 1, 0, 'C', true, '', 1, true, 'T', 'M'); } } } $this->Ln(); } $this->SetFont('helvetica', '', 10); $this->SetTextColor(0, 0, 0); foreach ($sts_value['rack'] as $rck_value) { // new rack ................................................ ++$rck_num; $obj_num = 0; $this->header_path = $dcn_value['dcn_name'] . ' > ' . $sts_value['sts_name'] . ' > ' . $rck_value['rck_name']; $this->AddPage(); $this->printTitle($dcn_num . '.' . $sts_num . '.' . $rck_num . '. ' . $this->l['t_rack'] . ': ' . $rck_value['rck_name'], 2); $this->printDataLine($this->l['w_description'], $rck_value['rck_description']); $this->printDataLine($this->l['w_label'], $rck_value['rck_label']); $this->printDataLine($this->l['w_tag'], $rck_value['rck_tag']); $this->printDataLine($this->l['w_height'], $rck_value['rck_height']); $this->printDataLine($this->l['w_position_x'], $rck_value['rck_position_x']); $this->printDataLine($this->l['w_position_y'], $rck_value['rck_position_y']); // permission if (isset($rck_value['rck_permissions']) and !empty($rck_value['rck_permissions'])) { $perms = ''; foreach ($rck_value['rck_permissions'] as $group_id => $perm) { $perms .= "\n• " . $perm; } $this->printDataLine($this->l['t_permissions'], $perms); } $this->Ln(10); // get HTML table code $rackobjs = $rck_value['rck_table']; // clean up the html code: // remove links $rackobjs = preg_replace('/<a[^\\>]*>(.*?)<\\/a>/si', "\\1", $rackobjs); $rackobjs = str_replace('>new<', 'style="background-color:#dddddd;"><', $rackobjs); $rackobjs = str_replace('style="max-width:20px;"', '', $rackobjs); $rackobjs = str_replace('class="rackobject"', 'style="background-color:#008000;color:#ffffff;"', $rackobjs); $rackobjs = str_replace('<th', '<th align="center"', $rackobjs); $rackobjs = str_replace('<td', '<td align="center"', $rackobjs); $rackobjs = str_replace('<tr style="font-size:80%;"><th align="center">#</th><th align="center" title="front - left">FL</th><th align="center" title="front - right">FR</th><th align="center" style="min-width:50px;">front</th><th align="center" style="min-width:50px;">center</th><th align="center" style="min-width:50px;">rear</th><th align="center" title="rear - left">RL</th><th align="center" title="rear - right">RR</th></tr><tr>', '<tr style="font-weight:bold;"><th align="center" width="10mm">#</th><th align="center" width="20mm">FL</th><th align="center" width="20mm">FR</th><th align="center" width="30mm">front</th><th align="center" width="30mm">center</th><th align="center" width="30mm">rear</th><th align="center" width="20mm">RL</th><th align="center" width="20mm">RR</th></tr><tr>', $rackobjs); $rackobjs = str_replace('> ', ' style="background-color:#dddddd;">', $rackobjs); $rackobjs = str_replace('<table class="rack">', '<table cellpadding="0" cellspacing="0" border="1">', $rackobjs); $this->SetFont('helvetica', '', 7); $this->writeHTML($rackobjs, true, false, true, false, ''); $this->SetFont('helvetica', '', 10); $this->SetTextColor(0, 0, 0); // create guest and capacity list $guestlist = ''; $capacitylist = ''; foreach ($rck_value['rck_rackstack'] as $rckobj) { // capacity (report free ports) if (isset($rckobj['capacity']) and !empty($rckobj['capacity'])) { foreach ($rckobj['capacity'] as $ck => $cv) { if ($cv['free'] > 0) { $capacitylist .= '<tr>'; $capacitylist .= sprintf('<td style="text-align:center;">%02d - %02d</td>', $rckobj['loc_row_top'], $rckobj['loc_row_bottom']); $capacitylist .= '<td>' . $rckobj['obj_name'] . ' - ' . $rckobj['obj_label'] . ' - ' . $rckobj['obj_tag'] . '</td>'; $capacitylist .= '<td style="text-align:center;">' . $ck . '</td>'; $capacitylist .= '<td style="text-align:right;">' . $cv['total'] . '</td>'; $capacitylist .= '<td style="text-align:right;color:#006600;font-weight:bold;">' . $cv['free'] . '</td>'; $capacitylist .= '</tr>' . K_NEWLINE; } } } // guests if (!empty($rckobj['guests'])) { $guestlist .= '<li><strong>[' . $rckobj['loc_row_top'] . '-' . $rckobj['loc_row_bottom'] . '] ' . $rckobj['obj_name'] . ' - ' . $rckobj['obj_label'] . ' - ' . $rckobj['obj_tag'] . '</strong><ul>'; foreach ($rckobj['guests'] as $guest) { $guestlist .= '<li>' . $guest['obj_label'] . '</li>' . K_NEWLINE; } $guestlist .= '</ul></li>'; } } if (!empty($capacitylist)) { $this->AddPage(); $this->printTitle($l['t_capacity_report'], 3); $capacitylist = '<table border="1" celpadding="2" cellspacing="0" style="font-size:80%;"><tr style="text-align:center;background-color:#003399;color:white;"><th width="10%">' . $l['w_position'] . '</th><th width="60%">' . $l['w_object'] . '</th><th width="10%">' . $l['w_port'] . '</th><th width="10%">' . $l['w_total'] . '</th><th width="10%">' . $l['w_free'] . '</th></tr>' . $capacitylist . '</table>' . K_NEWLINE; $this->SetFont('helvetica', '', 7); $this->writeHTML($capacitylist, true, false, true, false, ''); } if (!empty($guestlist)) { $this->AddPage(); $this->printTitle($l['t_guest_list'], 3); $guestlist = '<ul>' . $guestlist . '</ul>'; $this->SetFont('helvetica', '', 7); $this->writeHTML($guestlist, true, false, true, false, ''); } $this->SetFont('helvetica', '', 10); $this->SetTextColor(0, 0, 0); // display objects details if ($this->show_objects) { foreach ($rck_value['object'] as $obj_value) { // new object .......................................... ++$obj_num; $this->header_path = $dcn_value['dcn_name'] . ' > ' . $sts_value['sts_name'] . ' > ' . $rck_value['rck_name'] . ' > ' . $obj_value['obj_name']; $this->AddPage(); $this->printTitle($dcn_num . '.' . $sts_num . '.' . $rck_num . '.' . $obj_num . '. ' . $this->l['t_object'] . ': ' . $obj_value['obj_name'], 3); // get array of all object data $tempfields = F_get_template_array($obj_value); // extract template keys for lookup $tfkeys = implode("\n", array_keys($tempfields)); // print port capacity if (isset($obj_value['capacity']) and !empty($obj_value['capacity'])) { $capacity_data = ''; foreach ($obj_value['capacity'] as $ck => $cv) { $capacity_data .= "\n• " . $ck . ': ' . $cv['total'] . ' = (' . $cv['used'] . ' ' . $l['w_used'] . ' + ' . $cv['free'] . ' ' . $l['w_free'] . ')' . K_NEWLINE; } $this->printDataLine($this->l['w_capacity'], substr($capacity_data, 1)); } $this->printObjectInfo($obj_value['obj_id'], $obj_value, $tempfields, $tfkeys, 4); } // end foreach object } } // end foreach rack } // end foreach suite } // end foreach datacenter }
/** * Returns object data temnplates array. * @param $obj_id (int) Object ID. * @return array Object data array. */ function F_get_objects_templates_array($obj_id) { return F_get_template_array(F_get_object_data_array($obj_id)); }