Location: PHPKode > projects > PhpMyInventory > pmi281/detailed_sw.php
  checkPermissions(2, 1800);
  writeHeader("Count Software");
<TABLE border='0' cellpadding='4' cellspacing='0'>
  <tr class='title'>
    <td valign='bottom'><b>Product</b> &nbsp;</td>
    <td valign='bottom'><b>Copies</b> &nbsp;</td>
    <td valign='bottom'><b>Manufacturer</b> &nbsp;</td>
    <td valign='bottom'><b>Version</b> &nbsp;</td>
    <TD valign='bottom'><b>&nbsp;Remaining&nbsp;<br>&nbsp;Licenses</b></TD>
$strSQL = "SELECT count(s.id) as sCount, st.id, st.numLicenses, st.name, st.maker, st.version,
  st.licenseType FROM software as s, software_types as st WHERE st.id=s.type_id AND
  st.accountID=$accountID GROUP BY st.name, st.version ORDER BY name ASC";
$result = dbquery($strSQL);

While ($row = mysql_fetch_array($result)) {
  echo "<tr class='".alternateRowColor()."'>";
  echo "<td><font size='-1'>".$row["name"]."</font> &nbsp;</td>";
  echo "<td><font size='-1'>&nbsp;".$row["sCount"]."</font> &nbsp;</td>";
  echo "<td><font size='-1'>".$row["maker"]."</font> &nbsp;</td>";
  echo "<td><font size='-1'>&nbsp;".$row["version"]."</font> &nbsp;</td>";

       If ($row["licenseType"] == "peruser") {
          $strSQL2 = "SELECT t.id FROM software as s, tblSecurity as t, 
             hardware as h WHERE s.type_id=".$row["id"]." AND s.hardware_id=h.pk_asset AND 
             h.userID=t.id AND s.sparePart='0' AND h.sparePart='0' AND t.accountID=$accountID
             GROUP BY t.id";
          $result2            = dbquery($strSQL2);
          $usedLicenses       = mysql_num_rows($result2);
          $remainingLicenses  = $row["numLicenses"] - $usedLicenses;

       } ElseIf ($row["licenseType"] == "persystem") {
          $strSQL2 = "SELECT h.pk_asset FROM software as s, hardware as h WHERE s.type_id=".$row["id"]." 
             AND s.hardware_id=h.pk_asset AND s.sparePart='0' AND h.accountID=$accountID
             GROUP BY h.pk_asset";
          $result2            = dbquery($strSQL2);
          $usedLicenses       = mysql_num_rows($result2);
          $remainingLicenses  = $row["numLicenses"] - $usedLicenses;
       } Else {
          $remainingLicenses  = "N/A";

  echo "<td><font size='-1'>&nbsp;".$remainingLicenses."</font> &nbsp;</td>";
  echo "</tr>\n";

Return current item: PhpMyInventory