<br />
<h3>Available merge fields</h3>
{literal}
    <div id="mergefields" style="border:1px solid #8FBCE9;background:#ffffff;color:#000000;padding:5px;height:300px;overflow:auto;font-size:0.95em;z-index:10;">
        <table width="100%" cellspacing="0" cellpadding="0">
            <tbody>
            <tr>
                <td width="50%" valign="top">
                    <b>Invoice Related</b><br>
                    <table>
                        <tbody>
                        <tr><td width="200"><a href="#" onclick="insertMergeField('invoice_id');return false">Invoice ID</a></td><td>{$invoice_id}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_num');return false">Invoice Number</a></td><td>{$invoice_num}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_date_created');return false">Date Created</a></td><td>{$invoice_date_created}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_date_due');return false">Due Date</a></td><td>{$invoice_date_due}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_date_paid');return false">Paid Date</a></td><td>{$invoice_date_paid}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_amount_paid');return false">Amount Paid</a></td><td>{$invoice_amount_paid}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_balance');return false">Balance</a></td><td>{$invoice_balance}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_payment_module');return false">Payment Module</a></td><td>{$invoice_payment_module}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_payment_method');return false">Payment Method</a></td><td>{$invoice_payment_method}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_status');return false">Status</a></td><td>{$invoice_status}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_link');return false">Invoice Link</a></td><td>{$invoice_link}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('invoice_overdue');return false">Overdue level</a></td><td>{$invoice_overdue}</td></tr>
                        </tbody>
                    </table>
                    <br>
                    <b>Client Related</b><br>
                    <table>
                        <tbody>
                        <tr><td width="200"><a href="#" onclick="insertMergeField('client_id');return false">Client ID</a></td><td>{$client_id}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_firstname');return false">First Name</a></td><td>{$client_firstname}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_lastname');return false">Last Name</a></td><td>{$client_lastname}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_companyname');return false">Company Name</a></td><td>{$client_companyname}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_address1');return false">Address 1</a></td><td>{$client_address1}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_address2');return false">Address 2</a></td><td>{$client_address2}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_city');return false">City</a></td><td>{$client_city}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_state');return false">State/Region</a></td><td>{$client_state}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_postcode');return false">Postcode</a></td><td>{$client_postcode}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_countrycode');return false">Country Code</a></td><td>{$client_countrycode}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_country');return false">Country</a></td><td>{$client_country}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_tax_id');return false">VAT Number</a></td><td>{$client_tax_id}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_signup_date');return false">Signup Date</a></td><td>{$client_signup_date}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_group_id');return false">Client Group ID</a></td><td>{$client_group_id}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_group_name');return false">Client Group Name</a></td><td>{$client_group_name}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('client_custom_fields');return false">Custom Fields (array)</a></td><td>{$client_custom_fields}</td></tr>
                        </tbody>
                    </table>
                    <br>
                    <b>Other</b><br>
                    <table>
                        <tbody>
                        <tr><td width="200"><a href="#" onclick="insertMergeField('company_name');return false">Company Name</a></td><td>{$company_name}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('company_address');return false">Company Address</a></td><td>{$company_address}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('company_domain');return false">Domain</a></td><td>{$company_domain}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('company_tax_code');return false">Your Tax ID/VAT Number</a></td><td>{$company_tax_code}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('taxIdLabel');return false">Tax ID Label</a></td><td>{$taxIdLabel}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('tax_rate');return false">Tax Rate</a></td><td>{$tax_rate}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('whmcs_url');return false">WHMCS URL</a></td><td>{$whmcs_url}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('whmcs_link');return false">WHMCS Link</a></td><td>{$whmcs_link}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('locale');return false">Locale</a></td><td>{$locale}</td></tr>
                        <tr><td><a href="#" onclick="insertMergeField('lang');return false">Language strings</a></td><td>{$lang}</td></tr>
                        </tbody>
                    </table>
                    <br>
                </td>
                <td width="50%" valign="top">
                    <b>Conditional Display</b><br>
                    You can use conditionals to display text based on other values - for example:<br><br>
                    {if $invoice_payment_module eq "paypal"}<br>
                    Some info regarding PayPal<br>
                    {else}<br>
                    Your payment method is {$invoice_payment_method}<br>
                    {/if}<br>
                    <br>
                    <b>Language strings</b><br>
                    You can use the $lang variable to access the module's language strings:<br><br>
                    {$lang.example}
                </td>
            </tr>
            </tbody>
        </table>
    </div>
{/literal}

{$tinymce}

<script type="text/javascript">
    var tinymceSettings = {
        selector: "textarea.tinymce",
        height: 500,
        theme: "modern",
        entity_encoding: "raw",
        plugins: "autosave searchreplace autolink directionality visualblocks visualchars fullscreen image link template code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern paste help",
        toolbar: ["formatselect,fontselect,fontsizeselect,|,bold,italic,strikethrough,underline,forecolor,backcolor,|,link,unlink,|,alignleft aligncenter alignright alignjustify,|,searchreplace,|,bullist,numlist,", "outdent,indent,blockquote,|,undo,redo,|,cut,copy,paste,pastetext,|,table,|,hr,|,subscript,superscript,|,charmap,image,|,ltr,rtl,|,fullscreen,|,help,code,removeformat"],
        image_advtab: true,
        content_css: ["//fonts.googleapis.com/css?family=Lato:300,300i,400,400i", "//www.tinymce.com/css/codepen.min.css"],
        browser_spellcheck: false,
        convert_urls: false,
        relative_urls: false,
        forced_root_block: "p",
        media_poster: false,
        mobile: {
            theme: "mobile",
            plugins: ["autosave", "lists", "autolink"],
            toolbar: ["undo"]
        },
        menu: {
            edit: {
                title: "Edit",
                items: "undo redo | cut copy paste pastetext | selectall | searchreplace"
            },
            view: {
                title: "View",
                items: "visualaid visualchars visualblocks | preview fullscreen"
            },
            insert: {
                title: "Insert",
                items: "image link | charmap hr"
            },
            format: {
                title: "Format",
                items: "bold italic strikethrough underline superscript subscript codeformat | blockformats align | removeformat"
            },
            table: {
                title: "Table",
                items: "inserttable tableprops deletetable | cell row column"
            },
            help: {
                title: "Help",
                items: "help | code"
            }
        },
        font_formats: '{foreach $fonts as $fontFile => $fontName}{$fontName}={$fontFile};{/foreach}',
        valid_elements: "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang]," +
            "a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur]," +
            "strong/b,em/i,u,#p,-ol[type|compact],-ul[type|compact],-li,br," +
            "img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote," +
            "-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor]," +
            "-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot," +
            "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope]," +
            "#th[colspan|rowspan|width|height|align|valign|scope],-div,-span,-pre,-h1,-h2,-h3,-h4,-h5,-h6," +
            "hr[size|noshade],-font[face|size|color],dd,dl,dt,del[datetime|cite],small,tt"
    };

    $(document).ready(function() {
        tinymce.init(tinymceSettings).then(function(editors) {
            editorLoaded = true;
        });
    });

    var editorEnabled = true,
        editorLoaded = false;

    function toggleEditor() {
        if (editorEnabled === true) {
            tinymce.activeEditor.remove();
            editorEnabled = false;
        } else {
            tinymce.init(tinymceSettings);
            editorEnabled = true;
        }
    }

    function insertMergeField(mfield) {
        {literal}
        tinymce.activeEditor.insertContent('{$' + mfield + '}');
        {/literal}
    }
</script>
