<?
Include("Includes/global.inc.php");
checkPermissions(2, 1800);
writeHeader("Count Software");
?>
<TABLE border='0' cellpadding='4' cellspacing='0'>
<tr class='title'>
<td valign='bottom'><b>Product</b> </td>
<td valign='bottom'><b>Copies</b> </td>
<td valign='bottom'><b>Manufacturer</b> </td>
<td valign='bottom'><b>Version</b> </td>
<TD valign='bottom'><b> Remaining <br> Licenses</b></TD>
</tr>
<?
$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> </td>";
echo "<td><font size='-1'> ".$row["sCount"]."</font> </td>";
echo "<td><font size='-1'>".$row["maker"]."</font> </td>";
echo "<td><font size='-1'> ".$row["version"]."</font> </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'> ".$remainingLicenses."</font> </td>";
echo "</tr>\n";
}
?>
</TABLE>
<?
writeFooter();
?>