<?php

/* * ********************************************************************
 * ProxmoxAddon product developed. (Sep 12, 2018)
 * *
 *
 *  CREATED BY MODULESGARDEN       ->       http://modulesgarden.com
 *  CONTACT                        ->       contact@modulesgarden.com
 *
 *
 * This software is furnished under a license and may be used and copied
 * only  in  accordance  with  the  terms  of such  license and with the
 * inclusion of the above copyright notice.  This software  or any other
 * copies thereof may not be provided or otherwise made available to any
 * other person.  No title to and  ownership of the  software is  hereby
 * transferred.
 *
 *
 * ******************************************************************** */

namespace ModulesGarden\ProxmoxAddon\App\UI\Settings\Sections;

use ModulesGarden\ProxmoxAddon as main;
use ModulesGarden\ProxmoxAddon\Core\ModuleConstants;

/**
 * Description of CronSection
 *
 * @author Pawel Kopec <pawelk@modulesgardne.com>
 */
class CronSection extends main\Core\UI\Widget\Forms\Sections\BoxSection
{

    public function __construct($baseId = null)
    {
        parent::__construct();
        $this->initContent();
    }

    public function initContent()
    {
        $this->customTplVars['crons']['vps']          = ModuleConstants::getFullPath("cron", "cron.php") . " queue";
        $this->customTplVars['crons']['cloud']        = ModuleConstants::getFullPath("cron", "cron.php") . " rrddata";
        $this->customTplVars['crons']['users']        = ModuleConstants::getFullPath("cron", "cron.php") . " users";
        $this->customTplVars['crons']['recoveryList'] = ModuleConstants::getFullPath("cron", "cron.php") . " recoveryList";
        $this->customTplVars['crons']['migrateSync']  = ModuleConstants::getFullPath("cron", "cron.php") . " migrateSync";
        $this->customTplVars['crons']['task']         = ModuleConstants::getFullPath("cron", "cron.php") . " task";
        $this->customTplVars['crons']['usege']         = ModuleConstants::getFullPath("cron", "cron.php") . " update-server-usage";
        $this->customTplVars['crons']['backup']         = ModuleConstants::getFullPath("cron", "cron.php") . " remove-backups";
        $this->customTplVars['crons']['snapshots']         = ModuleConstants::getFullPath("cron", "cron.php") . " snapshots";
        $this->customTplVars['crons']['vmNames']         = ModuleConstants::getFullPath("cron", "cron.php") . " synchronize-vm-names";
        $this->customTplVars['proxmoxVps'] = $this->isProxmoxVps();
        $this->customTplVars['proxmoxCloudVps'] = $this->isProxmoxCloud();
    }

    private function isProxmoxVps(){
        return file_exists(ModuleConstants::getFullPathWhmcs("modules", "servers", "proxmoxVPS", "proxmoxVPS.php"));
    }

    private function isProxmoxCloud(){
        return file_exists(ModuleConstants::getFullPathWhmcs("modules", "servers", "ProxmoxCloudVps", "ProxmoxCloudVps.php"));
    }
}
