function details($cmd, $list, $rig) { global $dfmt, $poolcmd, $readonly, $showndate; global $rownum, $rigtotals, $forcerigtotals, $singlerigsum; $when = 0; $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal'); newtable(); if ($showndate === false) { showdatetime(); endtable(); newtable(); $showndate = true; } if (isset($list['STATUS'])) { newrow(); echo '<td>Computer: ' . $list['STATUS']['Description'] . '</td>'; if (isset($list['STATUS']['When'])) { echo '<td>When: ' . date($dfmt, $list['STATUS']['When']) . '</td>'; $when = $list['STATUS']['When']; } $sta = $list['STATUS']['STATUS']; echo '<td>Status: ' . $stas[$sta] . '</td>'; echo '<td>Message: ' . $list['STATUS']['Msg'] . '</td>'; endrow(); } if ($rigtotals === true && isset($singlerigsum[$cmd])) { $dototal = $singlerigsum[$cmd]; } else { $dototal = array(); } $total = array(); $section = ''; $oldvalues = null; foreach ($list as $item => $values) { if ($item == 'STATUS') { continue; } $sectionname = preg_replace('/\\d/', '', $item); // Handle 'devs' possibly containing >1 table if ($sectionname != $section) { if ($oldvalues != null && count($total) > 0 && ($rownum > 2 || $forcerigtotals === true)) { showtotal($total, $when, $oldvalues); } endtable(); newtable(); showhead($cmd, $values); $section = $sectionname; } newrow(); foreach ($values as $name => $value) { list($showvalue, $class) = fmt($section, $name, $value, $when, $values); echo "<td{$class}"; if ($rigtotals === true) { echo ' align=right'; } echo ">{$showvalue}</td>"; if (isset($dototal[$name]) || (isset($dototal['*']) and substr($name, 0, 1) == '*')) { if (isset($total[$name])) { $total[$name] += $value; } else { $total[$name] = $value; } } } if ($cmd == 'pools' && $readonly === false) { reset($values); $pool = current($values); foreach ($poolcmd as $name => $pcmd) { list($ignore, $class) = fmt('BUTTON', 'Pool', '', $when, $values); echo "<td{$class}>"; if ($pool === false) { echo ' '; } else { echo "<input type=button value='Pool {$pool}'"; echo " onclick='prc(\"{$pcmd}|{$pool}&rig={$rig}\",\"{$name} Pool {$pool}\")'>"; } echo '</td>'; } } endrow(); $oldvalues = $values; } if ($oldvalues != null && count($total) > 0 && ($rownum > 2 || $forcerigtotals === true)) { showtotal($total, $when, $oldvalues); } endtable(); }
function details($cmd, $list, $rig) { global $dfmt, $poolcmd, $readonly, $showndate; global $rownum, $rigtotals, $forcerigtotals, $singlerigsum; $when = 0; $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal'); newtable(); if ($showndate === false) { showdatetime(); endtable(); newtable(); $showndate = true; } if (isset($list['STATUS'])) { newrow(); echo '<td>Computer: ' . $list['STATUS']['Description'] . '</td>'; if (isset($list['STATUS']['When'])) { echo '<td>When: ' . date($dfmt, $list['STATUS']['When']) . '</td>'; $when = $list['STATUS']['When']; } $sta = $list['STATUS']['STATUS']; echo '<td>Status: ' . $stas[$sta] . '</td>'; echo '<td>Message: ' . $list['STATUS']['Msg'] . '</td>'; endrow(); } if ($rigtotals === true && isset($singlerigsum[$cmd])) { $dototal = $singlerigsum[$cmd]; } else { $dototal = array(); } $total = array(); $section = ''; $oldvalues = null; // Build a common row column for all entries $columns = array(); $columnsByIndex = array(); foreach ($list as $item => $values) { if ($item == 'STATUS') { continue; } if (isset($values['ID'])) { $repr = $values['Name'] . $values['ID']; if (isset($values['ProcID'])) { $repr .= join_get_field('ProcID', $values); } $list[$item] = $values = array('Device' => $repr) + array_slice($values, 1); unset($values['Name']); unset($values['ID']); unset($values['ProcID']); } $namesByIndex = array_keys($values); $nameCount = count($namesByIndex); for ($i = 0; $i < $nameCount; ++$i) { $name = $namesByIndex[$i]; if (isset($columns[$name])) { continue; } $value = $values[$name]; $before = null; for ($j = $i + 1; $j < $nameCount; ++$j) { $maybebefore = $namesByIndex[$j]; if (isset($columns[$maybebefore])) { $before = $columns[$maybebefore]; break; } } if (!$before) { $columns[$name] = array_push($columnsByIndex, $name) - 1; continue; } array_splice($columnsByIndex, $before, 0, $name); $columns[$name] = $before; $columnCount = count($columnsByIndex); for ($j = $before + 1; $j < $columnCount; ++$j) { $columns[$columnsByIndex[$j]] = $j; } } } asort($columns); endtable(); newtable(); showhead($cmd, $columns); foreach ($list as $item => $values) { if ($item == 'STATUS') { continue; } newrow(); foreach ($columns as $name => $columnidx) { if (!isset($values[$name])) { echo '<td></td>'; continue; } $value = $values[$name]; list($showvalue, $class) = fmt($section, $name, $value, $when, $values); echo "<td{$class}"; if ($rigtotals === true) { echo ' align=right'; } echo ">{$showvalue}</td>"; if (isset($dototal[$name]) || (isset($dototal['*']) and substr($name, 0, 1) == '*')) { if (isset($total[$name])) { if (isset($dototal[$name]) && $dototal[$name] == 2) { $total[$name] = max($total[$name], $value); } else { $total[$name] += $value; } } else { $total[$name] = $value; } } } if ($cmd == 'pools' && $readonly === false) { reset($values); $pool = current($values); foreach ($poolcmd as $name => $pcmd) { list($ignore, $class) = fmt('BUTTON', 'Pool', '', $when, $values); echo "<td{$class}>"; if ($pool === false) { echo ' '; } else { echo "<input type=button value='Pool {$pool}'"; echo " onclick='prc(\"{$pcmd}|{$pool}&rig={$rig}\",\"{$name} Pool {$pool}\")'>"; } echo '</td>'; } } endrow(); $oldvalues = $values; } if ($oldvalues != null && count($total) > 0 && ($rownum > 2 || $forcerigtotals === true)) { showtotal($total, $when, $columns); } endtable(); }