<?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\ProxmoxCloudVps\App\Helpers\ProxmoxAddonValidator::isInstalled()){
            return;
        }
        /**
         * @var  main\Core\Http\Request $request
         */
        $request = \ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl('request');

        logModuleCall(
            'proxmoxCloud',
            __FUNCTION__,
            $primarySidebar,
            'Debug',
            $request
        );
        
        if (!$request->get('id'))
        {
            return;
        }
        $clientAreaSideBar = new \ModulesGarden\ProxmoxAddon\App\Services\Cloud\ClientAreaSidebarService($request->get("id"), $primarySidebar);
        if (!$clientAreaSideBar->isActive() || !$clientAreaSideBar->isSupportedModule())
        {
            return;
        }
        if (!function_exists('ModuleBuildParams'))
        {
            require_once \ModulesGarden\Servers\ProxmoxCloudVps\Core\ModuleConstants::getFullPathWhmcs('includes') . DIRECTORY_SEPARATOR . "modulefunctions.php";
        }
        //Page Cancel
        if ($request->get('action') == "cancel")
        {
            $clientAreaSideBar->informationReplaceUri();
        } //Page Productdetails
        if ($request->get('action') == "productdetails")
        {
            $clientAreaSideBar->informationReplaceUri();
            $clientAreaSideBar->serviceDetailsOverview();
            $clientAreaSideBar->build();
        }

    }, 943
);
