{if isset($RSThemes['pages'][$templatefile]) && file_exists($RSThemes['pages'][$templatefile]['fullPath'])}
    {include file=$RSThemes['pages'][$templatefile]['fullPath']}
{else}	     
    {include file="$template/includes/tablelist.tpl" tableName="EmailsList" noSortColumns="-1" ajaxUrl="{$WEB_ROOT}/modules/addons/RSThemes/src/Api/clientApi.php?controller=ClientData&method=getClientEmails" tableIncludes="emails"}
    {if $emails}
        <script type="text/javascript">
            jQuery(document).ready( function ()
            {
                var table = jQuery('#tableEmailsList').removeClass('hidden').DataTable();
                {if $orderby == 'date'}
                    table.order(0, '{$sort}');
                {elseif $orderby == 'subject'}
                    table.order(1, '{$sort}');
                {/if}
                table.draw();
                {if isset($RSThemes.addonSettings.enable_table_ajax_load) && $RSThemes.addonSettings.enable_table_ajax_load == "enabled"}
                {else}
                    jQuery('.table-container').removeClass('loading');
                    jQuery('#tableLoading').addClass('hidden');
                {/if}
            });
        </script>
        <div class="table-container {if isset($RSThemes.addonSettings.enable_table_ajax_load) && $RSThemes.addonSettings.enable_table_ajax_load == "enabled"}table-container-ajax{/if} loading clearfix">
            <table id="tableEmailsList" class="table table-list">
                <thead>
                    <tr>
                        <th>{$LANG.clientareaemailsdate}<span class="sorting-arrows"></span></th>
                        <th>{$LANG.clientareaemailssubject}<span class="sorting-arrows"></span></th>
                    </tr>
                </thead>
                <tbody>
                    {if !isset($RSThemes.addonSettings.enable_table_ajax_load) || $RSThemes.addonSettings.enable_table_ajax_load == "disabled"}
                        {foreach from=$emails item=email}
                        <tr onclick="popupWindow('viewemail.php?id={$email.id}', 'emailWin', '650', '450')">
                            <td class="" tabindex="-1" aria-hidden="true"><span class="hidden">{$email.normalisedDate}</span>{$email.date}</td>
                            <td><a tabindex="0" href="">{if $email.attachmentCount > 0}<i class="fal fa-paperclip"></i> {/if}{$email.subject}</a></td>
                        </tr>
                        {/foreach}
                    {/if}    
                </tbody>
            </table>
            <div class="loader loader-table" id="tableLoading">
                {include file="$template/includes/common/loader.tpl"}    
            </div>
        </div>
    {else}
        <div class="message message-no-data">
            <div class="message-image">
                {include file="$template/includes/common/svg-icon.tpl" icon="64-mail-1"}     
            </div>
            <h6 class="message-title">{$rslang->trans('no_data_table.search.emails.title')}</h6>
            <p class="message-desc">{$rslang->trans('no_data_table.empty.emails.description')}</p>
        </div>
    {/if}
{/if}    