Jump to content

Add dedicated IP or hostname to the invoice.php page .


TimRef

Recommended Posts

2 minutes ago, TimRef said:

seems the hook page is Loaded , but not working . 

on page /clientarea.php?action=invoices . not showing anything  . its a blank page .

The hook is fine, will only be triggered once the Invoice is Created, I already use it on my personal Hosting Website.

 

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

4 minutes ago, andrezzz said:

The hook is fine, will only be triggered once the Invoice is Created, I already use it on my personal Hosting Website.

 

the issue is the invoice page is not shown now , only leave a blank. not sure why . I will check myself , thanks for your you guy's help .thanks .

Link to comment
Share on other sites

On 12/29/2021 at 8:25 PM, andrezzz said:

Hello,

Maybe we can manage a way, using a Hook file, interested in this?

Hi, andrezzz, and @pRieStaKos thanks for your help . 

Can I ask you another question . 

In this topic , what I need to do is to show dedicated Ip or hostname on clientareainvoices.tpl page . like this photo in attachment . 

Do you have any idear to do this ? and will the hook working for this ? 

dedicated ip.png

Link to comment
Share on other sites

Just now, TimRef said:

Hi, andrezzz, and @pRieStaKos thanks for your help . 

Can I ask you another question . 

In this topic , what I need to do is to show dedicated Ip or hostname on clientareainvoices.tpl page . like this photo in attachment . 

Do you have any idear to do this ? and will the hook working for this ? 

dedicated ip.png

Maybe this need to change something like dataTables.bootstrap.min.js or other js using https://datatables.net/ ? will the hook working for this ? 

Link to comment
Share on other sites

8 hours ago, pRieStaKos said:

Just…don’t. 
 Check this and pass the ip to the table

Hi, @pRieStaKos  sorry for another question , 

the clientareainvoices.tpl file use the mysql table ‘tblinvoices’ , and in that table have no 'hostname' or 'dedicted IP' . 

As I know whmcs should use 'userid' Column to connect the table 'tblinvoices' and 'tblhosting' , so in this way we can try to connect with them , and get the specified tblinvoices . invoicenum.userid  ------ > tblhosting.userid.dedicatedip or domain .   

I don't know whether this is right . And how to connect with them in the clientareainvoices.tpl page, or have they already connected by default? 

Relly appreciate for your help .

Link to comment
Share on other sites

maybe clientareaproducts.tpl can be a reference . but can we use 2 tablelist in one .tpl file ? 

 

{include file="$template/includes/tablelist.tpl" tableName="ServicesList" filterColumn="4" noSortColumns="0"}
<script type="text/javascript">
    jQuery(document).ready( function ()
    {
        var table = jQuery('#tableServicesList').removeClass('hidden').DataTable();
        {if $orderby == 'product'}
            table.order([1, '{$sort}'], [4, 'asc']);
        {elseif $orderby == 'amount' || $orderby == 'billingcycle'}
            table.order(2, '{$sort}');
        {elseif $orderby == 'nextduedate'}
            table.order(3, '{$sort}');
        {elseif $orderby == 'domainstatus'}
            table.order(4, '{$sort}');
        {/if}
        table.draw();
        jQuery('#tableLoading').addClass('hidden');
    });
</script>
<div class="table-container clearfix">
    <table id="tableServicesList" class="table table-list hidden">
        <thead>
            <tr>
                <th></th>
                <th>{$LANG.orderproduct}</th>
                <th>{$LANG.clientareaaddonpricing}</th>
                <th>{$LANG.clientareahostingnextduedate}</th>
                <th>{$LANG.clientareastatus}</th>
                <th class="responsive-edit-button" style="display: none;"></th>
            </tr>
        </thead>
        <tbody>
            {foreach key=num item=service from=$services}
                <tr onclick="clickableSafeRedirect(event, 'clientarea.php?action=productdetails&amp;id={$service.id}', false)">
                    <td class="text-center{if $service.sslStatus} ssl-info{/if}" data-element-id="{$service.id}" data-type="service"{if $service.domain} data-domain="{$service.domain}"{/if}>
                        {if $service.sslStatus}
                            <img src="{$service.sslStatus->getImagePath()}" data-toggle="tooltip" title="{$service.sslStatus->getTooltipContent()}" class="{$service.sslStatus->getClass()}"/>
                        {elseif !$service.isActive}
                            <img src="{$BASE_PATH_IMG}/ssl/ssl-inactive-domain.png" data-toggle="tooltip" title="{lang key='sslState.sslInactiveService'}">
                        {/if}
                    </td>
                    <td><strong>{$service.product}</strong>{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
                    <td class="text-center" data-order="{$service.amountnum}">{$service.amount}<br />{$service.billingcycle}</td>
                    <td class="text-center"><span class="hidden">{$service.normalisedNextDueDate}</span>{$service.nextduedate}</td>
                    <td class="text-center"><span class="label status status-{$service.status|strtolower}">{$service.statustext}</span></td>
                    <td class="responsive-edit-button" style="display: none;">
                        <a href="clientarea.php?action=productdetails&amp;id={$service.id}" class="btn btn-block btn-info">
                            {$LANG.manageproduct}
                        </a>
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>
    <div class="text-center" id="tableLoading">
        <p><i class="fas fa-spinner fa-spin"></i> {$LANG.loading}</p>
    </div>
</div>

 

Edited by TimRef
Link to comment
Share on other sites

how can we use two tablename in  the .tpl file ?  

{include file="$template/includes/tablelist.tpl" tableName="InvoicesList" filterColumn="4"}

like 

{include file="$template/includes/tablelist.tpl" tableName="InvoicesList" filterColumn="4"}
{include file="$template/includes/tablelist.tpl" tableName="ServicesList" filterColumn="4"}

 

Link to comment
Share on other sites

14 hours ago, pRieStaKos said:

Just…don’t. 
 Check this and pass the ip to the table

hi, @pRieStaKoscan we use this way to connect with the database tables? 

select * from tblinvoices t1 
left join tblinvoiceitems t2 on t1.id=t2.invoiceid
left join tblhosting t3 on t2.relid=t3.id
WHERE t3.dedicatedIP = value

then we use dedicated IP . if get this to Hook , do you have any idea . 

can we use this type

 

<?php

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

use WHMCS\Database\Capsule as DB;

add_hook('ClientAreaPageInvoices', 1, function($vars) {

    if (isset($vars['invoices'])) {
        $csVals = [];
        foreach ($vars['invoices'] as $invoices) {

            $fieldVal = '';
            $data = DB::table('tblinvoices AS t1')
            ->leftJoin('tblinvoiceitems AS t2', 't1.id', '=', 't2.invoiceid')
            ->leftJoin('tblhosting AS t3', 't2.relid', '=', 't3.id')
            ->select('t3.dedicatedip')
            ->where('t1.id', $fieldId)->where('t2.type', 'hosting')->where('t3.domain', $invoices['id'])
            ->first();
            if (!is_null($data)) {
                $fieldVal = $data->value;
            }
            $csVals[$invoice['id']] = $fieldVal;

        }

        return ['dedicatedip' => $csVals];
    }
});

//and add  {$dedicatedip}  to .tpl page /

I'm not good at this , sorry to take you any inconveniences. 

Edited by TimRef
Link to comment
Share on other sites

1 hour ago, pRieStaKos said:

Creating a hook to pass the variable to .tpl and adjust the table code to present it, it’s the correct approach.

Hi,  @pRieStaKos , thanks for your help . 

Do you offer this type of compensable service to get this done ? 

I have tried long time , I really have no ability to resolve this . 

Do you have a email to talk ? 

Link to comment
Share on other sites

3 minutes ago, TimRef said:

sorry, but i didnt get any email  , ang also dont know the ticket  link 

 

I will post it here:

I'm sending you what you can change on your hook and clientareainvoices.tpl:

  • Change your hook like the below. Feel free to change what you like, but follow the flow:
<?php

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

use WHMCS\Database\Capsule;

add_hook('ClientAreaPageInvoices', 1, function($vars) {
    if (!empty($vars['invoices'])) {
        foreach ($vars['invoices'] as $key => $invoices) {
          // Get service's dedicated ip
          $data = Capsule::table('tblinvoices AS t1')
              ->leftJoin('tblinvoiceitems AS t2', 't1.id', '=', 't2.invoiceid')
              ->leftJoin('tblhosting AS t3', 't2.relid', '=', 't3.id')
              ->select('t3.dedicatedip')
              ->where('t1.id', $fieldId)->where('t2.type', 'hosting')->where('t3.domain', $invoices['id'])
              ->first();
            // Assign dedicated ip to invoices template array
            $vars['invoices'][$key]['dedicatedip'] = !empty($data) ? $data->value : "-";
        }
      // return template invoices array (table)
      return ["invoices" => $vars['invoices']];
    }
});
  • Add the new column on clientareainvoices.tpl
<div class="table-container clearfix">
    <table id="tableInvoicesList" class="table table-list hidden">
        <thead>
            <tr>
                <th>{$LANG.invoicestitle}</th>
                <th>Dedicated IP</th> {* <--- Add this *}
                <th>{$LANG.invoicesdatecreated}</th>
                <th>{$LANG.invoicesdatedue}</th>
                <th>{$LANG.invoicestotal}</th>
                <th>{$LANG.invoicesstatus}</th>
                <th class="responsive-edit-button" style="display: none;"></th>
            </tr>
        </thead>
        <tbody>
            {foreach key=num item=invoice from=$invoices}
                <tr onclick="clickableSafeRedirect(event, 'viewinvoice.php?id={$invoice.id}', false)">
                    <td>{$invoice.invoicenum}</td>
                    <td>{$invoice.dedicatedip}</td> {* <--- Add this *}
                    <td><span class="hidden">{$invoice.normalisedDateCreated}</span>{$invoice.datecreated}</td>
                    <td><span class="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>
                    <td class="responsive-edit-button" style="display: none;">
                        <a href="viewinvoice.php?id={$invoice.id}" class="btn btn-block btn-info">
                            {$LANG.invoicesview}
                        </a>
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>
    <div class="text-center" id="tableLoading">
        <p><i class="fas fa-spinner fa-spin"></i> {$LANG.loading}</p>
    </div>
</div>

If the service doesn't have a Dedicated IP , the table will show a "- ".

Feel free to ask anything else, for this.

As for the price, you can buy me a coffee (or two) here .

Link to comment
Share on other sites

7 minutes ago, pRieStaKos said:

I will post it here:

I'm sending you what you can change on your hook and clientareainvoices.tpl:

  • Change your hook like the below. Feel free to change what you like, but follow the flow:

<?php

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

use WHMCS\Database\Capsule;

add_hook('ClientAreaPageInvoices', 1, function($vars) {
    if (!empty($vars['invoices'])) {
        foreach ($vars['invoices'] as $key => $invoices) {
          // Get service's dedicated ip
          $data = Capsule::table('tblinvoices AS t1')
              ->leftJoin('tblinvoiceitems AS t2', 't1.id', '=', 't2.invoiceid')
              ->leftJoin('tblhosting AS t3', 't2.relid', '=', 't3.id')
              ->select('t3.dedicatedip')
              ->where('t1.id', $fieldId)->where('t2.type', 'hosting')->where('t3.domain', $invoices['id'])
              ->first();
            // Assign dedicated ip to invoices template array
            $vars['invoices'][$key]['dedicatedip'] = !empty($data) ? $data->value : "-";
        }
      // return template invoices array (table)
      return ["invoices" => $vars['invoices']];
    }
});
  • Add the new column on clientareainvoices.tpl

<div class="table-container clearfix">
    <table id="tableInvoicesList" class="table table-list hidden">
        <thead>
            <tr>
                <th>{$LANG.invoicestitle}</th>
                <th>Dedicated IP</th> {* <--- Add this *}
                <th>{$LANG.invoicesdatecreated}</th>
                <th>{$LANG.invoicesdatedue}</th>
                <th>{$LANG.invoicestotal}</th>
                <th>{$LANG.invoicesstatus}</th>
                <th class="responsive-edit-button" style="display: none;"></th>
            </tr>
        </thead>
        <tbody>
            {foreach key=num item=invoice from=$invoices}
                <tr onclick="clickableSafeRedirect(event, 'viewinvoice.php?id={$invoice.id}', false)">
                    <td>{$invoice.invoicenum}</td>
                    <td>{$invoice.dedicatedip}</td> {* <--- Add this *}
                    <td><span class="hidden">{$invoice.normalisedDateCreated}</span>{$invoice.datecreated}</td>
                    <td><span class="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>
                    <td class="responsive-edit-button" style="display: none;">
                        <a href="viewinvoice.php?id={$invoice.id}" class="btn btn-block btn-info">
                            {$LANG.invoicesview}
                        </a>
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>
    <div class="text-center" id="tableLoading">
        <p><i class="fas fa-spinner fa-spin"></i> {$LANG.loading}</p>
    </div>
</div>

If the service doesn't have a Dedicated IP , the table will show a "- ".

Feel free to ask anything else, for this.

As for the price, you can buy me a coffee (or two) here .

thanks , I will try , and update you soon , also , i tried reset password via  cubric, didnt get anything, thanks anyway 

Link to comment
Share on other sites

21 minutes ago, TimRef said:

thanks , I will try , and update you soon , also , i tried reset password via  cubric, didnt get anything, thanks anyway 

 

32 minutes ago, pRieStaKos said:

I will post it here:

I'm sending you what you can change on your hook and clientareainvoices.tpl:

  • Change your hook like the below. Feel free to change what you like, but follow the flow:

<?php

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

use WHMCS\Database\Capsule;

add_hook('ClientAreaPageInvoices', 1, function($vars) {
    if (!empty($vars['invoices'])) {
        foreach ($vars['invoices'] as $key => $invoices) {
          // Get service's dedicated ip
          $data = Capsule::table('tblinvoices AS t1')
              ->leftJoin('tblinvoiceitems AS t2', 't1.id', '=', 't2.invoiceid')
              ->leftJoin('tblhosting AS t3', 't2.relid', '=', 't3.id')
              ->select('t3.dedicatedip')
              ->where('t1.id', $fieldId)->where('t2.type', 'hosting')->where('t3.domain', $invoices['id'])
              ->first();
            // Assign dedicated ip to invoices template array
            $vars['invoices'][$key]['dedicatedip'] = !empty($data) ? $data->value : "-";
        }
      // return template invoices array (table)
      return ["invoices" => $vars['invoices']];
    }
});
  • Add the new column on clientareainvoices.tpl

<div class="table-container clearfix">
    <table id="tableInvoicesList" class="table table-list hidden">
        <thead>
            <tr>
                <th>{$LANG.invoicestitle}</th>
                <th>Dedicated IP</th> {* <--- Add this *}
                <th>{$LANG.invoicesdatecreated}</th>
                <th>{$LANG.invoicesdatedue}</th>
                <th>{$LANG.invoicestotal}</th>
                <th>{$LANG.invoicesstatus}</th>
                <th class="responsive-edit-button" style="display: none;"></th>
            </tr>
        </thead>
        <tbody>
            {foreach key=num item=invoice from=$invoices}
                <tr onclick="clickableSafeRedirect(event, 'viewinvoice.php?id={$invoice.id}', false)">
                    <td>{$invoice.invoicenum}</td>
                    <td>{$invoice.dedicatedip}</td> {* <--- Add this *}
                    <td><span class="hidden">{$invoice.normalisedDateCreated}</span>{$invoice.datecreated}</td>
                    <td><span class="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>
                    <td class="responsive-edit-button" style="display: none;">
                        <a href="viewinvoice.php?id={$invoice.id}" class="btn btn-block btn-info">
                            {$LANG.invoicesview}
                        </a>
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>
    <div class="text-center" id="tableLoading">
        <p><i class="fas fa-spinner fa-spin"></i> {$LANG.loading}</p>
    </div>
</div>

If the service doesn't have a Dedicated IP , the table will show a "- ".

Feel free to ask anything else, for this.

As for the price, you can buy me a coffee (or two) here .

tried this ,all invoice dedicated ip  shown  '-' , see the photo ,   

sometimes one invoice have more than 1 server or hosting . maybe we should add a judge ?

but , only one in the invoice , also not shown .only can see '- '

is the ‘ClientAreaPageInvoices’ we used right ? 

seems didnt get the dedicated ip to pass .121212.png.115be184c3fba60acfcc0782126a2774.png

Link to comment
Share on other sites

The hook index is correct as it will return the IP address so table will render.

You need to decide what you want to present this and change the query properly:

- One invoice can have many products that got one dedicated ip. How will you present this. Comma separated ? Tooltip ?  
So you will have to check the invoices items for the service’s dedicated ip.

Link to comment
Share on other sites

8 minutes ago, pRieStaKos said:

The hook index is correct as it will return the IP address so table will render.

You need to decide what you want to present this and change the query properly:

- One invoice can have many products that got one dedicated ip. How will you present this. Comma separated ? Tooltip ?  
So you will have to check the invoices items for the service’s dedicated ip.

if one invoice have more than 1 products , we can only use the top one of it . 

but currently , only 1 product invoice , also not showing the ip. 

I am thinking maybe the pass or connection of field not correct ? 

Thanks for your time in advance 

Link to comment
Share on other sites

4 minutes ago, TimRef said:

if one invoice have more than 1 products , we can only use the top one of it . 

but currently , only 1 product invoice , also not showing the ip. 

I am thinking maybe the pass or connection of field not correct ? 

Thanks for your time in advance 

Yea. Query gets the first record. A better query or a loop should work.

Link to comment
Share on other sites

20 minutes ago, pRieStaKos said:

The hook index is correct as it will return the IP address so table will render.

You need to decide what you want to present this and change the query properly:

- One invoice can have many products that got one dedicated ip. How will you present this. Comma separated ? Tooltip ?  
So you will have to check the invoices items for the service’s dedicated ip.

BTW, when I try to buy coffee , show me  Failed to verify captcha.    do you have any other way to do this ?  like paypal 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • 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