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

if ($notify != "") {
    switch ($notify) {
        case "insert":
            $strError = "Record added successfully.";
            break;
        case "update":
            $strError = "Record updated successfully.";
            break;
        case "insertSys":
            $strError = "System added. <a href='showfull.php?hardwareID=$hardwareID&spare=$spare'>Click here</a>
              to add peripherals or software to it.";
            break;
        default:
            $strError = $notify;
            break;
    }
}

If ($systemStatus) {
    $sqlCondition = "h.hardwareStatus='$systemStatus' AND";
}

If (($spare === "0") OR !$spare) {
    $spare = "0";
    $strSQL = "SELECT t.type_desc, h.pk_asset, s.firstName, s.middleInit, s.lastName, s.id,
      h.hardwareStatus, h.ipAddress FROM hardware as h, hw_types as t, tblSecurity as s WHERE
      $sqlCondition t.accountID=$accountID AND s.id=h.userID AND h.type=t.type_pk
      ORDER BY s.lastName, s.userID";
} ElseIf ($spare === "1") {
    $strSQL = "SELECT t.type_desc, h.pk_asset, h.hardwareStatus, h.ipAddress FROM hardware as h,
      hw_types as t WHERE $sqlCondition h.sparePart='1' AND t.accountID=$accountID AND
      h.type=t.type_pk ORDER BY t.type_desc";
} ElseIf ($spare === "2") {
    $strSQL = "SELECT t.type_desc, h.pk_asset, h.hardwareStatus, h.ipAddress FROM hardware as h,
      hw_types as t WHERE $sqlCondition h.sparePart='2' AND t.accountID=$accountID AND
      h.type=t.type_pk ORDER BY t.type_desc";
} Else {
    $fatalError = "Sorry, please try that operation again.";
}

writeHeader();
declareError(TRUE);
?>

<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
  <td class='smaller'>
     <b>Ownership:</b> &nbsp;<a href='index.php?spare=0&systemStatus=<?=$systemStatus;?>'>User</a> &nbsp;|&nbsp;
             <a href='index.php?spare=1&systemStatus=<?=$systemStatus;?>'>Spare</a> &nbsp;|&nbsp;
             <a href='index.php?spare=2&systemStatus=<?=$systemStatus;?>'>Independent</a>
  </td>
  <td class='smaller'> &nbsp; </td>
  <td class='smaller'>
     <b>Status:</b> &nbsp;<a href='index.php?systemStatus=w&spare=<?=$spare;?>'>Working</a> &nbsp;|&nbsp;
             <a href='index.php?systemStatus=i&spare=<?=$spare;?>'>In Service</a> &nbsp;|&nbsp;
             <a href='index.php?systemStatus=n&spare=<?=$spare;?>'>Need Service</a> &nbsp;|&nbsp;
             <a href='index.php?spare=<?=$spare;?>'>Show All</a>
  </td>
</tr>
</table>

<?
If (($spare === "0") OR !$spare) {
    echo "<p><i>User-Assigned Systems:</i><p>";
}

If (!$fatalError) {
    $strSQL = determinePageNumber($strSQL);
    $result = dbquery($strSQL);
    
    createPaging("notify");
    If ($pageNumber > 1) {
        echo("<p>");
    }

    while ($row = mysql_fetch_array($result)) {
        If (($spare === "0") OR !$spare) {
            $intUserID     = $row['id'];
            $strFirstName  = $row['firstName'];
            $strMiddleInit = $row['middleInit'];
            $strLastName   = $row['lastName'];
        } Else {
            $intUserID = "noUser";
        }
        $pk_asset      = $row['pk_asset'];
        $strHardware   = $row['type_desc'];
        $strHwStatus   = $row['hardwareStatus'];
        $strIP         = $row['ipAddress'];

        if ($intUserID != $tempUserID) {
            If ($countStarted) {
                echo "</UL>\n";
            }
            If (($spare === "0") OR !$spare) {
                echo buildName($strFirstName, $strMiddleInit, $strLastName, 0);
            } ElseIf ($spare === "1") {
                echo "&nbsp;<br><i>Spare Systems:</i> <br>";
            } ElseIf ($spare === "2") {
                echo "&nbsp;<br><i>Independent Systems:</i> <br>";
            }
            echo "<UL>\n";
            $tempUserID = $intUserID;
        }
        $countStarted = TRUE;

        $extraInfo = " &nbsp;(".writeStatus($strHwStatus).")";
        If ($strIP) {
            $extraInfo .= ", &nbsp;IP: ".$strIP;
        }

        echo "<LI style='line-height: 35%'><A HREF='showfull.php?hardwareID=$pk_asset&spare=$spare'>
          $strHardware</A>$extraInfo &nbsp;<p>";
    }
    If ($countStarted) {
        echo "</UL>\n";
    }

    createPaging("notify");

    If (!$countStarted) {
        echo "<p>No systems found.";
    }
}

writeFooter();
?>
Return current item: PhpMyInventory