doufang8965 2015-11-17 17:07
浏览 26
已采纳

whmcs新标签中的发票

I want to open the invoices of whmcs in a new tab or a popup window. The biggest part of this problem is solved but one thing remains a problem. I used some js to open up the invoice in a new tab, but on the original page, after opening the invoice, it also loads and returns a 404. The invoice opens without any problems.

This is the js

            <script>
            function OpenInNewTab(url) {
                var win = window.open(url, '_blank');
                win.focus();
                 }
            </script>

this is the code to call the invoices and display it in a table. note: this is a smarty .tpl

<tr onclick="clickableSafeRedirect(event, OpenInNewTab('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>{$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.manageproduct}
                        </a>
                    </td>
                </tr>

I added the OpenInNewTab in this line

<tr onclick="clickableSafeRedirect(event, OpenInNewTab('viewinvoice.php?id={$invoice.id}'), false)">

and this was the original code

<tr onclick="clickableSafeRedirect(event, viewinvoice.php?id={$invoice.id}, false)">

Thanks in advance!!

EDIT: I tried to merge the clickableSafeRedirect function with the OpenInNewTab function, this resulted in an empty tab with the invoice loaded on the original page.

This is the clickableSafeRedirect function

function clickableSafeRedirect(clickEvent, target, newWindow) {

    var eventSource = clickEvent.target.tagName.toLowerCase();
    var eventParent = clickEvent.target.parentNode.tagName.toLowerCase();
    var eventTable = clickEvent.target.parentNode.parentNode.parentNode;
    if (jQuery(eventTable).hasClass('collapsed')) {
        // This is a mobile device sized display, and datatables has triggered folding
        return false;
    }
    if(eventSource != 'button' && eventSource != 'a') {
        if(eventParent != 'button' && eventParent != 'a') {
            if (newWindow) {
                window.open(target);

            } else {
                window.location.href = target;

            }
        }
    }
}
  • 写回答

1条回答 默认 最新

  • dongzhuo1733 2015-11-17 17:20
    关注

    This function clickableSafeRedirect() in WHMCS have a parameter that allows yo to open the new window instead of your custom function.

    Remove your OpenInNewTab() function and make this:

    clickableSafeRedirect(event, viewinvoice.php?id={$invoice.id}, true);
    ---------------------------------------------------------------^^^^
    

    Setting true in the third parameter open in new window. Look at the code in whmcs. The definition of the function is:

    function clickableSafeRedirect(clickEvent, target, newWindow)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab