isVmCreate()) { $this->customTplVars['warning'] = sl("lang")->abtr('Creating VM in progress. Please try again later.'); } else if ($this->isVmReinstall()) { $this->customTplVars['warning'] = sl("lang")->abtr('Rebuild VM in progress. Please try again later.'); } else if ($this->isVmUpgrade()){ $this->customTplVars['warning'] = sl("lang")->abtr('Upgrading VM in progress. Please try again later.'); }else if(!$this->getWhmcsCustomField("vmid")){ $this->customTplVars['warning'] = sl("lang")->abtr('Custom field VMID is empty.'); } } private function isVmCreate() { $jobs = [ CloneQemuJob::class, CreateQemuJob::class, CreateLxcJob::class, ]; return Job::waiting()->ofHostingId($this->getWhmcsParamByKey("serviceid"))->ofJobs($jobs)->count(); } private function isVmReinstall() { $jobs = [ CreateVmJob::class ]; return Job::waiting()->ofHostingId($this->getWhmcsParamByKey("serviceid"))->ofJobs($jobs)->count(); } private function isVmUpgrade() { $jobs = [ MigrateVmJob::class, \ModulesGarden\ProxmoxAddon\App\Jobs\Vps\RestoreVm::class, UpgradeVmJob::class ]; return Job::waiting()->ofHostingId($this->getWhmcsParamByKey("serviceid"))->ofJobs($jobs)->count(); } public function returnAjaxData() { $vars = []; $response = new RawDataJsonResponse(); if($this->isVpsCreated()){ $response->setCallBackFunction('mgRedirect'); $response->addData('redirectUrl' , ( new UrlServiceHelper())->home()); } return $response; } }