{if isset($RSThemes['pages'][$templatefile]) && file_exists($RSThemes['pages'][$templatefile]['fullPath'])}
    {include file=$RSThemes['pages'][$templatefile]['fullPath']}
{else}
    {assign var=iconsPages value=['clientareadomains', 'supportticketslist', 'clientareainvoices', 'clientareaproducts', 'clientareaquotes']}
    {if $tickets}
        {include file="$template/includes/tablelist.tpl" tableName="TicketsList" filterColumn="2" ajaxUrl="{$WEB_ROOT}/modules/addons/RSThemes/src/Api/clientApi.php?controller=ClientData&method=getClientTickets" tableIncludes="tickets"}
        <script type="text/javascript">
            jQuery(document).ready( function ()
            {
                var table = jQuery('#tableTicketsList').removeClass('hidden').DataTable();
                {if $orderby == 'did' || $orderby == 'dept'}
                    table.order(1, '{$sort}');
                {elseif $orderby == 'subject' || $orderby == 'title'}
                    table.order(1, '{$sort}');
                {elseif $orderby == 'status'}
                    table.order(2, '{$sort}');
                {elseif $orderby == 'lastreply'}
                    table.order(3, '{$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="ticket-table table-container {if isset($RSThemes.addonSettings.enable_table_ajax_load) && $RSThemes.addonSettings.enable_table_ajax_load == "enabled"}table-container-ajax{/if} loading clearfix">
            <div class="table-top">
                <div class="d-flex">
                    <label>{$LANG.clientareahostingaddonsview}</label>
                    <div 
                        class="dropdown view-filter-btns {if $RSThemes.addonSettings.show_status_icon == 'displayed'}iconsEnabled{/if}"
                        data-table-filters 
                        {if isset($RSThemes['pages'][$templatefile]) && isset($RSThemes['pages'][$templatefile]['config']['defaultStatusFilter']) && $RSThemes['pages'][$templatefile]['config']['defaultStatusFilter'] != "all" && !empty($RSThemes['pages'][$templatefile]['config']['defaultStatusFilter'])}
                            data-default-filter="{$RSThemes['pages'][$templatefile]['config']['defaultStatusFilter']|capitalize}"
                        {/if}
                    >
                        <button tabindex="0" type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                            {if $RSThemes.addonSettings.show_status_icon == 'displayed'}
                                {if file_exists("templates/$template/assets/img/status-icons/status-all.tpl")}
                                    <span class="status-icon status-ticket status-status-all" style="font-size: 0;">
                                        {include file="$template/assets/img/status-icons/status-all.tpl"}      
                                    </span>
                                {/if}
                            {else}
                                <span class="status hidden"></span>
                            {/if}
                            <span class="filter-name">{$rslang->trans('generals.all_entries')}</span>
                            <i class="ls ls-caret"></i>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li>
                                <a tabindex="0" href="#">
                                    <span data-value="all">
                                        {if $RSThemes.addonSettings.show_status_icon == 'displayed'}
                                            {if file_exists("templates/$template/assets/img/status-icons/status-all.tpl")}
                                                <span class="status-icon status-ticket status-status-all">
                                                    {include file="$template/assets/img/status-icons/status-all.tpl"}      
                                                </span>
                                            {/if}
                                            <span class="filter-name">{$rslang->trans('generals.all_entries')}</span>
                                        {else}
                                            {$rslang->trans('generals.all_entries')}
                                        {/if}
                                    </span>
                                </a>
                            </li>
                            {foreach key=num item=status from=$RSTicketsStatuses}
                                {if isset($RSThemes['pages'][$templatefile]) && $RSThemes['pages'][$templatefile]['config']['hideInactiveTickets'] == "1" && !empty($RSThemes['pages'][$templatefile]['config']['hideInactiveTickets'])}
                                    {include file="$template/includes/tickets/hide-inactive-tickets.tpl" type="status-dropdown"}                           
                                {/if}
                                {assign var="statusColor" value='style="color:'|explode:$status.status} 
                                {assign var="statusColor" value='">'|explode:$statusColor[1]} 
                                {if $RSThemes.addonSettings.show_status_icon == 'displayed' && in_array($templatefile, $iconsPages)}
                                <li {if $hiddeStatus}{if !$hideInactiveServices['inactiveServices']}class="hidden"{/if} data-table-filters-hidden{/if} data-status="{if $status.statusClass == "customer-reply"}{$status.statusClass|capitalize}{else}{$status.statusClass|replace:"-":" "|capitalize}{/if}">
                                        <a tabindex="0" href="#" data-status-color="{$statusColor[0]}">
                                            <span class="status status-{$status.statusClass} {if $RSThemes.addonSettings.show_status_icon == 'displayed'}dot-hidden{/if}" data-value="{$status.statustext}" data-status-class="{$status.statusClass}" data-status="ticket">
                                                {if $RSThemes.addonSettings.show_status_icon == 'displayed'}
                                                    {if file_exists("templates/$template/assets/img/status-icons/{$status.statusClass}.tpl")}
                                                        <span class="status-icon status-ticket status-{$status.statusClass}" data-status="ticket">
                                                            {include file="$template/assets/img/status-icons/{$status.statusClass}.tpl" statusColor={$statusColor[0]}}      
                                                        </span>
                                                    {else}
                                                        <span class="status-icon status-icon-ticket status-{$status.statusClass}">
                                                            {include file="$template/assets/img/status-icons/default.tpl" statusColor=$statusColor[0]}      
                                                        </span>
                                                    {/if}  
                                                    <span class="filter-name">
                                                        {$status.status|replace:'style="color':'class="status dot-hidden" data-status="ticket"'}
                                                    </span>
                                                {else}                   
                                                    <span class="filter-name">
                                                        {$status.status|replace:'style="color':'class="status" style="--status-color'}
                                                    </span>
                                                {/if}
                                            </span>
                                        </a>
                                    </li>
                                    {else}
                                        <li {if $hiddeStatus}{if !$hideInactiveServices['inactiveServices']}class="hidden"{/if} data-table-filters-hidden{/if} data-status="{if $status.statusClass == "customer-reply"}{$status.statusClass|capitalize}{else}{$status.statusClass|replace:"-":" "|capitalize}{/if}"><a tabindex="0" href="#" data-status-color="{$statusColor[0]}">{$status.status|replace:'style="color':'class="status" style="--status-color'}</a></li>
                                    {/if}
                            {/foreach}
                        </ul>
                        
                    </div>
                    <button tabindex="0" id="clearFilters" type="button" class="btn btn-link btn-xs hidden">{$rslang->trans('generals.clear_filters')}<i class="ls ls-close"></i></button>
                </div>
                {if isset($RSThemes['pages'][$templatefile]) && $RSThemes['pages'][$templatefile]['config']['hideInactiveTickets'] == "1" && !empty($RSThemes['pages'][$templatefile]['config']['hideInactiveTickets'])}
                    {include file="$template/includes/tickets/hide-inactive-tickets.tpl" type="switcher"}
                {/if}  
            </div>
                
            <table id="tableTicketsList" class="table table-list">
                <thead>
                    <tr>
                        <th>{$LANG.supportticketssubject}<span class="sorting-arrows"></span></th>
                        <th><button tabindex="0" type="button" tabindex="0" class="btn-table-collapse" aria-label="Collapse"></button>{$LANG.supportticketsdepartment}<span class="sorting-arrows"></span></th>
                        <th>{$LANG.supportticketsstatus}<span class="sorting-arrows"></span></th>
                        <th>{$LANG.supportticketsticketlastupdated}<span class="sorting-arrows"></span></th>
                        {if isset($RSThemes['pages'][$templatefile]) && $RSThemes['pages'][$templatefile]['config']['showManageButton'] == "1"}
                            <th></th>
                        {/if}
                    </tr>
                </thead>
                <tbody>
                    {if !isset($RSThemes.addonSettings.enable_table_ajax_load) || $RSThemes.addonSettings.enable_table_ajax_load == "disabled"}
                        {foreach from=$tickets item=ticket}
                            {if $RSThemes.addonSettings.show_status_icon == 'displayed' && in_array($templatefile, $iconsPages)}
                                {assign var="ticketColor" value='style="color:'|explode:$ticket.status} 
                                {assign var="ticketColor" value='">'|explode:$ticketColor[1]}
                            {/if}
                            <tr tabindex="-1" data-url="viewticket.php?tid={$ticket.tid}&amp;c={$ticket.c}">
                                <td> 
                                    <div class="d-flex align-items-center gap-base">
                                        {if is_array($graphics['department']) && $graphics['department'][$ticketsDepartmentsID[$ticket.id]]->enabled && $graphics['department'][$ticketsDepartmentsID[$ticket.id]]->getJson()->condensed->type}
                                            <div class="graphic-item graphic-item-sm">
                                                {assign var=graphic value=$graphics['department'][$ticketsDepartmentsID[$ticket.id]]->getJson()->condensed->graphic}
                                                {assign var=graphicType value=$graphics['department'][$ticketsDepartmentsID[$ticket.id]]->getJson()->condensed->type}
                                                {if $graphicType == "icon"}
                                                    {include file="$template/assets/svg-icon/{$graphic}"}
                                                {else if $graphicType == "font-icon"}
                                                    <span class="graphic-item-bg">
                                                        <i class="{$graphic}"></i>
                                                    </span>
                                                {else if $graphicType == "media"}
                                                    <img src="{$WEB_ROOT}/templates/{$template}/assets/img/page-manager/{$graphic}" alt="{$ticket.department}">
                                                {/if}
                                            </div>
                                        {/if}   
                                        {if isset($RSThemes['pages'][$templatefile]) && $RSThemes['pages'][$templatefile]['config']['hideInactiveTickets'] == "1" && !empty($RSThemes['pages'][$templatefile]['config']['hideInactiveTickets'])}
                                            {include file="$template/includes/tickets/hide-inactive-tickets.tpl" type="table-cell"}
                                        {/if}
                                        <div>
                                            <button tabindex="0" type="button" tabindex="0" class="btn-table-collapse" aria-label="Collapse"></button>
                                            <div class="text-primary p-md font-weight-medium d-flex align-items-center">
                                                <span>
                                                    #{$ticket.tid}
                                                </span>
                                                {if isset($sensitiveDataEnabled) && $sensitiveDataEnabled && $ticketSensitiveData[$ticket.id]}
                                                    <i class="ml-2" data-html="true" data-toggle="tooltip" data-original-title="{$rslang->trans('sensitive_data.tooltip')}">{include file="$template/core/extensions/SensitiveDataManager/assets/svg-icon/shield.svg"}</i>
                                                {/if}
                                            </div>
                                            <span class="p-sm">{$ticket.subject}</span>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <span>                      
                                        {$ticket.department}
                                    </span>
                                </td>
                                <td class="status-col">
                                    {if $RSThemes.addonSettings.show_status_icon == 'displayed' && in_array($templatefile, $iconsPages)}
                                        {if file_exists("templates/$template/assets/img/status-icons/{$ticket.statusClass}.tpl")}
                                            <div>
                                                <span class="status-icon status-icon-ticket {$ticketColor[0]}">
                                                    {include file="$template/assets/img/status-icons/{$ticket.statusClass}.tpl" statusColor={$ticketColor[0]}}      
                                                </span>
                                                {$ticket.status|replace:'style="color':'class="status status-ticket dot-hidden" style="--status-color'}
                                            </div>
                                        {else}
                                            <div>
                                                <span class="status-icon status-icon-ticket {$ticketColor[0]}">
                                                    {include file="$template/assets/img/status-icons/default.tpl" statusColor={$ticketColor[0]}}      
                                                </span>
                                                {$ticket.status|replace:'style="color':'class="status status-ticket dot-hidden" style="--status-color'}
                                            </div>
                                        {/if}     
                                    {else}                
                                        {$ticket.status|replace:'style="color':'class="status" style="--status-color'}
                                    {/if}  
                                    {* <span class="{if $RSThemes.addonSettings.show_status_icon == 'displayed'}status status-{$ticket.statusClass} dot-hidden{/if}" style="color: --status-color">
                                        {$ticket.status|replace:'style="color':'class="status" style="--status-color'}
                                    </span> *}
                                </td>
                                <td class="sorting_1 text-nowrap">
                                    <span class="hidden">{$ticket.normalisedLastReply}</span>
                                    {if isset($RSThemes['pages'][$templatefile]) && $RSThemes['pages'][$templatefile]['config']['dateAgo'] == "1"}
                                        <span data-html="true" data-toggle="tooltip" data-original-title="{$ticket.lastreply}">{$ticketsAgo[$ticket.id]['lastreplyago']}</span>
                                    {else}
                                        {$ticket.lastreply}
                                    {/if}
                                </td>
                                {if isset($RSThemes['pages'][$templatefile]) && $RSThemes['pages'][$templatefile]['config']['showManageButton'] == "1"}
                                    <td class="cell-action">
                                        <a tabindex="0" href="viewticket.php?tid={$ticket.tid}&amp;c={$ticket.c}"
                                            class="btn btn-default btn-sm btn-manage">{$_LANG['manage']}</a>
                                    </td>
                                {/if}
                            </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="ticket"}      
            </div>
            <h6 class="message-title">{$rslang->trans('nodata.no_recent_tickets')}</h6>
            <div class="message-action">
                <a tabindex="0" class="btn btn-primary" href="{$WEB_ROOT}/submitticket.php">
                    {$LANG.navopenticket}
                </a>
            </div>
        </div>
    {/if}
{/if}