function getExpirationsText() { $row_format = "%3s|%-30s|%-15s|%-15s|%s\r\n"; $ret = ''; $breakdown = array(); $breakdown[21] = array(array('from' => -365, 'to' => 0, 'title' => 'has expired within last year'), array('from' => 0, 'to' => 30, 'title' => 'expires within 30 days')); $breakdown[22] = $breakdown[21]; $breakdown[24] = $breakdown[21]; $attrmap = getAttrMap(); foreach ($breakdown as $attr_id => $sections) { $ret .= $attrmap[$attr_id]['name'] . "\r\n"; $ret .= "===========================================\r\n"; foreach ($sections as $section) { $count = 1; $result = scanAttrRelativeDays($attr_id, $section['from'], $section['to']); if (!count($result)) { continue; } $ret .= $section['title'] . "\r\n"; $ret .= "-----------------------------------------------------------------------------------\r\n"; $ret .= sprintf($row_format, '#', 'Name', 'Asset Tag', 'OEM S/N 1', 'Date Warranty Expires'); $ret .= "-----------------------------------------------------------------------------------\r\n"; foreach ($result as $row) { $object = spotEntity('object', $row['object_id']); $attributes = getAttrValues($object['id']); $ret .= sprintf($row_format, $count, $object['dname'], $object['asset_no'], array_key_exists(1, $attributes) ? $attributes[1]['a_value'] : '', datetimestrFromTimestamp($row['uint_value'])); $count++; } $ret .= "-----------------------------------------------------------------------------------\r\n"; } $ret .= "\r\n"; } return $ret; }
function renderExpirations() { global $nextorder; $breakdown = array(); $breakdown[21] = array(array('from' => -365, 'to' => 0, 'class' => 'has_problems_', 'title' => 'has expired within last year'), array('from' => 0, 'to' => 30, 'class' => 'row_', 'title' => 'expires within 30 days'), array('from' => 30, 'to' => 60, 'class' => 'row_', 'title' => 'expires within 60 days'), array('from' => 60, 'to' => 90, 'class' => 'row_', 'title' => 'expires within 90 days')); $breakdown[22] = $breakdown[21]; $breakdown[24] = $breakdown[21]; $attrmap = getAttrMap(); foreach ($breakdown as $attr_id => $sections) { startPortlet($attrmap[$attr_id]['name']); foreach ($sections as $section) { $count = 1; $order = 'odd'; $result = scanAttrRelativeDays($attr_id, $section['from'], $section['to']); echo '<table align=center width=60% border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; echo "<caption>{$section['title']}</caption>\n"; if (!count($result)) { echo "<tr><td colspan=4>(none)</td></tr></table><br>\n"; continue; } echo '<tr valign=top><th align=center>Count</th><th align=center>Name</th>'; echo "<th align=center>Asset Tag</th><th align=center>OEM S/N 1</th><th align=center>Date Warranty <br> Expires</th></tr>\n"; foreach ($result as $row) { $date_value = datetimestrFromTimestamp($row['uint_value']); $object = spotEntity('object', $row['object_id']); $attributes = getAttrValues($object['id']); $oem_sn_1 = array_key_exists(1, $attributes) ? $attributes[1]['a_value'] : ' '; echo '<tr class=' . $section['class'] . $order . ' valign=top>'; echo "<td>{$count}</td>"; echo '<td>' . mkA($object['dname'], 'object', $object['id']) . '</td>'; echo "<td>{$object['asset_no']}</td>"; echo "<td>{$oem_sn_1}</td>"; echo "<td>{$date_value}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; $count++; } echo "</table><br>\n"; } finishPortlet(); } }
function formatAttributeValue($record) { if ('date' == $record['type']) { return datetimestrFromTimestamp($record['value']); } if (!isset($record['key'])) { if ($record['id'] == 3) { // FQDN attribute foreach (getMgmtProtosConfig() as $proto => $filter) { try { if (considerGivenConstraint(NULL, $filter)) { $blank = preg_match('/^https?$/', $proto) ? 'target=_blank' : ''; return "<a {$blank} title='Open {$proto} session' class='mgmt-link' href='" . $proto . '://' . $record['a_value'] . "'>{$record['a_value']}</a>"; } } catch (RackTablesError $e) { // syntax error in $filter continue; } } } return isset($record['href']) ? "<a href=\"" . $record['href'] . "\">{$record['a_value']}</a>" : $record['a_value']; } $href = makeHref(array('page' => 'depot', 'tab' => 'default', 'andor' => 'and', 'cfe' => '{$attr_' . $record['id'] . '_' . $record['key'] . '}')); $result = "<a href='{$href}'>" . $record['a_value'] . "</a>"; if (isset($record['href'])) { $result .= " <a class='img-link' href='{$record['href']}'>" . getImageHREF('html', 'vendor's info page') . "</a>"; } return $result; }