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

  writeHeader("Spare Peripherals");
?>
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
  <td class='smaller'>
     <b>Status:</b> &nbsp;<a href='sparePeripherals.php?systemStatus=w'>Working</a> &nbsp;|&nbsp;
             <a href='sparePeripherals.php?systemStatus=i'>In Service</a> &nbsp;|&nbsp; 
             <a href='sparePeripherals.php?systemStatus=n'>Need Service</a> &nbsp;|&nbsp;
             <a href='sparePeripherals.php'>Show All</a>
  </td>
</tr>
</table><p>

Note: Peripherals assigned to a spare system are not also considered "spare"; they
 are assigned to a system. Only peripherals that truly have no association wind up here.<p>
 
<?
  If ($systemStatus) {
      $sqlCondition = "p.peripheralStatus='$systemStatus' AND";
  }

  $strSQL = "SELECT * FROM peripherals as p, peripheral_types as pt WHERE $sqlCondition p.sparePart='1'
    AND pt.peripheral_pk=p.peripheral_fk AND pt.accountID=$accountID ORDER BY description ASC";
  $strSQL = determinePageNumber($strSQL);
  $result = dbquery($strSQL);
?>
  <p><table border='0' cellspacing='0' cellpadding='4' width='100%'>
  <TR class='title'>
    <TD><b>Description</b></TD>
    <TD><b>Model</b></TD>
    <TD><b>Serial Number</b></TD>
    <TD><b>Ext?</b></TD>
    <TD><b>Status</b></TD>
    <TD><b>Action</b></TD>
<?
  $iCount = 0;
  $rowStyle = "";
  While ($row = mysql_fetch_array($result)) {

    $pk_peripheral = $row["pk_peripheral"];
    $serial_num    = $row["serial_num"];
    $peripheral_fk = $row["peripheral_fk"];
    $external      = $row["external"];
    $manufacturer  = $row['manufacturer'];
    $model         = $row['model'];
    $description   = $row['description'];
    $periphStatus  = $row['peripheralStatus'];

    // Display all the peripherals belonging to this server
?>
    <TR class='<? echo alternateRowColor(); ?>'>
    <TD><? echo $description; ?></TD>
    <TD><? echo $model; ?></TD>
    <TD><? echo writeNA($serial_num); ?></TD>
    <TD><? echo $external; ?></TD>
    <TD><? echo writeStatus($periphStatus); 

      If ($sessionSecurity > 1) {
          echo "&nbsp;";
      } Else {
    ?>
          (<a style='text-decoration: none' href='<?=$SCRIPT_NAME?>?rowOffset=<?=$rowOffset?>&systemStatus=<?=$systemStatus?>&peripheralID=<?=$pk_peripheral?>&setStatus=w'>W</a>
          <a style='text-decoration: none' href='<?=$SCRIPT_NAME?>?rowOffset=<?=$rowOffset?>&systemStatus=<?=$systemStatus?>&peripheralID=<?=$pk_peripheral?>&setStatus=n'>N</a>
          <a style='text-decoration: none' href='<?=$SCRIPT_NAME?>?rowOffset=<?=$rowOffset?>&systemStatus=<?=$systemStatus?>&peripheralID=<?=$pk_peripheral?>&setStatus=i'>I</a>)
    <? 
      }
    ?>
    </TD>
    <TD>
    <?
      If ($sessionSecurity > 1) {
          echo "N/A";
      } Else {
    ?>
          <A HREF="admin_peripherals.php?pk_peripheral=<?=$pk_peripheral;?>&uid=<?=$uid;?>">Edit</A>
          <A HREF="move_peripheral.php?objectID=<?=$pk_peripheral;?>&fromSystem=0">Move</A>
        <?
          If ($sessionSecurity < 1) {
        ?>
              <A HREF="delete.php?peripheralID=<?=$pk_peripheral;?>" onClick="return warn_on_submit('Are you sure you want to delete this?');">Delete</A>
        <?
          }
      }
      echo "</TD>";
  }
  echo "</table>";
  createPaging();

  writeFooter();
?>
Return current item: PhpMyInventory