...
|
...
|
@@ -196,6 +196,7 @@ class AdminProjectController extends AdminBaseController |
|
|
$arr = [
|
|
|
['id' => 0,'name'=>'员工'],
|
|
|
['id' => 1,'name'=>'领导'],
|
|
|
['id' => 2,'name'=>'总领导'],
|
|
|
];
|
|
|
$this->assign('list',$arr);
|
|
|
$this->assign('company_id',$company_id);
|
...
|
...
|
@@ -245,33 +246,32 @@ class AdminProjectController extends AdminBaseController |
|
|
$u_l_id = ','.$u_l_id;
|
|
|
|
|
|
//如果有总领导
|
|
|
$u_ls_id = 0;
|
|
|
$u_ls_id = '';
|
|
|
$companyModel = new CompanyModel();
|
|
|
|
|
|
if($data['is_children'] == 1){
|
|
|
$res = $common->getIsMobile($data['mobile2']);
|
|
|
$userModel = new UserModel();
|
|
|
if(!$res){
|
|
|
//创建总领导
|
|
|
if(!empty($data['mobile2'])){
|
|
|
$leader['user_login'] = $data['user_login2'];
|
|
|
$leader['mobile'] = $data['mobile2'];
|
|
|
$leader['position'] = $data['position2'];
|
|
|
$leader['user_pass'] = cmf_password(123456);
|
|
|
$leader['user_type'] = 2;
|
|
|
$leader['identity'] = 2;
|
|
|
$leader['create_time'] = time();
|
|
|
$arr2 = $userModel->create($leader);
|
|
|
$u_ls_id = $arr2->id;
|
|
|
}
|
|
|
}else{
|
|
|
if(!empty($data['mobile2'])){
|
|
|
$leader['user_login'] = $data['user_login2'];
|
|
|
$leader['position'] = $data['position2'];
|
|
|
$userModel->where('mobile',$data['mobile2'])->update($leader);
|
|
|
$u_ls_id = $res['id'];
|
|
|
//合并甲方总领导
|
|
|
if(!empty($data['mobile2'])){
|
|
|
$res2 = $common->array_merge_more($keys, $data['user_login2'], $data['mobile2'], $data['position2']);
|
|
|
foreach ($res2 as $value2){
|
|
|
$res = $common->getIsMobile($value2['mobile']);
|
|
|
if(!$res){
|
|
|
//创建总领导
|
|
|
$value2['user_pass'] = cmf_password(123456);
|
|
|
$value2['user_type'] = 2;
|
|
|
$value2['identity'] = 2;
|
|
|
$value2['create_time'] = time();
|
|
|
$arr2 = $userModel->create($value2);
|
|
|
$u_ls_id .= $arr2->id.',';
|
|
|
}else{
|
|
|
$u_ls_id .= $res['id'].',';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(!empty($u_ls_id)){
|
|
|
$u_ls_id = ','.$u_ls_id;
|
|
|
}
|
|
|
|
|
|
//创建甲方公司
|
|
|
$admin_id = cmf_get_current_admin_id();
|
...
|
...
|
@@ -366,17 +366,9 @@ class AdminProjectController extends AdminBaseController |
|
|
$part_a = $common->getCompanyById($post['a_cid'],'*');
|
|
|
$post['part_a'] = $part_a;
|
|
|
|
|
|
//根据总领导id获取总领导信息
|
|
|
$leader['user_login'] = '';
|
|
|
$leader['mobile'] = '';
|
|
|
$leader['position'] = '';
|
|
|
if($part_a['is_children'] == 1){
|
|
|
$user_leader = $common->getUserInfo($part_a['u_ls_id']);
|
|
|
$leader['user_login'] = $user_leader['user_login'];
|
|
|
$leader['mobile'] = $user_leader['mobile'];
|
|
|
$leader['position'] = $user_leader['position'];
|
|
|
}
|
|
|
$post['u_ls_id_a'] = $leader;
|
|
|
//获取甲方企业总领导
|
|
|
$u_ls_ids = explode(',',trim($part_a['u_ls_id'],','));
|
|
|
$post['u_ls_id_a'] = $common->getUserName($u_ls_ids);
|
|
|
|
|
|
//获取甲方企业负责人
|
|
|
$u_l_ids = explode(',',trim($part_a['u_l_id'],','));
|
...
|
...
|
@@ -436,6 +428,16 @@ class AdminProjectController extends AdminBaseController |
|
|
|
|
|
//甲方企业id,甲方员工id
|
|
|
$project = $common->getProject(['id'=>$data['id']],'id,a_cid');
|
|
|
|
|
|
//领导
|
|
|
if(!empty($data['u_l_id'])){
|
|
|
$company_a['u_l_id'] = ','.implode($data['u_l_id'],',').',';//领导
|
|
|
}
|
|
|
//员工
|
|
|
if(!empty($data['u_s_id'])){
|
|
|
$company_a['u_s_id'] = ','.implode($data['u_s_id'],',').',';//员工
|
|
|
}
|
|
|
|
|
|
$companyModel = new CompanyModel();
|
|
|
//更新甲方企业公司名称,logo,营业执照
|
|
|
$company_a['company_name'] = $data['company_name'];
|
...
|
...
|
@@ -446,37 +448,13 @@ class AdminProjectController extends AdminBaseController |
|
|
$company_a['company_name_head'] = $data['company_name_head'];//甲方总公司名称
|
|
|
$company_a['head_logo'] = $data['head_logo'];//总公司logo
|
|
|
//$company_a['address'] = $data['address'];//地区
|
|
|
//查询该总领导是否存在
|
|
|
$res = $common->getIsMobile($data['mobile2']);
|
|
|
$userModel = new UserModel();
|
|
|
if(!$res){
|
|
|
//创建总领导
|
|
|
if(!empty($data['mobile2'])){
|
|
|
$leader['user_login'] = $data['user_login2'];
|
|
|
$leader['mobile'] = $data['mobile2'];
|
|
|
$leader['position'] = $data['position2'];
|
|
|
$leader['user_pass'] = cmf_password(123456);
|
|
|
$leader['user_type'] = 2;
|
|
|
$leader['identity'] = 2;
|
|
|
$leader['create_time'] = time();
|
|
|
$arr2 = $userModel->create($leader);
|
|
|
$u_ls_id = $arr2->id;
|
|
|
$companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$u_ls_id]);
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
if(!empty($data['mobile2'])){
|
|
|
$leader['user_login'] = $data['user_login2'];
|
|
|
$leader['position'] = $data['position2'];
|
|
|
$userModel->where('mobile',$data['mobile2'])->update($leader);
|
|
|
$companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$res['id']]);
|
|
|
}
|
|
|
|
|
|
if(!empty($data['u_ls_id'])){
|
|
|
$company_a['u_ls_id'] = ','.implode($data['u_ls_id'],',').',';//总领导
|
|
|
}
|
|
|
}else{
|
|
|
$company_a['company_name_head'] = '';//甲方总公司名称
|
|
|
//$company_a['address'] = '';//地区
|
|
|
$company_a['u_ls_id'] = 0;//总领导
|
|
|
$company_a['u_ls_id'] = '';//总领导
|
|
|
}
|
|
|
$companyModel->where('id',$project['a_cid'])->update($company_a);
|
|
|
|
...
|
...
|
@@ -551,10 +529,7 @@ class AdminProjectController extends AdminBaseController |
|
|
public function addUserPost(){
|
|
|
$data = $this->request->param();
|
|
|
$adminCommon = new AdminCommonController();
|
|
|
$res = $adminCommon->getIsMobile($data['mobile']);
|
|
|
if($res){
|
|
|
$this->error('手机号不能重复');
|
|
|
}
|
|
|
|
|
|
//创建普通用户
|
|
|
$userModel = new UserModel();
|
|
|
$arr['user_login'] = $data['user_login'];
|
...
|
...
|
@@ -564,7 +539,27 @@ class AdminProjectController extends AdminBaseController |
|
|
$arr['user_pass'] = cmf_password(123456);
|
|
|
$arr['user_type'] = 2;
|
|
|
$arr['create_time'] = time();
|
|
|
$res_user = $userModel->create($arr);
|
|
|
|
|
|
if($data['identity'] == 2){
|
|
|
//总领导
|
|
|
$res = $adminCommon->getIsMobile($data['mobile']);
|
|
|
if($res){
|
|
|
//存在则不用添加
|
|
|
$res_user = 2;
|
|
|
$uid = $res['id'];
|
|
|
}else{
|
|
|
//不存在则新增用户
|
|
|
$res_user = $userModel->create($arr);
|
|
|
$uid = $res_user->id;
|
|
|
}
|
|
|
}else{
|
|
|
$res = $adminCommon->getIsMobile($data['mobile']);
|
|
|
if($res){
|
|
|
$this->error('手机号不能重复');
|
|
|
}
|
|
|
$res_user = $userModel->create($arr);
|
|
|
$uid = $res_user->id;
|
|
|
}
|
|
|
|
|
|
if($res_user){
|
|
|
$common = new AdminCommonController();
|
...
|
...
|
@@ -573,7 +568,6 @@ class AdminProjectController extends AdminBaseController |
|
|
|
|
|
//更新所属公司的员工或领导
|
|
|
$companyModel = new CompanyModel();
|
|
|
$uid = $res_user->id;
|
|
|
if($data['identity'] == 0){
|
|
|
//更新项目甲方员工
|
|
|
$projectModel = new ProjectModel();
|
...
|
...
|
@@ -584,11 +578,16 @@ class AdminProjectController extends AdminBaseController |
|
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_s_id');
|
|
|
$u_s_id = $res['u_s_id'].$uid.',';
|
|
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_s_id'=>$u_s_id]);
|
|
|
}else{
|
|
|
}else if($data['identity'] == 1){
|
|
|
//更新甲方公司的领导
|
|
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_l_id');
|
|
|
$u_l_id = $res['u_l_id'].$uid.',';
|
|
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_l_id'=>$u_l_id]);
|
|
|
}else{
|
|
|
//更新甲方公司的总领导
|
|
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_ls_id');
|
|
|
$u_ls_id = $res['u_ls_id'].$uid.',';
|
|
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$u_ls_id]);
|
|
|
}
|
|
|
if($res1){
|
|
|
$this->success("添加成功");
|
...
|
...
|
@@ -603,12 +602,26 @@ class AdminProjectController extends AdminBaseController |
|
|
public function delUserPost(){
|
|
|
$data = $this->request->param();
|
|
|
$userModel = new UserModel();
|
|
|
$res_user = $userModel->where(['id'=>$data['uid']])->delete();
|
|
|
if($res_user){
|
|
|
$common = new AdminCommonController();
|
|
|
//甲方企业id,甲方员工id
|
|
|
$project = $common->getProject(['id'=>$data['project_id']],'id,a_cid,a_sid');
|
|
|
$common = new AdminCommonController();
|
|
|
//甲方企业id,甲方员工id
|
|
|
$project = $common->getProject(['id'=>$data['project_id']],'id,a_cid,a_sid');
|
|
|
|
|
|
if($data['identity'] == 2){
|
|
|
//总领导,查询该账号是否存在其他项目中
|
|
|
$u_ls_id = ','.$data['uid'].',';
|
|
|
$res = $this->getLeadersCount(['id'=>['<>',$project['a_cid']],'u_ls_id'=>['like','%'.$u_ls_id.'%']]);
|
|
|
if($res == 0){
|
|
|
//不存在则删除
|
|
|
$res_user = $userModel->where(['id'=>$data['uid']])->delete();
|
|
|
}else{
|
|
|
//存在不用删除
|
|
|
$res_user = 1;
|
|
|
}
|
|
|
}else{
|
|
|
$res_user = $userModel->where(['id'=>$data['uid']])->delete();
|
|
|
}
|
|
|
|
|
|
if($res_user){
|
|
|
$companyModel = new CompanyModel();
|
|
|
$uid = ','.$data['uid'];
|
|
|
if($data['identity'] == 0){
|
...
|
...
|
@@ -621,11 +634,16 @@ class AdminProjectController extends AdminBaseController |
|
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_s_id');
|
|
|
$u_s_id = str_replace($uid,'',$res['u_s_id']);
|
|
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_s_id'=>$u_s_id]);
|
|
|
}else{
|
|
|
}else if($data['identity'] == 1){
|
|
|
//更新甲方公司的领导
|
|
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_l_id');
|
|
|
$u_l_id = str_replace($uid,'',$res['u_l_id']);
|
|
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_l_id'=>$u_l_id]);
|
|
|
}else{
|
|
|
//更新甲方公司的总领导
|
|
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_ls_id');
|
|
|
$u_ls_id = str_replace($uid,'',$res['u_ls_id']);
|
|
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$u_ls_id]);
|
|
|
}
|
|
|
if($res1){
|
|
|
//更新推送甲方表
|
...
|
...
|
@@ -647,6 +665,14 @@ class AdminProjectController extends AdminBaseController |
|
|
$this->error("删除用户失败");
|
|
|
}
|
|
|
|
|
|
//查询甲方其他公司是否存在总领导
|
|
|
public function getLeadersCount($where){
|
|
|
$res = Db::name('company')
|
|
|
->where($where)
|
|
|
->count();
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
//查询甲方公司领导或者员工
|
|
|
public function getStaffLeader($id,$field){
|
|
|
$res = Db::name('company')
|
...
|
...
|
|