The WHMCS resource usage function doesn't take into account any updates to resources made directly in the SolidCP directly, it only uses a hard coded limit in the "Module Settings" in WHMCS itself.
This is a problem as if we use Add Ons (or just edit a plan resources manually) to sell a user more space, the WHMCS report still shows the old numbers.
It should really get the resource limits directly from SolidCP 🙂
Hello,
Wouldn't it be more easy to add the addon via whmcs?
It can either be done via addons or configurable options.
Regards,
Marco
Hi Marco,
I have added the Addon via WHMCS - but the resource allowance doesn't update.
I had a quick look at the WHMCS module source code, and it seems to just use the value typed in the "Module Settings" tab, it doesn't take into account any addons or configurable options.
In "SolidCP_UsageUpdate":
// Diskspace and Bandwidth limits for this package
$disklimit = $service->configoption2;
$bwidthlimit = $service->configoption3;
I believe this should be updated to get the real limits directly from SolidCP itself?
Any ideas? I thought I could get the real resource allocation from the array returned by "getUserPackages" - but this just returns 0!
Have reported this as a possible API bug ( https://solidcp.com/forum/question/bug-getmypackages-api-command-always-returns-0-for-disk-space-and-bandwidth-quota/)
But for anyone who wants a work around until then.
Edit the /addons/solidcp_module/lib/enterprise.php file and add the following under the whole "convertArray" function (so just above the final } in the file):
/**
* Executes the "GetPackageQuota" method
*
* @access public
* @param string $packageId SolidCP Package ID
* @param string $quotaName Quota Name
* @throws Exception
* @return array
*/
public function getPackageQuota($packageId, $quotaName)
{
try
{
return $this->convertArray($this->execute('esPackages.asmx', 'GetPackageQuota', array('packageId' => $packageId, 'quotaName' => $quotaName))->GetPackageQuotaResult);
}
catch (Exception $e)
{
throw new Exception("GetPackageQuota Fault: (Code: {$e->getCode()}, Message: {$e->getMessage()})", $e->getCode(), $e);
}
}
Then in the /servers/SolidCP/SolidCP.php file, find line:
$package = $scp->getUserPackages($user['UserId']);
and then UNDER that, add:
$disklimit = $scp->getPackageQuota($package['PackageId'], 'OS.Diskspace')['QuotaAllocatedValue'];
$bwidthlimit = $scp->getPackageQuota($package['PackageId'], 'OS.Bandwidth')['QuotaAllocatedValue'];
It's not super efficient though, as it needs to make an extra two server calls per package. It would be much better if the proper "getUserPackages" function returned it already filled in.