template_dir = 'tpl'; $smarty->compile_dir = 'tpl_c'; $smarty->registerPlugin('function', 'treelist', 'print_tree'); $smarty->assign("suser_tooltips", $_SESSION['suser_tooltips'] ?? 'off'); // ========== DATABASE FUCTIONS =============================================== function db_get_options_asset() { global $dbh; $sql = "SELECT asset_id, asset_name FROM asset ORDER BY asset_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_assetclass() { global $dbh; $sql = "SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_assetclassgroup() { global $dbh; $sql = "SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_location() { global $dbh; $sql = "SELECT location_id, location_name FROM location ORDER BY location_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_subnet() { global $dbh; $sql = "SELECT subnet_id, CONCAT_WS('/', subnet_address, subnet_mask) AS subnet_name FROM subnet ORDER BY INET_ATON(subnet_address)"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } function db_get_options_vlan() { global $dbh; $sql = "SELECT vlan_id, vlan_name FROM vlan ORDER BY vlan_name"; $sth = $dbh->query($sql); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $rec) { $options[$rec[0]] = $rec[1]; } return $options; } ?>