|
@@ -114,8 +114,27 @@ class Home extends Base_Controller {
|
|
|
$data['day_faulty_count'] = $total['total'];
|
|
|
}else{
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where = ['P.company ='=>$company];
|
|
|
- if (!empty($projectIdArr)) $where['P.id'] = $projectIdArr;
|
|
|
+ $type = $this->get_user_info('role');
|
|
|
+ // $where = ['P.company ='=>$company];
|
|
|
+ $where = array();
|
|
|
+
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu ='] = $company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where['L.supplier ='] = $company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where['L.po ='] = $company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where['P.cityid ='] = $company;
|
|
|
+ }
|
|
|
+ // if (!empty($projectIdArr)) $where['P.id'] = $projectIdArr;
|
|
|
$join = [
|
|
|
['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'inner']
|
|
|
];
|
|
@@ -179,7 +198,24 @@ class Home extends Base_Controller {
|
|
|
$where = array();
|
|
|
if ($role != SYSTEM_ADMIN){
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where['P.company'] = $company;
|
|
|
+ // $where['P.company'] = $company;
|
|
|
+
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu ='] = $company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where['L.supplier ='] = $company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where['L.po ='] = $company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where['P.cityid ='] = $company;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!empty($projectIdArr)) $where['L.projectid'] = $projectIdArr;
|
|
@@ -224,7 +260,24 @@ class Home extends Base_Controller {
|
|
|
$where = array();
|
|
|
if ($role != SYSTEM_ADMIN){
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where[] = 'P.company = '.$company;
|
|
|
+ // $where[] = 'P.company = '.$company;
|
|
|
+
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where[] = 'L.manu = '.$company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where[] = 'L.supplier = '.$company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where[] = 'L.po = '.$company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where[] = 'P.cityid = '.$company;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($type == 2) {
|
|
@@ -341,7 +394,24 @@ class Home extends Base_Controller {
|
|
|
$where = array();
|
|
|
if ($role != SYSTEM_ADMIN){
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where[] = 'P.company = '.$company;
|
|
|
+ // $where[] = 'P.company = '.$company;
|
|
|
+
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where[] = 'L.manu = '.$company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where[] = 'L.supplier = '.$company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where[] = 'L.po = '.$company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where[] = 'P.cityid = '.$company;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!empty($projectIdArr)) $where[] = 'P.id in ('.implode(',', $projectIdArr).')';
|
|
@@ -581,10 +651,27 @@ class Home extends Base_Controller {
|
|
|
$where = array();
|
|
|
if ($role != SYSTEM_ADMIN) {
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where['company'] = $company;
|
|
|
+ $type = $this->get_user_info('role');
|
|
|
+ // $where['company'] = $company;
|
|
|
+
|
|
|
+ if ($type == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu'] = $company;
|
|
|
+ }elseif ($type == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ $where['L.supplier'] = $company;
|
|
|
+ }elseif ($type == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ $where['L.po'] = $company;
|
|
|
+ }else {
|
|
|
+ $where['P.cityid'] = $company;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- $pro_list = $this->Project_model->get_list($where,'cityid');
|
|
|
+ // $pro_list = $this->Project_model->get_list($where,'P.cityid');
|
|
|
+ $join = array();
|
|
|
+ $join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
|
|
|
+ $pro_list = $this->Lamp_model->get_list_by_join($where, 'P.cityid',NULL, NULL, $join, null, 'L.projectid', 'L');
|
|
|
$cityArr = array_unique(array_column($pro_list, 'cityid'));
|
|
|
$list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid');
|
|
|
$areaList = array();
|
|
@@ -635,10 +722,27 @@ class Home extends Base_Controller {
|
|
|
$where = array();
|
|
|
if ($role != SYSTEM_ADMIN) {
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where['company'] = $company;
|
|
|
+ $type = $this->get_user_info('role');
|
|
|
+ // $where['company'] = $company;
|
|
|
+
|
|
|
+ if ($type == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu'] = $company;
|
|
|
+ }elseif ($type == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ $where['L.supplier'] = $company;
|
|
|
+ }elseif ($type == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ $where['L.po'] = $company;
|
|
|
+ }else {
|
|
|
+ $where['P.cityid'] = $company;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- $pro_list = $this->Project_model->get_list($where,'cityid');
|
|
|
+ // $pro_list = $this->Project_model->get_list($where,'cityid');
|
|
|
+ $join = array();
|
|
|
+ $join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
|
|
|
+ $pro_list = $this->Lamp_model->get_list_by_join($where, 'P.cityid',NULL, NULL, $join, null, 'L.projectid', 'L');
|
|
|
$cityArr = array_unique(array_column($pro_list, 'cityid'));
|
|
|
$list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid');
|
|
|
$areaList = array();
|
|
@@ -706,7 +810,24 @@ class Home extends Base_Controller {
|
|
|
$company = $this->get_user_info('company');
|
|
|
$where = array();
|
|
|
|
|
|
- if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
|
|
|
+ if ($role != SYSTEM_ADMIN) {
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu = '] = $company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where['L.supplier = '] = $company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where['L.po = '] = $company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where['P.cityid = '] = $company;
|
|
|
+ }
|
|
|
+ }
|
|
|
$where['G3.level'] = 2;
|
|
|
$where['G3.pid'] = 92;
|
|
|
$join = array();
|
|
@@ -714,9 +835,10 @@ class Home extends Base_Controller {
|
|
|
$join[] = ['table'=>'global_location as G2','cond'=>'G3.id = G2.pid AND G2.level = 3','type'=>'left'];
|
|
|
$join[] = ['table'=>'global_location as G1','cond'=>'G2.id = G1.pid AND G1.level = 4','type'=>'left'];
|
|
|
$join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
|
|
|
+ $join[] = ['table'=>'lampinfo as L','cond'=>'L.projectid = P.id','type'=>'left'];
|
|
|
|
|
|
// $join[] = ['table'=>'global_location as G3','cond'=>'G3.id = G2.pid AND G3.level = 2','type'=>'left'];
|
|
|
- $list = $this->Global_location_model->get_list_by_join($where, 'G3.id,G3.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G3.id', 'G3');
|
|
|
+ $list = $this->Global_location_model->get_list_by_join($where, 'G3.id,G3.english_name as name,count(L.id) as lampcount',NULL, NULL, $join, NULL, 'G3.id', 'G3');
|
|
|
foreach ($list as $key => $value) {
|
|
|
$list[$key]['lampcount'] = intval($value['lampcount']);
|
|
|
}
|
|
@@ -731,14 +853,33 @@ class Home extends Base_Controller {
|
|
|
$proId = intval($this->input->post('proId',true));
|
|
|
|
|
|
if (!empty($proId)) $where['G2.pid'] = $proId;
|
|
|
- if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
|
|
|
+ if ($role != SYSTEM_ADMIN) {
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu = '] = $company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where['L.supplier = '] = $company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where['L.po = '] = $company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where['P.cityid = '] = $company;
|
|
|
+ }
|
|
|
+ }
|
|
|
$where['G2.level'] = 3;
|
|
|
$join = array();
|
|
|
|
|
|
$join[] = ['table'=>'global_location as G1','cond'=>'G2.id = G1.pid','type'=>'left'];
|
|
|
$join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
|
|
|
+ $join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
|
|
|
+ $join[] = ['table'=>'lampinfo as L','cond'=>'L.projectid = P.id','type'=>'left'];
|
|
|
// $join[] = ['table'=>'global_location as G2','cond'=>'G2.id = G1.pid','type'=>'left'];
|
|
|
- $list = $this->Global_location_model->get_list_by_join($where, 'G2.id,G2.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G2.id', 'G2');
|
|
|
+ $list = $this->Global_location_model->get_list_by_join($where, 'G2.id,G2.english_name as name,count(L.id) as lampcount',NULL, NULL, $join, NULL, 'G2.id', 'G2');
|
|
|
foreach ($list as $key => $value) {
|
|
|
$list[$key]['lampcount'] = intval($value['lampcount']);
|
|
|
}
|
|
@@ -753,11 +894,29 @@ class Home extends Base_Controller {
|
|
|
$cityId = intval($this->input->post('cityId',true));
|
|
|
|
|
|
if (!empty($cityId)) $where['G1.pid'] = $cityId;
|
|
|
- if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
|
|
|
+ if ($role != SYSTEM_ADMIN) {
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where['L.manu = '] = $company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where['L.supplier = '] = $company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where['L.po = '] = $company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where['P.cityid = '] = $company;
|
|
|
+ }
|
|
|
+ }
|
|
|
$where['G1.level'] = 4;
|
|
|
$join = array();
|
|
|
|
|
|
$join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
|
|
|
+ $join[] = ['table'=>'lampinfo as L','cond'=>'L.projectid = P.id','type'=>'left'];
|
|
|
// $join[] = ['table'=>'global_location as G1','cond'=>'G1.id = P.cityid','type'=>'left'];
|
|
|
|
|
|
$list = $this->Global_location_model->get_list_by_join($where, 'G1.id,G1.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G1.id', 'G1');
|
|
@@ -789,7 +948,23 @@ class Home extends Base_Controller {
|
|
|
$where[] = 'P.id in ('.implode(',', $projectIdArr).')';
|
|
|
if ($role != SYSTEM_ADMIN){
|
|
|
$company = $this->get_user_info('company');
|
|
|
- $where[] = 'P.company = '.$company;
|
|
|
+ // $where[] = 'P.company = '.$company;
|
|
|
+ if ($role == 2) {
|
|
|
+ // $filter .= ' AND L.manu = '.$company;
|
|
|
+ $where[] = 'L.manu = '.$company;
|
|
|
+ // $countWhere[] = 'manu = '.$company;
|
|
|
+ }elseif ($role == 3) {
|
|
|
+ // $filter .= ' AND L.supplier = '.$company;
|
|
|
+ // $countWhere[] = 'supplier = '.$company;
|
|
|
+ $where[] = 'L.supplier = '.$company;
|
|
|
+ }elseif ($role == 4) {
|
|
|
+ // $filter .= ' AND L.po = '.$company;
|
|
|
+ // $countWhere[] = 'po = '.$company;
|
|
|
+ $where[] = 'L.po = '.$company;
|
|
|
+ }else {
|
|
|
+ // $filter .= ' AND P.cityid = '.$company;
|
|
|
+ $where[] = 'P.cityid = '.$company;
|
|
|
+ }
|
|
|
$data['project_count'] = $this->Project_model->get_count(['id'=>$projectIdArr,'company'=>$company]);
|
|
|
}else{
|
|
|
$data['project_count'] = count($projectIdArr);
|