|
@@ -502,8 +502,9 @@ class Project extends Base_Controller {
|
|
|
$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';
|
|
|
+ $fields2 = 'L.manu as cId';
|
|
|
}elseif ($type == 3) {
|
|
|
- // $sectionWhere = ['supplier'=>$company];
|
|
|
+
|
|
|
if ($role != SYSTEM_ADMIN) {
|
|
|
if ($role == 2) {
|
|
|
// $filter .= ' AND L.manu = '.$company;
|
|
@@ -515,11 +516,15 @@ class Project extends Base_Controller {
|
|
|
// $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;
|
|
|
+ $where['L.supplier !='] = 0;
|
|
|
$sectionWhere['L.po'] = $company;
|
|
|
+ $sectionWhere['supplier !='] = 0;
|
|
|
+ // $sectionWhere['supplier !='] = '';
|
|
|
}else {
|
|
|
// $filter .= ' AND P.cityid = '.$company;
|
|
|
$where['P.cityid = '] = $company;
|
|
@@ -530,6 +535,7 @@ class Project extends Base_Controller {
|
|
|
$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';
|
|
|
+ $fields2 = 'L.supplier as cId';
|
|
|
}elseif ($type == 4) {
|
|
|
// $sectionWhere = ['po'=>$company];
|
|
|
if ($role != SYSTEM_ADMIN) {
|
|
@@ -558,6 +564,7 @@ class Project extends Base_Controller {
|
|
|
$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';
|
|
|
+ $fields2 = 'L.po as cId';
|
|
|
}else {
|
|
|
// $sectionWhere = ['upazilla !='=>0];
|
|
|
if ($role != SYSTEM_ADMIN) {
|
|
@@ -587,6 +594,7 @@ class Project extends Base_Controller {
|
|
|
$group = 'P.cityid,p.id';
|
|
|
$order = 'convert(G.english_name using gbk) asc';
|
|
|
$fields = 'G.english_name as company,P.projectname,P.id,G.id as cId,count(*) as lampcount';
|
|
|
+ $fields2 = 'P.cityid as cId';
|
|
|
}
|
|
|
// var_dump($where);die;
|
|
|
$data = $this->Lamp_model->get_list_by_join($where, $fields,NULL, NULL, $join, $order, $group, 'L');
|
|
@@ -607,28 +615,55 @@ class Project extends Base_Controller {
|
|
|
}
|
|
|
$projectIdArr = array_column($data, 'id');
|
|
|
$sectionWhere['L.projectid'] = $projectIdArr;
|
|
|
- $sectionWhere['L.section !='] = '';
|
|
|
+ // $sectionWhere['L.section !='] = '';
|
|
|
// var_dump($sectionWhere);die;
|
|
|
// array(2) { ["L.po"]=> string(3) "144" ["L.projectid"]=> array(8) { [0]=> string(2) "20" [1]=> string(2) "28" [2]=> string(2) "43" [3]=> string(2) "20" [4]=> string(2) "39" [5]=> string(2) "28" [6]=> string(2) "42" [7]=> string(2) "51" } }
|
|
|
// "projectid = 28 AND supplier = 116 AND po = 144 AND section = "1234""
|
|
|
// $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');
|
|
|
+ $sectionList = $this->Lamp_model->get_list_by_join($sectionWhere, 'L.section as name,L.projectid,count(*) as lampcount,'.$fields2,NULL, NULL,$join, 'convert(L.section using gbk) asc', $group.',L.section','L');
|
|
|
foreach ($sectionList as $key => $value) {
|
|
|
- if (isset($temp[$value['projectid']])) {
|
|
|
- unset($value['projectid']);
|
|
|
- $temp[$sectionList[$key]['projectid']]['sectionList'][] = $value;
|
|
|
+ if (isset($temp2[$value['cId']])) {
|
|
|
+ if (!isset($temp2[$value['cId']]['projectList'][$value['projectid']]['sectionList'])) {
|
|
|
+ $temp2[$value['cId']]['projectList'][$value['projectid']]['sectionList'] = array();
|
|
|
+ }
|
|
|
+ $temp2[$value['cId']]['projectList'][$value['projectid']]['sectionList'][] = $value;
|
|
|
+ // var_dump($value);
|
|
|
}
|
|
|
+ // if (isset($temp[$value['projectid']])) {
|
|
|
+ // unset($value['projectid']);
|
|
|
+ // $temp[$sectionList[$key]['projectid']]['sectionList'][] = $value;
|
|
|
+ // }
|
|
|
}
|
|
|
- $temp = array_values($temp);
|
|
|
- foreach ($temp as $key => $value) {
|
|
|
- if (isset($temp2[$value['cId']])) {
|
|
|
- unset($value['cId']);
|
|
|
- unset($value['company']);
|
|
|
- $temp2[$temp[$key]['cId']]['projectList'][] = $value;
|
|
|
+ // $temp = array_values($temp);
|
|
|
+ // foreach ($temp as $key => $value) {
|
|
|
+ // if (isset($temp2[$value['cId']])) {
|
|
|
+ // unset($value['cId']);
|
|
|
+ // unset($value['company']);
|
|
|
+ // $temp2[$temp[$key]['cId']]['projectList'][] = $value;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ foreach ($temp2 as $key => $value) {
|
|
|
+ foreach ($value['projectList'] as $key2 => $value2) {
|
|
|
+ foreach ($value2['sectionList'] as $k => $sec) {
|
|
|
+ if (empty($sec['name'])) {
|
|
|
+ unset($value2['sectionList'][$k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $temp2[$key]['projectList'][$key2]['sectionList'] = array_values($value2['sectionList']);
|
|
|
+ if (isset($temp[$key2])) {
|
|
|
+ $temp2[$key]['projectList'][$key2]['projectname'] = $temp[$key2]['projectname'];
|
|
|
+ $temp2[$key]['projectList'][$key2]['id'] = $temp[$key2]['id'];
|
|
|
+ $temp2[$key]['projectList'][$key2]['lampcount'] = $temp[$key2]['lampcount'];
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+ foreach ($temp2 as $key => $value) {
|
|
|
+ $temp2[$key]['projectList'] = array_values($value['projectList']);
|
|
|
+ }
|
|
|
+
|
|
|
$data = array_values($temp2);
|
|
|
}
|
|
|
if ($this->os == 2) {
|