WHMCS-Action-Hook-Factory
WHMCS-Action-Hook-Factory copied to clipboard
[Feature Request] Add Colum Description on My Invoice Pages
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.
Thank's
@bakhtiyarsierad What if invoice is not only for one domain/service ?
may be displayed with a comma separator with break row . or any sugest?
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.
Hello Thanks for help,
its work when invoice have one services.
and blank when more than one servies or manualy invoice created
Thank's alot