Jump to content
monsterit

Changing the admin theme

Recommended Posts

Hi, is it possible to change these

image.thumb.png.09cc07a56bcd93b796cb66338758bbf6.png

so instead of tickets waiting we can have unpaid invoices? just a though to make things easier for us. as we do not use the ticketing system at all. we are using 7.9.1 and have setup a custom admin theme.

Edited by monsterit

Share this post


Link to post
Share on other sites
11 minutes ago, monsterit said:

so instead of tickets waiting we can have unpaid invoices? just a though to make things easier for us. as we do not use the ticketing system at all. we are using 7.9.1 and have setup a custom admin theme.

they're generated by the Badges widget in /modules/widgets - it's not encrypted, so you will be able to edit it to tweak the output.

Share this post


Link to post
Share on other sites
4 hours ago, monsterit said:

whats the string i need to view unpaid invoices?

do you mean the language string, or the db query to get the actual value ?

if it's the database query to get the unpaid invoices count, then it should need...

use WHMCS\Billing\Invoice;

and the pendingorders value is calculated using...

'pendingOrders' => (int) Invoice::where('status', '=', 'Unpaid')->count(),

yeah, forget that i'm still calling the variable pendingorders when it's really calculating the count of unpaid invoices - i'm being lazy because as I mentioned in that other thread, it would have meant replacing all occurrences of pendingorders in the code - but you can do that if it makes it clearer.

... and don't forget not to edit the original badges.php file as that will just get overwritten during an update.

Share this post


Link to post
Share on other sites

@brian!

 

So far i've got it looking like this.

<?php

namespace WHMCS\Module\Widget;

use WHMCS\Carbon;
use WHMCS\Clients;
use WHMCS\Module\AbstractWidget;
use WHMCS\Module\Queue as ModuleQueue;
use WHMCS\Orders;
use WHMCS\Billing\Invoice;

/**
 * Badges Widget.
 *
 * @copyright Copyright (c) WHMCS Limited 2005-2018
 * @license https://www.whmcs.com/license/ WHMCS Eula
 */
class Badges extends AbstractWidget
{
    protected $title = 'Badges';
    protected $description = '';
    protected $columns = 3;
    protected $weight = 0;
    protected $wrapper = false;
    protected $cache = true;
    protected $cacheExpiry = 120;
    protected $draggable = false;

    public function getData()
    {
        $clients = new Clients();
        $orders = new Orders();

        $ticketCounts = localApi('GetTicketCounts', array());

        return array(
            'pendingOrders' => $orders->getPendingCount(),
            'unpaidOrders' => (int) Invoice::where('status', '=', 'Unpaid')->count(),
            'cancellations' => $clients->getNumberOfOpenCancellationRequests(),
            'moduleQueueCount' => ModuleQueue::incomplete()->count(),
        );
    }

    public function generateOutput($data)
    {
        $pendingOrders = (int) $data['pendingOrders'];
        $unpaidOrders = (int) $data['unpaidOrders'];
        $pendingCancellations = (int) $data['cancellations'];
        $moduleQueueCount = (int) $data['moduleQueueCount'];

        return <<<EOF
<div class="row home-status-badge-row">
    <div class="col-sm-3">

        <div class="health-status-block status-badge-green clearfix">
            <div class="icon">
                <a href="orders.php">
                    <i class="fas fa-shopping-cart"></i>
                </a>
            </div>
            <div class="detail">
                <a href="orders.php?status=Pending">
                    <span class="count">{$pendingOrders}</span>
                    <span class="desc">Pending Orders</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-pink clearfix">
            <div class="icon">
                <a href="invoices.php?status=Unpaid">
                    <i class="fas fa-file-invoice-dollar"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Unpaid">
                    <span class="count">{$unpaidOrders}</span>
                    <span class="desc">Unpaid Orders</span>
                </a>
            </div>
        </div>

    </div>

 

Share this post


Link to post
Share on other sites
5 hours ago, monsterit said:

So far i've got it looking like this.

I assume you know there are a few lines at the end missing from the above post.... i'm assuming that's just an issue with your copy&paste and not the original file. 🙂

also, have you renamed the file yet, or are you still editing the original badges.php ??

Share this post


Link to post
Share on other sites

im editing the badges-new.php but struggling with it. tbh.everytime i edit it i loose everything.

Share this post


Link to post
Share on other sites

This is my whole output.

<?php

add_hook('AdminHomeWidgets', 1, function() {
    return new InvoicesWidget();
});

use WHMCS\Carbon;
use WHMCS\Clients;
use WHMCS\Module\AbstractWidget;
use WHMCS\Module\Queue as ModuleQueue;
use WHMCS\Orders;
use WHMCS\Billing\Invoice;

/**
 * Badges Widget.
 *
 * @copyright Copyright (c) WHMCS Limited 2005-2018
 * @license https://www.whmcs.com/license/ WHMCS Eula
 */
 class InvoicesWidget extends \WHMCS\Module\AbstractWidget
{
	protected $title = "Invoices Widget";
    protected $description = 'Invoices';
    protected $columns = 3;
    protected $weight = 0;
    protected $wrapper = false;
    protected $cache = true;
    protected $cacheExpiry = 120;
    protected $draggable = false;

    public function getData()
    {
        $clients = new Clients();
        $orders = new Orders();
	     

        return array(
            'pendingOrders' => $orders->getPendingCount(),
            'unpaidInvoices' => (int) Invoice::where('status', '=', 'Unpaid')->count(),
            'overdueInvoices' => (int) Invoice::where('status', '=', 'Overdue')->count(),
            'moduleQueueCount' => ModuleQueue::incomplete()->count(),
        );
    }

    public function generateOutput($data)
    {
        $pendingOrders = (int) $data['pendingOrders'];
        $unpaidInvoices = (int) $data['unpaidInvoices'];
        $overdueInvoices = (int) $data['overdueInvoices'];
        $moduleQueueCount = (int) $data['moduleQueueCount'];

        return <<<EOF
<div class="row home-status-badge-row">
    <div class="col-sm-3">

        <div class="health-status-block status-badge-green clearfix">
            <div class="icon">
                <a href="orders.php">
                    <i class="fas fa-shopping-cart"></i>
                </a>
            </div>
            <div class="detail">
                <a href="orders.php?status=Pending">
                    <span class="count">{$pendingOrders}</span>
                    <span class="desc">Active Clients</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-pink clearfix">
            <div class="icon">
                <a href="invoices.php">
                    <i class="fas fa-file-invoice-dollar"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Unpaid">
                    <span class="count">{$unpaidInvoices}</span>
                    <span class="desc">Unpaid Invoices</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-orange clearfix">
            <div class="icon">
                <a href="invoices.php">
                    <i class="fas fa-business-time"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Overdue">
                    <span class="count">{$overdueInvoices}</span>
                    <span class="desc">Overdue Invoices</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-cyan clearfix">
            <div class="icon">
                <a href="modulequeue.php">
                    <i class="fas fa-ban"></i>
                </a>
            </div>
            <div class="detail">
                <a href="modulequeue.php">
                    <span class="count">{$moduleQueueCount}</span>
                    <span class="desc">Pending Module Actions</span>
                </a>
            </div>
        </div>

    </div>
</div>
EOF;
    }
}

I can see unpaid invoices now but no over invoices. above is the code and below is my screen shot.

image.thumb.png.e1495e72ff5e74d81a725b5556f385b9.png

Edited by monsterit

Share this post


Link to post
Share on other sites

Sorry ignore the above one. i've managed to put alot in but for some reason it's only showing one module counting and i cannot put my finger on it.

see the image below.

image.thumb.png.00bd771f28bcef484cfad8ddf54e14d5.png

 

Heres my very long winded coding section. (complete).

<?php

add_hook('AdminHomeWidgets', 1, function() {
    return new InvoicesWidget();
});

use WHMCS\Carbon;
use WHMCS\Clients;
use WHMCS\Module\AbstractWidget;
use WHMCS\Module\Queue as ModuleQueue;
use WHMCS\Orders;
use WHMCS\Billing\Invoice;
use WHMCS\User\Client;
/**
 * Badges Widget.
 *
 * @copyright Copyright (c) WHMCS Limited 2005-2018
 * @license https://www.whmcs.com/license/ WHMCS Eula
 */
 class InvoicesWidget extends \WHMCS\Module\AbstractWidget
{
	protected $title = "Invoices Widget";
    protected $description = 'Invoices';
    protected $columns = 3;
    protected $weight = 0;
    protected $wrapper = false;
    protected $cache = true;
    protected $cacheExpiry = 120;
    protected $draggable = false;

    public function getData()
    {
        $clients = new Clients();
        $orders = new Orders();
	    $incomeStats = getAdminHomeStats('income');
        foreach ($incomeStats['income'] as $key => $value) {
            $incomeStats['income'][$key] = $value->toPrefixed();
        }
        return $incomeStats; 

        return array(
            'activeCount' => (int) Client::where('status', '=', 'Active')->count(),
            'unpaidInvoices' => (int) Invoice::where('status', '=', 'Unpaid')->count(),
            'overdueInvoices' => (int) Invoice::where('status', '=', 'Overdue')->count(),
        );
    }

    public function generateOutput($data)
    {
        $activeClients = number_format((int) $data['activeCount']);
        $unpaidInvoices = (int) $data['unpaidInvoices'];
        $overdueInvoices = (int) $data['overdueInvoices'];
        $incomeThisMonth = $data['income']['thismonth'];

        return <<<EOF
<div class="row home-status-badge-row">
    <div class="col-sm-3">

        <div class="health-status-block status-badge-green clearfix">
            <div class="icon">
                <a href="clients.php?status=Active">
                    <i class="fas fa-user-friends"></i>
                </a>
            </div>
            <div class="detail">
                <a href="clients.php?status=Active">
                    <span class="count">{$activeClients}</span>
                    <span class="desc">Active Clients</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-pink clearfix">
            <div class="icon">
                <a href="invoices.php">
                    <i class="fas fa-file-invoice-dollar"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Unpaid">
                    <span class="count">{$unpaidInvoices}</span>
                    <span class="desc">Unpaid Invoices</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-orange clearfix">
            <div class="icon">
                <a href="invoices.php">
                    <i class="fas fa-business-time"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Overdue">
                    <span class="count">{$overdueInvoices}</span>
                    <span class="desc">Overdue Invoices</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-cyan clearfix">
            <div class="icon">
                <a href="modulequeue.php">
                    <i class="fas fa-wallet"></i>
                </a>
            </div>
            <div class="detail">
                <a href="modulequeue.php">
                    <span class="count">{$incomeThisMonth}</span>
                    <span class="desc">Income This Month</span>
                </a>
            </div>
        </div>

    </div>
</div>
EOF;
    }
}

 

Share this post


Link to post
Share on other sites
48 minutes ago, monsterit said:

Sorry ignore the above one. i've managed to put alot in but for some reason it's only showing one module counting and i cannot put my finger on it.

I don't like that getData has two returns - the widget will only see the first (the one taken from the billing widget code) and ignore the second (hence your output).

btw, some of the queries can be improved too...

    public function getData()
    {
		$incomeStats = getAdminHomeStats('income');
		foreach ($incomeStats['income'] as $key => $value) {
			$incomeStats['income'][$key] = $value->toPrefixed();
		}
		return array(
			'activeCount' => Client::where('status', '=', 'Active')->count('id'),
			'unpaidInvoices' => Invoice::unpaid()->count('id'),
			'overdueInvoices' => Invoice::overdue()->count('id'),
			'incomestats' => $incomeStats,
		);
	}

	public function generateOutput($data)
	{
		$activeCount = (int) $data['activeCount'];
		$unpaidInvoices = (int) $data['unpaidInvoices'];
		$overdueInvoices = (int) $data['overdueInvoices'];
		$incomeThisMonth = $data['incomestats']['income']['thismonth'];

Share this post


Link to post
Share on other sites

Great thank you. I've changed a part below too as it was clients, so changed that to count. 🙂

<?php

add_hook('AdminHomeWidgets', 1, function() {
    return new InvoicesWidget();
});

use WHMCS\Carbon;
use WHMCS\Clients;
use WHMCS\Module\AbstractWidget;
use WHMCS\Module\Queue as ModuleQueue;
use WHMCS\Orders;
use WHMCS\Billing\Invoice;
use WHMCS\User\Client;
/**
 * Badges Widget.
 *
 * @copyright Copyright (c) WHMCS Limited 2005-2018
 * @license https://www.whmcs.com/license/ WHMCS Eula
 */
 class InvoicesWidget extends \WHMCS\Module\AbstractWidget
{
	protected $title = "Invoices Widget";
    protected $description = 'Invoices';
    protected $columns = 3;
    protected $weight = 0;
    protected $wrapper = false;
    protected $cache = false;
    protected $cacheExpiry = 120;
    protected $draggable = false;

    public function getData()
    {
		$incomeStats = getAdminHomeStats('income');
		foreach ($incomeStats['income'] as $key => $value) {
			$incomeStats['income'][$key] = $value->toPrefixed();
		}
		return array(
			'activeCount' => Client::where('status', '=', 'Active')->count('id'),
			'unpaidInvoices' => Invoice::unpaid()->count('id'),
			'overdueInvoices' => Invoice::overdue()->count('id'),
			'incomestats' => $incomeStats,
		);
	}

	public function generateOutput($data)
	{
		$activeCount = (int) $data['activeCount'];
		$unpaidInvoices = (int) $data['unpaidInvoices'];
		$overdueInvoices = (int) $data['overdueInvoices'];
		$incomeThisMonth = $data['incomestats']['income']['thismonth'];

        return <<<EOF
<div class="row home-status-badge-row">
    <div class="col-sm-3">

        <div class="health-status-block status-badge-red clearfix">
            <div class="icon">
                <a href="clients.php?status=Active">
                    <i class="fas fa-user-friends"></i>
                </a>
            </div>
            <div class="detail">
                <a href="clients.php?status=Active">
                    <span class="count">{$activeCount}</span>
                    <span class="desc">Active Clients</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-purple clearfix">
            <div class="icon">
                <a href="invoices.php">
                    <i class="fas fa-file-invoice-dollar"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Unpaid">
                    <span class="count">{$unpaidInvoices}</span>
                    <span class="desc">Unpaid Invoices</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-teal clearfix">
            <div class="icon">
                <a href="invoices.php">
                    <i class="fas fa-business-time"></i>
                </a>
            </div>
            <div class="detail">
                <a href="invoices.php?status=Overdue">
                    <span class="count">{$overdueInvoices}</span>
                    <span class="desc">Overdue Invoices</span>
                </a>
            </div>
        </div>

    </div>
    <div class="col-sm-3">

        <div class="health-status-block status-badge-gold clearfix">
            <div class="icon">
                <a href="modulequeue.php">
                    <i class="fas fa-wallet"></i>
                </a>
            </div>
            <div class="detail">
                <a href="modulequeue.php">
                    <span class="count">{$incomeThisMonth}</span>
                    <span class="desc">Income This Month</span>
                </a>
            </div>
        </div>

    </div>
</div>
EOF;
    }
}

all working perfectly. Thank you once again.

Share this post


Link to post
Share on other sites
3 minutes ago, monsterit said:

all working perfectly. Thank you once again.

we got there in the end. 🙂

btw, this isn't important, but you could probably trim those uses at the start to just the 3 below - everything else you are seemingly no longer using...

use WHMCS\Module\AbstractWidget;
use WHMCS\User\Client;
use WHMCS\Billing\Invoice;

.. or could you leave them in for future use, e.g if you're planning on having more than 4 badges any time soon.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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