Select Agent after choose sales
This commit is contained in:
parent
e7c715f1b3
commit
61060c4173
@ -170,7 +170,6 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ui->assign('admins', $admins);
|
$ui->assign('admins', $admins);
|
||||||
|
|
||||||
$ui->assign('d', $d);
|
$ui->assign('d', $d);
|
||||||
$ui->assign('search', $search);
|
$ui->assign('search', $search);
|
||||||
$ui->assign('paginator', $paginator);
|
$ui->assign('paginator', $paginator);
|
||||||
@ -183,6 +182,7 @@ switch ($action) {
|
|||||||
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('Add User'));
|
$ui->assign('_title', Lang::T('Add User'));
|
||||||
|
$ui->assign('agents', ORM::for_table('tbl_users')->where('user_type', 'Agent')->find_many());
|
||||||
$ui->display('users-add.tpl');
|
$ui->display('users-add.tpl');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -197,13 +197,17 @@ switch ($action) {
|
|||||||
} else {
|
} else {
|
||||||
if ($admin['user_type'] == 'SuperAdmin') {
|
if ($admin['user_type'] == 'SuperAdmin') {
|
||||||
$d = ORM::for_table('tbl_users')->find_one($id);
|
$d = ORM::for_table('tbl_users')->find_one($id);
|
||||||
|
$ui->assign('agents', ORM::for_table('tbl_users')->where('user_type', 'Agent')->find_many());
|
||||||
} else if ($admin['user_type'] == 'Admin') {
|
} else if ($admin['user_type'] == 'Admin') {
|
||||||
$d = ORM::for_table('tbl_users')->where_any_is([
|
$d = ORM::for_table('tbl_users')->where_any_is([
|
||||||
['user_type' => 'Report'],
|
['user_type' => 'Report'],
|
||||||
['user_type' => 'Agent'],
|
['user_type' => 'Agent'],
|
||||||
['user_type' => 'Sales']
|
['user_type' => 'Sales']
|
||||||
])->find_one($id);
|
])->find_one($id);
|
||||||
|
$ui->assign('agents', ORM::for_table('tbl_users')->where('user_type', 'Agent')->find_many());
|
||||||
} else {
|
} else {
|
||||||
|
// Agent cannot move Sales to other Agent
|
||||||
|
$ui->assign('agents', ORM::for_table('tbl_users')->where('id', $admin['id'])->find_many());
|
||||||
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->find_one($id);
|
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->find_one($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,6 +251,7 @@ switch ($action) {
|
|||||||
$subdistrict = _post('subdistrict');
|
$subdistrict = _post('subdistrict');
|
||||||
$ward = _post('ward');
|
$ward = _post('ward');
|
||||||
$send_notif = _post('send_notif');
|
$send_notif = _post('send_notif');
|
||||||
|
$root = _post('root');
|
||||||
$msg = '';
|
$msg = '';
|
||||||
if (Validator::Length($username, 45, 2) == false) {
|
if (Validator::Length($username, 45, 2) == false) {
|
||||||
$msg .= Lang::T('Username should be between 3 to 45 characters') . '<br>';
|
$msg .= Lang::T('Username should be between 3 to 45 characters') . '<br>';
|
||||||
@ -279,7 +284,10 @@ switch ($action) {
|
|||||||
$d->status = 'Active';
|
$d->status = 'Active';
|
||||||
$d->creationdate = $date_now;
|
$d->creationdate = $date_now;
|
||||||
if ($admin['user_type'] == 'Agent') {
|
if ($admin['user_type'] == 'Agent') {
|
||||||
|
// Prevent hacking from form
|
||||||
$d->root = $admin['id'];
|
$d->root = $admin['id'];
|
||||||
|
}else if($user_type == 'Sales'){
|
||||||
|
$d->root = $root;
|
||||||
}
|
}
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
@ -308,6 +316,7 @@ switch ($action) {
|
|||||||
$subdistrict = _post('subdistrict');
|
$subdistrict = _post('subdistrict');
|
||||||
$ward = _post('ward');
|
$ward = _post('ward');
|
||||||
$status = _post('status');
|
$status = _post('status');
|
||||||
|
$root = _post('root');
|
||||||
$msg = '';
|
$msg = '';
|
||||||
if (Validator::Length($username, 45, 2) == false) {
|
if (Validator::Length($username, 45, 2) == false) {
|
||||||
$msg .= Lang::T('Username should be between 3 to 45 characters') . '<br>';
|
$msg .= Lang::T('Username should be between 3 to 45 characters') . '<br>';
|
||||||
@ -370,6 +379,13 @@ switch ($action) {
|
|||||||
$d->ward = $ward;
|
$d->ward = $ward;
|
||||||
$d->status = $status;
|
$d->status = $status;
|
||||||
|
|
||||||
|
if ($admin['user_type'] == 'Agent') {
|
||||||
|
// Prevent hacking from form
|
||||||
|
$d->root = $admin['id'];
|
||||||
|
}else if($user_type == 'Sales'){
|
||||||
|
$d->root = $root;
|
||||||
|
}
|
||||||
|
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
_log('[' . $admin['username'] . ']: $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']);
|
||||||
|
@ -411,5 +411,7 @@
|
|||||||
"Agent": "Agent",
|
"Agent": "Agent",
|
||||||
"Send To Customer": "Send To Customer",
|
"Send To Customer": "Send To Customer",
|
||||||
"Code": "Code",
|
"Code": "Code",
|
||||||
"Generated By": "Generated By"
|
"Generated By": "Generated By",
|
||||||
|
"Report Viewer": "Report Viewer",
|
||||||
|
"Super Administrator": "Super Administrator"
|
||||||
}
|
}
|
@ -46,22 +46,32 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-3 control-label">{Lang::T('User Type')}</label>
|
<label class="col-md-3 control-label">{Lang::T('User Type')}</label>
|
||||||
<div class="col-md-9">
|
<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" onchange="checkUserType(this)">
|
||||||
{if $_admin['user_type'] eq 'Agent'}
|
{if $_admin['user_type'] eq 'Agent'}
|
||||||
<option value="Sales">Sales</option>
|
<option value="Sales">{Lang::T('Sales')}</option>
|
||||||
{/if}
|
{/if}
|
||||||
{if $_admin['user_type'] eq 'Admin' || $_admin['user_type'] eq 'SuperAdmin'}
|
{if $_admin['user_type'] eq 'Admin' || $_admin['user_type'] eq 'SuperAdmin'}
|
||||||
<option value="Report">Report Viewer</option>
|
<option value="Report">{Lang::T('Report Viewer')}</option>
|
||||||
<option value="Agent">Agent</option>
|
<option value="Agent">{Lang::T('Agent')}</option>
|
||||||
<option value="Sales">Sales</option>
|
<option value="Sales">{Lang::T('Sales')}</option>
|
||||||
{/if}
|
{/if}
|
||||||
{if $_admin['user_type'] eq 'SuperAdmin'}
|
{if $_admin['user_type'] eq 'SuperAdmin'}
|
||||||
<option value="Admin">Administrator</option>
|
<option value="Admin">{Lang::T('Administrator')}</option>
|
||||||
<option value="SuperAdmin">Super Administrator</option>
|
<option value="SuperAdmin">{Lang::T('Super Administrator')}</option>
|
||||||
{/if}
|
{/if}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group hidden" id="agentChooser">
|
||||||
|
<label class="col-md-3 control-label">{Lang::T('Agent')}</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<select name="root" id="root" class="form-control">
|
||||||
|
{foreach $agents as $agent}
|
||||||
|
<option value="{$agent['id']}">{$agent['username']} | {$agent['fullname']} | {$agent['phone']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
|
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
@ -94,4 +104,16 @@
|
|||||||
Or <a href="{$_url}settings/users">{Lang::T('Cancel')}</a>
|
Or <a href="{$_url}settings/users">{Lang::T('Cancel')}</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{literal}
|
||||||
|
<script>
|
||||||
|
function checkUserType($field){
|
||||||
|
if($field.value=='Sales'){
|
||||||
|
$('#agentChooser').removeClass('hidden');
|
||||||
|
}else{
|
||||||
|
$('#agentChooser').addClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/literal}
|
||||||
|
|
||||||
{include file="sections/footer.tpl"}
|
{include file="sections/footer.tpl"}
|
@ -87,6 +87,16 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group {if $d['user_type'] eq 'Sales'}hidden{/if}" id="agentChooser">
|
||||||
|
<label class="col-md-3 control-label">{Lang::T('Agent')}</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<select name="root" id="root" class="form-control">
|
||||||
|
{foreach $agents as $agent}
|
||||||
|
<option value="{$agent['id']}">{$agent['username']} | {$agent['fullname']} | {$agent['phone']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
|
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
|
||||||
@ -120,4 +130,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{literal}
|
||||||
|
<script>
|
||||||
|
function checkUserType($field){
|
||||||
|
if($field.value=='Sales'){
|
||||||
|
$('#agentChooser').removeClass('hidden');
|
||||||
|
}else{
|
||||||
|
$('#agentChooser').addClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/literal}
|
||||||
{include file="sections/footer.tpl"}
|
{include file="sections/footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user