* code for task#1037.
This commit is contained in:
@@ -263,13 +263,23 @@ class user extends control
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
die(js::locate($this->createLink('company', 'browse'), 'parent'));
|
||||
}
|
||||
$groups = $this->dao->select('id, name, role')->from(TABLE_GROUP)->fetchAll();
|
||||
$groupList = array('' => '');
|
||||
$roleGroup = array();
|
||||
foreach($groups as $group)
|
||||
{
|
||||
$groupList[$group->id] = $group->name;
|
||||
if($group->role) $roleGroup[$group->role] = $group->id;
|
||||
}
|
||||
|
||||
$header['title'] = $this->lang->company->common . $this->lang->colon . $this->lang->user->create;
|
||||
$position[] = $this->lang->user->create;
|
||||
$this->view->header = $header;
|
||||
$this->view->position = $position;
|
||||
$this->view->depts = $this->dept->getOptionMenu();
|
||||
$this->view->deptID = $deptID;
|
||||
$this->view->header = $header;
|
||||
$this->view->position = $position;
|
||||
$this->view->depts = $this->dept->getOptionMenu();
|
||||
$this->view->groupList = $groupList;
|
||||
$this->view->roleGroup = $roleGroup;
|
||||
$this->view->deptID = $deptID;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -284,6 +294,15 @@ class user extends control
|
||||
*/
|
||||
public function batchCreate($deptID = 0)
|
||||
{
|
||||
$groups = $this->dao->select('id, name, role')->from(TABLE_GROUP)->fetchAll();
|
||||
$groupList = array('' => '');
|
||||
$roleGroup = array();
|
||||
foreach($groups as $group)
|
||||
{
|
||||
$groupList[$group->id] = $group->name;
|
||||
if($group->role) $roleGroup[$group->role] = $group->id;
|
||||
}
|
||||
|
||||
$this->lang->set('menugroup.user', 'company');
|
||||
$this->lang->user->menu = $this->lang->company->menu;
|
||||
$this->lang->user->menuOrder = $this->lang->company->menuOrder;
|
||||
@@ -296,10 +315,12 @@ class user extends control
|
||||
|
||||
$header['title'] = $this->lang->company->common . $this->lang->colon . $this->lang->user->batchCreate;
|
||||
$position[] = $this->lang->user->batchCreate;
|
||||
$this->view->header = $header;
|
||||
$this->view->position = $position;
|
||||
$this->view->depts = $this->dept->getOptionMenu();
|
||||
$this->view->deptID = $deptID;
|
||||
$this->view->header = $header;
|
||||
$this->view->position = $position;
|
||||
$this->view->depts = $this->dept->getOptionMenu();
|
||||
$this->view->deptID = $deptID;
|
||||
$this->view->groupList = $groupList;
|
||||
$this->view->roleGroup = $roleGroup;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
11
module/user/js/batchcreate.js
Normal file
11
module/user/js/batchcreate.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function changeGroup(role, i)
|
||||
{
|
||||
if(role || roleGroup[role])
|
||||
{
|
||||
$('#group' + i).val(roleGroup[role]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#group' + i).val('');
|
||||
}
|
||||
}
|
||||
11
module/user/js/create.js
Normal file
11
module/user/js/create.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function changeGroup(role)
|
||||
{
|
||||
if(role || roleGroup[role])
|
||||
{
|
||||
$('#group').val(roleGroup[role]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#group').val('');
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ $lang->user->account = 'Account';
|
||||
$lang->user->password = 'Password';
|
||||
$lang->user->password2 = 'Repeat password';
|
||||
$lang->user->role = 'Role';
|
||||
$lang->user->group = 'Group';
|
||||
$lang->user->realname = 'Fullname';
|
||||
$lang->user->nickname = 'Nickname';
|
||||
$lang->user->commiter = 'Commit account';
|
||||
|
||||
@@ -17,6 +17,7 @@ $lang->user->account = '用户名';
|
||||
$lang->user->password = '密码';
|
||||
$lang->user->password2 = '请重复密码';
|
||||
$lang->user->role = '角色';
|
||||
$lang->user->group = '分组';
|
||||
$lang->user->realname = '真实姓名';
|
||||
$lang->user->nickname = '昵称';
|
||||
$lang->user->commiter = '源代码帐号';
|
||||
|
||||
@@ -201,7 +201,7 @@ class userModel extends model
|
||||
->setDefault('join', '0000-00-00')
|
||||
->setIF($this->post->password1 != false, 'password', md5($this->post->password1))
|
||||
->setIF($this->post->password1 == false, 'password', '')
|
||||
->remove('password1, password2')
|
||||
->remove('group, password1, password2')
|
||||
->get();
|
||||
|
||||
$this->dao->insert(TABLE_USER)->data($user)
|
||||
@@ -211,16 +211,12 @@ class userModel extends model
|
||||
->check('account', 'account')
|
||||
->checkIF($this->post->email != false, 'email', 'email')
|
||||
->exec();
|
||||
if($this->post->role)
|
||||
if($this->post->group)
|
||||
{
|
||||
$group = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->like('%' . $this->post->role . '%')->fetch();
|
||||
if($group)
|
||||
{
|
||||
$data = new stdClass();
|
||||
$data->account = $this->post->account;
|
||||
$data->group = $group->id;
|
||||
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
|
||||
}
|
||||
$data = new stdClass();
|
||||
$data->account = $this->post->account;
|
||||
$data->group = $this->post->group;
|
||||
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,6 +250,7 @@ class userModel extends model
|
||||
$data[$i]->account = $users->account[$i];
|
||||
$data[$i]->realname = $users->realname[$i];
|
||||
$data[$i]->role = $users->role[$i] == 'ditto' ? (isset($prev['role']) ? $prev['role'] : '') : $users->role[$i];
|
||||
$data[$i]->group = $users->group[$i] == 'ditto' ? (isset($prev['group']) ? $prev['group'] : '') : $users->group[$i];
|
||||
$data[$i]->email = $users->email[$i];
|
||||
$data[$i]->gender = $users->gender[$i];
|
||||
$data[$i]->password = md5($users->password[$i]);
|
||||
@@ -261,12 +258,21 @@ class userModel extends model
|
||||
$accounts[$i] = $data[$i]->account;
|
||||
$prev['dept'] = $data[$i]->dept;
|
||||
$prev['role'] = $data[$i]->role;
|
||||
$prev['group'] = $data[$i]->group;
|
||||
$prev['password'] = $users->password[$i];
|
||||
}
|
||||
}
|
||||
|
||||
foreach($data as $user)
|
||||
{
|
||||
if($user->group)
|
||||
{
|
||||
$group = new stdClass();
|
||||
$group->account = $user->account;
|
||||
$group->group = $user->group;
|
||||
}
|
||||
unset($user->group);
|
||||
$this->dao->insert(TABLE_USERGROUP)->data($group)->exec();
|
||||
$this->dao->insert(TABLE_USER)->data($user)->autoCheck()->exec();
|
||||
if(dao::isError())
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/chosen.html.php';?>
|
||||
<?php js::set('roleGroup', json_encode($roleGroup));?>
|
||||
<form method='post' target='hiddenwin' id='dataform'>
|
||||
<table class='table-1 fixed'>
|
||||
<caption><?php echo $lang->user->batchCreate;?></caption>
|
||||
@@ -21,19 +22,22 @@
|
||||
<th class='w-130px'><?php echo $lang->user->account;?></th>
|
||||
<th class='w-130px'><?php echo $lang->user->realname;?></th>
|
||||
<th class='w-100px'><?php echo $lang->user->role;?></th>
|
||||
<th class='w-100px'><?php echo $lang->user->group;?></th>
|
||||
<th><?php echo $lang->user->email;?></th>
|
||||
<th class='w-60px'><?php echo $lang->user->gender;?></th>
|
||||
<th><?php echo $lang->user->password;?></th>
|
||||
</tr>
|
||||
<?php $depts = $depts + array('ditto' => $lang->user->ditto)?>
|
||||
<?php $lang->user->roleList = $lang->user->roleList + array('ditto' => $lang->user->ditto)?>
|
||||
<?php $groupList = $groupList + array('ditto' => $lang->user->ditto)?>
|
||||
<?php for($i = 0; $i < $config->user->batchCreate; $i++):?>
|
||||
<tr class='a-center'>
|
||||
<td><?php echo $i+1;?></td>
|
||||
<td><?php echo html::select("dept[$i]", $depts, $i > 0 ? 'ditto' : $deptID, "class='select-1'");?>
|
||||
<td><?php echo html::input("account[$i]", '', "class='text-1 account_$i' autocomplete='off' onchange='changeEmail($i)'");?></td>
|
||||
<td><?php echo html::input("realname[$i]", '', "class='text-1'");?></td>
|
||||
<td><?php echo html::select("role[$i]", $lang->user->roleList, $i > 0 ? 'ditto' : '', "class='select-1'");?></td>
|
||||
<td><?php echo html::select("role[$i]", $lang->user->roleList, $i > 0 ? 'ditto' : '', "class='select-1' onchange='changeGroup(this.value, $i)'");?></td>
|
||||
<td><?php echo html::select("group[$i]", $groupList, $i > 0 ? 'ditto' : '', "class='select-1'");?></td>
|
||||
<td><?php echo html::input("email[$i]", '', "class='text-1 email_$i' onchange='setDefaultEmail($i)'");?></td>
|
||||
<td><?php echo html::radio("gender[$i]", (array)$lang->user->genderList, 'm');?></td>
|
||||
<td>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<?php js::set('holders', json_encode($lang->user->placeholder));?>
|
||||
<?php js::set('roleGroup', json_encode($roleGroup));?>
|
||||
<form method='post' target='hiddenwin' id='dataform'>
|
||||
<table align='center' class='table-5'>
|
||||
<caption><?php echo $lang->user->create;?></caption>
|
||||
@@ -38,7 +39,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->user->role;?></th>
|
||||
<td><?php echo html::select('role', $lang->user->roleList, '', "class='select-3'");?></td>
|
||||
<td><?php echo html::select('role', $lang->user->roleList, '', "class='select-3' onchange='changeGroup(this.value)'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->user->group;?></th>
|
||||
<td><?php echo html::select('group', $groupList, '', "class='select-3'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->user->email;?></th>
|
||||
|
||||
Reference in New Issue
Block a user