diff --git a/api/application/config/constants.php b/api/application/config/constants.php index b52f5cae..a33ca1c0 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', 'getCityHierarchy'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'saveEntityRegionMapping'); // 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 a006ba8c..a0538a77 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -124,6 +124,7 @@ $route['getLocationHierarchy'] = 'Entity_Management_Controller/getLocationHierar $route['getEntityMasterInfo'] = 'Entity_Management_Controller/getEntityMasterInfo'; $route['saveEntityBillingInfo'] = 'Entity_Management_Controller/saveEntityBillingInfo'; $route['getCityHierarchy'] = 'Entity_Management_Controller/getCityHierarchy'; +$route['saveEntityRegionMapping'] = 'Entity_Management_Controller/saveEntityRegionMapping'; //PD RELATED $route['triggerNewPD'] = 'PD_Controller/triggerNewPD'; diff --git a/api/application/controllers/Entity_Management_Controller.php b/api/application/controllers/Entity_Management_Controller.php index 2dd1e9a2..b087df57 100644 --- a/api/application/controllers/Entity_Management_Controller.php +++ b/api/application/controllers/Entity_Management_Controller.php @@ -371,24 +371,44 @@ class Entity_Management_Controller extends REST_Controller { * Save Entity Regions Mapping , //fk_region_id, fk_city_id, fk_entity_id, createdon, fk_createdby, updatedon, fk_updatedby */ - public function SaveEntityRegionMapping_post() + public function saveEntityRegionMapping_post() { - // $records = $this->post('records'); + $count = 0; + $records = $this->post('records'); + + foreach($records as $key => $record) + { + + if($record['entity_region_map_id'] != null || $record['entity_region_map_id'] != "") + { + + $where_condition_array = array('entity_region_map_id' => $record['entity_region_map_id']); + $entity_region_map_id = $this->Entity_Management_Model->updateRecords($record,ENTITYREGION,$where_condition_array); + if($entity_region_map_id != "" || $entity_region_map_id != null){ $count++; } + } + else + { + + $entity_region_map_id = $this->Entity_Management_Model->saveRecords($record,ENTITYREGION); + if($entity_region_map_id != "" || $entity_region_map_id != null){ $count++; } + } + } + + if(count($records) == $count) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Records Not Found'; + $this->response($data,REST_Controller::HTTP_OK); + } - // foreach($records as $key => $record) - // { - // if($record['entity_region_map_id'] != "" || $record['entity_region_map_id'] != null) - // { - // $where_condition_array = array('entity_region_map_id' => $record['entity_region_map_id']); - // $entity_region_map_id = $this->Entity_Management_Model->updateRecords($record,ENTITYREGION,$where_condition_array); - // if($entity_region_map_id != "" || $entity_region_map_id != null){ $count++; } - // } - // else - // { - // $entity_region_map_id = $this->Entity_Management_Model->saveRecords($record,ENTITYREGION,$where_condition_array); - // if($entity_region_map_id != "" || $entity_region_map_id != null){ $count++; } - // } - // } } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 3340936d..deb7ed8c 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -325,7 +325,7 @@ class PD_Model extends SPARQ_Model { } } - //$result_data['child'] = array('Hi'=>'Welcome'); + $result_data['child'] = array('testkey'=>'testvalue'); $result_data['master'] = $actual_logs; // Child History Start