Add Edit Admin

This commit is contained in:
Ibnu Maksum 2024-02-15 16:13:55 +07:00
parent a06d7db0b1
commit d17c434c7b
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
10 changed files with 353 additions and 163 deletions

View File

@ -191,6 +191,8 @@ CREATE TABLE `tb_languages` (
ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`; 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` 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_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` ADD `phone` VARCHAR(32) NOT NULL DEFAULT '' AFTER `password`, ADD `email` VARCHAR(128) NOT NULL DEFAULT '' AFTER `phone`, ADD `city` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kota' AFTER `email`, ADD `subdistrict` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kecamatan' AFTER `city`, ADD `ward` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kelurahan' AFTER `subdistrict`;
ALTER TABLE `tbl_appconfig` ALTER TABLE `tbl_appconfig`
ADD PRIMARY KEY (`id`); ADD PRIMARY KEY (`id`);
@ -309,7 +311,7 @@ VALUES (
'admin', 'admin',
'Administrator', 'Administrator',
'd033e22ae348aeb5660fc2140aec35850c4da997', 'd033e22ae348aeb5660fc2140aec35850c4da997',
'Admin', 'SuperAdmin',
'Active', 'Active',
'2022-09-06 16:09:50', '2022-09-06 16:09:50',
'2014-06-23 01:43:07' '2014-06-23 01:43:07'

View File

@ -192,7 +192,7 @@ class Lang
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.1 Mobile/15E148 Safari/605.1.15"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.1 Mobile/15E148 Safari/605.1.15");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_HEADER, 0);
$hasil = curl_exec ($ch); $hasil = curl_exec ($ch);
curl_close($ch); curl_close($ch);

View File

@ -9,9 +9,6 @@ _admin();
$ui->assign('_title', Lang::T('Dashboard')); $ui->assign('_title', Lang::T('Dashboard'));
$admin = Admin::_info(); $admin = Admin::_info();
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "home", 'e', Lang::T('You do not have permission to access this page'));
}
$fdate = date('Y-m-01'); $fdate = date('Y-m-01');
$tdate = date('Y-m-t'); $tdate = date('Y-m-t');

View File

@ -97,19 +97,56 @@ switch ($action) {
break; break;
case 'users': case 'users':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page')); r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));
} }
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/users.js"></script>');
$username = _post('username'); $username = _post('username');
if ($username != '') { if ($username != '') {
if ($admin['user_type'] == 'SuperAdmin') {
$paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $username . '%'], $username); $paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $username . '%'], $username);
$d = ORM::for_table('tbl_users')->where_like('username', '%' . $username . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many(); $d = ORM::for_table('tbl_users')
->where_like('username', '%' . $username . '%')
->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->find_many();
} else if ($admin['user_type'] == 'Admin') {
$paginator = Paginator::build(ORM::for_table('tbl_users'), [
'username' => '%' . $username . '%',
['user_type' => 'Report'],
['user_type' => 'Agent'],
['user_type' => 'Sales']
], $username);
$d = ORM::for_table('tbl_users')
->where_like('username', '%' . $username . '%')
->where_any_is([
['user_type' => 'Report'],
['user_type' => 'Agent'],
['user_type' => 'Sales']
])
->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $username . '%'], $username);
$d = ORM::for_table('tbl_users')
->where_like('username', '%' . $username . '%')
->where('root', $admin['id'])
->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->find_many();
}
} else {
if ($admin['user_type'] == 'SuperAdmin') {
$paginator = Paginator::build(ORM::for_table('tbl_users')); $paginator = Paginator::build(ORM::for_table('tbl_users'));
$d = ORM::for_table('tbl_users')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many(); $d = ORM::for_table('tbl_users')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
} else if ($admin['user_type'] == 'Admin') {
$paginator = Paginator::build(ORM::for_table('tbl_users'));
$d = ORM::for_table('tbl_users')->where_any_is([
['user_type' => 'Report'],
['user_type' => 'Agent'],
['user_type' => 'Sales']
])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
} else {
$paginator = Paginator::build(ORM::for_table('tbl_users'));
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
}
} }
$ui->assign('d', $d); $ui->assign('d', $d);
@ -119,21 +156,36 @@ switch ($action) {
break; break;
case 'users-add': case 'users-add':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page')); r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));
} }
run_hook('view_add_admin'); #HOOK $ui->assign('_title', Lang::T('Add User'));
$ui->display('users-add.tpl'); $ui->display('users-add.tpl');
break; break;
case 'users-edit': case 'users-edit':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page')); r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));
} }
$ui->assign('_title', Lang::T('Edit User'));
$id = $routes['2']; $id = $routes['2'];
if ($admin['id'] == $id) {
$d = ORM::for_table('tbl_users')->find_one($id); $d = ORM::for_table('tbl_users')->find_one($id);
} else {
if ($admin['user_type'] == 'SuperAdmin') {
$d = ORM::for_table('tbl_users')->find_one($id);
} else if ($admin['user_type'] == 'Admin') {
$d = ORM::for_table('tbl_users')->where_any_is([
['user_type' => 'Report'],
['user_type' => 'Agent'],
['user_type' => 'Sales']
])->find_one($id);
} else {
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->find_one($id);
}
}
if ($d) { if ($d) {
$ui->assign('id', $id);
$ui->assign('d', $d); $ui->assign('d', $d);
run_hook('view_edit_admin'); #HOOK run_hook('view_edit_admin'); #HOOK
$ui->display('users-edit.tpl'); $ui->display('users-edit.tpl');
@ -165,20 +217,22 @@ switch ($action) {
$username = _post('username'); $username = _post('username');
$fullname = _post('fullname'); $fullname = _post('fullname');
$password = _post('password'); $password = _post('password');
$cpassword = _post('cpassword');
$user_type = _post('user_type'); $user_type = _post('user_type');
$phone = _post('phone');
$email = _post('email');
$city = _post('city');
$subdistrict = _post('subdistrict');
$ward = _post('ward');
$send_notif = _post('send_notif');
$msg = ''; $msg = '';
if (Validator::Length($username, 16, 2) == false) { if (Validator::Length($username, 45, 2) == false) {
$msg .= 'Username should be between 3 to 15 characters' . '<br>'; $msg .= Lang::T('Username should be between 3 to 45 characters') . '<br>';
} }
if (Validator::Length($fullname, 26, 2) == false) { if (Validator::Length($fullname, 45, 2) == false) {
$msg .= 'Full Name should be between 3 to 25 characters' . '<br>'; $msg .= Lang::T('Full Name should be between 3 to 45 characters') . '<br>';
} }
if (!Validator::Length($password, 15, 5)) { if (!Validator::Length($password, 1000, 5)) {
$msg .= 'Password should be between 6 to 15 characters' . '<br>'; $msg .= Lang::T('Password should be minimum 6 characters') . '<br>';
}
if ($password != $cpassword) {
$msg .= 'Passwords does not match' . '<br>';
} }
$d = ORM::for_table('tbl_users')->where('username', $username)->find_one(); $d = ORM::for_table('tbl_users')->where('username', $username)->find_one();
@ -194,12 +248,22 @@ switch ($action) {
$d->fullname = $fullname; $d->fullname = $fullname;
$d->password = $password; $d->password = $password;
$d->user_type = $user_type; $d->user_type = $user_type;
$d->phone = $phone;
$d->email = $email;
$d->city = $city;
$d->subdistrict = $subdistrict;
$d->ward = $ward;
$d->status = 'Active'; $d->status = 'Active';
$d->creationdate = $date_now; $d->creationdate = $date_now;
$d->save(); $d->save();
_log('[' . $admin['username'] . ']: ' . Lang::T('Account Created Successfully'), $admin['user_type'], $admin['id']); if ($send_notif == 'wa') {
Message::sendWhatsapp(Lang::phoneFormat($phone), Lang::T('Hello, Your account has been created successfully.') . "\nUsername: $username\nPassword: $password\n\n" . $config['CompanyName']);
} else if ($send_notif == 'sms') {
Message::sendSMS($phone, Lang::T('Hello, Your account has been created successfully.') . "\nUsername: $username\nPassword: $password\n\n" . $config['CompanyName']);
}
_log('[' . $admin['username'] . ']: ' . "Created $user_type <b>$username</b>", $admin['user_type'], $admin['id']);
r2(U . 'settings/users', 's', Lang::T('Account Created Successfully')); r2(U . 'settings/users', 's', Lang::T('Account Created Successfully'));
} else { } else {
r2(U . 'settings/users-add', 'e', $msg); r2(U . 'settings/users-add', 'e', $msg);
@ -211,34 +275,53 @@ switch ($action) {
$fullname = _post('fullname'); $fullname = _post('fullname');
$password = _post('password'); $password = _post('password');
$cpassword = _post('cpassword'); $cpassword = _post('cpassword');
$user_type = _post('user_type');
$phone = _post('phone');
$email = _post('email');
$city = _post('city');
$subdistrict = _post('subdistrict');
$ward = _post('ward');
$status = _post('status');
$msg = ''; $msg = '';
if (Validator::Length($username, 16, 2) == false) { if (Validator::Length($username, 45, 2) == false) {
$msg .= 'Username should be between 3 to 15 characters' . '<br>'; $msg .= Lang::T('Username should be between 3 to 45 characters') . '<br>';
} }
if (Validator::Length($fullname, 26, 2) == false) { if (Validator::Length($fullname, 45, 2) == false) {
$msg .= 'Full Name should be between 3 to 25 characters' . '<br>'; $msg .= Lang::T('Full Name should be between 3 to 45 characters') . '<br>';
} }
if ($password != '') { if ($password != '') {
if (!Validator::Length($password, 15, 5)) { if (!Validator::Length($password, 1000, 5)) {
$msg .= 'Password should be between 6 to 15 characters' . '<br>'; $msg .= Lang::T('Password should be minimum 6 characters') . '<br>';
} }
if ($password != $cpassword) { if ($password != $cpassword) {
$msg .= 'Passwords does not match' . '<br>'; $msg .= Lang::T('Passwords does not match') . '<br>';
} }
} }
$id = _post('id'); $id = _post('id');
if ($admin['id'] == $id) {
$d = ORM::for_table('tbl_users')->find_one($id); $d = ORM::for_table('tbl_users')->find_one($id);
if ($d) {
} else { } else {
if ($admin['user_type'] == 'SuperAdmin') {
$d = ORM::for_table('tbl_users')->find_one($id);
} else if ($admin['user_type'] == 'Admin') {
$d = ORM::for_table('tbl_users')->where_any_is([
['user_type' => 'Report'],
['user_type' => 'Agent'],
['user_type' => 'Sales']
])->find_one($id);
} else {
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->find_one($id);
}
}
if (!$d) {
$msg .= Lang::T('Data Not Found') . '<br>'; $msg .= Lang::T('Data Not Found') . '<br>';
} }
if ($d['username'] != $username) { if ($d['username'] != $username) {
$c = ORM::for_table('tbl_users')->where('username', $username)->find_one(); $c = ORM::for_table('tbl_users')->where('username', $username)->find_one();
if ($c) { if ($c) {
$msg .= Lang::T('Account already axist') . '<br>'; $msg .= "<b>$username</b> ".Lang::T('Account already axist') . '<br>';
} }
} }
run_hook('edit_admin'); #HOOK run_hook('edit_admin'); #HOOK
@ -254,10 +337,16 @@ switch ($action) {
$user_type = _post('user_type'); $user_type = _post('user_type');
$d->user_type = $user_type; $d->user_type = $user_type;
} }
$d->phone = $phone;
$d->email = $email;
$d->city = $city;
$d->subdistrict = $subdistrict;
$d->ward = $ward;
$d->status = $status;
$d->save(); $d->save();
_log('[' . $admin['username'] . ']: ' . Lang::T('User Updated Successfully'), $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: $username ' . Lang::T('User Updated Successfully'), $admin['user_type'], $admin['id']);
r2(U . 'settings/users', 's', 'User Updated Successfully'); r2(U . 'settings/users', 's', 'User Updated Successfully');
} else { } else {
r2(U . 'settings/users-edit/' . $id, 'e', $msg); r2(U . 'settings/users-edit/' . $id, 'e', $msg);

View File

@ -393,5 +393,16 @@
"Active Users": "Active Users", "Active Users": "Active Users",
"All Users Insights": "All Users Insights", "All Users Insights": "All Users Insights",
"Radius": "Radius", "Radius": "Radius",
"Radius NAS": "Radius NAS" "Radius NAS": "Radius NAS",
"Profile": "Profile",
"Credentials": "Credentials",
"Phone": "Phone",
"City": "City",
"Sub District": "Sub District",
"Ward": "Ward",
"Send Notification": "Send Notification",
"Add User": "Add User",
"Username should be between 3 to 45 characters": "Username should be between 3 to 45 characters",
"Password should be minimum 6 characters": "Password should be minimum 6 characters",
"Login": "Login"
} }

View File

@ -48,5 +48,9 @@
], ],
"2024.2.12": [ "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;" "ALTER TABLE `tbl_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;"
],
"2024.2.15":[
"ALTER TABLE `tbl_users` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;",
"ALTER TABLE `tbl_users` ADD `phone` VARCHAR(32) NOT NULL DEFAULT '' AFTER `password`, ADD `email` VARCHAR(128) NOT NULL DEFAULT '' AFTER `phone`, ADD `city` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kota' AFTER `email`, ADD `subdistrict` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kecamatan' AFTER `city`, ADD `ward` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kelurahan' AFTER `subdistrict`;"
] ]
} }

View File

@ -84,7 +84,7 @@
<p> <p>
{$_admin['fullname']} {$_admin['fullname']}
<small>{if $_admin['user_type'] eq 'Admin'} {Lang::T('Administrator')} <small>{if $_admin['user_type'] eq 'SuperAdmin'} {Lang::T('Administrator')}
{else} {else}
{Lang::T('Sales')} {/if}</small> {Lang::T('Sales')} {/if}</small>
</p> </p>
@ -124,7 +124,7 @@
</a> </a>
</li> </li>
{$_MENU_AFTER_DASHBOARD} {$_MENU_AFTER_DASHBOARD}
{if $_admin['user_type'] eq 'Admin' || $_admin['user_type'] eq 'Sales'} {if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<li class="{if $_system_menu eq 'customers'}active{/if} treeview"> <li class="{if $_system_menu eq 'customers'}active{/if} treeview">
<a href="#"> <a href="#">
<i class="ion ion-android-contacts"></i> <span>{Lang::T('Customer')}</span> <i class="ion ion-android-contacts"></i> <span>{Lang::T('Customer')}</span>
@ -204,7 +204,7 @@
</li> </li>
{$_MENU_AFTER_REPORTS} {$_MENU_AFTER_REPORTS}
{/if} {/if}
{if $_admin['user_type'] eq 'Admin'} {if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<li class="{if $_system_menu eq 'network'}active{/if} treeview"> <li class="{if $_system_menu eq 'network'}active{/if} treeview">
<a href="#"> <a href="#">
<i class="ion ion-network"></i> <span>{Lang::T('Network')}</span> <i class="ion ion-network"></i> <span>{Lang::T('Network')}</span>
@ -215,10 +215,6 @@
<ul class="treeview-menu"> <ul class="treeview-menu">
<li {if $_routes[0] eq 'routers' and $_routes[1] eq 'list'}class="active" {/if}><a <li {if $_routes[0] eq 'routers' and $_routes[1] eq 'list'}class="active" {/if}><a
href="{$_url}routers/list">{Lang::T('Routers')}</a></li> href="{$_url}routers/list">{Lang::T('Routers')}</a></li>
{if $_c['radius_enable']}
<li {if $_routes[0] eq 'radius' and $_routes[1] eq 'nas-list'}class="active" {/if}><a
href="{$_url}radius/nas-list">Radius NAS</a></li>
{/if}
<li {if $_routes[0] eq 'pool' and $_routes[1] eq 'list'}class="active" {/if}><a <li {if $_routes[0] eq 'pool' and $_routes[1] eq 'list'}class="active" {/if}><a
href="{$_url}pool/list">{Lang::T('IP Pool')}</a></li> href="{$_url}pool/list">{Lang::T('IP Pool')}</a></li>
{$_MENU_NETWORK} {$_MENU_NETWORK}
@ -239,8 +235,8 @@
{$_MENU_RADIUS} {$_MENU_RADIUS}
</ul> </ul>
</li> </li>
{$_MENU_AFTER_RADIUS}
{/if} {/if}
{$_MENU_AFTER_RADIUS}
<li class="{if $_system_menu eq 'pages'}active{/if} treeview"> <li class="{if $_system_menu eq 'pages'}active{/if} treeview">
<a href="#"> <a href="#">
<i class="ion ion-document"></i> <span>{Lang::T("Static Pages")}</span> <i class="ion ion-document"></i> <span>{Lang::T("Static Pages")}</span>

View File

@ -1,63 +1,97 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<!-- user-edit --> <!-- user-edit -->
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Add New Administrator')}</div>
<div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}settings/users-post"> <form class="form-horizontal" method="post" role="form" action="{$_url}settings/users-post">
<div class="row">
<div class="col-sm-6 col-md-6">
<div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Profile')}</div>
<div class="panel-body">
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Username')}</label> <label class="col-md-3 control-label">{Lang::T('Full Name')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="text" class="form-control" id="username" name="username">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Full Name')}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="fullname" name="fullname"> <input type="text" class="form-control" id="fullname" name="fullname">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('User Type')}</label> <label class="col-md-3 control-label">{Lang::T('Phone')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="number" class="form-control" id="phone" name="phone">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Email')}</label>
<div class="col-md-9">
<input type="text" class="form-control" id="email" name="email">
</div>
</div>
<div class="form-group">
<div class="col-md-4">
<input type="text" class="form-control" id="city" name="city" placeholder="{Lang::T('City')}">
</div>
<div class="col-md-4">
<input type="text" class="form-control" id="subdistrict" name="subdistrict" placeholder="{Lang::T('Sub District')}">
</div>
<div class="col-md-4">
<input type="text" class="form-control" id="ward" name="ward" placeholder="{Lang::T('Ward')}">
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Credentials')}</div>
<div class="panel-body">
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('User Type')}</label>
<div class="col-md-9">
<select name="user_type" id="user_type" class="form-control"> <select name="user_type" id="user_type" class="form-control">
<option value="SuperAdmin">SuperAdministrator</option> {if $_admin['user_type'] eq 'Agent'}
<option value="Admin">Administrator</option> <option value="Sales">Sales</option>
{/if}
{if $_admin['user_type'] eq 'Admin' || $_admin['user_type'] eq 'SuperAdmin'}
<option value="Report">Report Viewer</option> <option value="Report">Report Viewer</option>
<option value="Agent">Agent</option> <option value="Agent">Agent</option>
<option value="Sales">Sales</option> <option value="Sales">Sales</option>
{/if}
{if $_admin['user_type'] eq 'SuperAdmin'}
<option value="Admin">Administrator</option>
<option value="SuperAdmin">Super Administrator</option>
{/if}
</select> </select>
<span class="help-block">{Lang::T('Choose User Type Sales to disable access to Settings')}</span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Password')}</label> <label class="col-md-3 control-label">{Lang::T('Username')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="password" class="form-control" id="password" name="password"> <input type="text" class="form-control" id="username" name="username">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Confirm Password')}</label> <label class="col-md-3 control-label">{Lang::T('Password')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="password" class="form-control" id="cpassword" name="cpassword"> <input type="password" class="form-control" id="password" value="{rand(000000,999999)}" name="password"
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-lg-offset-2 col-lg-10"> <label class="col-md-5 control-label">{Lang::T('Send Notification')}</label>
<button class="btn btn-primary waves-effect waves-light" <div class="col-md-7">
type="submit">{Lang::T('Save Changes')}</button> <select name="send_notif" id="send_notif" class="form-control">
<option value="-">Don't Send</option>
<option value="sms">By SMS</option>
<option value="wa">By WhatsApp</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group text-center">
<button class="btn btn-primary waves-effect waves-light" type="submit">{Lang::T('Save Changes')}</button>
Or <a href="{$_url}settings/users">{Lang::T('Cancel')}</a> Or <a href="{$_url}settings/users">{Lang::T('Cancel')}</a>
</div> </div>
</div>
</form> </form>
</div>
</div>
</div>
</div>
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View File

@ -1,74 +1,123 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<!-- user-edit --> <!-- user-edit -->
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Edit User')}</div>
<div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}settings/users-edit-post"> <form class="form-horizontal" method="post" role="form" action="{$_url}settings/users-edit-post">
<div class="row">
<div class="col-sm-6 col-md-6">
<div
class="panel panel-{if $d['status'] != 'Active'}danger{else}primary{/if} panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Profile')}</div>
<div class="panel-body">
<input type="hidden" name="id" value="{$d['id']}"> <input type="hidden" name="id" value="{$d['id']}">
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Username')}</label> <label class="col-md-3 control-label">{Lang::T('Full Name')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="text" class="form-control" id="username" name="username"
value="{$d['username']}">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Full Name')}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="fullname" name="fullname" <input type="text" class="form-control" id="fullname" name="fullname"
value="{$d['fullname']}"> value="{$d['fullname']}">
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Phone')}</label>
<div class="col-md-9">
<input type="number" class="form-control" id="phone" name="phone" value="{$d['phone']}">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Email')}</label>
<div class="col-md-9">
<input type="text" class="form-control" id="email" name="email" value="{$d['email']}">
</div>
</div>
<div class="form-group">
<div class="col-md-4">
<input type="text" class="form-control" id="city" name="city"
placeholder="{Lang::T('City')}" value="{$d['city']}">
</div>
<div class="col-md-4">
<input type="text" class="form-control" id="subdistrict" name="subdistrict"
placeholder="{Lang::T('Sub District')}" value="{$d['subdistrict']}">
</div>
<div class="col-md-4">
<input type="text" class="form-control" id="ward" name="ward"
placeholder="{Lang::T('Ward')}" value="{$d['ward']}">
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div
class="panel panel-{if $d['status'] != 'Active'}danger{else}primary{/if} panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Credentials')}</div>
<div class="panel-body">
{if ($_admin['id']) neq ($d['id'])} {if ($_admin['id']) neq ($d['id'])}
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('User Type')}</label> <label class="col-md-3 control-label">{Lang::T('Status')}</label>
<div class="col-md-6"> <div class="col-md-9">
<select name="status" id="status" class="form-control">
<option value="Active" {if $d['status'] eq 'Active'}selected="selected" {/if}>
Active</option>
<option value="Inactive" {if $d['status'] eq 'Inactive'}selected="selected" {/if}>
Inactive</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('User Type')}</label>
<div class="col-md-9">
<select name="user_type" id="user_type" class="form-control"> <select name="user_type" id="user_type" class="form-control">
<option value="SuperAdmin" {if $d['user_type'] eq 'SuperAdmin'}selected="selected" {if $_admin['user_type'] eq 'Agent'}
{/if}>SuperAdministrator</option> <option value="Sales" {if $d['user_type'] eq 'Sales'}selected="selected" {/if}>Sales
<option value="Admin" {if $d['user_type'] eq 'Admin'}selected="selected" {/if}> </option>
Administrator</option> {/if}
{if $_admin['user_type'] eq 'Admin' || $_admin['user_type'] eq 'SuperAdmin'}
<option value="Report" {if $d['user_type'] eq 'Report'}selected="selected" {/if}>Report <option value="Report" {if $d['user_type'] eq 'Report'}selected="selected" {/if}>Report
Viewer</option> Viewer</option>
<option value="Agent" {if $d['user_type'] eq 'Agent'}selected="selected" {/if}>Agent <option value="Agent" {if $d['user_type'] eq 'Agent'}selected="selected" {/if}>Agent
</option> </option>
<option value="Sales" {if $d['user_type'] eq 'Sales'}selected="selected" {/if}>Sales <option value="Sales" {if $d['user_type'] eq 'Sales'}selected="selected" {/if}>Sales
</option> </option>
{/if}
{if $_admin['user_type'] eq 'SuperAdmin'}
<option value="Admin" {if $d['user_type'] eq 'Admin'}selected="selected" {/if}>
Administrator</option>
<option value="SuperAdmin" {if $d['user_type'] eq 'SuperAdmin'}selected="selected"
{/if}>Super Administrator</option>
{/if}
</select> </select>
<span class="help-block">{Lang::T('Choose User Type Sales to disable access to Settings')}</span>
</div> </div>
</div> </div>
{/if} {/if}
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Password')}</label> <label class="col-md-3 control-label">{Lang::T('Username')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="text" class="form-control" id="username" name="username"
value="{$d['username']}">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Password')}</label>
<div class="col-md-9">
<input type="password" class="form-control" id="password" name="password"> <input type="password" class="form-control" id="password" name="password">
<span class="help-block">{Lang::T('Keep Blank to do not change Password')}</span> <span class="help-block">{Lang::T('Keep Blank to do not change Password')}</span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Confirm Password')}</label> <label class="col-md-3 control-label">{Lang::T('Password')}</label>
<div class="col-md-6"> <div class="col-md-9">
<input type="password" class="form-control" id="cpassword" name="cpassword"> <input type="password" class="form-control" id="cpassword" name="cpassword"
placeholder="{Lang::T('Confirm Password')}">
<span class="help-block">{Lang::T('Keep Blank to do not change Password')}</span>
</div> </div>
</div> </div>
</div>
<div class="form-group"> </div>
<div class="col-lg-offset-2 col-lg-10"> </div>
<button class="btn btn-success waves-effect waves-light" </div>
type="submit">{Lang::T('Save Changes')}</button> <div class="form-group text-center">
<button class="btn btn-primary waves-effect waves-light" type="submit">{Lang::T('Save Changes')}</button>
Or <a href="{$_url}settings/users">{Lang::T('Cancel')}</a> Or <a href="{$_url}settings/users">{Lang::T('Cancel')}</a>
</div> </div>
</div>
</form> </form>
</div>
</div>
</div>
</div>
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View File

@ -30,26 +30,34 @@
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th>{Lang::T('Username')}</th> <th>{Lang::T('Username')}</th>
<th>{Lang::T('Full Name')}</th> <th>{Lang::T('Full Name')}</th>
<th>{Lang::T('Phone')}</th>
<th>{Lang::T('Email')}</th>
<th>{Lang::T('Type')}</th> <th>{Lang::T('Type')}</th>
<th>{Lang::T('Location')}</th>
<th>{Lang::T('Last Login')}</th> <th>{Lang::T('Last Login')}</th>
<th>{Lang::T('Manage')}</th> <th>{Lang::T('Manage')}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach $d as $ds} {foreach $d as $ds}
<tr> <tr {if $ds['status'] != 'Active'}class="danger"{/if}>
<td>{$ds['id']}</td>
<td>{$ds['username']}</td> <td>{$ds['username']}</td>
<td>{$ds['fullname']}</td> <td>{$ds['fullname']}</td>
<td>{$ds['phone']}</td>
<td>{$ds['email']}</td>
<td>{$ds['user_type']}</td> <td>{$ds['user_type']}</td>
<td>{$ds['last_login']}</td> <td>{$ds['city']}, {$ds['subdistrict']}, {$ds['ward']}</td>
<td>{Lang::dateTimeFormat($ds['last_login'])}</td>
<td> <td>
<a href="{$_url}settings/users-edit/{$ds['id']}" <a href="{$_url}settings/users-edit/{$ds['id']}"
class="btn btn-warning btn-sm">{Lang::T('Edit')}</a> class="btn btn-warning btn-xs">{Lang::T('Edit')}</a>
{if ($_admin['username']) neq ($ds['username'])} {if ($_admin['username']) neq ($ds['username'])}
<a href="{$_url}settings/users-delete/{$ds['id']}" id="{$ds['id']}" <a href="{$_url}settings/users-delete/{$ds['id']}" id="{$ds['id']}"
class="btn btn-danger btn-sm" onclick="return confirm('{Lang::T('Delete')}?')">{Lang::T('Delete')}</a> class="btn btn-danger btn-xs" onclick="return confirm('{Lang::T('Delete')}?')">{Lang::T('Delete')}</a>
{/if} {/if}
</td> </td>
</tr> </tr>