Jump to content

Customise background color if invoice number is renamed SERVICE SUSPENDED


zitu4life

Recommended Posts

Hello there

I was testing something on my DEV.

I have a quite number of invoices overdue that means I need to suspended service related...It is not a hosting or domain so this means also it is not fully automated on WHMCS ...so i have to do it manually (I can leave with that).

What I was thinking is that since sometimes the number of invoices can increase, I intend to give it some customization, like backgroud color or icone like this ⚠️ to auto request my attention.

Picture is good to explain better 🙂

1. here we have some overdue invoices.

image.thumb.png.9d097ad0bb3f1626c5852a309d659850.png

2. Now I will edit for example (John Smith invoice) that I decide manually suspend his service writing on invoice #4 SERVICE SUSPENDED

image.thumb.png.42ee0da6b3b37efd278bf6d26a82b12a.png

 

image.thumb.png.e099f74faabba5bd62297341c34a584b.png

3. A hook can be applied here to auto detect that inf invoice number is renamed to SERVICE SUSPENDED customized it to to have color RED or background color red. or have icon picture below.

image.thumb.png.14e3ffae1d788ae075066851d7493bbd.png

 

PS: These customization is just to improve my internal management and also communication with staff, so other staff will automatically know that a SERVICE SUSPENSION were applied on that invoice, so this means an attention is required after payment received to UN-SUSPEND THAT SERVICE related

Edited by zitu4life
edited PS note
Link to comment
Share on other sites

Firstly and honestly changing the invoice number is not the way to go here because it adds in more manual steps and that just leads to potential errors. 

Instead, what I would suggest is an admin area hook that checks if the invoices page is being showed, I don't think there is a hook for just the invoice tab.    The hook would get the client's unpaid invoices and then loop through those and their invoice items and check if the service is suspended.  Using the invoice item class, this step is pretty easy.   Then once you have the invoices that have suspended services, you inject javascript that loops through the invoices and then finds the invoice row in the invoices list table and changes its background color, adds a icon to the invoice number column, etc. 

 

Link to comment
Share on other sites

2 hours ago, steven99 said:

Firstly and honestly changing the invoice number is not the way to go here because it adds in more manual steps and that just leads to potential errors. 

yeah, I agree that changing invoice is not the right way, but as I can not use WHMCS as a official accountable system it opens a possibility to made changes. Actually I have in place an other cloud software for invoice clients...WHMCS i only use it for managements and automate things not for official invoicing. By the way I have deactivated PDF invoices on settings.

it is hard to have WHMCS invoices as official invoices...by the way I do not know even if WHMCS it self's uses WHMCS as official invoices or if they also uses another accountable software too.

I guess most of country will not accept WHMCS invoices as official.

The idea is just to make a relationship between invoices overdue with service suspension that happen on other platform away from WHMCS. lets say.

1 - invoice is overdue and client did not make payment after some days.

2- I will manually suspend his service on other platform, so at this time I went to WHMCS and edit invoice as SUSPENDED, just for my better control.

3 - after while this client can claim that NO SERVICE, so our sales team, even without technical advanced  skills will just know that a service is SUSPENDED and inform client on clain that there is no NETWORK ISSUES from our company side, but SUSPENSION were made due to invoice overdue.

4 - If I have +40 invoices overdue and some of them were suspended and other not suspended, I need to get those suspended Highlighted.

 

 

Edited by zitu4life
Link to comment
Share on other sites

Had some free time between coders blocker on another project.  So here you go.  Place following in a file called "hook_invoice_highlight_service_suspend.php" in the whmcs_install_folder/includes/hooks .  It will highlight invoice on the main unpaid invoices page and in the client invoices page for any service that is suspended.

<?php
use WHMCS\User\Client;

/**
 *  Invoice Highlight: by service status 
 * @Author: steven99
 * #version: 0.1
 */
add_hook('AdminAreaFooterOutput', 1, function ($vars) {
    if (isset($_GET['userid']) and is_numeric($_GET['userid']))
    {
        $Client = Client::find($_GET['userid']);
        if ($Client)
        {
            $Invoices = $Client->invoices ;
            $InvoicesWithSuspendedServices = array();
            foreach($Invoices as $invoice)
            {
                $Items = $invoice->items;
                foreach($Items as $item)
                {
                    if (isset($item->service) AND $item->service->status === 'Suspended')
                    {
                        $InvoicesWithSuspendedServices[] = $invoice->getInvoiceNumber();
                    }
                }
            }
        }
    }
    else
    {
        // We are not on a client page, aer we on the invoices page?
        if ( isset($vars['filename']) and $vars['filename'] == 'invoices' and isset($_GET['status']) AND $_GET['status']=='Unpaid')
        {
            $results = localAPI('GetInvoices', array( 'status'=>'Unpaid' ));
            if ($results['result'] == 'success' and isset($results['invoices']['invoice']))
            {
                foreach($results['invoices']['invoice'] as $inv)
                {
                    /** @var \WHMCS\Billing\Invoice $invoice */
                    $invoice = \WHMCS\Billing\Invoice::find($inv['id']);
                    if ($invoice)
                    {
                        /** @var  $item */
                        foreach($invoice->items as $item)
                        {
                            if (isset($item->service) AND $item->service->status === 'Suspended')
                            {
                                //WHMCS 8
                                $InvoicesWithSuspendedServices[] = $invoice->getInvoiceNumber();
                            }
                        }
                    }
                }
            }
        }
    }

    if (isset($InvoicesWithSuspendedServices) and !empty($InvoicesWithSuspendedServices ) and isset($vars['filename']) )
    {
        $HTML = "<script>$( document ).ready(function() {";

        foreach($InvoicesWithSuspendedServices as $invoice)
        {
            if ($vars['filename'] == 'clientsinvoices')
                $HTML .= "$('#sortabletbl1 td a:contains(\"$invoice\")').parent().css('background-color','#ffae80');";
            elseif ($vars['filename'] == 'invoices')
                $HTML .= "$('#sortabletbl0 td a:contains(\"$invoice\")').parent().css('background-color','#ffae80');";
        }

        $HTML .=" }); </script>";
        return $HTML;

    }

});

 

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