UserType 'SuperAdmin','Admin','Report','Agent','Sales'

This commit is contained in:
Ibnu Maksum 2024-02-12 17:02:43 +07:00
parent bf6ec9d4cd
commit 792b1367d3
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
18 changed files with 62 additions and 49 deletions

View File

@ -190,6 +190,7 @@ CREATE TABLE `tb_languages` (
ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`;
ALTER TABLE `tbl_users` ADD `root` INT NOT NULL DEFAULT '0' COMMENT 'for sub account' AFTER `id`;
ALTER TABLE `tbl_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_appconfig`
ADD PRIMARY KEY (`id`);

View File

@ -25,11 +25,11 @@ switch ($do) {
Admin::setCookie($d['id']);
$d->last_login = date('Y-m-d H:i:s');
$d->save();
_log($username . ' ' . $_L['Login_Successful'], 'Admin', $d['id']);
_log($username . ' ' . $_L['Login_Successful'], $d['user_type'], $d['id']);
r2(U . 'dashboard');
} else {
_msglog('e', $_L['Invalid_Username_or_Password']);
_log($username . ' ' . $_L['Failed_Login'], 'Admin');
_log($username . ' ' . $_L['Failed_Login'], $d['user_type']);
r2(U . 'admin');
}
} else {

View File

@ -12,7 +12,7 @@ $action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if($admin['user_type'] != 'Admin' AND $admin['user_type'] != 'Sales'){
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U."dashboard",'e',$_L['Do_Not_Access']);
}

View File

@ -15,7 +15,7 @@ $admin = Admin::_info();
$ui->assign('_admin', $admin);
$cache = File::pathFixer('system/cache/codecanyon.json');
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
if (empty($config['envato_token'])) {

View File

@ -14,7 +14,7 @@ $admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -50,8 +50,8 @@ switch ($action) {
case 'csv':
$cs = ORM::for_table('tbl_customers')
->select('tbl_customers.id','id')
->select('tbl_customers.username','username')
->select('tbl_customers.id', 'id')
->select('tbl_customers.username', 'username')
->select('fullname')
->select('phonenumber')
->select('email')
@ -59,7 +59,7 @@ switch ($action) {
->select('namebp')
->select('routers')
->select('status')
->select('method','Payment')
->select('method', 'Payment')
->join('tbl_user_recharges', array('tbl_customers.id', '=', 'tbl_user_recharges.customer_id'))
->order_by_asc('tbl_customers.id')->find_array();
$h = false;
@ -77,11 +77,11 @@ switch ($action) {
$ks[] = $k;
$vs[] = $v;
}
if(!$h){
echo '"'.implode('";"', $ks)."\"\n";
if (!$h) {
echo '"' . implode('";"', $ks) . "\"\n";
$h = true;
}
echo '"'.implode('";"', $vs)."\"\n";
echo '"' . implode('";"', $vs) . "\"\n";
}
break;
case 'add':
@ -137,7 +137,7 @@ switch ($action) {
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->where('enabled', '1')->find_one();
if ($p) {
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, $p['expiration'].' '.$p['time']);
Radius::customerAddPlan($c, $p, $p['expiration'] . ' ' . $p['time']);
r2(U . 'customers/view/' . $id_customer, 's', 'Success sync customer to Radius');
} else {
$mikrotik = Mikrotik::info($b['routers']);
@ -167,7 +167,7 @@ switch ($action) {
$v = $routes['3'];
if (empty($v) || $v == 'order') {
$v = 'order';
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'),['username'=>$customer['username']]);
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'), ['username' => $customer['username']]);
$order = ORM::for_table('tbl_payment_gateway')
->where('username', $customer['username'])
->offset($paginator['startpoint'])
@ -177,7 +177,7 @@ switch ($action) {
$ui->assign('paginator', $paginator);
$ui->assign('order', $order);
} else if ($v == 'activation') {
$paginator = Paginator::build(ORM::for_table('tbl_transactions'),['username'=>$customer['username']]);
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['username' => $customer['username']]);
$activation = ORM::for_table('tbl_transactions')
->where('username', $customer['username'])
->offset($paginator['startpoint'])
@ -369,11 +369,11 @@ switch ($action) {
$c->save();
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
if ($p['is_radius']) {
if($userDiff){
if ($userDiff) {
Radius::customerChangeUsername($oldusername, $username);
}
Radius::customerAddPlan($d, $p, $p['expiration'].' '.$p['time']);
}else{
Radius::customerAddPlan($d, $p, $p['expiration'] . ' ' . $p['time']);
} else {
$mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);

View File

@ -9,7 +9,7 @@ _admin();
$ui->assign('_title', $_L['Dashboard']);
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if (!in_array($admin['user_type'], ['Admin', 'Sales'])) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "home", 'e', $_L['Do_Not_Access']);
}

View File

@ -13,7 +13,7 @@ $action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -15,7 +15,7 @@ $admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -13,7 +13,7 @@ $action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -13,7 +13,7 @@ $action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Sales'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -128,7 +128,7 @@ switch ($action) {
$ui->assign('in', $in);
$ui->assign('date', date("Y-m-d H:i:s"));
$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['user_type'], $admin['id']);
} else {
r2(U . 'prepaid/recharge', 'e', "Failed to recharge account");
}
@ -202,7 +202,7 @@ switch ($action) {
}
}
$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['user_type'], $admin['id']);
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
}
break;
@ -247,7 +247,7 @@ switch ($action) {
if($d['status'] == 'on'){
Package::changeTo($username, $id_plan, $id);
}
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']);
r2(U . 'prepaid/list', 's', $_L['Updated_Successfully']);
} else {
r2(U . 'prepaid/edit/' . $id, 'e', $msg);

View File

@ -12,7 +12,7 @@ $admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -13,7 +13,7 @@ $action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Sales'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -17,7 +17,7 @@ use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -12,7 +12,7 @@ $action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}

View File

@ -14,7 +14,7 @@ $ui->assign('_admin', $admin);
switch ($action) {
case 'app':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -70,7 +70,7 @@ switch ($action) {
break;
case 'localisation':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
$folders = [];
@ -89,7 +89,7 @@ switch ($action) {
break;
case 'users':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -111,7 +111,7 @@ switch ($action) {
break;
case 'users-add':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
run_hook('view_add_admin'); #HOOK
@ -119,7 +119,7 @@ switch ($action) {
break;
case 'users-edit':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -135,7 +135,7 @@ switch ($action) {
break;
case 'users-delete':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -191,7 +191,7 @@ switch ($action) {
$d->save();
_log('[' . $admin['username'] . ']: ' . $_L['account_created_successfully'], 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: ' . $_L['account_created_successfully'], $admin['user_type'], $admin['id']);
r2(U . 'settings/users', 's', $_L['account_created_successfully']);
} else {
r2(U . 'settings/users-add', 'e', $msg);
@ -249,7 +249,7 @@ switch ($action) {
$d->save();
_log('[' . $admin['username'] . ']: ' . $_L['User_Updated_Successfully'], 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: ' . $_L['User_Updated_Successfully'], $admin['user_type'], $admin['id']);
r2(U . 'settings/users', 's', 'User Updated Successfully');
} else {
r2(U . 'settings/users-edit/' . $id, 'e', $msg);
@ -316,7 +316,7 @@ switch ($action) {
}
}
_log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], $admin['user_type'], $admin['id']);
r2(U . 'settings/app', 's', $_L['Settings_Saved_Successfully']);
}
@ -404,13 +404,13 @@ switch ($action) {
$d->value = $lan;
$d->save();
_log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], $admin['user_type'], $admin['id']);
r2(U . 'settings/localisation', 's', $_L['Settings_Saved_Successfully']);
}
break;
case 'change-password':
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
run_hook('view_change_password'); #HOOK
@ -439,7 +439,7 @@ switch ($action) {
$d->save();
_msglog('s', $_L['Password_Changed_Successfully']);
_log('[' . $admin['username'] . ']: Password changed successfully', 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: Password changed successfully', $admin['user_type'], $admin['id']);
r2(U . 'admin');
} else {
@ -454,7 +454,7 @@ switch ($action) {
break;
case 'notifications':
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
run_hook('view_notifications'); #HOOK
@ -471,7 +471,7 @@ switch ($action) {
r2(U . 'settings/notifications', 's', $_L['Settings_Saved_Successfully']);
break;
case 'dbstatus':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
@ -489,7 +489,7 @@ switch ($action) {
break;
case 'dbbackup':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
$tables = $_POST['tables'];
@ -509,7 +509,7 @@ switch ($action) {
echo json_encode($array);
break;
case 'dbrestore':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
if (file_exists($_FILES['json']['tmp_name'])) {
@ -539,7 +539,7 @@ switch ($action) {
}
break;
case 'language':
if ($admin['user_type'] != 'Admin') {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
run_hook('view_add_language'); #HOOK

View File

@ -45,5 +45,8 @@
"2024.2.7": [
"ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`;",
"ALTER TABLE `tbl_users` ADD `root` INT NOT NULL DEFAULT '0' COMMENT 'for sub account' AFTER `id`;"
],
"2024.2.12": [
"ALTER TABLE `tbl_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;"
]
}

View File

@ -24,8 +24,11 @@
<label class="col-md-2 control-label">{$_L['User_Type']}</label>
<div class="col-md-6">
<select name="user_type" id="user_type" class="form-control">
<option value="Admin">{$_L['Full_Administrator']}</option>
<option value="Sales">{$_L['Sales']}</option>
<option value="SuperAdmin">SuperAdministrator</option>
<option value="Admin">Administrator</option>
<option value="Report">Report Viewer</option>
<option value="Agent">Agent</option>
<option value="Sales">Sales</option>
</select>
<span class="help-block">{$_L['user_type_help']}</span>
</div>

View File

@ -28,8 +28,14 @@
<label class="col-md-2 control-label">{$_L['User_Type']}</label>
<div class="col-md-6">
<select name="user_type" id="user_type" class="form-control">
<option value="Admin" {if $d['user_type'] eq 'Admin'}selected="selected" {/if}>Full
<option value="SuperAdmin" {if $d['user_type'] eq 'SuperAdmin'}selected="selected"
{/if}>SuperAdministrator</option>
<option value="Admin" {if $d['user_type'] eq 'Admin'}selected="selected" {/if}>
Administrator</option>
<option value="Report" {if $d['user_type'] eq 'Report'}selected="selected" {/if}>Report
Viewer</option>
<option value="Agent" {if $d['user_type'] eq 'Agent'}selected="selected" {/if}>Agent
</option>
<option value="Sales" {if $d['user_type'] eq 'Sales'}selected="selected" {/if}>Sales
</option>
</select>