ajax select customer
This commit is contained in:
parent
27a2938534
commit
54ff67fa49
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||||
* used for ajax
|
* used for ajax
|
||||||
**/
|
**/
|
||||||
|
|
||||||
_admin();
|
_admin();
|
||||||
$ui->assign('_title', $_L['Network']);
|
$ui->assign('_title', $_L['Network']);
|
||||||
@ -16,13 +17,13 @@ switch ($action) {
|
|||||||
case 'pool':
|
case 'pool':
|
||||||
$routers = _get('routers');
|
$routers = _get('routers');
|
||||||
$d = ORM::for_table('tbl_pool')->where('routers', $routers)->find_many();
|
$d = ORM::for_table('tbl_pool')->where('routers', $routers)->find_many();
|
||||||
$ui->assign('d',$d);
|
$ui->assign('d', $d);
|
||||||
$ui->display('autoload-pool.tpl');
|
$ui->display('autoload-pool.tpl');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'server':
|
case 'server':
|
||||||
$d = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
|
$d = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
|
||||||
$ui->assign('d',$d);
|
$ui->assign('d', $d);
|
||||||
|
|
||||||
$ui->display('autoload-server.tpl');
|
$ui->display('autoload-server.tpl');
|
||||||
break;
|
break;
|
||||||
@ -31,11 +32,28 @@ switch ($action) {
|
|||||||
$server = _post('server');
|
$server = _post('server');
|
||||||
$jenis = _post('jenis');
|
$jenis = _post('jenis');
|
||||||
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->where('enabled', '1')->find_many();
|
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->where('enabled', '1')->find_many();
|
||||||
$ui->assign('d',$d);
|
$ui->assign('d', $d);
|
||||||
|
|
||||||
$ui->display('autoload.tpl');
|
$ui->display('autoload.tpl');
|
||||||
break;
|
break;
|
||||||
|
case 'customer_select2':
|
||||||
|
|
||||||
|
$s = addslashes(_get('s'));
|
||||||
|
if (empty($s)) {
|
||||||
|
$c = ORM::for_table('tbl_customers')->limit(30)->find_many();
|
||||||
|
} else {
|
||||||
|
$c = ORM::for_table('tbl_customers')->where_raw("(`username` LIKE '%$s%' OR `fullname` LIKE '%$s%' OR `phonenumber` LIKE '%$s%' OR `email` LIKE '%$s%')", [$s,$s,$s,$s])->limit(30)->find_many();
|
||||||
|
}
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
foreach ($c as $cust){
|
||||||
|
$json[] = [
|
||||||
|
'id' => $cust['id'],
|
||||||
|
'text' => $cust['username'].' - '.$cust['fullname'].' - '.$cust['email']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
echo json_encode(['results'=>$json]);
|
||||||
|
die();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
echo 'action not defined';
|
echo 'action not defined';
|
||||||
}
|
}
|
@ -18,7 +18,24 @@ if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
|
|||||||
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
|
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
|
||||||
}
|
}
|
||||||
|
|
||||||
use PEAR2\Net\RouterOS;
|
$select2_customer = <<<EOT
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
$('#personSelect').select2({
|
||||||
|
theme: "bootstrap",
|
||||||
|
ajax: {
|
||||||
|
url: function(params) {
|
||||||
|
if(params.term != undefined){
|
||||||
|
return './index.php?_route=autoload/customer_select2&s='+params.term;
|
||||||
|
}else{
|
||||||
|
return './index.php?_route=autoload/customer_select2';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
EOT;
|
||||||
|
|
||||||
require_once 'system/autoload/PEAR2/Autoload.php';
|
require_once 'system/autoload/PEAR2/Autoload.php';
|
||||||
|
|
||||||
@ -43,8 +60,7 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'recharge':
|
case 'recharge':
|
||||||
$c = ORM::for_table('tbl_customers')->find_many();
|
$ui->assign('xfooter', $select2_customer);
|
||||||
$ui->assign('c', $c);
|
|
||||||
$p = ORM::for_table('tbl_plans')->where('enabled', '1')->find_many();
|
$p = ORM::for_table('tbl_plans')->where('enabled', '1')->find_many();
|
||||||
$ui->assign('p', $p);
|
$ui->assign('p', $p);
|
||||||
$r = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
|
$r = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
|
||||||
@ -81,14 +97,14 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
if(Package::rechargeUser($id_customer, $server, $plan, "Recharge", $admin['fullname'])){
|
if (Package::rechargeUser($id_customer, $server, $plan, "Recharge", $admin['fullname'])) {
|
||||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||||
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
||||||
$ui->assign('in', $in);
|
$ui->assign('in', $in);
|
||||||
$ui->assign('date', date("Y-m-d H:i:s"));
|
$ui->assign('date', date("Y-m-d H:i:s"));
|
||||||
$ui->display('invoice.tpl');
|
$ui->display('invoice.tpl');
|
||||||
_log('[' . $admin['username'] . ']: ' . 'Recharge '.$c['username'].' ['.$in['plan_name'].']['.Lang::moneyFormat($in['price']).']', 'Admin', $admin['id']);
|
_log('[' . $admin['username'] . ']: ' . 'Recharge ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', 'Admin', $admin['id']);
|
||||||
}else{
|
} else {
|
||||||
r2(U . 'prepaid/recharge', 'e', "Failed to recharge account");
|
r2(U . 'prepaid/recharge', 'e', "Failed to recharge account");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -129,20 +145,20 @@ switch ($action) {
|
|||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_customer_active_plan'); #HOOK
|
run_hook('delete_customer_active_plan'); #HOOK
|
||||||
if ($d['type'] == 'Hotspot') {
|
if ($d['type'] == 'Hotspot') {
|
||||||
if(!$config['radius_mode']){
|
if (!$config['radius_mode']) {
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removeHotspotUser($client,$c['username']);
|
Mikrotik::removeHotspotUser($client, $c['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
} else {
|
} else {
|
||||||
if(!$config['radius_mode']){
|
if (!$config['radius_mode']) {
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removePpoeUser($client,$c['username']);
|
Mikrotik::removePpoeUser($client, $c['username']);
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
}
|
}
|
||||||
_log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer '.$c['username'].' ['.$in['plan_name'].']['.Lang::moneyFormat($in['price']).']', 'Admin', $admin['id']);
|
_log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', 'Admin', $admin['id']);
|
||||||
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
|
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -167,8 +183,8 @@ switch ($action) {
|
|||||||
$d->recharged_on = $recharged_on;
|
$d->recharged_on = $recharged_on;
|
||||||
$d->expiration = $expiration;
|
$d->expiration = $expiration;
|
||||||
$d->save();
|
$d->save();
|
||||||
Package::changeTo($username,$id_plan);
|
Package::changeTo($username, $id_plan);
|
||||||
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer '.$d['username'].' to ['.$d['plan_name'].']['.Lang::moneyFormat($d['price']).']', 'Admin', $admin['id']);
|
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['plan_name'] . '][' . Lang::moneyFormat($d['price']) . ']', 'Admin', $admin['id']);
|
||||||
r2(U . 'prepaid/list', 's', $_L['Updated_Successfully']);
|
r2(U . 'prepaid/list', 's', $_L['Updated_Successfully']);
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'prepaid/edit/' . $id, 'e', $msg);
|
r2(U . 'prepaid/edit/' . $id, 'e', $msg);
|
||||||
@ -341,10 +357,8 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'refill':
|
case 'refill':
|
||||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/ui/scripts/form-elements.init.js"></script>');
|
$ui->assign('xfooter', $select2_customer);
|
||||||
$ui->assign('_title', $_L['Refill_Account']);
|
$ui->assign('_title', $_L['Refill_Account']);
|
||||||
$c = ORM::for_table('tbl_customers')->find_many();
|
|
||||||
$ui->assign('c', $c);
|
|
||||||
run_hook('view_refill'); #HOOK
|
run_hook('view_refill'); #HOOK
|
||||||
$ui->display('refill.tpl');
|
$ui->display('refill.tpl');
|
||||||
|
|
||||||
@ -358,7 +372,7 @@ switch ($action) {
|
|||||||
|
|
||||||
run_hook('refill_customer'); #HOOK
|
run_hook('refill_customer'); #HOOK
|
||||||
if ($v1) {
|
if ($v1) {
|
||||||
if(Package::rechargeUser($user, $v1['routers'], $v1['id_plan'], "Refill", "Voucher")){
|
if (Package::rechargeUser($user, $v1['routers'], $v1['id_plan'], "Refill", "Voucher")) {
|
||||||
$v1->status = "1";
|
$v1->status = "1";
|
||||||
$v1->user = $c['username'];
|
$v1->user = $c['username'];
|
||||||
$v1->save();
|
$v1->save();
|
||||||
@ -367,7 +381,7 @@ switch ($action) {
|
|||||||
$ui->assign('in', $in);
|
$ui->assign('in', $in);
|
||||||
$ui->assign('date', date("Y-m-d H:i:s"));
|
$ui->assign('date', date("Y-m-d H:i:s"));
|
||||||
$ui->display('invoice.tpl');
|
$ui->display('invoice.tpl');
|
||||||
}else{
|
} else {
|
||||||
r2(U . 'prepaid/refill', 'e', "Failed to refill account");
|
r2(U . 'prepaid/refill', 'e', "Failed to refill account");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -376,7 +390,7 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
case 'deposit':
|
case 'deposit':
|
||||||
$ui->assign('_title', Lang::T('Refill Balance'));
|
$ui->assign('_title', Lang::T('Refill Balance'));
|
||||||
$ui->assign('c', ORM::for_table('tbl_customers')->find_many());
|
$ui->assign('xfooter', $select2_customer);
|
||||||
$ui->assign('p', ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many());
|
$ui->assign('p', ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many());
|
||||||
run_hook('view_deposit'); #HOOK
|
run_hook('view_deposit'); #HOOK
|
||||||
$ui->display('deposit.tpl');
|
$ui->display('deposit.tpl');
|
||||||
@ -387,13 +401,13 @@ switch ($action) {
|
|||||||
|
|
||||||
run_hook('deposit_customer'); #HOOK
|
run_hook('deposit_customer'); #HOOK
|
||||||
if (!empty($user) && !empty($plan)) {
|
if (!empty($user) && !empty($plan)) {
|
||||||
if(Package::rechargeUser($user, 'balance', $plan, "Deposit", $admin['fullname'])){
|
if (Package::rechargeUser($user, 'balance', $plan, "Deposit", $admin['fullname'])) {
|
||||||
$c = ORM::for_table('tbl_customers')->where('id', $user)->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id', $user)->find_one();
|
||||||
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
||||||
$ui->assign('in', $in);
|
$ui->assign('in', $in);
|
||||||
$ui->assign('date', date("Y-m-d H:i:s"));
|
$ui->assign('date', date("Y-m-d H:i:s"));
|
||||||
$ui->display('invoice.tpl');
|
$ui->display('invoice.tpl');
|
||||||
}else{
|
} else {
|
||||||
r2(U . 'prepaid/refill', 'e', "Failed to refill account");
|
r2(U . 'prepaid/refill', 'e', "Failed to refill account");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,10 +11,6 @@
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<select id="personSelect" class="form-control select2" name="id_customer" style="width: 100%"
|
<select id="personSelect" class="form-control select2" name="id_customer" style="width: 100%"
|
||||||
data-placeholder="{$_L['Select_Customer']}...">
|
data-placeholder="{$_L['Select_Customer']}...">
|
||||||
<option></option>
|
|
||||||
{foreach $c as $cs}
|
|
||||||
<option value="{$cs['id']}">{$cs['username']} - {$cs['fullname']}</option>
|
|
||||||
{/foreach}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
<label class="col-md-2 control-label">{$_L['Select_Account']}</label>
|
<label class="col-md-2 control-label">{$_L['Select_Account']}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<select id="personSelect" class="form-control select2" name="id_customer" style="width: 100%" data-placeholder="{$_L['Select_Customer']}...">
|
<select id="personSelect" class="form-control select2" name="id_customer" style="width: 100%" data-placeholder="{$_L['Select_Customer']}...">
|
||||||
<option></option>
|
|
||||||
{foreach $c as $cs}
|
|
||||||
<option value="{$cs['id']}">{$cs['username']}</option>
|
|
||||||
{/foreach}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,12 +9,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">{$_L['Select_Account']}</label>
|
<label class="col-md-2 control-label">{$_L['Select_Account']}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<select id="personSelect" class="form-control select2" name="id_customer" style="width: 100%"
|
<select id="personSelect" class="form-control select2" name="id_customer"
|
||||||
data-placeholder="{$_L['Select_Customer']}...">
|
style="width: 100%" data-placeholder="{$_L['Select_Customer']}...">
|
||||||
<option></option>
|
|
||||||
{foreach $c as $cs}
|
|
||||||
<option value="{$cs['id']}">{$cs['username']}</option>
|
|
||||||
{/foreach}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -39,4 +35,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{include file="sections/footer.tpl"}
|
{include file="sections/footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user