Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add Colum Description on My Invoice Pages #37

Open
mrburgercheese opened this issue Sep 13, 2021 · 4 comments
Open

[Feature Request] Add Colum Description on My Invoice Pages #37

mrburgercheese opened this issue Sep 13, 2021 · 4 comments
Assignees
Labels
feature request New feature or request

Comments

@mrburgercheese
Copy link

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 mrburgercheese added the feature request New feature or request label Sep 13, 2021
@pRieStaKos
Copy link

pRieStaKos commented Sep 13, 2021

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

@mrburgercheese
Copy link
Author

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

image

@LosBooom
Copy link

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.

@mrburgercheese
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants