Location: PHPKode > projects > PhpMyInventory > pmi281/move_hardware.php
<?
  Include("Includes/global.inc.php");
  checkPermissions(1, 1800);

// Has the form been submitted
if ($btnSubmit) {
    if ($hardware_id) {
        $strIP    = validateIP("1", FALSE);
        $cboUser  = validateChoice("Assign to", $cboUser);
    
        If (!$strError) {
             If ($cboUser == "spare") {
                 $strSQL = "UPDATE hardware SET userID=0, sparePart='1', ipAddress='$strIP'
                   WHERE accountID=$accountID AND pk_asset=$hardware_id";
                 $spare = "1";
             } ElseIf ($cboUser == "independent") {
                 $strSQL = "UPDATE hardware SET userID=0, sparePart='2', ipAddress='$strIP'
                   WHERE accountID=$accountID AND pk_asset=$hardware_id";
                 $spare = "2";
             } Else {
                 $strSQL = "UPDATE hardware SET userID=$cboUser, sparePart='0', ipAddress='$strIP'
                   WHERE accountID=$accountID AND pk_asset=$hardware_id";
                 $spare = "0";
             }
             $result = dbquery($strSQL);
             redirect("index.php", "notify=update&spare=$spare");
        }
    } else {
        $strError = "Unexpected error: please return to the <a href='index.php'>home page</a>, and retry this operation.";
    }
} elseif ($hardware_id) {
    $strSQL = "SELECT * FROM hardware WHERE pk_asset=$hardware_id AND accountID=$accountID";
    $result = dbquery($strSQL);

    While ($row = mysql_fetch_array($result)) {
        $strIP = $row["ipAddress"];
    }
}

writeHeader("Assign System");
declareError(TRUE);
?>

<FORM METHOD="post" ACTION="<? echo $PHP_SELF?>">
<INPUT TYPE="hidden" NAME="hardware_id" VALUE="<? echo $hardware_id; ?>">

Assign to: &nbsp;<? echo buildUserSelect($cboUser, TRUE); ?><p>
IP Address: &nbsp;<? buildIP($strIP, "1"); ?>
<p>

<font size='-1'>
<INPUT TYPE="submit" NAME="btnSubmit" VALUE="Submit Change">&nbsp; <A HREF="index.php">Never Mind</A></font>
</FORM>

<?
writeFooter();
?>
Return current item: PhpMyInventory