Evgeny Posted July 24, 2020 Share Posted July 24, 2020 Hello, We try to add link in template (six) ->clientareainvoices.tpl in foreach section. {foreach key=num item=invoice from=$invoices} <tr onclick="clickableSafeRedirect(event, 'viewinvoice.php?id={$invoice.id}', false)"> <td>{$invoice.invoicenum} <br><a href="/index.php?m=mymodule&id={$invoice.id}" target="_blank"><u>Contract</u></a> </td> <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} This line <br><a href="/index.php?m=mymodule&id={$invoice.id}" target="_blank"><u>Contract</u></a> And link have added in all invoices, but we want to show this link only in Paid invoices. How it make, we try add if $status="Paid", but it doesn’t work, we do something wrong, help me how it should look. Thanks. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 29, 2020 Share Posted July 29, 2020 if you were going to do it in the template, you could do something like the code below and that should only show a contract link for paid invoices... <table id="tableInvoicesList" class="table table-list hidden"> <thead> <tr> <th>{$LANG.invoicestitle}</th> <th>{$LANG.invoicesdatecreated}</th> <th>{$LANG.invoicesdatedue}</th> <th>{$LANG.invoicestotal}</th> <th>{$LANG.invoicesstatus}</th> <th></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><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="text-center">{if $invoice.rawstatus eq 'paid'}<a href="index.php?m=mymodule&id={$invoice.id}" target="_blank"><u>Contract</u></a>{/if}</td> </tr> {/foreach} </tbody> </table> 0 Quote Link to comment Share on other sites More sharing options...
Evgeny Posted July 29, 2020 Author Share Posted July 29, 2020 Many thanks, please tell me how to add one more condition here. Those. show a link for paid invoices only for payment gateway bank transfer. bank transfer gateway have id 10 in our gateway list. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 5, 2020 Share Posted August 5, 2020 On 29/07/2020 at 12:50, Evgeny said: please tell me how to add one more condition here. Those. show a link for paid invoices only for payment gateway bank transfer. the array used on that invoices page doesn't include the gateway of each invoice, so you would have to adjust it with a hook... <?php # Add Gateway To Paid Invoices Array Hook # Written by brian! use WHMCS\Database\Capsule; function add_gateway_to_invoices_array_hook($vars) { $invoices = $vars['invoices']; foreach ($invoices as $key => $invoice) { $paymentmethod = Capsule::table('tblinvoices')->where('id',$invoice['id'])->value('paymentmethod'); if ($invoice['rawstatus'] == 'paid' && $paymentmethod == 'banktransfer') { $invoices[$key]['gateway'] = $paymentmethod; } } return array("invoices" => $invoices); } add_hook("ClientAreaPageInvoices", 1, "add_gateway_to_invoices_array_hook"); that allows you to change your if statement in the template from... <td class="text-center">{if $invoice.rawstatus eq 'paid'}<a href="index.php?m=mymodule&id={$invoice.id}" target="_blank"><u>Contract</u></a>{/if}</td> to... <td class="text-center">{if $invoice.gateway}<a href="index.php?m=mymodule&id={$invoice.id}" target="_blank"><u>Contract</u></a>{/if}</td> and then the link will open appear for paid invoice using banktransfer. 0 Quote Link to comment Share on other sites More sharing options...
Evgeny Posted August 5, 2020 Author Share Posted August 5, 2020 That's what we need, works good, thanks brian! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.