<?php
/* Smarty version 4.5.3, created on 2026-05-21 04:04:22
  from '/var/www/html/billing/system/plugin/ui/goWhatsappGateway_logs.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.3',
  'unifunc' => 'content_6a0e8446481443_68065949',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '2f7995d66eb9c3c1f23ca92c6f54fca4e5cdc54a' => 
    array (
      0 => '/var/www/html/billing/system/plugin/ui/goWhatsappGateway_logs.tpl',
      1 => 1774695046,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:sections/header.tpl' => 1,
    'file:sections/footer.tpl' => 1,
  ),
),false)) {
function content_6a0e8446481443_68065949 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_checkPlugins(array(0=>array('file'=>'/var/www/html/billing/system/vendor/smarty/smarty/libs/plugins/modifier.count.php','function'=>'smarty_modifier_count',),));
$_smarty_tpl->_subTemplateRender("file:sections/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>

<div class="p-4 md:p-6 space-y-4">

    
    <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
        <div class="flex items-center gap-3">
            <div class="w-10 h-10 rounded-xl bg-green-600 flex items-center justify-center shadow">
                <svg class="w-5 h-5 text-white" fill="currentColor" viewBox="0 0 24 24">
                    <path d="M12 2C6.48 2 2 6.48 2 12c0 1.85.5 3.58 1.38 5.06L2 22l5.09-1.35A9.956 9.956 0 0012 22c5.52 0 10-4.48 10-10S17.52 2 12 2zm0 18c-1.66 0-3.2-.46-4.53-1.25l-.32-.2-3.02.8.82-2.96-.21-.33A7.96 7.96 0 014 12c0-4.41 3.59-8 8-8s8 3.59 8 8-3.59 8-8 8z"/>
                </svg>
            </div>
            <div>
                <h1 class="text-xl font-bold text-gray-800 leading-tight">WhatsApp Message Logs</h1>
                <p class="text-sm text-gray-500"><?php echo $_smarty_tpl->tpl_vars['total_logs']->value;?>
 total record<?php if ($_smarty_tpl->tpl_vars['total_logs']->value != 1) {?>s<?php }?></p>
            </div>
        </div>
        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway"
           class="inline-flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 shadow-sm transition">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7"/>
            </svg>
            Back to Gateway
        </a>
    </div>

        <div class="grid grid-cols-2 sm:grid-cols-4 gap-3">
        <div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4 flex items-center gap-3">
            <div class="w-9 h-9 rounded-lg bg-blue-100 flex items-center justify-center shrink-0">
                <svg class="w-5 h-5 text-blue-600" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M8 10h.01M12 10h.01M16 10h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>
                </svg>
            </div>
            <div>
                <p class="text-2xl font-bold text-gray-800"><?php echo $_smarty_tpl->tpl_vars['stats_total']->value;?>
</p>
                <p class="text-xs text-gray-500">Total Sent</p>
            </div>
        </div>
        <div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4 flex items-center gap-3">
            <div class="w-9 h-9 rounded-lg bg-green-100 flex items-center justify-center shrink-0">
                <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/>
                </svg>
            </div>
            <div>
                <p class="text-2xl font-bold text-green-700"><?php echo $_smarty_tpl->tpl_vars['stats_delivered']->value;?>
</p>
                <p class="text-xs text-gray-500">Delivered</p>
            </div>
        </div>
        <div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4 flex items-center gap-3">
            <div class="w-9 h-9 rounded-lg bg-red-100 flex items-center justify-center shrink-0">
                <svg class="w-5 h-5 text-red-500" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
                </svg>
            </div>
            <div>
                <p class="text-2xl font-bold text-red-600"><?php echo $_smarty_tpl->tpl_vars['stats_failed']->value;?>
</p>
                <p class="text-xs text-gray-500">Failed</p>
            </div>
        </div>
        <div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4 flex items-center gap-3">
            <div class="w-9 h-9 rounded-lg bg-purple-100 flex items-center justify-center shrink-0">
                <svg class="w-5 h-5 text-purple-600" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
                </svg>
            </div>
            <div>
                <p class="text-2xl font-bold text-purple-700"><?php echo $_smarty_tpl->tpl_vars['stats_rate']->value;?>
%</p>
                <p class="text-xs text-gray-500">Success Rate</p>
            </div>
        </div>
    </div>

        <form method="get" id="filterForm" class="bg-white rounded-xl border border-gray-200 shadow-sm p-4">
        <div class="flex flex-wrap gap-3 items-end">
            <div class="flex-1 min-w-[160px]">
                <label class="block text-xs font-medium text-gray-500 mb-1">Search</label>
                <input type="text" name="search" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['search']->value, ENT_QUOTES, 'UTF-8', true);?>
" placeholder="Phone or message..."
                    class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500">
            </div>
            <div>
                <label class="block text-xs font-medium text-gray-500 mb-1">Status</label>
                <select name="status" class="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500">
                    <option value="">All</option>
                    <option value="delivered" <?php if ($_smarty_tpl->tpl_vars['filter_status']->value == 'delivered') {?>selected<?php }?>>Delivered</option>
                    <option value="failed"    <?php if ($_smarty_tpl->tpl_vars['filter_status']->value == 'failed') {?>selected<?php }?>>Failed</option>
                    <option value="sent"      <?php if ($_smarty_tpl->tpl_vars['filter_status']->value == 'sent') {?>selected<?php }?>>Sent</option>
                </select>
            </div>
            <div>
                <label class="block text-xs font-medium text-gray-500 mb-1">From</label>
                <input type="date" name="date_from" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['date_from']->value, ENT_QUOTES, 'UTF-8', true);?>
"
                    class="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500">
            </div>
            <div>
                <label class="block text-xs font-medium text-gray-500 mb-1">To</label>
                <input type="date" name="date_to" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['date_to']->value, ENT_QUOTES, 'UTF-8', true);?>
"
                    class="border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500">
            </div>
            <input type="hidden" name="per_page" value="<?php echo $_smarty_tpl->tpl_vars['per_page']->value;?>
">
            <input type="hidden" name="page" value="1">
            <button type="submit"
                class="inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-green-600 text-white text-sm font-medium hover:bg-green-700 transition">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-4.35-4.35M17 11A6 6 0 115 11a6 6 0 0112 0z"/>
                </svg>
                Filter
            </button>
            <?php if ($_smarty_tpl->tpl_vars['search']->value || $_smarty_tpl->tpl_vars['filter_status']->value || $_smarty_tpl->tpl_vars['date_from']->value || $_smarty_tpl->tpl_vars['date_to']->value) {?>
            <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway_logs"
                class="inline-flex items-center gap-1.5 px-4 py-2 rounded-lg border border-gray-300 bg-white text-sm text-gray-600 hover:bg-gray-50 transition">
                Clear
            </a>
            <?php }?>
            <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway_logs&export=csv&search=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['search']->value);?>
&status=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['filter_status']->value);?>
&date_from=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['date_from']->value);?>
&date_to=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['date_to']->value);?>
"
                class="inline-flex items-center gap-1.5 px-4 py-2 rounded-lg border border-gray-300 bg-white text-sm text-gray-700 hover:bg-gray-50 transition ml-auto">
                <svg class="w-4 h-4 text-green-600" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
                </svg>
                Export CSV
            </a>
        </div>
    </form>

        <div class="flex flex-wrap gap-2">
        <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, array(''=>'All','delivered'=>'Delivered','failed'=>'Failed','sent'=>'Sent'), 'tab_label', false, 'tab_val');
$_smarty_tpl->tpl_vars['tab_label']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['tab_val']->value => $_smarty_tpl->tpl_vars['tab_label']->value) {
$_smarty_tpl->tpl_vars['tab_label']->do_else = false;
?>
            <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway_logs&per_page=<?php echo $_smarty_tpl->tpl_vars['per_page']->value;?>
&search=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['search']->value);?>
&date_from=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['date_from']->value);?>
&date_to=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['date_to']->value);?>
&status=<?php echo rawurlencode((string)$_smarty_tpl->tpl_vars['tab_val']->value);?>
"
                class="px-4 py-1.5 rounded-full border text-sm font-medium transition <?php if ($_smarty_tpl->tpl_vars['filter_status']->value == $_smarty_tpl->tpl_vars['tab_val']->value) {?>bg-green-600 border-green-600 text-white<?php } else { ?>bg-white border-gray-300 text-gray-600 hover:bg-gray-50<?php }?>">
                <?php echo $_smarty_tpl->tpl_vars['tab_label']->value;?>

            </a>
        <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
    </div>

    <div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4">
        <form method="post" id="logsForm">
            <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">

                
                <div class="flex flex-wrap items-center gap-4">
                    <label class="flex items-center gap-2 text-sm text-gray-600">
                        <span>Show</span>
                        <select id="perPageSelect" onchange="changePerPage()"
                            class="border border-gray-300 rounded-lg px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-green-500">
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, array(10,50,100,150,200,500), 'n');
$_smarty_tpl->tpl_vars['n']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['n']->value) {
$_smarty_tpl->tpl_vars['n']->do_else = false;
?>
                                <option value="<?php echo $_smarty_tpl->tpl_vars['n']->value;?>
" <?php if ($_smarty_tpl->tpl_vars['per_page']->value == $_smarty_tpl->tpl_vars['n']->value) {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['n']->value;?>
</option>
                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                        <span>per page</span>
                    </label>

                    <label class="flex items-center gap-2 text-sm text-gray-600 cursor-pointer select-none">
                        <input type="checkbox" id="selectAll"
                            class="w-4 h-4 accent-green-600 rounded cursor-pointer">
                        <span>Select all</span>
                    </label>

                    <span class="text-xs text-gray-400">
                        <?php if (smarty_modifier_count($_smarty_tpl->tpl_vars['logs']->value) > 0) {?>
                            <?php $_smarty_tpl->_assignInScope('from', ($_smarty_tpl->tpl_vars['page']->value-1)*$_smarty_tpl->tpl_vars['per_page']->value+1);?>
                            <?php $_smarty_tpl->_assignInScope('to', ($_smarty_tpl->tpl_vars['page']->value-1)*$_smarty_tpl->tpl_vars['per_page']->value+smarty_modifier_count($_smarty_tpl->tpl_vars['logs']->value));?>
                            <?php echo $_smarty_tpl->tpl_vars['from']->value;?>
–<?php echo $_smarty_tpl->tpl_vars['to']->value;?>
 of <?php echo $_smarty_tpl->tpl_vars['total_logs']->value;?>

                        <?php } else { ?>
                            No records
                        <?php }?>
                    </span>
                </div>

                
                <div class="flex items-center gap-2">
                    <button type="button" id="deleteSelectedBtn" disabled onclick="deleteSelected()"
                        class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-amber-100 text-amber-800 hover:bg-amber-200 disabled:opacity-40 disabled:cursor-not-allowed transition">
                        <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M8 7V5a1 1 0 011-1h6a1 1 0 011 1v2"/>
                        </svg>
                        Delete Selected
                    </button>
                    <button type="button" onclick="deleteAll()"
                        class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-red-100 text-red-700 hover:bg-red-200 transition">
                        <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M8 7V5a1 1 0 011-1h6a1 1 0 011 1v2"/>
                        </svg>
                        Delete All
                    </button>
                </div>
            </div>

            
            <div class="mt-4 overflow-x-auto rounded-xl border border-gray-200">
                <table class="min-w-full divide-y divide-gray-200 text-sm">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="w-10 px-3 py-3 text-center">
                                <input type="checkbox" id="selectAllHeader"
                                    class="w-4 h-4 accent-green-600 rounded cursor-pointer">
                            </th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">ID</th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Phone</th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Message</th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Status</th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Response</th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">Date / Time</th>
                            <th class="px-3 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Actions</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-100">
                        <?php if (smarty_modifier_count($_smarty_tpl->tpl_vars['logs']->value) > 0) {?>
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['logs']->value, 'log');
$_smarty_tpl->tpl_vars['log']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['log']->value) {
$_smarty_tpl->tpl_vars['log']->do_else = false;
?>
                                <tr class="hover:bg-gray-50 transition-colors">
                                    <td class="px-3 py-3 text-center">
                                        <input type="checkbox" name="selected_logs[]" value="<?php echo $_smarty_tpl->tpl_vars['log']->value['id'];?>
"
                                            class="log-checkbox w-4 h-4 accent-green-600 rounded cursor-pointer">
                                    </td>
                                    <td class="px-3 py-3 text-gray-500 font-mono text-xs"><?php echo $_smarty_tpl->tpl_vars['log']->value['id'];?>
</td>
                                    <td class="px-3 py-3 font-medium text-gray-800 whitespace-nowrap"><?php echo $_smarty_tpl->tpl_vars['log']->value['phone_number'];?>
</td>
                                    <td class="px-3 py-3 text-gray-700 max-w-xs">
                                        <div class="truncate" title="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['log']->value['message'], ENT_QUOTES, 'UTF-8', true);?>
"><?php echo $_smarty_tpl->tpl_vars['log']->value['message'];?>
</div>
                                    </td>
                                    <td class="px-3 py-3 whitespace-nowrap">
                                        <?php if ($_smarty_tpl->tpl_vars['log']->value['status'] == 'delivered') {?>
                                            <span class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-green-100 text-green-800">
                                                <span class="w-1.5 h-1.5 rounded-full bg-green-500"></span> delivered
                                            </span>
                                        <?php } elseif ($_smarty_tpl->tpl_vars['log']->value['status'] == 'failed') {?>
                                            <span class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-red-100 text-red-700">
                                                <span class="w-1.5 h-1.5 rounded-full bg-red-500"></span> failed
                                            </span>
                                        <?php } else { ?>
                                            <span class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-amber-100 text-amber-800">
                                                <span class="w-1.5 h-1.5 rounded-full bg-amber-500"></span> <?php echo $_smarty_tpl->tpl_vars['log']->value['status'];?>

                                            </span>
                                        <?php }?>
                                    </td>
                                    <td class="px-3 py-3 text-gray-500 text-xs max-w-xs">
                                        <div class="truncate font-mono" title="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['log']->value['response'], ENT_QUOTES, 'UTF-8', true);?>
"><?php echo $_smarty_tpl->tpl_vars['log']->value['response'];?>
</div>
                                    </td>
                                    <td class="px-3 py-3 text-gray-500 text-xs whitespace-nowrap"><?php echo $_smarty_tpl->tpl_vars['log']->value['created_at'];?>
</td>
                                    <td class="px-3 py-3">
                                        <form method="post" style="display:inline" onsubmit="return window.confirm('Resend this message to <?php echo $_smarty_tpl->tpl_vars['log']->value['phone_number'];?>
?')">
                                            <input type="hidden" name="resend_id" value="<?php echo $_smarty_tpl->tpl_vars['log']->value['id'];?>
">
                                            <button type="submit" class="inline-flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs font-medium bg-blue-50 text-blue-700 hover:bg-blue-100 border border-blue-200 transition whitespace-nowrap">
                                                <svg class="w-3 h-3" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
                                                Resend
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        <?php } else { ?>
                            <tr>
                                <td colspan="8" class="px-4 py-16 text-center text-gray-400">
                                    <div class="flex flex-col items-center gap-2">
                                        <svg class="w-10 h-10 text-gray-300" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"/>
                                        </svg>
                                        <p class="font-medium">No logs found</p>
                                        <p class="text-xs">Messages sent via WhatsApp will appear here</p>
                                    </div>
                                </td>
                            </tr>
                        <?php }?>
                    </tbody>
                </table>
            </div>
        </form>

        
        <?php if ($_smarty_tpl->tpl_vars['total_pages']->value > 1) {?>
        <div class="mt-4 flex flex-wrap items-center justify-between gap-3">
            <p class="text-xs text-gray-500">Page <?php echo $_smarty_tpl->tpl_vars['page']->value;?>
 of <?php echo $_smarty_tpl->tpl_vars['total_pages']->value;?>
</p>
            <div class="flex items-center gap-1">
                <?php if ($_smarty_tpl->tpl_vars['page']->value > 1) {?>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway_logs&page=<?php echo $_smarty_tpl->tpl_vars['page']->value-1;?>
&per_page=<?php echo $_smarty_tpl->tpl_vars['per_page']->value;?>
"
                        class="px-3 py-1.5 rounded-lg border border-gray-300 bg-white text-sm text-gray-600 hover:bg-gray-50 shadow-sm transition">
                        &#8592; Prev
                    </a>
                <?php }?>

                <?php
$_smarty_tpl->tpl_vars['p'] = new Smarty_Variable(null, $_smarty_tpl->isRenderingCache);$_smarty_tpl->tpl_vars['p']->step = 1;$_smarty_tpl->tpl_vars['p']->total = (int) ceil(($_smarty_tpl->tpl_vars['p']->step > 0 ? $_smarty_tpl->tpl_vars['total_pages']->value+1 - (1) : 1-($_smarty_tpl->tpl_vars['total_pages']->value)+1)/abs($_smarty_tpl->tpl_vars['p']->step));
if ($_smarty_tpl->tpl_vars['p']->total > 0) {
for ($_smarty_tpl->tpl_vars['p']->value = 1, $_smarty_tpl->tpl_vars['p']->iteration = 1;$_smarty_tpl->tpl_vars['p']->iteration <= $_smarty_tpl->tpl_vars['p']->total;$_smarty_tpl->tpl_vars['p']->value += $_smarty_tpl->tpl_vars['p']->step, $_smarty_tpl->tpl_vars['p']->iteration++) {
$_smarty_tpl->tpl_vars['p']->first = $_smarty_tpl->tpl_vars['p']->iteration === 1;$_smarty_tpl->tpl_vars['p']->last = $_smarty_tpl->tpl_vars['p']->iteration === $_smarty_tpl->tpl_vars['p']->total;?>
                    <?php if ($_smarty_tpl->tpl_vars['p']->value >= $_smarty_tpl->tpl_vars['page']->value-3 && $_smarty_tpl->tpl_vars['p']->value <= $_smarty_tpl->tpl_vars['page']->value+3) {?>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway_logs&page=<?php echo $_smarty_tpl->tpl_vars['p']->value;?>
&per_page=<?php echo $_smarty_tpl->tpl_vars['per_page']->value;?>
"
                        class="px-3 py-1.5 rounded-lg border text-sm shadow-sm transition <?php if ($_smarty_tpl->tpl_vars['p']->value == $_smarty_tpl->tpl_vars['page']->value) {?>border-green-600 bg-green-600 text-white font-semibold<?php } else { ?>border-gray-300 bg-white text-gray-600 hover:bg-gray-50<?php }?>">
                        <?php echo $_smarty_tpl->tpl_vars['p']->value;?>

                    </a>
                    <?php }?>
                <?php }
}
?>

                <?php if ($_smarty_tpl->tpl_vars['page']->value < $_smarty_tpl->tpl_vars['total_pages']->value) {?>
                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/goWhatsappGateway_logs&page=<?php echo $_smarty_tpl->tpl_vars['page']->value+1;?>
&per_page=<?php echo $_smarty_tpl->tpl_vars['per_page']->value;?>
"
                        class="px-3 py-1.5 rounded-lg border border-gray-300 bg-white text-sm text-gray-600 hover:bg-gray-50 shadow-sm transition">
                        Next &#8594;
                    </a>
                <?php }?>
            </div>
        </div>
        <?php }?>
    </div>
</div>

<?php echo '<script'; ?>
>
(function () {
    var selectAllMain   = document.getElementById('selectAll');
    var selectAllHeader = document.getElementById('selectAllHeader');
    var deleteBtn       = document.getElementById('deleteSelectedBtn');

    function getCheckboxes() {
        return document.querySelectorAll('.log-checkbox');
    }
    function getChecked() {
        return document.querySelectorAll('.log-checkbox:checked');
    }

    function sync() {
        var all     = getCheckboxes();
        var checked = getChecked();
        var allChecked = all.length > 0 && checked.length === all.length;
        selectAllMain.checked   = allChecked;
        selectAllHeader.checked = allChecked;
        deleteBtn.disabled = checked.length === 0;
    }

    function checkAll(state) {
        getCheckboxes().forEach(function (cb) { cb.checked = state; });
        sync();
    }

    selectAllMain.addEventListener('change',   function () { checkAll(this.checked); });
    selectAllHeader.addEventListener('change', function () { checkAll(this.checked); });
    document.addEventListener('change', function (e) {
        if (e.target && e.target.classList.contains('log-checkbox')) sync();
    });
    sync();
}());

function deleteSelected() {
    var checked = document.querySelectorAll('.log-checkbox:checked');
    if (checked.length === 0) { window.alert('Please select at least one log to delete.'); return; }
    if (!window.confirm('Delete ' + checked.length + ' selected log(s)? This cannot be undone.')) return;
    var form = document.getElementById('logsForm');
    var inp  = document.createElement('input');
    inp.type = 'hidden'; inp.name = 'delete_selected'; inp.value = '1';
    form.appendChild(inp);
    form.submit();
}

function deleteAll() {
    if (!window.confirm('Delete ALL WhatsApp logs? This cannot be undone.')) return;
    if (!window.confirm('Final confirmation — permanently delete every log?')) return;
    var form = document.getElementById('logsForm');
    var inp  = document.createElement('input');
    inp.type = 'hidden'; inp.name = 'delete_all'; inp.value = '1';
    form.appendChild(inp);
    form.submit();
}

function changePerPage() {
    var val = document.getElementById('perPageSelect').value;
    var url = new URL(window.location.href);
    url.searchParams.set('per_page', val);
    url.searchParams.set('page', '1');
    window.location.href = url.toString();
}
<?php echo '</script'; ?>
>

<?php $_smarty_tpl->_subTemplateRender("file:sections/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
}
}
