Location: PHPKode > scripts > rConfig > rconfig/www/lib/crud/devices.frm.func.php
<?php
require_once("../classes/db.class.php");
require_once("../classes/ADLog.class.php");

function vendorId($id = null) {
	// $id is set if from is reploaded with errors so that selected item is pre-populated after form reload
    $db  = new db();
    $log = ADLog::getInstance();
    
    /*
     * Extract Nodes vendorId for select list below
     */
    $q        = "SELECT * FROM vendors WHERE status = 1 ORDER BY vendorname ASC";
    $result   = $db->q($q);
    $num_rows = mysql_numrows($result);
    if (!$result || ($num_rows < 0)) {
        $log->Warn("Failure: Problem Displaying vendorId options (File: " . $_SERVER['PHP_SELF'] . ")");
        echo "Error displaying info";
        return;
    }
    if ($num_rows == 0) {
        $log->Warn("Failure: Problem Displaying vendorId - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
        echo "Database table empty";
        return;
    }
	if($id == null){ 
		echo "<option value=\"\" selected></option>";
	} else {
		echo "<option value=\"\"></option>";
	}
    for ($i = 0; $i < $num_rows; $i++) {
        $vendorId   = mysql_result($result, $i, "id");
        $vendorName = mysql_result($result, $i, "vendorName");
        if($id == $vendorId && $id != null){
			echo "<option value=" . $vendorId . " selected>" . $vendorName . "</option>";
		} else {
			echo "<option value=" . $vendorId . ">" . $vendorName . "</option>";
		}
    }
}

function accessMethod($id = null) {
	// $id is set if from is reploaded with errors so that selected item is pre-populated after form reload

    $db       = new db();
    $log      = ADLog::getInstance();
    /*
     * Extract Nodes accessMethod for select list below
     */
    $q        = "SELECT * FROM devicesaccessmethod";
    $result   = $db->q($q);
    $num_rows = mysql_numrows($result);
    if (!$result || ($num_rows < 0)) {
        $log->Warn("Failure: Problem Displaying devicesaccessmethod options (File: " . $_SERVER['PHP_SELF'] . ")");
        echo "Error displaying info";
        return;
    }
    if ($num_rows == 0) {
        $log->Warn("Failure: Problem Displaying devicesaccessmethod - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
        echo "Database table empty";
        return;
    }
	if($id == null){ 
		echo "<option selected=\"selected\" value=\"\">- Select an option -</option>";
	} else {
	echo "<option value=\"\">- Select an option -</option>";
	}

    for ($i = 0; $i < $num_rows; $i++) {
        $accessId   = mysql_result($result, $i, "id");
        $accessName = mysql_result($result, $i, "devicesAccessMethod");
        if($id == $accessId && $id != null){
			echo "<option value=" . $accessId . " selected>" . $accessName . "</option>";
		} else {
			echo "<option value=" . $accessId . ">" . $accessName . "</option>";
		}		
    }    
}

function categories($id=null) {
	// $id is set if from is reploaded with errors so that selected item is pre-populated after form reload	
    $db       = new db();
    $log      = ADLog::getInstance();
    /*
     * Extract Categories for select list below
     */
    $q        = "SELECT * FROM categories WHERE status = 1";
    $result   = $db->q($q);
    $num_rows = mysql_numrows($result);
    
    if (!$result || ($num_rows < 0)) {
        echo "Error displaying info";
        $log->Warn("Failure: Problem Displaying categories options (File: " . $_SERVER['PHP_SELF'] . ")");
        return;
    }
    if ($num_rows == 0) {
        echo "Database table empty";
        $log->Warn("Failure: Database table returned empty  on categories - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
        return;
    }
	if($id == null){ 
    echo "<option value=\"\" selected>Select a Category </option>";
	} else {
    echo "<option value=\"\">Select a Category </option>";
	}
    for ($i = 0; $i < $num_rows; $i++) {
        $catId   = mysql_result($result, $i, "id");
        $catName = mysql_result($result, $i, "categoryName");
        if($id == $catId && $id != null){
			echo "<option value=" . $catId . " selected>" . $catName . "</option>";
		} else {
			echo "<option value=" . $catId . ">" . $catName . "</option>";
		}		
    }    
	
} // end categories function

function customProp()
{
    $db       = new db();
    $q        = "SELECT * FROM customProperties";
    $result   = $db->q($q);
    $num_rows = mysql_numrows($result);
    
    for ($i = 0; $i < $num_rows; $i++) {
        $custprop = mysql_result($result, $i, "customProperty");
        
        // remove 'custom_' bit for display purposes
        $newcustprop = substr($custprop, 7);
        
        echo "<label>" . $newcustprop . ":</label>  
		<input type=\"text\" name=\"$custprop\" id=\"$custprop\" tabindex=12  style=\"width:150px;\"/> ";
    }
} // end custom properties function

?>
Return current item: rConfig