<?php
/* Smarty version 4.5.3, created on 2026-02-21 09:06:29
  from '/var/www/html/kaptembwa/system/plugin/ui/quickadd.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.3',
  'unifunc' => 'content_69994b65378d40_72208975',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '76c4a3d6592aa522f307dda3aa01cce19b13a768' => 
    array (
      0 => '/var/www/html/kaptembwa/system/plugin/ui/quickadd.tpl',
      1 => 1770489334,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:sections/header.tpl' => 1,
    'file:sections/footer.tpl' => 1,
  ),
),false)) {
function content_69994b65378d40_72208975 (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);
?>

<form method="post" role="form" action="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/quickadd/add<?php if ($_smarty_tpl->tpl_vars['routes']->value['2'] == 'pppoe') {?>/pppoe<?php }?>"> 
    <div class="row">
        <div class="col-md-6">
            <div class="card border-0 shadow-sm mb-4">
                <ul class="nav nav-tabs">
                    <li class="nav-item">
                        <a class="nav-link <?php if ($_smarty_tpl->tpl_vars['routes']->value['2'] == '') {?>active<?php }?>" href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/quickadd" aria-controls="plugin"><?php echo Lang::T('Hotspot');?>
</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link <?php if ($_smarty_tpl->tpl_vars['routes']->value['2'] == 'pppoe') {?>active<?php }?>" href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
plugin/quickadd/pppoe"><?php echo Lang::T('PPPoE');?>
</a>
                    </li>
                </ul>
                <div class="card-header bg-primary bg-gradient text-white"><?php echo Lang::T('Add New customer');?>
</div>
                <div class="card-body">
                    <input type="hidden" name="account_type" value="Hotspot">
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Username');?>
</label>
                        <div class="col-md-9">
                            <div class="input-group">
                                <?php if ($_smarty_tpl->tpl_vars['_c']->value['country_code_phone'] != '') {?>
                                    <span class="input-group-text"><i class="isax isax-call"></i></span>
                                <?php } else { ?>
                                    <span class="input-group-text"><i class="isax isax-user"></i></span>
                                <?php }?>
                                <input type="text" class="form-control" name="username" required
                                    placeholder="<?php if ($_smarty_tpl->tpl_vars['_c']->value['country_code_phone'] != '') {
echo $_smarty_tpl->tpl_vars['_c']->value['country_code_phone'];?>
 <?php echo Lang::T('Phone Number');
} else {
echo Lang::T('Username');
}?>">
                            </div>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Full Name');?>
</label>
                        <div class="col-md-9">
                            <input type="text" required class="form-control" id="fullname" name="fullname">
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Email');?>
</label>
                        <div class="col-md-9">
                            <input type="email" class="form-control" id="email" name="email">
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Phone Number');?>
</label>
                        <div class="col-md-9">
                            <div class="input-group">
                                <?php if ($_smarty_tpl->tpl_vars['_c']->value['country_code_phone'] != '') {?>
                                    <span class="input-group-text">+</span>
                                <?php } else { ?>
                                    <span class="input-group-text"><i class="isax isax-call"></i></span>
                                <?php }?>
                                <input type="text" class="form-control" name="phonenumber"
                                    placeholder="<?php if ($_smarty_tpl->tpl_vars['_c']->value['country_code_phone'] != '') {
echo $_smarty_tpl->tpl_vars['_c']->value['country_code_phone'];
}?> <?php echo Lang::T('Phone Number');?>
">
                            </div>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Password');?>
</label>
                        <div class="col-md-9">
                            <input type="password" class="form-control" autocomplete="off" required id="password"
                                value="<?php echo rand(000000,999999);?>
" name="password" onmouseleave="this.type = 'password'"
                                onmouseenter="this.type = 'text'">
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Address');?>
</label>
                        <div class="col-md-9">
                            <textarea name="address" id="address" class="form-control"></textarea>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Select Package');?>
</label>
                        <div class="col-md-9">
                            <select class="form-select select2"
                                name="ppln" style="width: 100%" data-placeholder="<?php echo Lang::T('Select Package');?>
...">
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['plans']->value, 'plan');
$_smarty_tpl->tpl_vars['plan']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['plan']->value) {
$_smarty_tpl->tpl_vars['plan']->do_else = false;
?>
                                <option value="<?php echo $_smarty_tpl->tpl_vars['plan']->value['id'];?>
"><?php echo $_smarty_tpl->tpl_vars['plan']->value['name_plan'];?>
 &bull; <?php echo Lang::moneyFormat($_smarty_tpl->tpl_vars['plan']->value['price']);
if ($_smarty_tpl->tpl_vars['plan']->value['routers']) {?> &bull; <?php echo $_smarty_tpl->tpl_vars['plan']->value['routers'];
}?></option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                            </select>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Payment Method');?>
</label>
                        <div class="col-md-9">
                            <select class="form-select select2"
                                name="using" style="width: 100%" data-placeholder="<?php echo Lang::T('Select Method');?>
...">
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['usings']->value, 'using');
$_smarty_tpl->tpl_vars['using']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['using']->value) {
$_smarty_tpl->tpl_vars['using']->do_else = false;
?>
                                    <option value="<?php echo trim($_smarty_tpl->tpl_vars['using']->value);?>
"><?php echo trim(ucWords($_smarty_tpl->tpl_vars['using']->value));?>
</option>
                                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                                <?php if (in_array($_smarty_tpl->tpl_vars['_admin']->value['user_type'],array('SuperAdmin','Admin'))) {?>
                                    <option value="Recharge Zero"><?php echo $_smarty_tpl->tpl_vars['_c']->value['currency_code'];?>
 0</option>
                                <?php }?>
                            </select>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Expired Date');?>
</label>
                        <div class="col-md-9">
                            <input type="hidden" name="custom_field_name[]" value="Expired Date" />
                            <input type="text" id="custom_field_value[]" name="custom_field_value[]" class="form-control" placeholder="20" />
                            <small class="form-text text-muted"><?php echo Lang::T('Use for custom expired date postpaid plan.');?>
</small>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-md-3 col-form-label"><?php echo Lang::T('Activation Fee');?>
</label>
                        <div class="col-md-9">
                            <input type="hidden" name="custom_field_name[]" value="Activation Bill" />
                            <input type="text" id="custom_field_value[]" name="custom_field_value[]" class="form-control" placeholder="350000:1" />
                            <small class="form-text text-muted"><?php echo Lang::T('Use code ":0" for postpaid customers to avoid re-billing.');?>
</small>
                        </div>
                    </div>
                    
                    <?php if ($_smarty_tpl->tpl_vars['routes']->value['2'] == 'pppoe') {?>
                        <div class="card-header bg-primary bg-gradient text-white mt-3">PPPoE Configuration</div>
                        <div class="card-body">
                            <div class="row mb-3">
                                <label class="col-md-3 col-form-label"><?php echo Lang::T('Usernames');?>
 <span class="badge bg-danger"
                                        id="warning_pppoe_username"></span></label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control" id="pppoe_username" name="pppoe_username"
                                        onkeyup="checkUsername(this, 0)" placeholder="<?php echo Lang::T('PPPoE Username');?>
">
                                </div>
                            </div>
                            <div class="row mb-3">
                                <label class="col-md-3 col-form-label"><?php echo Lang::T('Password');?>
</label>
                                <div class="col-md-9">
                                    <input type="password" class="form-control" id="pppoe_password" name="pppoe_password"
                                        placeholder="<?php echo Lang::T('PPPoE Password');?>
" onmouseleave="this.type = 'password'"
                                        onmouseenter="this.type = 'text'">
                                </div>
                            </div>
                            <div class="row mb-3">
                                <label class="col-md-3 col-form-label">Remote IP <span class="badge bg-danger"
                                        id="warning_ip"></span></label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control" id="pppoe_ip" name="pppoe_ip"
                                        onkeyup="checkIP(this, 0)" placeholder="Remote IP">
                                </div>
                            </div>
                        </div>
                    <?php }?>
                    <div class="card-header bg-primary bg-gradient text-white mt-3"></div>
                    <div class="card-body">
                        <div class="row mb-3">
                            <label class="col-md-3 col-form-label"><?php echo Lang::T('Send Welcome Message');?>
</label>
                            <div class="col-md-9">
                                <div class="form-check form-switch">
                                    <input class="form-check-input" type="checkbox" id="send_welcome_message" value="1" name="send_welcome_message">
                                </div>
                            </div>
                        </div>
                        <div class="row mb-3" id="method" style="display: none;">
                            <label class="col-md-3 col-form-label"><?php echo Lang::T('Method');?>
</label>
                            <div class="col-md-9">
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="checkbox" name="sms" value="1" id="sms">
                                    <label class="form-check-label" for="sms"><?php echo Lang::T('SMS');?>
</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="checkbox" name="wa" value="1" id="wa">
                                    <label class="form-check-label" for="wa"><?php echo Lang::T('WA');?>
</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="checkbox" name="mail" value="1" id="mail">
                                    <label class="form-check-label" for="mail"><?php echo Lang::T('Email');?>
</label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <input type="text" id="service_type" name="service_type" value="<?php if ($_smarty_tpl->tpl_vars['routes']->value['2'] == 'pppoe') {?>PPPoE<?php } else { ?>hotspot<?php }?>" hidden>
                </div>
            </div>
            <div class="text-center">
                <button class="btn btn-primary" onclick="return ask(this, 'Continue the process of adding Customer Data?')" type="submit">
                    <?php echo Lang::T('Create Account');?>

                </button>
                <br><a href="<?php echo $_smarty_tpl->tpl_vars['_url']->value;?>
customers" class="btn btn-link"><?php echo Lang::T('Cancel');?>
</a>
            </div>
        </div>
    </div>
</form>


    <?php echo '<script'; ?>
>
        // Fungsi dari edit.tpl untuk validasi Username PPPoE (onkeyup)
        function checkUsername(obj, id) {
            var username = obj.value;
            $.post(APP_URL + '/customers/checkUsername', {
                username: username,
                id: id
            }).done(function(data) {
                var warningSpan = document.getElementById('warning_pppoe_username');
                if (data == 'true') {
                    warningSpan.textContent = " {Lang::T('Username has been used')}";
                    warningSpan.style.display = 'inline';
                } else {
                    warningSpan.textContent = "";
                    warningSpan.style.display = 'none';
                }
            }).fail(function(e) {
                console.log(e);
            });
        }

        // Fungsi dari edit.tpl untuk validasi Remote IP (onkeyup)
        function checkIP(obj, id) {
            var ip = obj.value;
            $.post(APP_URL + '/customers/checkIP', {
                ip: ip,
                id: id
            }).done(function(data) {
                var warningSpan = document.getElementById('warning_ip');
                if (data == 'true') {
                    warningSpan.textContent = " {Lang::T('IP has been used')}";
                    warningSpan.style.display = 'inline';
                } else {
                    warningSpan.textContent = "";
                    warningSpan.style.display = 'none';
                }
            }).fail(function(e) {
                console.log(e);
            });
        }

        document.addEventListener('DOMContentLoaded', function() {
            var sendWelcomeCheckbox = document.getElementById('send_welcome_message');
            var methodSection = document.getElementById('method');

            function toggleMethodSection() {
                if (sendWelcomeCheckbox.checked) {
                    methodSection.style.display = 'block';
                } else {
                    methodSection.style.display = 'none';
                }
            }

            toggleMethodSection();

            sendWelcomeCheckbox.addEventListener('change', toggleMethodSection);
            document.querySelector('form').addEventListener('submit', function(event) {
                if (sendWelcomeCheckbox.checked) {
                    var methodCheckboxes = methodSection.querySelectorAll('input[type="checkbox"]');
                    var oneChecked = Array.from(methodCheckboxes).some(function(checkbox) {
                        return checkbox.checked;
                    });

                    if (!oneChecked) {
                        event.preventDefault();
                        alert('Please choose at least one method.');
                        methodSection.focus();
                    }
                }
                
                // Pengecekan tambahan: jika ada warning IP atau Username PPPoE
                var warningIp = document.getElementById('warning_ip');
                var warningPppoeUsername = document.getElementById('warning_pppoe_username');

                if ((warningIp && warningIp.textContent.trim() !== "") || (warningPppoeUsername && warningPppoeUsername.textContent.trim() !== "")) {
                    event.preventDefault();
                    alert('Please fix the warnings for PPPoE Username or Remote IP before continuing.');
                }
            });
        });
    <?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);
}
}
