diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 8f3d37a4..590a6d87 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', 'getDashBoardMaster'); // 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/config/routes.php b/api/application/config/routes.php index 81f8965a..1738a90e 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -151,6 +151,8 @@ $route['getAnswersForPD'] = 'PD_Controller/getAnswersForPD'; $route['checkOTP'] = 'PD_Controller/checkOTP'; //Dashboard and Reports Related routes -$route['getDashBoardMaster'] = 'Dash_Board_Controller/getDetailsOfPDTypeAndPDStatusWithDayWeekMonth'; +$route['getDashBoardMaster'] = 'Dash_Board_Controller/getDashBoardDetailsOfPDTypeAndPDStatusWithDayWeekMonth'; +$route['getDashBoardLenderCity'] = 'Dash_Board_Controller/getDashBoardDetailsOfLenderAndCitywise'; +$route['getDashBoardDetailsOfCity'] = 'Dash_Board_Controller/getDashBoardDetailsOfCitywise'; diff --git a/api/application/controllers/Dash_Board_Controller.php b/api/application/controllers/Dash_Board_Controller.php index 022d4619..00093c57 100644 --- a/api/application/controllers/Dash_Board_Controller.php +++ b/api/application/controllers/Dash_Board_Controller.php @@ -21,7 +21,7 @@ class Dash_Board_Controller extends REST_Controller { } - public function getDetailsOfPDTypeAndPDStatusWithDayWeekMonth_get() + public function getDashBoardDetailsOfPDTypeAndPDStatusWithDayWeekMonth_get() { $res = $this->Dash_Board_Model->getDetailsOfPDTypeAndPDStatusWithDayWeekMonth(); @@ -31,7 +31,7 @@ class Dash_Board_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } - public function getDetailsOfLenderAndCitywise_get() + public function getDashBoardDetailsOfLenderAndCitywise_get() { $res = $this->Dash_Board_Model->getDetailsOfLenderAndCitywise(); @@ -40,5 +40,15 @@ class Dash_Board_Controller extends REST_Controller { $data['records'] = $res; $this->response($data,REST_Controller::HTTP_OK); } + + public function getDashBoardDetailsOfCitywise_get() + { + $res = $this->Dash_Board_Model->getDashBoardDetailsOfCitywise(); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res; + $this->response($data,REST_Controller::HTTP_OK); + } } \ No newline at end of file diff --git a/api/application/models/Dash_Board_Model.php b/api/application/models/Dash_Board_Model.php index c6109225..26807d84 100644 --- a/api/application/models/Dash_Board_Model.php +++ b/api/application/models/Dash_Board_Model.php @@ -13,26 +13,62 @@ class Dash_Board_Model extends SPARQ_Model { public function getDetailsOfPDTypeAndPDStatusWithDayWeekMonth() { - $sql_query_current_day = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count FROM sine_edge_test.t_pd_triggered where date_format(createdon,'%Y-%m-%d') = date_format(CURDATE(),'%Y-%m-%d') group by fk_pd_type,pd_status;"; + $sql_query_current_day = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count FROM t_pd_triggered where date_format(createdon,'%Y-%m-%d') = date_format(CURDATE(),'%Y-%m-%d') group by fk_pd_type,pd_status;"; $result_data['current_day'] = $this->db->query($sql_query_current_day)->result_array(); - $sql_query_current_week = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count,WEEK(createdon),WEEK(CURDATE()) FROM sine_edge_test.t_pd_triggered where WEEK(createdon) = WEEK(CURDATE()) group by fk_pd_type,pd_status;"; + $sql_query_current_week = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count,WEEK(createdon),WEEK(CURDATE()) FROM t_pd_triggered where WEEK(createdon) = WEEK(CURDATE()) group by fk_pd_type,pd_status;"; $result_data['current_week'] = $this->db->query($sql_query_current_week)->result_array(); - $sql_query_current_month = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count FROM sine_edge_test.t_pd_triggered where MONTH(createdon) = MONTH(CURDATE()) group by fk_pd_type,pd_status;"; + $sql_query_current_month = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count FROM t_pd_triggered where MONTH(createdon) = MONTH(CURDATE()) group by fk_pd_type,pd_status;"; $result_data['current_month'] = $this->db->query($sql_query_current_month)->result_array(); return $result_data; } public function getDetailsOfLenderAndCitywise() { - $sql_query_current_day = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count FROM sine_edge_test.t_pd_triggered where date_format(createdon,'%Y-%m-%d') = date_format(CURDATE(),'%Y-%m-%d') group by fk_pd_type,pd_status;"; + $sql_query_current_day = "SELECT pd.fk_lender_id,entity.full_name,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_entity as entity on pd.fk_lender_id = entity.entity_id + JOIN m_city as city on pd.fk_city = city.city_id + where date_format(pd.createdon,'%Y-%m-%d') = date_format(CURDATE(),'%Y-%m-%d') + group by pd.fk_lender_id,pd.fk_city,pd.fk_pd_type,pd.pd_status;"; $result_data['current_day'] = $this->db->query($sql_query_current_day)->result_array(); - $sql_query_current_week = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count,WEEK(createdon),WEEK(CURDATE()) FROM sine_edge_test.t_pd_triggered where WEEK(createdon) = WEEK(CURDATE()) group by fk_pd_type,pd_status;"; + $sql_query_current_week = "SELECT pd.fk_lender_id,entity.full_name,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_entity as entity on pd.fk_lender_id = entity.entity_id + JOIN m_city as city on pd.fk_city = city.city_id + where WEEK(pd.createdon) = WEEK(CURDATE()) + group by pd.fk_lender_id,pd.fk_city,pd.fk_pd_type,pd.pd_status;"; $result_data['current_week'] = $this->db->query($sql_query_current_week)->result_array(); - $sql_query_current_month = "SELECT if(fk_pd_type = 1,'FULL',if(fk_pd_type = 2,'SMART',if(fk_pd_type = 3,'TELE','NULL'))) as PDTYPE,pd_status,count(*) as count FROM sine_edge_test.t_pd_triggered where MONTH(createdon) = MONTH(CURDATE()) group by fk_pd_type,pd_status;"; + $sql_query_current_month = "SELECT pd.fk_lender_id,entity.full_name,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_entity as entity on pd.fk_lender_id = entity.entity_id + JOIN m_city as city on pd.fk_city = city.city_id + where MONTH(pd.createdon) = MONTH(CURDATE()) + group by pd.fk_lender_id,pd.fk_city,pd.fk_pd_type,pd.pd_status;"; + $result_data['current_month'] = $this->db->query($sql_query_current_month)->result_array(); + return $result_data; + } + + + public function getDashBoardDetailsOfCitywise() + { + $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;"; + + $result_data['current_day'] = $this->db->query($sql_query_current_day)->result_array(); + + $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;"; + $result_data['current_week'] = $this->db->query($sql_query_current_week)->result_array(); + + $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;"; $result_data['current_month'] = $this->db->query($sql_query_current_month)->result_array(); return $result_data; }