|
@@ -405,7 +405,7 @@ class Project extends Base_Controller {
|
|
if (empty($type)) {
|
|
if (empty($type)) {
|
|
if ($role != SYSTEM_ADMIN) $where['company'] = $company;
|
|
if ($role != SYSTEM_ADMIN) $where['company'] = $company;
|
|
|
|
|
|
- $data = $this->Project_model->get_list($where, 'projectname,id',NULL, NULL, 'convert(projectname using gbk) asc', NUll);
|
|
|
|
|
|
+ $data = $this->Project_model->get_list($where, 'projectname,id,lampcount',NULL, NULL, 'convert(projectname using gbk) asc', NUll);
|
|
if (!empty($data)) {
|
|
if (!empty($data)) {
|
|
$temp = array();
|
|
$temp = array();
|
|
foreach ($data as $key => $value) {
|
|
foreach ($data as $key => $value) {
|
|
@@ -413,7 +413,7 @@ class Project extends Base_Controller {
|
|
$temp[$value['id']] = $value;
|
|
$temp[$value['id']] = $value;
|
|
}
|
|
}
|
|
$projectIdArr = array_column($data, 'id');
|
|
$projectIdArr = array_column($data, 'id');
|
|
- $sectionList = $this->Lamp_model->get_list(['projectid'=>$projectIdArr], 'section as name,projectid',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
|
|
|
|
|
|
+ $sectionList = $this->Lamp_model->get_list(['projectid'=>$projectIdArr], 'section as name,projectid,count(*) as lampcount',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
|
|
foreach ($sectionList as $key => $value) {
|
|
foreach ($sectionList as $key => $value) {
|
|
if (isset($temp[$value['projectid']])) {
|
|
if (isset($temp[$value['projectid']])) {
|
|
unset($value['projectid']);
|
|
unset($value['projectid']);
|
|
@@ -434,26 +434,26 @@ class Project extends Base_Controller {
|
|
$join[] = ['table'=>'company as C','cond'=>'L.manu = C.id','type'=>'inner'];
|
|
$join[] = ['table'=>'company as C','cond'=>'L.manu = C.id','type'=>'inner'];
|
|
$group = 'L.manu,L.projectid';
|
|
$group = 'L.manu,L.projectid';
|
|
$order = 'convert(C.name using gbk) asc';
|
|
$order = 'convert(C.name using gbk) asc';
|
|
- $fields = 'C.name as company,P.projectname,P.id,C.id as cId';
|
|
|
|
|
|
+ $fields = 'C.name as company,P.projectname,P.id,C.id as cId,count(*) as lampcount';
|
|
}elseif ($type == 3) {
|
|
}elseif ($type == 3) {
|
|
$sectionWhere = ['supplier !='=>0];
|
|
$sectionWhere = ['supplier !='=>0];
|
|
$join[] = ['table'=>'company as C','cond'=>'L.supplier = C.id','type'=>'inner'];
|
|
$join[] = ['table'=>'company as C','cond'=>'L.supplier = C.id','type'=>'inner'];
|
|
$group = 'L.supplier,L.projectid';
|
|
$group = 'L.supplier,L.projectid';
|
|
$order = 'convert(C.name using gbk) asc';
|
|
$order = 'convert(C.name using gbk) asc';
|
|
- $fields = 'C.name as company,P.projectname,P.id,C.id as cId';
|
|
|
|
|
|
+ $fields = 'C.name as company,P.projectname,P.id,C.id as cId,count(*) as lampcount';
|
|
}elseif ($type == 4) {
|
|
}elseif ($type == 4) {
|
|
$sectionWhere = ['po !='=>0];
|
|
$sectionWhere = ['po !='=>0];
|
|
$join[] = ['table'=>'company as C','cond'=>'L.po = C.id','type'=>'inner'];
|
|
$join[] = ['table'=>'company as C','cond'=>'L.po = C.id','type'=>'inner'];
|
|
$group = 'L.po,L.projectid';
|
|
$group = 'L.po,L.projectid';
|
|
$order = 'convert(C.name using gbk) asc';
|
|
$order = 'convert(C.name using gbk) asc';
|
|
- $fields = 'C.name as company,P.projectname,P.id,C.id as cId';
|
|
|
|
|
|
+ $fields = 'C.name as company,P.projectname,P.id,C.id as cId,count(*) as lampcount';
|
|
}else {
|
|
}else {
|
|
// $sectionWhere = ['upazilla !='=>0];
|
|
// $sectionWhere = ['upazilla !='=>0];
|
|
$join[] = ['table'=>'global_location as G','cond'=>'G.id = P.cityid','type'=>'left'];
|
|
$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'];
|
|
// $join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
|
|
$group = 'P.cityid,p.id';
|
|
$group = 'P.cityid,p.id';
|
|
$order = 'convert(G.english_name using gbk) asc';
|
|
$order = 'convert(G.english_name using gbk) asc';
|
|
- $fields = 'G.english_name as company,P.projectname,P.id,G.id as cId';
|
|
|
|
|
|
+ $fields = 'G.english_name as company,P.projectname,P.id,G.id as cId,count(*) as lampcount';
|
|
}
|
|
}
|
|
|
|
|
|
$data = $this->Lamp_model->get_list_by_join($where, $fields,NULL, NULL, $join, $order, $group, 'L');
|
|
$data = $this->Lamp_model->get_list_by_join($where, $fields,NULL, NULL, $join, $order, $group, 'L');
|
|
@@ -463,11 +463,11 @@ class Project extends Base_Controller {
|
|
foreach ($data as $key => $value) {
|
|
foreach ($data as $key => $value) {
|
|
$value['sectionList'] = array();
|
|
$value['sectionList'] = array();
|
|
$temp[$value['id']] = $value;
|
|
$temp[$value['id']] = $value;
|
|
- $temp2[$value['cId']] = array('company'=>$value['company'],'cId'=>$value['cId'],'projectList'=>array());
|
|
|
|
|
|
+ $temp2[$value['cId']] = array('company'=>$value['company'],'lampcount'=>$value['lampcount'],'cId'=>$value['cId'],'projectList'=>array());
|
|
}
|
|
}
|
|
$projectIdArr = array_column($data, 'id');
|
|
$projectIdArr = array_column($data, 'id');
|
|
$sectionWhere['projectid'] = $projectIdArr;
|
|
$sectionWhere['projectid'] = $projectIdArr;
|
|
- $sectionList = $this->Lamp_model->get_list($sectionWhere, 'section as name,projectid',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
|
|
|
|
|
|
+ $sectionList = $this->Lamp_model->get_list($sectionWhere, 'section as name,projectid,count(*) as lampcount',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
|
|
foreach ($sectionList as $key => $value) {
|
|
foreach ($sectionList as $key => $value) {
|
|
if (isset($temp[$value['projectid']])) {
|
|
if (isset($temp[$value['projectid']])) {
|
|
unset($value['projectid']);
|
|
unset($value['projectid']);
|