WHMCS-Action-Hook-Factory icon indicating copy to clipboard operation
WHMCS-Action-Hook-Factory copied to clipboard

[Feature Request] Add Colum Description on My Invoice Pages

Open mrburgercheese opened this issue 3 years ago • 4 comments

Describe the solution you'd like

Hello, may be you can help, in pages My Invoice on client area. May be can added one coloum to describe about the service, only inform can get from domain service or service name.

image

Thank's

mrburgercheese avatar Sep 13 '21 01:09 mrburgercheese

@bakhtiyarsierad What if invoice is not only for one domain/service ?

pRieStaKos avatar Sep 13 '21 09:09 pRieStaKos

may be displayed with a comma separator with break row . or any sugest?

image

mrburgercheese avatar Sep 14 '21 22:09 mrburgercheese

This solution is not ideal, but it can be a good start for customizing your system. In template templates/TEMPLATENAME/clientareainvoices.tpl In head you can use <th>{lang key='navservices'}</th> or add your own lang variable. Change loop like this {foreach $invoices as $index => $invoice} and for td in row <td>{$cstmInvoices[$index]}</td> So that template will look like:

<thead>
    <tr>
        <th>{lang key='invoicestitle'}</th>
        <th>{lang key='navservices'}</th>
        <th>{lang key='invoicesdatecreated'}</th>
        <th>{lang key='invoicesdatedue'}</th>
        <th>{lang key='invoicestotal'}</th>
        <th>{lang key='invoicesstatus'}</th>
    </tr>
</thead>
<tbody>
    {foreach $invoices as $index => $invoice}
        <tr onclick="clickableSafeRedirect(event, 'viewinvoice.php?id={$invoice.id}', false)">
            <td>{$invoice.invoicenum}</td>
            <td>{$cstmInvoices[$index]}</td>
            <td><span class="w-hidden">{$invoice.normalisedDateCreated}</span>{$invoice.datecreated}</td>
            <td><span class="w-hidden">{$invoice.normalisedDateDue}</span>{$invoice.datedue}</td>
            <td data-order="{$invoice.totalnum}">{$invoice.total}</td>
            <td><span class="label status status-{$invoice.statusClass}">{$invoice.status}</span></td>
        </tr>
    {/foreach}
</tbody>

And for hook includes/hooks/desctoinvoice_hook.php:

<?php

if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

use WHMCS\Database\Capsule;

function cstmAddDescToInvoice($vars)
{
    $cstmInvoices = [];
    foreach ($vars['invoices'] as $index => $invoice) {
        $domains = Capsule::table('tblinvoiceitems')
            ->where('invoiceid', $invoice['id'])
            ->where('type', 'hosting')
            ->join('tblhosting', 'tblhosting.id', '=', 'tblinvoiceitems.relid')
            ->pluck('domain')
            ->toArray(); // for whmcs8+

        $cstmInvoices[$index] = implode(' – ', array_filter($domains));
    }
    return ['cstmInvoices' => $cstmInvoices];
}

add_hook("ClientAreaPageInvoices", 1, "cstmAddDescToInvoice");

I do not recommend using this code in production, this is just an example. Test on your development for edge cases.

LosBooom avatar Sep 14 '21 23:09 LosBooom

Hello Thanks for help,

its work when invoice have one services. image

and blank when more than one servies or manualy invoice created image

Thank's alot

mrburgercheese avatar Sep 15 '21 04:09 mrburgercheese