wzh 5 yıl önce
ebeveyn
işleme
8c60c0b128
1 değiştirilmiş dosya ile 95 ekleme ve 8 silme
  1. 95 8
      api/application/controllers/Project.php

+ 95 - 8
api/application/controllers/Project.php

@@ -444,29 +444,113 @@ class Project extends Base_Controller {
             $join = [];
             $join[] = ['table'=>'project as P','cond'=>'L.projectid = P.id','type'=>'inner'];
             if ($type == 2) {
-                if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
+                if ($role != SYSTEM_ADMIN) {
+                    if ($role == 2) {
+                        // $filter .= ' AND L.manu = '.$company;
+                        $where['L.manu = '] = $company;
+                        $sectionWhere['L.manu'] = $company;
+                        // $countWhere[] = 'manu = '.$company;
+                    }elseif ($role == 3) {
+                        // $filter .= ' AND L.supplier = '.$company;
+                        // $countWhere[] = 'supplier = '.$company;
+                        $where['L.supplier = '] = $company;
+                        $sectionWhere['L.supplier'] = $company;
+                    }elseif ($role == 4) {
+                        // $filter .= ' AND L.po = '.$company;
+                        // $countWhere[] = 'po = '.$company;
+                        $where['L.po = '] = $company;
+                        $sectionWhere['L.po'] = $company;
+                    }else {
+                        // $filter .= ' AND P.cityid = '.$company;
+                        $where['P.cityid = '] = $company;
+                        $sectionWhere['P.cityid'] = $company;
+                    }
+                }
                 // $sectionWhere = ['manu !='=>0];
                 $join[] = ['table'=>'company as C','cond'=>'L.manu = C.id','type'=>'inner'];
                 $group = 'L.manu,L.projectid';
                 $order = 'convert(C.name using gbk) asc';
                 $fields = 'C.name as company,C.no,P.projectname,P.id,C.id as cId,count(*) as lampcount';
             }elseif ($type == 3) {
-                $sectionWhere = ['supplier'=>$company];
-                if ($role != SYSTEM_ADMIN) $where = ['L.supplier'=>$company];
+                // $sectionWhere = ['supplier'=>$company];
+                if ($role != SYSTEM_ADMIN) {
+                    if ($role == 2) {
+                        // $filter .= ' AND L.manu = '.$company;
+                        $where['L.manu = '] = $company;
+                        $sectionWhere['L.manu'] = $company;
+                        // $countWhere[] = 'manu = '.$company;
+                    }elseif ($role == 3) {
+                        // $filter .= ' AND L.supplier = '.$company;
+                        // $countWhere[] = 'supplier = '.$company;
+                        $where['L.supplier = '] = $company;
+                        $sectionWhere['L.supplier'] = $company;
+                    }elseif ($role == 4) {
+                        // $filter .= ' AND L.po = '.$company;
+                        // $countWhere[] = 'po = '.$company;
+                        $where['L.po = '] = $company;
+                        $sectionWhere['L.po'] = $company;
+                    }else {
+                        // $filter .= ' AND P.cityid = '.$company;
+                        $where['P.cityid = '] = $company;
+                        $sectionWhere['P.cityid'] = $company;
+                    }
+                }
                 $join[] = ['table'=>'company as C','cond'=>'L.supplier = C.id','type'=>'inner'];
                 $group = 'L.supplier,L.projectid';
                 $order = 'convert(C.name using gbk) asc';
                 $fields = 'C.name as company,C.no,P.projectname,P.id,C.id as cId,count(*) as lampcount';
             }elseif ($type == 4) {
-                $sectionWhere = ['po'=>$company];
-                if ($role != SYSTEM_ADMIN) $where = ['L.po'=>$company];
+                // $sectionWhere = ['po'=>$company];
+                if ($role != SYSTEM_ADMIN) {
+                    if ($role == 2) {
+                        // $filter .= ' AND L.manu = '.$company;
+                        $where['L.manu = '] = $company;
+                        $sectionWhere['L.manu'] = $company;
+                        // $countWhere[] = 'manu = '.$company;
+                    }elseif ($role == 3) {
+                        // $filter .= ' AND L.supplier = '.$company;
+                        // $countWhere[] = 'supplier = '.$company;
+                        $where['L.supplier = '] = $company;
+                        $sectionWhere['L.supplier'] = $company;
+                    }elseif ($role == 4) {
+                        // $filter .= ' AND L.po = '.$company;
+                        // $countWhere[] = 'po = '.$company;
+                        $where['L.po = '] = $company;
+                        $sectionWhere['L.po'] = $company;
+                    }else {
+                        // $filter .= ' AND P.cityid = '.$company;
+                        $where['P.cityid = '] = $company;
+                        $sectionWhere['P.cityid'] = $company;
+                    }
+                }
                 $join[] = ['table'=>'company as C','cond'=>'L.po = C.id','type'=>'inner'];
                 $group = 'L.po,L.projectid';
                 $order = 'convert(C.name using gbk) asc';
                 $fields = 'C.name as company,C.no,P.projectname,P.id,C.id as cId,count(*) as lampcount';
             }else {
                 // $sectionWhere = ['upazilla !='=>0];
-                if ($role != SYSTEM_ADMIN) $where = ['P.cityid'=>$company];
+                if ($role != SYSTEM_ADMIN) {
+                    if ($role == 2) {
+                        // $filter .= ' AND L.manu = '.$company;
+                        $where['L.manu = '] = $company;
+                        $sectionWhere['L.manu'] = $company;
+                        // $countWhere[] = 'manu = '.$company;
+                    }elseif ($role == 3) {
+                        // $filter .= ' AND L.supplier = '.$company;
+                        // $countWhere[] = 'supplier = '.$company;
+                        $where['L.supplier = '] = $company;
+                        $sectionWhere['L.supplier'] = $company;
+                    }elseif ($role == 4) {
+                        // $filter .= ' AND L.po = '.$company;
+                        // $countWhere[] = 'po = '.$company;
+                        $where['L.po = '] = $company;
+                        $sectionWhere['L.po'] = $company;
+                    }else {
+                        // $filter .= ' AND P.cityid = '.$company;
+                        $where['P.cityid = '] = $company;
+                        $sectionWhere['P.cityid'] = $company;
+                    }
+                }
                 $join[] = ['table'=>'global_location as G','cond'=>'G.id = P.cityid','type'=>'left'];
                 // $join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
                 $group = 'P.cityid,p.id';
@@ -491,8 +575,11 @@ class Project extends Base_Controller {
                     
                 }
                 $projectIdArr = array_column($data, 'id');
-                $sectionWhere['projectid'] = $projectIdArr;
-                $sectionList = $this->Lamp_model->get_list($sectionWhere, 'section as name,projectid,count(*) as lampcount',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
+                $sectionWhere['L.projectid'] = $projectIdArr;
+                // $sectionList = $this->Lamp_model->get_list($sectionWhere, 'section as name,projectid,count(*) as lampcount',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
+                $join = array();
+                $join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
+                $sectionList = $this->Lamp_model->get_list_by_join($sectionWhere, 'L.section as name,L.projectid,count(*) as lampcount',NULL, NULL,$join, 'convert(L.section using gbk) asc', 'L.projectid,L.section','L');
                 foreach ($sectionList as $key => $value) {
                     if (isset($temp[$value['projectid']])) {
                         unset($value['projectid']);