<?php
/* Smarty version 4.5.3, created on 2024-12-04 06:41:33
  from '/var/www/html/admin/ui/ui/plan.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.3',
  'unifunc' => 'content_674fcf6d401c82_41862760',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    'a2bbf24a1dbb0331226c224725d6d3c64939c9ee' => 
    array (
      0 => '/var/www/html/admin/ui/ui/plan.tpl',
      1 => 1732479316,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:sections/header.tpl' => 1,
    'file:pagination.tpl' => 1,
    'file:sections/footer.tpl' => 1,
  ),
),false)) {
function content_674fcf6d401c82_41862760 (Smarty_Internal_Template $_smarty_tpl) {
$_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="row">
    <div class="col-12">
        <div class="panel panel-hovered mb20 panel-primary">
            <div class="panel-heading">
                <?php if (in_array($_smarty_tpl->tpl_vars['_admin']->value['user_type'],array('SuperAdmin','Admin'))) {?>
                <div class="btn-group pull-right">
                    <!-- Sync Button for All Routers -->
                    <a class="btn btn-primary btn-xs" title="Sync Customer Active Plan to Mikrotik" href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/sync"
                        onclick="return ask(this, 'This will sync/send Customer active plan to Mikrotik?')">
                        <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Sync All Routers
                    </a>
                </div>
                <?php }?>
                &nbsp;
                <?php echo Lang::T('Active Customers');?>

            </div>

            <!-- Combined Form for Filter and Sync -->
            <form id="combined-form" method="post" action="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/sync">
                <div class="row row-no-gutters" style="padding: 5px;">
                    <!-- Router Selection for Sync and Filter -->
                    <div class="col-12 col-sm-6 col-md-3 mb-2">
                        <select class="form-control" id="router" name="router" title="<?php echo Lang::T('Filter by Router');?>
" aria-label="<?php echo Lang::T('Filter by Router');?>
">
                            <option value=""><?php echo Lang::T('All Routers');?>
</option>
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['routers']->value, 'r');
$_smarty_tpl->tpl_vars['r']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['r']->value) {
$_smarty_tpl->tpl_vars['r']->do_else = false;
?>
                                <option value="<?php echo $_smarty_tpl->tpl_vars['r']->value;?>
" <?php if ($_smarty_tpl->tpl_vars['router']->value == $_smarty_tpl->tpl_vars['r']->value) {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['r']->value;?>
</option>
                            <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                        </select>
                    </div>
            
                    <!-- Status Selection for Sync and Filter -->
                    <div class="col-12 col-sm-6 col-md-3 mb-2">
                        <select class="form-control" id="status" name="status" title="<?php echo Lang::T('Filter by Status');?>
" aria-label="<?php echo Lang::T('Filter by Status');?>
">
                            <option value=""><?php echo Lang::T('All Status');?>
</option>
                            <option value="on" <?php if ($_smarty_tpl->tpl_vars['status']->value == 'on') {?>selected<?php }?>><?php echo Lang::T('Active');?>
</option>
                            <option value="off" <?php if ($_smarty_tpl->tpl_vars['status']->value == 'off') {?>selected<?php }?>><?php echo Lang::T('Expired');?>
</option>
                        </select>
                    </div>
            
                    <!-- Sync Button -->
                    <div class="col-12 col-md-2 mb-2">
                        <button class="btn btn-primary btn-block" type="submit" aria-label="<?php echo Lang::T('Sync');?>
"
                            onclick="return ask(this, 'This will sync/send Customer active plan to Mikrotik?')">
                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Sync
                        </button>
                    </div>
            
                    <!-- Filter Button (Submit to filter the clients) -->
                    <div class="col-12 col-md-3 mb-2">
                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/recharge" class="btn btn-primary btn-block"><i
                                class="ion ion-android-add"></i> <?php echo Lang::T('Recharge Account');?>
</a>
                    </div>
                </div>
            </form>

            <!-- Search Form for Active Customers -->
            <form id="site-search" method="post" action="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/list/">
                <div class="panel-body">
                    <div class="row row-no-gutters" style="padding: 5px">
                        <div class="col-12 col-sm-6 col-md-3 mb-2">
                            <div class="input-group">
                                <div class="input-group-btn">
                                    <a class="btn btn-danger" title="<?php echo Lang::T('Clear Search Query');?>
" href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/list">
                                        <span class="glyphicon glyphicon-remove-circle"></span> Clear
                                    </a>
                                </div>
                                <input type="text" name="search" class="form-control"
                                    placeholder="<?php echo Lang::T('Search');?>
..." value="<?php echo $_smarty_tpl->tpl_vars['search']->value;?>
" aria-label="<?php echo Lang::T('Search');?>
">
                            </div>
                        </div>

                        <!-- Router Filter -->
                        <div class="col-12 col-sm-6 col-md-2 mb-2">
                            <select class="form-control" id="router" name="router" aria-label="<?php echo Lang::T('Filter by Router');?>
">
                                <option value=""><?php echo Lang::T('Router');?>
</option>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['routers']->value, 'r');
$_smarty_tpl->tpl_vars['r']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['r']->value) {
$_smarty_tpl->tpl_vars['r']->do_else = false;
?>
                                <option value="<?php echo $_smarty_tpl->tpl_vars['r']->value;?>
" <?php if ($_smarty_tpl->tpl_vars['router']->value == $_smarty_tpl->tpl_vars['r']->value) {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['r']->value;?>
</option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </select>
                        </div>

                        <!-- Plan Filter -->
                        <div class="col-12 col-sm-6 col-md-2 mb-2">
                            <select class="form-control" id="plan" name="plan" aria-label="<?php echo Lang::T('Filter by Plan Name');?>
">
                                <option value=""><?php echo Lang::T('Plan Name');?>
</option>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['plans']->value, 'p');
$_smarty_tpl->tpl_vars['p']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['p']->value) {
$_smarty_tpl->tpl_vars['p']->do_else = false;
?>
                                <option value="<?php echo $_smarty_tpl->tpl_vars['p']->value['id'];?>
" <?php if ($_smarty_tpl->tpl_vars['plan']->value == $_smarty_tpl->tpl_vars['p']->value['id']) {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['p']->value['name_plan'];?>
</option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </select>
                        </div>

                        <!-- Status Filter -->
                        <div class="col-12 col-sm-6 col-md-2 mb-2">
                            <select class="form-control" id="status" name="status" aria-label="<?php echo Lang::T('Filter by Status');?>
">
                                <option value="-"><?php echo Lang::T('Status');?>
</option>
                                <option value="on" <?php if ($_smarty_tpl->tpl_vars['status']->value == 'on') {?>selected<?php }?>><?php echo Lang::T('Active');?>
</option>
                                <option value="off" <?php if ($_smarty_tpl->tpl_vars['status']->value == 'off') {?>selected<?php }?>><?php echo Lang::T('Expired');?>
</option>
                            </select>
                        </div>

                        <!-- Search Button -->
                        <div class="col-12 col-md-2 mb-2">
                            <button class="btn btn-success btn-block" type="submit" aria-label="<?php echo Lang::T('Search');?>
">
                                <span class="fa fa-search"></span>
                            </button>
                        </div>

                    </div>
                </div>
            </form>

            <!-- Table for Active Customers -->
            <div class="table-responsive">
                <div style="margin-left: 5px; margin-right: 5px;">&nbsp;
                    <table id="datatable" class="table table-bordered table-striped table-condensed">
                        <thead>
                            <tr>
                                <th><?php echo Lang::T('Username');?>
</th>
                                <th><?php echo Lang::T('Plan Name');?>
</th>
                                <th><?php echo Lang::T('Type');?>
</th>
                                <th><?php echo Lang::T('Created On');?>
</th>
                                <th><?php echo Lang::T('Expires On');?>
</th>
                                <th><?php echo Lang::T('Method');?>
</th>
                                <th><a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
routers/list"><?php echo Lang::T('Router');?>
</a></th>
                                <th><?php echo Lang::T('Status');?>
</th>
                                <th><?php echo Lang::T('Manage');?>
</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['d']->value, 'ds');
$_smarty_tpl->tpl_vars['ds']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['ds']->value) {
$_smarty_tpl->tpl_vars['ds']->do_else = false;
?>
                            <tr <?php if ($_smarty_tpl->tpl_vars['ds']->value['status'] == 'off') {?>class="danger"<?php }?>>
                                <td>
                                    <?php if ($_smarty_tpl->tpl_vars['ds']->value['customer_id'] == '0') {?>
                                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/voucher/&search=<?php echo $_smarty_tpl->tpl_vars['ds']->value['username'];?>
"><?php echo $_smarty_tpl->tpl_vars['ds']->value['username'];?>
</a>
                                    <?php } else { ?>
                                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers/viewu/<?php echo $_smarty_tpl->tpl_vars['ds']->value['username'];?>
"><?php echo $_smarty_tpl->tpl_vars['ds']->value['username'];?>
</a>
                                    <?php }?>
                                </td>
                                <td>
                                    <?php if ($_smarty_tpl->tpl_vars['ds']->value['type'] == 'Hotspot') {?>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
services/edit/<?php echo $_smarty_tpl->tpl_vars['ds']->value['plan_id'];?>
"><?php echo $_smarty_tpl->tpl_vars['ds']->value['namebp'];?>
</a>
                                    <?php } elseif ($_smarty_tpl->tpl_vars['ds']->value['type'] == 'PPPOE') {?>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
services/pppoe-edit/<?php echo $_smarty_tpl->tpl_vars['ds']->value['plan_id'];?>
"><?php echo $_smarty_tpl->tpl_vars['ds']->value['namebp'];?>
</a>
                                    <?php } elseif ($_smarty_tpl->tpl_vars['ds']->value['type'] == 'VPN') {?>
                                        <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
services/vpn-edit/<?php echo $_smarty_tpl->tpl_vars['ds']->value['plan_id'];?>
"><?php echo $_smarty_tpl->tpl_vars['ds']->value['namebp'];?>
</a>
                                    <?php }?>
                                </td>
                                <td><?php echo $_smarty_tpl->tpl_vars['ds']->value['type'];?>
</td>
                                <td><?php echo Lang::dateAndTimeFormat($_smarty_tpl->tpl_vars['ds']->value['recharged_on'],$_smarty_tpl->tpl_vars['ds']->value['recharged_time']);?>
</td>
                                <td><?php echo Lang::dateAndTimeFormat($_smarty_tpl->tpl_vars['ds']->value['expiration'],$_smarty_tpl->tpl_vars['ds']->value['time']);?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['ds']->value['method'];?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['ds']->value['routers'];?>
</td>

                                <!-- Status Column with Color Change -->
                                <td class="<?php if ($_smarty_tpl->tpl_vars['ds']->value['status'] == 'on') {?>text-success<?php } else { ?>text-danger<?php }?>">
                                    <?php if ($_smarty_tpl->tpl_vars['ds']->value['status'] == 'on') {
echo Lang::T('Active');
} else {
echo Lang::T('Expired');
}?>
                                </td>

                                <td>
                                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/edit/<?php echo $_smarty_tpl->tpl_vars['ds']->value['id'];?>
" class="btn btn-warning btn-xs" style="color: black;" aria-label="<?php echo Lang::T('Edit');?>
">
                                        <?php echo Lang::T('Edit');?>

                                    </a>
                                    <?php if (in_array($_smarty_tpl->tpl_vars['_admin']->value['user_type'],array('SuperAdmin','Admin'))) {?>
                                    <a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/delete/<?php echo $_smarty_tpl->tpl_vars['ds']->value['id'];?>
" id="<?php echo $_smarty_tpl->tpl_vars['ds']->value['id'];?>
"
                                        onclick="return ask(this, '<?php echo Lang::T('Delete');?>
?')" class="btn btn-danger btn-xs" aria-label="<?php echo Lang::T('Delete');?>
">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </a>
                                    <?php }?>
                                    <?php if ($_smarty_tpl->tpl_vars['ds']->value['status'] == 'off' && $_smarty_tpl->tpl_vars['_c']->value['extend_expired']) {?>
                                    <a href="javascript:extend('<?php echo $_smarty_tpl->tpl_vars['ds']->value['id'];?>
')" class="btn btn-info btn-xs" aria-label="<?php echo Lang::T('Extend');?>
">
                                        <?php echo Lang::T('Extend');?>

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

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

<?php echo '<script'; ?>
>
    function extend(idP) {
        var res = prompt("Extend for how many days?", "3");
        if (res) {
            if (confirm("Extend for " + res + " days?")) {
                window.location.href = "<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plan/extend/" + idP + "/" + res + "&stoken=<?php echo App::getToken();?>
";
            }
        }
    }
<?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);
}
}
