irm/include/functions.php
/* Added March 12th, 2001 (micajc)
 * This function attempts to find an lID of an unassigned 
 * license for the passed software ID. Remember
 * to lock the inst_software table if your going to use this
 * to assign a license.
 */
Added March 12th, 2001 (micajc)
This function attempts to find an lID of an unassigned
license for the passed software ID. Remember
to lock the inst_software table if your going to use this
to assign a license.
Added March 12th 2001 ( micajc ) This function attempts to find an lID of an unassigned license for the passed software ID . Remember to lock the inst_software table if your going to use this to assign a license .
function find_license($ID, $lcnt_needed) {
	$DB = Config::Database();
	$qID = $DB->getTextValue($ID);
	$q = "SELECT software_licenses.ID AS lID,
		     (IF(software_licenses.entitlement,software_licenses.entitlement,0)
		       - IF(SUM(inst_software.lCnt),SUM(inst_software.lCnt),0))
		       AS available
		   FROM inst_software RIGHT JOIN software_licenses
		   		ON software_licenses.ID=inst_software.lID
		   WHERE software_licenses.sID=$qID
		   GROUP BY software_licenses.ID";
	$license_info = $DB->getAll($q);
	foreach ($license_info as $ld)
	{
		if ($ld['available'] >= $lcnt_needed)
		{
			return $ld['lID'];
		}
	}
	return NULL;
}
function find_license ( $ ID , $ lcnt_needed ) { $ DB = Config :: Database ( ) ; $ qID = $ DB -> getTextValue ( $ ID ) ; $ q = " SELECT software_licenses.ID AS lID,
		     (IF(software_licenses.entitlement,software_licenses.entitlement,0)
		       - IF(SUM(inst_software.lCnt),SUM(inst_software.lCnt),0))
		       AS available
		   FROM inst_software RIGHT JOIN software_licenses
		   		ON software_licenses.ID=inst_software.lID
		   WHERE software_licenses.sID= $ qID 
		   GROUP BY software_licenses.ID " ; $ license_info = $ DB -> getAll ( $ q ) ; foreach ( $ license_info as $ ld ) { if ( $ ld [ 'available' ] >= $ lcnt_needed ) { return $ ld [ 'lID' ] ; } } return NULL ; }
Added March 12th, 2001 (micajc)
 This function attempts to find an lID of an unassigned
 license for the passed software ID.
Added March 12th 2001 ( micajc ) This function attempts to find an lID of an unassigned license for the passed software ID .