diff --git a/api/application/config/constants.php b/api/application/config/constants.php index cc9c0395..3c529f5a 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -87,7 +87,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto // define login route name for token verification //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllTemplates/:any)'); // no errors -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getDashBoardLenderCity'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getDashBoardDetailsOfCity'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); diff --git a/api/application/controllers/Dash_Board_Controller.php b/api/application/controllers/Dash_Board_Controller.php index 2c6085ab..e4e10373 100644 --- a/api/application/controllers/Dash_Board_Controller.php +++ b/api/application/controllers/Dash_Board_Controller.php @@ -34,7 +34,7 @@ class Dash_Board_Controller extends REST_Controller { public function getDashBoardDetailsOfLenderAndCitywise_get() { $res = $this->Dash_Board_Model->getDetailsOfLenderAndCitywise(); - print_r($res); die(); + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $res; diff --git a/api/application/models/Dash_Board_Model.php b/api/application/models/Dash_Board_Model.php index aa1aa506..53f7a95e 100644 --- a/api/application/models/Dash_Board_Model.php +++ b/api/application/models/Dash_Board_Model.php @@ -60,24 +60,25 @@ class Dash_Board_Model extends SPARQ_Model { $sql_query_current_day = "SELECT pd.fk_city,city.name as city_name,if(pd.fk_pd_type = 1,'FULL',if(pd.fk_pd_type = 2,'SMART',if(pd.fk_pd_type = 3,'TELE','OTHERS'))) as PDTYPE,pd.pd_status,count(*) as count FROM t_pd_triggered as pd JOIN m_city as city on pd.fk_city = city.city_id where date_format(pd.createdon,'%Y-%m-%d') = date_format('31-10-2018','%Y-%m-%d') - group by pd.fk_city,pd.fk_pd_type,pd.pd_status;"; + group by pd.fk_city,pd.fk_pd_type;"; $result_data['current_day'] = $this->db->query($sql_query_current_day)->result_array(); + $result_data['current_day'] = $this->groupgDashBoardDetailsOfCitywiseData($result_data['current_day']); $sql_query_current_week = "SELECT pd.fk_city,city.name as city_name,if(pd.fk_pd_type = 1,'FULL',if(pd.fk_pd_type = 2,'SMART',if(pd.fk_pd_type = 3,'TELE','OTHERS'))) as PDTYPE,pd.pd_status,count(*) as count FROM t_pd_triggered as pd JOIN m_city as city on pd.fk_city = city.city_id where WEEK(pd.createdon) = WEEK(CURDATE()) - group by pd.fk_city,pd.fk_pd_type,pd.pd_status;"; + group by pd.fk_city,pd.fk_pd_type;"; $result_data['current_week'] = $this->db->query($sql_query_current_week)->result_array(); - + $result_data['current_week'] = $this->groupgDashBoardDetailsOfCitywiseData($result_data['current_week']); $sql_query_current_month = "SELECT pd.fk_city,city.name as city_name,if(pd.fk_pd_type = 1,'FULL',if(pd.fk_pd_type = 2,'SMART',if(pd.fk_pd_type = 3,'TELE','OTHERS'))) as PDTYPE,pd.pd_status,count(*) as count FROM t_pd_triggered as pd JOIN m_city as city on pd.fk_city = city.city_id where MONTH(pd.createdon) = MONTH(CURDATE()) - group by pd.fk_city,pd.fk_pd_type,pd.pd_status;"; + group by pd.fk_city,pd.fk_pd_type;"; $result_data['current_month'] = $this->db->query($sql_query_current_month)->result_array(); - //print_r($result_data['current_month']); + $result_data['current_month'] = $this->groupgDashBoardDetailsOfCitywiseData($result_data['current_month']); return $result_data; @@ -134,5 +135,35 @@ class Dash_Board_Model extends SPARQ_Model { return $array; } + //for Internal purpose + public function groupgDashBoardDetailsOfCitywiseData($arrayOfData) + { + + + $pre_city = ""; + $array = array(); + $fkey = ""; + foreach($arrayOfData as $key => $d) + { + //print_r($d); + + if($d['fk_city'] != $pre_city) + { + //echo "New"; + $array[$key] = array('city_name'=>$d['city_name'],$d['PDTYPE'] => $d['count']); + $pre_city = $d['fk_city']; + $fkey = $key; + } + else + { + //echo "OLd"; + $array[$fkey] = array_merge($array[$fkey],array($d['PDTYPE'] => $d['count'])); + + $pre_city = $d['fk_city']; + } + } + return $array; + } + } \ No newline at end of file