<?php
/* * ********************************************************************
*  ProxmoxVPS Product developed. (26.03.19)
* *
*
*  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.
*
*
* ******************************************************************** */


$hookManager->register(
    function (\WHMCS\View\Menu\Item $primarySidebar)
    {
        if(!\ModulesGarden\Servers\ProxmoxVps\App\Helpers\ProxmoxAddonValidator::isInstalled()){
            return;
        }
        /**
         * @var  main\Core\Http\Request $request
         */
        $request = \ModulesGarden\Servers\ProxmoxVps\Core\Helper\sl('request');
        if (!$request->get('id'))
        {
            return;
        }
        $clientAreaSideBar = new \ModulesGarden\ProxmoxAddon\App\Services\Vps\ClientAreaSidebarService($request->get("id"), $primarySidebar);
        if (!$clientAreaSideBar->isActive() || !$clientAreaSideBar->isSupportedModule())
        {
            return;
        }
        if (!function_exists('ModuleBuildParams'))
        {
            require_once \ModulesGarden\Servers\ProxmoxVps\Core\ModuleConstants::getFullPathWhmcs('includes') . DIRECTORY_SEPARATOR . "modulefunctions.php";
        }
        $params = \ModuleBuildParams($request->get("id"));
        \ModulesGarden\Servers\ProxmoxVps\Core\Helper\sl("whmcsParams")->setParams($params);
        if(!$clientAreaSideBar->isVpsCreated()){
            return;
        }
        //Page Cancel
        if ($request->get('action') == "cancel")
        {
            $clientAreaSideBar->informationReplaceUri();
        } //Page Productdetails
        else
        {
            if ($request->get('action') == "productdetails")
            {
                $clientAreaSideBar->informationReplaceUri();
                $clientAreaSideBar->build();
            }
        }
    }, 943
);
