Cara Custom Badges Widget Admin Homepage pada WHMCS 8

Posted on

Halo semua, buat teman-teman yang menggunakan WHMCS sebagai blling usaha hosting atau layanan sejenis pada bagian home admin dapat ditambahkan badge yang menampilkan beberapa informasi tambahan selain dari default nya. Badge static yang di maksud adalah menampilkan informasi

  • domain ( aktif, expired )
  • produk ( suspended, terminated )
  • invoice ( unpaid, overdue )

Contohnya seperti berikut

 

Silakan backup modules > widgets > Badges.php kemudian replace semua kodenya dengan ini

<?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\Database\Capsule;
use WHMCS\Billing\Invoice;

/**
 * Badges Widget.
 * Custom by Rahmat Sabilludin
 *
 * @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(),
            'ticketsAwaitingReply' => $ticketCounts['awaitingReply'],
            'cancellations' => $clients->getNumberOfOpenCancellationRequests(),
            'moduleQueueCount' => ModuleQueue::incomplete()->count(),
            'unpaidInvoices' => Capsule::table('tblinvoices')->where('status','Unpaid')->count(),
            'overdueInvoices' => Invoice::overdue()->count(),
            'suspendedServices' => Capsule::table('tblhosting')->where('domainstatus','Suspended')->count(),
            'terminatedServices' => Capsule::table('tblhosting')->where('domainstatus','Terminated')->count(),
            'activeDomains' => Capsule::table('tbldomains')->where('status','Active')->count(),
            'expiredDomains' => Capsule::table('tbldomains')->where('status','Expired')->count(),
        );
    }

    public function generateOutput($data)
    {
        $pendingOrders = (int) $data['pendingOrders'];
        $awaitingReply = (int) $data['ticketsAwaitingReply'];
        $pendingCancellations = (int) $data['cancellations'];
        $moduleQueueCount = (int) $data['moduleQueueCount'];
        $unpaidInvoices = (int) $data['unpaidInvoices'];
        $overdueInvoices = (int) $data['overdueInvoices'];
        $suspendedServices = (int) $data['suspendedServices'];
        $terminatedServices = (int) $data['terminatedServices'];
        $activeDomains = (int) $data['activeDomains'];
        $expiredDomains = (int) $data['expiredDomains'];

        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="supporttickets.php">
                    <i class="fas fa-comment"></i>
                </a>
            </div>
            <div class="detail">
                <a href="supporttickets.php">
                    <span class="count">{$awaitingReply}</span>
                    <span class="desc">Tickets Waiting</span>
                </a>
            </div>
        </div>

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

        <div class="health-status-block status-badge-orange clearfix">
            <div class="icon">
                <a href="cancelrequests.php">
                    <i class="fas fa-ban"></i>
                </a>
            </div>
            <div class="detail">
                <a href="cancelrequests.php">
                    <span class="count">{$pendingCancellations}</span>
                    <span class="desc">Pending Cancellations</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-exclamation-triangle"></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 class="col-sm-2 col-xs-6 tile">
        <div class="health-status-block btn-primary clearfix">
            <div class="icon">
                <a href="invoices.php?status=Unpaid">
                    <i class="fas fa-cog"></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-2 col-xs-6 tile">
        <div class="health-status-block btn-warning clearfix">
            <div class="icon">
                <a href="invoices.php?status=Overdue">
                    <i class="fas fa-trash"></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-2 col-xs-6 tile">
        <div class="health-status-block btn-info clearfix">
            <div class="icon">
                <a href="services?status=suspended">
                    <i class="fas fa-rocket"></i>
                </a>
            </div>
            <div class="detail">
                <a href="services?status=suspended">
                    <span class="count">{$suspendedServices}</span>
                    <span class="desc">Suspended Services</span>
                </a>
            </div>
        </div>
    </div>

    <div class="col-sm-2 col-xs-6 tile">
        <div class="health-status-block btn-danger clearfix">
            <div class="icon">
                <a href="services?status=terminated">
                    <i class="fas fa-info-circle"></i>
                </a>
            </div>
            <div class="detail">
                <a href="services?status=terminated">
                    <span class="count">{$terminatedServices}</span>
                    <span class="desc">Terminated Services</span>
                </a>
            </div>
        </div>
    </div>

    <div class="col-sm-2 col-xs-6 tile">
        <div class="health-status-block btn-success clearfix">
            <div class="icon">
                <a href="domains?status=active">
                    <i class="fas fa-globe"></i>
                </a>
            </div>
            <div class="detail">
                <a href="domains?status=active">
                    <span class="count">{$activeDomains}</span>
                    <span class="desc">Active Domains</span>
                </a>
            </div>
        </div>
    </div>

    <div class="col-sm-2 col-xs-6 tile">
        <div class="health-status-block btn-warning clearfix">
            <div class="icon">
                <a href="domains?status=expired">
                    <i class="fas fa-exclamation-circle"></i>
                </a>
            </div>
            <div class="detail">
                <a href="domains?status=expired">
                    <span class="count">{$expiredDomains}</span>
                    <span class="desc">Expired Domains</span>
                </a>
            </div>
        </div>
    </div>

</div>
EOF;
    }
}

 

 

Selamat mencoba

sumber : https://www.diskusiwebhosting.com/threads/custom-badges-widget-admin-homepage-pada-whmcs-8.36099/#post-273220

 

Leave a Reply

Your email address will not be published. Required fields are marked *