2010-01-09 17:21:37 +00:00
< ? php print_optionbar_start ( '25' ); ?>
2009-08-11 15:41:11 +00:00
2014-01-13 10:05:19 +00:00
< form method = " post " action = " " class = " form-inline " role = " form " >
< div class = " form-group " >
< input type = " text " name = " string " id = " string " value = " <?php echo( $_POST['string'] ); ?> " placeholder = " Description " class = " form-control input-sm " />
</ div >
< div class = " form-group " >
2009-01-06 15:04:49 +00:00
< strong > Part No </ strong >
2014-01-13 10:05:19 +00:00
< select name = " part " id = " part " class = " form-control input-sm " >
2009-01-06 15:04:49 +00:00
< option value = " " > All Parts </ option >
< ? php
2011-05-14 21:51:58 +00:00
foreach ( dbFetchRows ( " SELECT `entPhysicalModelName` FROM `entPhysical` GROUP BY `entPhysicalModelName` ORDER BY `entPhysicalModelName` " ) as $data )
2011-03-17 00:09:20 +00:00
{
2009-01-06 15:04:49 +00:00
echo ( " <option value=' " . $data [ 'entPhysicalModelName' ] . " ' " );
2011-03-17 00:09:20 +00:00
if ( $data [ 'entPhysicalModelName' ] == $_POST [ 'part' ]) { echo ( " selected " ); }
2009-01-06 15:04:49 +00:00
echo ( " > " . $data [ 'entPhysicalModelName' ] . " </option> " );
}
?>
</ select >
2014-01-13 10:05:19 +00:00
</ div >
< div class = " form-group " >
< input type = " text " name = " serial " id = " serial " value = " <?php echo( $_POST['serial'] ); ?> " placeholder = " Serial " class = " form-control input-sm " />
</ div >
< div class = " form-group " >
2009-01-06 15:04:49 +00:00
< strong > Device </ strong >
2014-01-13 10:05:19 +00:00
< select name = " device " id = " device " class = " form-control input-sm " >
2009-01-06 15:04:49 +00:00
< option value = " " > All Devices </ option >
< ? php
2011-05-14 21:51:58 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `devices` ORDER BY `hostname` " ) as $data )
2011-03-17 00:09:20 +00:00
{
2009-01-06 15:04:49 +00:00
echo ( " <option value=' " . $data [ 'device_id' ] . " ' " );
2011-03-17 00:09:20 +00:00
if ( $data [ 'device_id' ] == $_POST [ 'device' ]) { echo ( " selected " ); }
2009-01-06 15:04:49 +00:00
echo ( " > " . $data [ 'hostname' ] . " </option> " );
}
?>
</ select >
2014-01-13 10:05:19 +00:00
</ div >
< div class = " form-group " >
< input type = " text " size = 24 name = " device_string " id = " device_string " value = " <?php if ( $_POST['device_string'] ) { echo( $_POST['device_string'] ); } ?> " placeholder = " Description " class = " form-control input-sm " />
</ div >
< button type = " submit " class = " btn btn-default input-sm " > Search </ button >
</ form >
2009-09-07 11:07:59 +00:00
< ? php
2008-11-05 13:11:40 +00:00
2011-10-18 14:41:19 +00:00
$pagetitle [] = " Inventory " ;
2010-01-09 17:21:37 +00:00
print_optionbar_end ();
2011-05-14 21:51:58 +00:00
$param = array ();
if ( $_SESSION [ 'userlevel' ] >= '5' )
2011-03-17 00:09:20 +00:00
{
2011-05-14 21:51:58 +00:00
$sql = " SELECT * from entPhysical AS E, devices AS D WHERE D.device_id = E.device_id " ;
} else {
$sql = " SELECT * from entPhysical AS E, devices AS D, devices_perms AS P WHERE D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ? " ;
$param [] = $_SESSION [ 'user_id' ];
2009-04-11 19:10:48 +00:00
}
2011-05-14 21:51:58 +00:00
if ( isset ( $_POST [ 'string' ]) && strlen ( $_POST [ 'string' ]))
2011-03-17 00:09:20 +00:00
{
2011-05-14 21:51:58 +00:00
$sql .= " AND E.entPhysicalDescr LIKE ? " ;
2011-09-20 09:55:11 +00:00
$param [] = " % " . $_POST [ 'string' ] . " % " ;
2009-01-06 15:04:49 +00:00
}
2008-11-05 13:11:40 +00:00
2011-05-14 21:51:58 +00:00
if ( isset ( $_POST [ 'device_string' ]) && strlen ( $_POST [ 'device_string' ]))
2011-03-17 00:09:20 +00:00
{
2011-05-14 21:51:58 +00:00
$sql .= " AND D.hostname LIKE ? " ;
$param [] = " % " . $_POST [ 'device_string' ] . " % " ;
2009-01-06 15:04:49 +00:00
}
2008-11-05 13:11:40 +00:00
2011-05-14 21:51:58 +00:00
if ( isset ( $_POST [ 'part' ]) && strlen ( $_POST [ 'part' ]))
2011-03-17 00:09:20 +00:00
{
2011-05-14 21:51:58 +00:00
$sql .= " AND E.entPhysicalModelName = ? " ;
$param [] = $_POST [ 'part' ];
2009-01-06 15:04:49 +00:00
}
2011-05-14 21:51:58 +00:00
if ( isset ( $_POST [ 'serial' ]) && strlen ( $_POST [ 'serial' ]))
2011-03-17 00:09:20 +00:00
{
2011-05-14 21:51:58 +00:00
$sql .= " AND E.entPhysicalSerialNum LIKE ? " ;
$param [] = " % " . $_POST [ 'serial' ] . " % " ;
2009-01-06 15:04:49 +00:00
}
2008-11-05 13:11:40 +00:00
2011-05-14 21:51:58 +00:00
if ( isset ( $_POST [ 'device' ]) && is_numeric ( $_POST [ 'device' ]))
2011-03-17 00:09:20 +00:00
{
2011-05-14 21:51:58 +00:00
$sql .= " AND D.device_id = ? " ;
$param [] = $_POST [ 'device' ];
2009-08-12 15:20:20 +00:00
}
2008-11-05 13:11:40 +00:00
2014-03-02 15:36:40 +00:00
echo ( ' < div class = " panel panel-default panel-condensed " >
2014-03-02 15:35:04 +00:00
< div class = " panel-heading " >
< strong > Inventory </ strong >
</ div >
< table class = " table table-hover table-condensed table-striped " > ' );
2008-11-05 13:11:40 +00:00
echo ( " <tr><th>Hostname</th><th>Description</th><th>Name</th><th>Part No</th><th>Serial No</th></tr> " );
2011-05-14 21:51:58 +00:00
foreach ( dbFetchRows ( $sql , $param ) as $entry )
2011-03-17 00:09:20 +00:00
{
2014-03-03 00:09:10 +00:00
echo ( '<tr><td>' . generate_device_link ( $entry , shortHost ( $entry [ 'hostname' ])) . '</td><td>' . $entry [ 'entPhysicalDescr' ] .
2012-04-10 17:21:49 +00:00
'</td><td>' . $entry [ 'entPhysicalName' ] . '</td><td>' . $entry [ 'entPhysicalModelName' ] . '</td><td>' . $entry [ 'entPhysicalSerialNum' ] . '</td></tr>' );
2008-11-05 13:11:40 +00:00
}
echo ( " </table> " );
2014-03-02 15:35:04 +00:00
echo ( '</div>' );
2008-11-05 13:11:40 +00:00
?>