} if (isset($_POST['part']) && strlen($_POST['part'])) { $sql .= " AND E.entPhysicalModelName = ?"; $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { $sql .= " AND E.entPhysicalSerialNum LIKE ?"; $param[] = "%" . $_POST['serial'] . "%"; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { $sql .= " AND D.device_id = ?"; $param[] = $_POST['device']; } echo "<table class=\"table table-striped table-condensed\" style=\"margin-top: 10px;\">\n"; echo " <thead>\n"; echo " <tr>\n"; echo " <th>Device</th>\n"; echo " <th>Descr</th>\n"; echo " <th>Name</th>\n"; echo " <th>Part #</th>\n"; echo " <th>Serial #</th>\n"; echo " </tr>\n"; echo " </thead>\n"; echo '<tbody>'; foreach (dbFetchRows($sql, $param) as $entry) { echo '<tr class="inventory"><td>' . generate_device_link($entry, shortHost($entry['hostname'])) . '</td><td>' . $entry['entPhysicalDescr'] . '</td><td>' . $entry['entPhysicalName'] . '</td><td>' . $entry['entPhysicalModelName'] . '</td><td>' . $entry['entPhysicalSerialNum'] . '</td></tr>'; } echo "</table>"; ?> </table>
} if (isset($_POST['serial']) && strlen($_POST['serial'])) { $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; $param[] = '%' . $_POST['serial'] . '%'; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { $sql .= ' AND D.device_id = ?'; $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) {$sql}"; $total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } if (!isset($sort) || empty($sort)) { $sort = '`hostname` DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` {$sql}"; foreach (dbFetchRows($sql, $param) as $invent) { $response[] = array('hostname' => generate_device_link($invent, shortHost($invent['hostname'])), 'description' => $invent['description'], 'name' => $invent['name'], 'model' => $invent['model'], 'serial' => $invent['serial']); } $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
} if ($_POST['part']) { $where .= " AND E.entPhysicalModelName = '" . $_POST['part'] . "'"; } if ($_POST['serial']) { $where .= " AND E.entPhysicalSerialNum LIKE '%" . $_POST['serial'] . "%'"; } if ($_POST['device']) { $where .= " AND D.device_id = '" . $_POST['device'] . "'"; } if ($_SESSION['userlevel'] >= '5') { $sql = "SELECT * from entPhysical AS E, devices AS D WHERE E.device_id = D.device_id {$where} ORDER BY D.hostname"; } else { $sql = "SELECT * from entPhysical AS E, devices AS D, devices_perms AS P \n WHERE E.device_id = D.device_id AND D.device_id = P.device_id {$where} ORDER BY D.hostname"; } $query = mysql_query($sql); echo "<table cellspacing=0 cellpadding=2 width=100%>"; echo "<tr><th>Hostname</th><th>Description</th><th>Name</th><th>Part No</th><th>Serial No</th></tr>"; while ($entry = mysql_fetch_array($query)) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg = $list_colour_a; } echo "<tr style=\"background-color: {$bg}\"><td>" . generatedevicelink($entry, shortHost($entry['hostname'])) . "</td><td>" . $entry['entPhysicalDescr'] . "</td><td>" . $entry['entPhysicalName'] . "</td><td>" . $entry['entPhysicalModelName'] . "</td><td>" . $entry['entPhysicalSerialNum'] . "</td></tr>"; } echo "</table>"; ?> </table>