|
@@ -196,6 +196,7 @@ class AdminProjectController extends AdminBaseController |
|
@@ -196,6 +196,7 @@ class AdminProjectController extends AdminBaseController |
196
|
$arr = [
|
196
|
$arr = [
|
197
|
['id' => 0,'name'=>'员工'],
|
197
|
['id' => 0,'name'=>'员工'],
|
198
|
['id' => 1,'name'=>'领导'],
|
198
|
['id' => 1,'name'=>'领导'],
|
|
|
199
|
+ ['id' => 2,'name'=>'总领导'],
|
199
|
];
|
200
|
];
|
200
|
$this->assign('list',$arr);
|
201
|
$this->assign('list',$arr);
|
201
|
$this->assign('company_id',$company_id);
|
202
|
$this->assign('company_id',$company_id);
|
|
@@ -245,33 +246,32 @@ class AdminProjectController extends AdminBaseController |
|
@@ -245,33 +246,32 @@ class AdminProjectController extends AdminBaseController |
245
|
$u_l_id = ','.$u_l_id;
|
246
|
$u_l_id = ','.$u_l_id;
|
246
|
|
247
|
|
247
|
//如果有总领导
|
248
|
//如果有总领导
|
248
|
- $u_ls_id = 0;
|
249
|
+ $u_ls_id = '';
|
249
|
$companyModel = new CompanyModel();
|
250
|
$companyModel = new CompanyModel();
|
|
|
251
|
+
|
250
|
if($data['is_children'] == 1){
|
252
|
if($data['is_children'] == 1){
|
251
|
- $res = $common->getIsMobile($data['mobile2']);
|
|
|
252
|
- $userModel = new UserModel();
|
|
|
253
|
- if(!$res){
|
|
|
254
|
- //创建总领导
|
|
|
255
|
- if(!empty($data['mobile2'])){
|
|
|
256
|
- $leader['user_login'] = $data['user_login2'];
|
|
|
257
|
- $leader['mobile'] = $data['mobile2'];
|
|
|
258
|
- $leader['position'] = $data['position2'];
|
|
|
259
|
- $leader['user_pass'] = cmf_password(123456);
|
|
|
260
|
- $leader['user_type'] = 2;
|
|
|
261
|
- $leader['identity'] = 2;
|
|
|
262
|
- $leader['create_time'] = time();
|
|
|
263
|
- $arr2 = $userModel->create($leader);
|
|
|
264
|
- $u_ls_id = $arr2->id;
|
|
|
265
|
- }
|
|
|
266
|
- }else{
|
|
|
267
|
- if(!empty($data['mobile2'])){
|
|
|
268
|
- $leader['user_login'] = $data['user_login2'];
|
|
|
269
|
- $leader['position'] = $data['position2'];
|
|
|
270
|
- $userModel->where('mobile',$data['mobile2'])->update($leader);
|
|
|
271
|
- $u_ls_id = $res['id'];
|
253
|
+ //合并甲方总领导
|
|
|
254
|
+ if(!empty($data['mobile2'])){
|
|
|
255
|
+ $res2 = $common->array_merge_more($keys, $data['user_login2'], $data['mobile2'], $data['position2']);
|
|
|
256
|
+ foreach ($res2 as $value2){
|
|
|
257
|
+ $res = $common->getIsMobile($value2['mobile']);
|
|
|
258
|
+ if(!$res){
|
|
|
259
|
+ //创建总领导
|
|
|
260
|
+ $value2['user_pass'] = cmf_password(123456);
|
|
|
261
|
+ $value2['user_type'] = 2;
|
|
|
262
|
+ $value2['identity'] = 2;
|
|
|
263
|
+ $value2['create_time'] = time();
|
|
|
264
|
+ $arr2 = $userModel->create($value2);
|
|
|
265
|
+ $u_ls_id .= $arr2->id.',';
|
|
|
266
|
+ }else{
|
|
|
267
|
+ $u_ls_id .= $res['id'].',';
|
|
|
268
|
+ }
|
272
|
}
|
269
|
}
|
273
|
}
|
270
|
}
|
274
|
}
|
271
|
}
|
|
|
272
|
+ if(!empty($u_ls_id)){
|
|
|
273
|
+ $u_ls_id = ','.$u_ls_id;
|
|
|
274
|
+ }
|
275
|
|
275
|
|
276
|
//创建甲方公司
|
276
|
//创建甲方公司
|
277
|
$admin_id = cmf_get_current_admin_id();
|
277
|
$admin_id = cmf_get_current_admin_id();
|
|
@@ -366,17 +366,9 @@ class AdminProjectController extends AdminBaseController |
|
@@ -366,17 +366,9 @@ class AdminProjectController extends AdminBaseController |
366
|
$part_a = $common->getCompanyById($post['a_cid'],'*');
|
366
|
$part_a = $common->getCompanyById($post['a_cid'],'*');
|
367
|
$post['part_a'] = $part_a;
|
367
|
$post['part_a'] = $part_a;
|
368
|
|
368
|
|
369
|
- //根据总领导id获取总领导信息
|
|
|
370
|
- $leader['user_login'] = '';
|
|
|
371
|
- $leader['mobile'] = '';
|
|
|
372
|
- $leader['position'] = '';
|
|
|
373
|
- if($part_a['is_children'] == 1){
|
|
|
374
|
- $user_leader = $common->getUserInfo($part_a['u_ls_id']);
|
|
|
375
|
- $leader['user_login'] = $user_leader['user_login'];
|
|
|
376
|
- $leader['mobile'] = $user_leader['mobile'];
|
|
|
377
|
- $leader['position'] = $user_leader['position'];
|
|
|
378
|
- }
|
|
|
379
|
- $post['u_ls_id_a'] = $leader;
|
369
|
+ //获取甲方企业总领导
|
|
|
370
|
+ $u_ls_ids = explode(',',trim($part_a['u_ls_id'],','));
|
|
|
371
|
+ $post['u_ls_id_a'] = $common->getUserName($u_ls_ids);
|
380
|
|
372
|
|
381
|
//获取甲方企业负责人
|
373
|
//获取甲方企业负责人
|
382
|
$u_l_ids = explode(',',trim($part_a['u_l_id'],','));
|
374
|
$u_l_ids = explode(',',trim($part_a['u_l_id'],','));
|
|
@@ -436,6 +428,16 @@ class AdminProjectController extends AdminBaseController |
|
@@ -436,6 +428,16 @@ class AdminProjectController extends AdminBaseController |
436
|
|
428
|
|
437
|
//甲方企业id,甲方员工id
|
429
|
//甲方企业id,甲方员工id
|
438
|
$project = $common->getProject(['id'=>$data['id']],'id,a_cid');
|
430
|
$project = $common->getProject(['id'=>$data['id']],'id,a_cid');
|
|
|
431
|
+
|
|
|
432
|
+ //领导
|
|
|
433
|
+ if(!empty($data['u_l_id'])){
|
|
|
434
|
+ $company_a['u_l_id'] = ','.implode($data['u_l_id'],',').',';//领导
|
|
|
435
|
+ }
|
|
|
436
|
+ //员工
|
|
|
437
|
+ if(!empty($data['u_s_id'])){
|
|
|
438
|
+ $company_a['u_s_id'] = ','.implode($data['u_s_id'],',').',';//员工
|
|
|
439
|
+ }
|
|
|
440
|
+
|
439
|
$companyModel = new CompanyModel();
|
441
|
$companyModel = new CompanyModel();
|
440
|
//更新甲方企业公司名称,logo,营业执照
|
442
|
//更新甲方企业公司名称,logo,营业执照
|
441
|
$company_a['company_name'] = $data['company_name'];
|
443
|
$company_a['company_name'] = $data['company_name'];
|
|
@@ -446,37 +448,13 @@ class AdminProjectController extends AdminBaseController |
|
@@ -446,37 +448,13 @@ class AdminProjectController extends AdminBaseController |
446
|
$company_a['company_name_head'] = $data['company_name_head'];//甲方总公司名称
|
448
|
$company_a['company_name_head'] = $data['company_name_head'];//甲方总公司名称
|
447
|
$company_a['head_logo'] = $data['head_logo'];//总公司logo
|
449
|
$company_a['head_logo'] = $data['head_logo'];//总公司logo
|
448
|
//$company_a['address'] = $data['address'];//地区
|
450
|
//$company_a['address'] = $data['address'];//地区
|
449
|
- //查询该总领导是否存在
|
|
|
450
|
- $res = $common->getIsMobile($data['mobile2']);
|
|
|
451
|
- $userModel = new UserModel();
|
|
|
452
|
- if(!$res){
|
|
|
453
|
- //创建总领导
|
|
|
454
|
- if(!empty($data['mobile2'])){
|
|
|
455
|
- $leader['user_login'] = $data['user_login2'];
|
|
|
456
|
- $leader['mobile'] = $data['mobile2'];
|
|
|
457
|
- $leader['position'] = $data['position2'];
|
|
|
458
|
- $leader['user_pass'] = cmf_password(123456);
|
|
|
459
|
- $leader['user_type'] = 2;
|
|
|
460
|
- $leader['identity'] = 2;
|
|
|
461
|
- $leader['create_time'] = time();
|
|
|
462
|
- $arr2 = $userModel->create($leader);
|
|
|
463
|
- $u_ls_id = $arr2->id;
|
|
|
464
|
- $companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$u_ls_id]);
|
|
|
465
|
- }
|
|
|
466
|
-
|
|
|
467
|
- }else{
|
|
|
468
|
- if(!empty($data['mobile2'])){
|
|
|
469
|
- $leader['user_login'] = $data['user_login2'];
|
|
|
470
|
- $leader['position'] = $data['position2'];
|
|
|
471
|
- $userModel->where('mobile',$data['mobile2'])->update($leader);
|
|
|
472
|
- $companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$res['id']]);
|
|
|
473
|
- }
|
|
|
474
|
-
|
451
|
+ if(!empty($data['u_ls_id'])){
|
|
|
452
|
+ $company_a['u_ls_id'] = ','.implode($data['u_ls_id'],',').',';//总领导
|
475
|
}
|
453
|
}
|
476
|
}else{
|
454
|
}else{
|
477
|
$company_a['company_name_head'] = '';//甲方总公司名称
|
455
|
$company_a['company_name_head'] = '';//甲方总公司名称
|
478
|
//$company_a['address'] = '';//地区
|
456
|
//$company_a['address'] = '';//地区
|
479
|
- $company_a['u_ls_id'] = 0;//总领导
|
457
|
+ $company_a['u_ls_id'] = '';//总领导
|
480
|
}
|
458
|
}
|
481
|
$companyModel->where('id',$project['a_cid'])->update($company_a);
|
459
|
$companyModel->where('id',$project['a_cid'])->update($company_a);
|
482
|
|
460
|
|
|
@@ -551,10 +529,7 @@ class AdminProjectController extends AdminBaseController |
|
@@ -551,10 +529,7 @@ class AdminProjectController extends AdminBaseController |
551
|
public function addUserPost(){
|
529
|
public function addUserPost(){
|
552
|
$data = $this->request->param();
|
530
|
$data = $this->request->param();
|
553
|
$adminCommon = new AdminCommonController();
|
531
|
$adminCommon = new AdminCommonController();
|
554
|
- $res = $adminCommon->getIsMobile($data['mobile']);
|
|
|
555
|
- if($res){
|
|
|
556
|
- $this->error('手机号不能重复');
|
|
|
557
|
- }
|
532
|
+
|
558
|
//创建普通用户
|
533
|
//创建普通用户
|
559
|
$userModel = new UserModel();
|
534
|
$userModel = new UserModel();
|
560
|
$arr['user_login'] = $data['user_login'];
|
535
|
$arr['user_login'] = $data['user_login'];
|
|
@@ -564,7 +539,27 @@ class AdminProjectController extends AdminBaseController |
|
@@ -564,7 +539,27 @@ class AdminProjectController extends AdminBaseController |
564
|
$arr['user_pass'] = cmf_password(123456);
|
539
|
$arr['user_pass'] = cmf_password(123456);
|
565
|
$arr['user_type'] = 2;
|
540
|
$arr['user_type'] = 2;
|
566
|
$arr['create_time'] = time();
|
541
|
$arr['create_time'] = time();
|
567
|
- $res_user = $userModel->create($arr);
|
542
|
+
|
|
|
543
|
+ if($data['identity'] == 2){
|
|
|
544
|
+ //总领导
|
|
|
545
|
+ $res = $adminCommon->getIsMobile($data['mobile']);
|
|
|
546
|
+ if($res){
|
|
|
547
|
+ //存在则不用添加
|
|
|
548
|
+ $res_user = 2;
|
|
|
549
|
+ $uid = $res['id'];
|
|
|
550
|
+ }else{
|
|
|
551
|
+ //不存在则新增用户
|
|
|
552
|
+ $res_user = $userModel->create($arr);
|
|
|
553
|
+ $uid = $res_user->id;
|
|
|
554
|
+ }
|
|
|
555
|
+ }else{
|
|
|
556
|
+ $res = $adminCommon->getIsMobile($data['mobile']);
|
|
|
557
|
+ if($res){
|
|
|
558
|
+ $this->error('手机号不能重复');
|
|
|
559
|
+ }
|
|
|
560
|
+ $res_user = $userModel->create($arr);
|
|
|
561
|
+ $uid = $res_user->id;
|
|
|
562
|
+ }
|
568
|
|
563
|
|
569
|
if($res_user){
|
564
|
if($res_user){
|
570
|
$common = new AdminCommonController();
|
565
|
$common = new AdminCommonController();
|
|
@@ -573,7 +568,6 @@ class AdminProjectController extends AdminBaseController |
|
@@ -573,7 +568,6 @@ class AdminProjectController extends AdminBaseController |
573
|
|
568
|
|
574
|
//更新所属公司的员工或领导
|
569
|
//更新所属公司的员工或领导
|
575
|
$companyModel = new CompanyModel();
|
570
|
$companyModel = new CompanyModel();
|
576
|
- $uid = $res_user->id;
|
|
|
577
|
if($data['identity'] == 0){
|
571
|
if($data['identity'] == 0){
|
578
|
//更新项目甲方员工
|
572
|
//更新项目甲方员工
|
579
|
$projectModel = new ProjectModel();
|
573
|
$projectModel = new ProjectModel();
|
|
@@ -584,11 +578,16 @@ class AdminProjectController extends AdminBaseController |
|
@@ -584,11 +578,16 @@ class AdminProjectController extends AdminBaseController |
584
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_s_id');
|
578
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_s_id');
|
585
|
$u_s_id = $res['u_s_id'].$uid.',';
|
579
|
$u_s_id = $res['u_s_id'].$uid.',';
|
586
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_s_id'=>$u_s_id]);
|
580
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_s_id'=>$u_s_id]);
|
587
|
- }else{
|
581
|
+ }else if($data['identity'] == 1){
|
588
|
//更新甲方公司的领导
|
582
|
//更新甲方公司的领导
|
589
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_l_id');
|
583
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_l_id');
|
590
|
$u_l_id = $res['u_l_id'].$uid.',';
|
584
|
$u_l_id = $res['u_l_id'].$uid.',';
|
591
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_l_id'=>$u_l_id]);
|
585
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_l_id'=>$u_l_id]);
|
|
|
586
|
+ }else{
|
|
|
587
|
+ //更新甲方公司的总领导
|
|
|
588
|
+ $res = $this->getStaffLeader($project['a_cid'],'id,u_ls_id');
|
|
|
589
|
+ $u_ls_id = $res['u_ls_id'].$uid.',';
|
|
|
590
|
+ $res1 = $companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$u_ls_id]);
|
592
|
}
|
591
|
}
|
593
|
if($res1){
|
592
|
if($res1){
|
594
|
$this->success("添加成功");
|
593
|
$this->success("添加成功");
|
|
@@ -603,12 +602,26 @@ class AdminProjectController extends AdminBaseController |
|
@@ -603,12 +602,26 @@ class AdminProjectController extends AdminBaseController |
603
|
public function delUserPost(){
|
602
|
public function delUserPost(){
|
604
|
$data = $this->request->param();
|
603
|
$data = $this->request->param();
|
605
|
$userModel = new UserModel();
|
604
|
$userModel = new UserModel();
|
606
|
- $res_user = $userModel->where(['id'=>$data['uid']])->delete();
|
|
|
607
|
- if($res_user){
|
|
|
608
|
- $common = new AdminCommonController();
|
|
|
609
|
- //甲方企业id,甲方员工id
|
|
|
610
|
- $project = $common->getProject(['id'=>$data['project_id']],'id,a_cid,a_sid');
|
605
|
+ $common = new AdminCommonController();
|
|
|
606
|
+ //甲方企业id,甲方员工id
|
|
|
607
|
+ $project = $common->getProject(['id'=>$data['project_id']],'id,a_cid,a_sid');
|
|
|
608
|
+
|
|
|
609
|
+ if($data['identity'] == 2){
|
|
|
610
|
+ //总领导,查询该账号是否存在其他项目中
|
|
|
611
|
+ $u_ls_id = ','.$data['uid'].',';
|
|
|
612
|
+ $res = $this->getLeadersCount(['id'=>['<>',$project['a_cid']],'u_ls_id'=>['like','%'.$u_ls_id.'%']]);
|
|
|
613
|
+ if($res == 0){
|
|
|
614
|
+ //不存在则删除
|
|
|
615
|
+ $res_user = $userModel->where(['id'=>$data['uid']])->delete();
|
|
|
616
|
+ }else{
|
|
|
617
|
+ //存在不用删除
|
|
|
618
|
+ $res_user = 1;
|
|
|
619
|
+ }
|
|
|
620
|
+ }else{
|
|
|
621
|
+ $res_user = $userModel->where(['id'=>$data['uid']])->delete();
|
|
|
622
|
+ }
|
611
|
|
623
|
|
|
|
624
|
+ if($res_user){
|
612
|
$companyModel = new CompanyModel();
|
625
|
$companyModel = new CompanyModel();
|
613
|
$uid = ','.$data['uid'];
|
626
|
$uid = ','.$data['uid'];
|
614
|
if($data['identity'] == 0){
|
627
|
if($data['identity'] == 0){
|
|
@@ -621,11 +634,16 @@ class AdminProjectController extends AdminBaseController |
|
@@ -621,11 +634,16 @@ class AdminProjectController extends AdminBaseController |
621
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_s_id');
|
634
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_s_id');
|
622
|
$u_s_id = str_replace($uid,'',$res['u_s_id']);
|
635
|
$u_s_id = str_replace($uid,'',$res['u_s_id']);
|
623
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_s_id'=>$u_s_id]);
|
636
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_s_id'=>$u_s_id]);
|
624
|
- }else{
|
637
|
+ }else if($data['identity'] == 1){
|
625
|
//更新甲方公司的领导
|
638
|
//更新甲方公司的领导
|
626
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_l_id');
|
639
|
$res = $this->getStaffLeader($project['a_cid'],'id,u_l_id');
|
627
|
$u_l_id = str_replace($uid,'',$res['u_l_id']);
|
640
|
$u_l_id = str_replace($uid,'',$res['u_l_id']);
|
628
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_l_id'=>$u_l_id]);
|
641
|
$res1 = $companyModel->where('id',$project['a_cid'])->update(['u_l_id'=>$u_l_id]);
|
|
|
642
|
+ }else{
|
|
|
643
|
+ //更新甲方公司的总领导
|
|
|
644
|
+ $res = $this->getStaffLeader($project['a_cid'],'id,u_ls_id');
|
|
|
645
|
+ $u_ls_id = str_replace($uid,'',$res['u_ls_id']);
|
|
|
646
|
+ $res1 = $companyModel->where('id',$project['a_cid'])->update(['u_ls_id'=>$u_ls_id]);
|
629
|
}
|
647
|
}
|
630
|
if($res1){
|
648
|
if($res1){
|
631
|
//更新推送甲方表
|
649
|
//更新推送甲方表
|
|
@@ -647,6 +665,14 @@ class AdminProjectController extends AdminBaseController |
|
@@ -647,6 +665,14 @@ class AdminProjectController extends AdminBaseController |
647
|
$this->error("删除用户失败");
|
665
|
$this->error("删除用户失败");
|
648
|
}
|
666
|
}
|
649
|
|
667
|
|
|
|
668
|
+ //查询甲方其他公司是否存在总领导
|
|
|
669
|
+ public function getLeadersCount($where){
|
|
|
670
|
+ $res = Db::name('company')
|
|
|
671
|
+ ->where($where)
|
|
|
672
|
+ ->count();
|
|
|
673
|
+ return $res;
|
|
|
674
|
+ }
|
|
|
675
|
+
|
650
|
//查询甲方公司领导或者员工
|
676
|
//查询甲方公司领导或者员工
|
651
|
public function getStaffLeader($id,$field){
|
677
|
public function getStaffLeader($id,$field){
|
652
|
$res = Db::name('company')
|
678
|
$res = Db::name('company')
|