feat: add VNC check, SSH key paste, resources panel, sliders, and self-service billing
- VNC panel auto-hides when VNC is disabled on the server - SSH key paste textarea at checkout with API key creation during provisioning - Resources panel with current allocation, traffic progress bar, and upgrade link - changePackage() now applies individual resource modifications from configurable options - Order form configurable option dropdowns replaced with styled range sliders - Self-service billing: credit balance, usage breakdown, credit top-up from client area - Self-service config options (mode, auto top-off threshold/amount) on products - Auto top-off via WHMCS cron when credit falls below threshold - CHANGELOG.md covering all versions from 0.0.6 to present Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,27 @@ function VirtFusionDirect_ConfigOptions()
|
||||
"Description" => "The default number of IPv4 addresses to assign to each server.",
|
||||
"Default" => "1",
|
||||
],
|
||||
"selfServiceMode" => [
|
||||
"FriendlyName" => "Self-Service Mode",
|
||||
"Type" => "dropdown",
|
||||
"Options" => "0|Disabled,1|Hourly,2|Resource Packs,3|Both",
|
||||
"Description" => "Enable VirtFusion self-service billing for users created by this product.",
|
||||
"Default" => "0",
|
||||
],
|
||||
"autoTopOffThreshold" => [
|
||||
"FriendlyName" => "Auto Top-Off Threshold",
|
||||
"Type" => "text",
|
||||
"Size" => "10",
|
||||
"Description" => "Credit balance below which auto top-off triggers during cron. 0 = disabled.",
|
||||
"Default" => "0",
|
||||
],
|
||||
"autoTopOffAmount" => [
|
||||
"FriendlyName" => "Auto Top-Off Amount",
|
||||
"Type" => "text",
|
||||
"Size" => "10",
|
||||
"Description" => "Credit amount to add when auto top-off triggers.",
|
||||
"Default" => "100",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -238,6 +259,32 @@ function VirtFusionDirect_UsageUpdate(array $params)
|
||||
->where('id', $service->id)
|
||||
->update($update);
|
||||
}
|
||||
|
||||
// Self-service auto top-off
|
||||
$product = \WHMCS\Database\Capsule::table('tblproducts')
|
||||
->where('id', $service->packageid)
|
||||
->first();
|
||||
|
||||
if ($product) {
|
||||
$threshold = (float) ($product->configoption5 ?? 0);
|
||||
$topOffAmount = (float) ($product->configoption6 ?? 0);
|
||||
|
||||
if ($threshold > 0 && $topOffAmount > 0) {
|
||||
$usageData = $module->getSelfServiceUsage($service->id);
|
||||
if ($usageData) {
|
||||
$usageInner = $usageData['data'] ?? $usageData;
|
||||
$credit = $usageInner['credit'] ?? $usageInner['balance'] ?? null;
|
||||
if ($credit !== null && (float) $credit < $threshold) {
|
||||
$module->addSelfServiceCredit($service->id, $topOffAmount, 'Auto top-off');
|
||||
\WHMCS\Module\Server\VirtFusionDirect\Log::insert(
|
||||
'UsageUpdate:autoTopOff',
|
||||
['serviceId' => $service->id, 'credit' => $credit, 'threshold' => $threshold],
|
||||
['amount' => $topOffAmount]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Log but continue processing other services
|
||||
\WHMCS\Module\Server\VirtFusionDirect\Log::insert('UsageUpdate:service:' . $service->id, [], $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user