<?php
/* Smarty version 4.5.3, created on 2026-03-17 20:58:00
  from '/var/www/html/admin/ui/ui_custom/admin/pppoe/add.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.3',
  'unifunc' => 'content_69b99628e11a93_33470063',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '7625e2ff9091234591d00436c4f0b56431b62b23' => 
    array (
      0 => '/var/www/html/admin/ui/ui_custom/admin/pppoe/add.tpl',
      1 => 1770489334,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:sections/header.tpl' => 1,
    'file:sections/footer.tpl' => 1,
  ),
),false)) {
function content_69b99628e11a93_33470063 (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-sm-12 col-md-12">
        <div class="card border-0 shadow-sm mb-4">
            <div class="card-header bg-primary bg-gradient text-white"><?php echo Lang::T('Add Service Plan');?>
</div>
            <div class="card-body">
                <form method="post" role="form" action="<?php echo Text::url('');?>
services/pppoe-add-post">
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Status');?>

                            <a tabindex="0" class="btn btn-link btn-sm" role="button" data-bs-toggle="popover"
                                data-bs-trigger="focus" data-bs-container="body"
                                data-bs-content="<?php echo Lang::T("Customer cannot buy disabled Package, but admin can recharge it, use it if you want only admin recharge it");?>
">?</a>
                        </label>
                        <div class="col-md-10">
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" checked name="enabled" value="1" id="enabled1">
                                <label class="form-check-label" for="enabled1"><?php echo Lang::T('Enable');?>
</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="enabled" value="0" id="enabled0">
                                <label class="form-check-label" for="enabled0"><?php echo Lang::T('Disable');?>
</label>
                            </div>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Type');?>

                            <a tabindex="0" class="btn btn-link btn-sm" role="button" data-bs-toggle="popover"
                                data-bs-trigger="focus" data-bs-container="body"
                                data-bs-content="<?php echo Lang::T("Postpaid will have fix expired date");?>
">?</a>
                        </label>
                        <div class="col-md-10">
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="prepaid" onclick="prePaid()" value="yes" checked id="prepaidyes">
                                <label class="form-check-label" for="prepaidyes"><?php echo Lang::T('Prepaid');?>
</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="prepaid" onclick="postPaid()" value="no" id="prepaidno">
                                <label class="form-check-label" for="prepaidno"><?php echo Lang::T('Postpaid');?>
</label>
                            </div>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Plan Type');?>

                            <a tabindex="0" class="btn btn-link btn-sm" role="button" data-bs-toggle="popover"
                                data-bs-trigger="focus" data-bs-container="body"
                                data-bs-content="<?php echo Lang::T("Personal Package will only show to personal Customer, Business package will only show to Business Customer");?>
">?</a>
                        </label>
                        <div class="col-md-10">
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="plan_type" value="Personal" checked id="plantypepersonal">
                                <label class="form-check-label" for="plantypepersonal"><?php echo Lang::T('Personal');?>
</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="plan_type" value="Business" id="plantypebusiness">
                                <label class="form-check-label" for="plantypebusiness"><?php echo Lang::T('Business');?>
</label>
                            </div>
                        </div>
                    </div>
                    <?php if ($_smarty_tpl->tpl_vars['_c']->value['radius_enable']) {?>
                        <div class="row mb-3">
                            <label class="col-md-2 col-form-label">Radius
                                <a tabindex="0" class="btn btn-link btn-sm" role="button" data-bs-toggle="popover"
                                    data-bs-trigger="focus" data-bs-container="body"
                                    data-bs-content="<?php echo Lang::T("If you enable Radius, choose device to radius, except if you have custom device.");?>
">?</a>
                            </label>
                            <div class="col-md-6">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="radius" onclick="isRadius(this)" value="1" id="radius">
                                    <label class="form-check-label" for="radius">Radius Plan</label>
                                </div>
                            </div>
                            <small class="form-text text-muted col-md-4"><?php echo Lang::T('Cannot be change after saved');?>
</small>
                        </div>
                    <?php }?>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Device');?>

                            <a tabindex="0" class="btn btn-link btn-sm" role="button" data-bs-toggle="popover"
                                data-bs-trigger="focus" data-bs-container="body"
                                data-bs-content="<?php echo Lang::T("This Device are the logic how PHPNuxBill Communicate with Mikrotik or other Devices");?>
">?</a>
                        </label>
                        <div class="col-md-6">
                            <select class="form-select" id="device" name="device">
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['devices']->value, 'dev');
$_smarty_tpl->tpl_vars['dev']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['dev']->value) {
$_smarty_tpl->tpl_vars['dev']->do_else = false;
?>
                                    <option value="<?php echo $_smarty_tpl->tpl_vars['dev']->value;?>
"><?php echo $_smarty_tpl->tpl_vars['dev']->value;?>
</option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </select>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Plan Name');?>
</label>
                        <div class="col-md-6">
                            <input type="text" class="form-control" id="name_plan" maxlength="40" name="name_plan">
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><a
                                href="<?php echo Text::url('');?>
bandwidth/add"><?php echo Lang::T('Bandwidth Name');?>
</a></label>
                        <div class="col-md-6">
                            <select id="id_bw" name="id_bw" class="form-select select2">
                                <option value=""><?php echo Lang::T('Select Bandwidth');?>
...</option>
                                <?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;
?>
                                    <option value="<?php echo $_smarty_tpl->tpl_vars['ds']->value['id'];?>
"><?php echo $_smarty_tpl->tpl_vars['ds']->value['name_bw'];?>
</option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </select>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Plan Price');?>
</label>
                        <div class="col-md-6">
                            <div class="input-group">
                                <span class="input-group-text"><?php echo $_smarty_tpl->tpl_vars['_c']->value['currency_code'];?>
</span>
                                <input type="number" class="form-control" name="price" required>
                            </div>
                        </div>
                        <?php if ($_smarty_tpl->tpl_vars['_c']->value['enable_tax'] == 'yes') {?>
                            <?php if ($_smarty_tpl->tpl_vars['_c']->value['tax_rate'] == 'custom') {?>
                                <small class="form-text text-muted col-md-4"><?php echo number_format($_smarty_tpl->tpl_vars['_c']->value['custom_tax_rate'],2);?>
 % <?php echo Lang::T('Tax Rates
                            will be added');?>
</small>
                            <?php } else { ?>
                                <small class="form-text text-muted col-md-4"><?php echo number_format($_smarty_tpl->tpl_vars['_c']->value['tax_rate']*100,2);?>
 % <?php echo Lang::T('Tax Rates
                            will be added');?>
</small>
                            <?php }?>
                        <?php }?>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Plan Validity');?>
</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="validity" name="validity">
                        </div>
                        <div class="col-md-2">
                            <select class="form-select" id="validity_unit" name="validity_unit">
                            </select>
                        </div>
                        <small class="form-text text-muted col-md-4"><?php echo Lang::T('1 Period = 1 Month, Expires the 20th of each month');?>

                        </small>
                    </div>
                    <div class="row mb-3 d-none" id="expired_date">
                        <label class="col-md-2 col-form-label"><?php echo Lang::T('Expired Date');?>

                            <a tabindex="0" class="btn btn-link btn-sm" role="button" data-bs-toggle="popover"
                                data-bs-trigger="focus" data-bs-container="body"
                                data-bs-content="<?php echo Lang::T("Expired will be this date every month");?>
">?</a>
                        </label>
                        <div class="col-md-6">
                            <input type="number" class="form-control" name="expired_date" maxlength="2" value="20" min="1" max="28" step="1" >
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><a
                                href="<?php echo Text::url('');?>
routers/add"><?php echo Lang::T('Router Name');?>
</a></label>
                        <div class="col-md-6">
                            <select id="routers" name="routers" required class="form-select select2" onchange="loadPools(this.value)">
                                <option value=''><?php echo Lang::T('Select Routers');?>
</option>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['r']->value, 'rs');
$_smarty_tpl->tpl_vars['rs']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['rs']->value) {
$_smarty_tpl->tpl_vars['rs']->do_else = false;
?>
                                    <option value="<?php echo $_smarty_tpl->tpl_vars['rs']->value['name'];?>
"><?php echo $_smarty_tpl->tpl_vars['rs']->value['name'];?>
</option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </select>
                            <small class="form-text text-muted"><?php echo Lang::T('Cannot be change after saved');?>
</small>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-2 col-form-label"><a href="<?php echo Text::url('');?>
pool/add"><?php echo Lang::T('IP Pool');?>
</a></label>
                        <div class="col-md-6">
                            <select id="pool_name" name="pool_name" required class="form-select select2">
                                <option value=''><?php echo Lang::T('Select Pool');?>
</option>
                            </select>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <div class="offset-md-2 col-md-10">
                            <button class="btn btn-primary" onclick="return ask(this, '<?php echo Lang::T("Continue the process of adding the PPPoE Package?");?>
')" type="submit"><?php echo Lang::T('Save Changes');?>
</button>
                            Or <a href="<?php echo Text::url('');?>
services/pppoe"><?php echo Lang::T('Cancel');?>
</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php echo '<script'; ?>
>
    var preOpt = `<option value="Mins"><?php echo Lang::T('Mins');?>
</option>
    <option value="Hrs"><?php echo Lang::T('Hrs');?>
</option>
    <option value="Days"><?php echo Lang::T('Days');?>
</option>
    <option value="Months"><?php echo Lang::T('Months');?>
</option>`;
    var postOpt = `<option value="Period"><?php echo Lang::T('Period');?>

    <option value="Months"><?php echo Lang::T('Months');?>
</option>`;
    
    function prePaid() {
        document.getElementById('validity_unit').innerHTML = preOpt;
        document.getElementById('expired_date').classList.add('d-none');
    }

    function postPaid() {
        document.getElementById('validity_unit').innerHTML = postOpt;
        document.getElementById('expired_date').classList.remove('d-none');
    }
    
    function loadPools(routerName) {
      
        if (routerName) {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', '<?php echo Text::url("autoload/pool");?>
&routers=' + encodeURIComponent(routerName), true);
            xhr.onreadystatechange = function() {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById('pool_name').innerHTML = xhr.responseText;
                    } else {
                        console.error('Error loading pools:', xhr.status, xhr.statusText);
                        document.getElementById('pool_name').innerHTML = '<option value=""><?php echo Lang::T("Error loading pools");?>
</option>';
                    }
                }
            };
            xhr.onerror = function() {
                console.error('Network error loading pools');
                document.getElementById('pool_name').innerHTML = '<option value=""><?php echo Lang::T("Error loading pools");?>
</option>';
            };
            xhr.send();
        } else {
            document.getElementById('pool_name').innerHTML = '<option value=""><?php echo Lang::T("Select Pool");?>
</option>';
        }
    }
    
    document.addEventListener("DOMContentLoaded", function(event) {
        prePaid();
        
        // Handle router change to load IP pools
        var routersSelect = document.getElementById('routers');
        if (routersSelect) {
            routersSelect.addEventListener('change', function() {
                loadPools(this.value);
            });
        }
    });
<?php echo '</script'; ?>
>
<?php if ($_smarty_tpl->tpl_vars['_c']->value['radius_enable']) {?>
    <?php echo '<script'; ?>
>
        function isRadius(cek) {
            if (cek.checked) {
                document.getElementById("routers").required = false;
                document.getElementById("routers").disabled = true;
                loadPools('radius');
            } else {
                document.getElementById("routers").required = true;
                document.getElementById("routers").disabled = false;
                document.getElementById('pool_name').innerHTML = '<option value=""><?php echo Lang::T("Select Pool");?>
</option>';
            }
        }
    <?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);
}
}
