Jump to content

Adding tabs to client area & Dashboard


Recommended Posts

Hi All, I'm trying to build a Asset register for all my clients within WHMCS. So far the admin side is working fine but for the life of me I cannot get it to create tabs on the client sides for them to see or even on the clients pages within the admin login.

 

Does anyone know how to get around this or make it work. Happy to provide files for assistance.

<?php
if (!defined("WHMCS")) {
    die("This file cannot be accessed directly");
}

// The incompatible widget file has been removed from here.
require_once __DIR__ . '/activation.php';

/**
 * Define addon module configuration parameters.
 */
function asset_manager_config()
{
    return [
        'name' => 'Asset Manager',
        'description' => 'A module to manage client IT assets.',
        'author' => 'Gemini',
        'language' => 'english',
        'version' => '1.4',
        'fields' => []
    ];
}

/**
 * Activate addon module.
 */
function asset_manager_activate()
{
    return AssetManagerActivation::activate();
}

/**
 * Deactivate addon module.
 */
function asset_manager_deactivate()
{
    return AssetManagerActivation::deactivate();
}

/**
 * Admin area output.
 */
function asset_manager_output($vars)
{
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
    $dispatcher = new \WHMCS\Module\Addon\AssetManager\Admin\AdminDispatcher();
    echo $dispatcher->dispatch($action, $vars);
}

/**
 * Client area output.
 */
function asset_manager_clientarea($vars)
{
    $showInClientArea = \WHMCS\Database\Capsule::table('tbladdonmodules')
        ->where('module', 'asset_manager')
        ->where('setting', 'showInClientArea')
        ->value('value');

    if ($showInClientArea !== 'on') {
        return;
    }

    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'assets';
    $dispatcher = new \WHMCS\Module\Addon\AssetManager\Client\ClientDispatcher();
    return $dispatcher->dispatch($action, $vars);
}

/**
 * This function is automatically called by WHMCS to create a tab on the client summary page.
 */
function asset_manager_AdminAreaClientSummaryPageTabs($vars)
{
    try {
        $userId = (int)$vars['userid'];
        $assets = \WHMCS\Module\Addon\AssetManager\Models\Asset::where('userid', $userId)->with('type')->get();

        $smarty = new \Smarty();
        $smarty->assign('assets', $assets);
        $smarty->assign('userid', $userId);
        
        $templatePath = __DIR__ . '/templates/admin/client_profile_tab.tpl';
        if (file_exists($templatePath)) {
            $content = $smarty->fetch($templatePath);
            return ['Assets' => $content];
        }
        return ['Assets' => 'Error: client_profile_tab.tpl not found.'];

    } catch (\Exception $e) {
        return ['Assets' => 'Error loading assets: ' . $e->getMessage()];
    }
}

 

Edited by monsterit
update 1.4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated