load->model('Entity_Management_Model'); $this->load->library('AWS_S3'); } public function listAllEntites_get() { $page = 0;$limit = 0;$sort = 'ASC';$entity_type_id = ''; if($this->get('page')) { $page = $this->get('page'); } if($this->get('limit')){ $limit = $this->get('limit'); } if($this->get('sort')) { $sort = $this->get('sort'); } if($this->get('etid')) { $entity_type_id = $this->get('etid'); } $result = $this->Entity_Management_Model->listAllEntities($page,$limit,$sort,$entity_type_id); if($result['data_status']) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result['data']; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } public function saveNewEntity_post() { //print_r($this->post()); $records = ""; $entity_child = ""; $entity_id = ""; if($this->post('records')){ $records = $this->post('records'); } //print_r(); if(array_key_exists('entity_child',$records)) { $entity_child = $records['entity_child']; unset($records['entity_child']); } if($records != "") { $entity_id = $this->Entity_Management_Model->saveRecords($records,ENTITY);//insert user records and get userid } if($entity_child != "") { foreach($entity_child as $child) { $entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$entity_id,'createdon'=>$records['createdon'],'fk_createdby'=>$records['fk_createdby']); $this->Entity_Management_Model->saveRecords($entity_child_array,ENTITYCHILD); } } if($entity_id != '' || $entity_id != null) { // If New Entity is Lender(2) type, then create a S3 bucket for corresponding lender. if($records['fk_entity_type_id'] == 2) { //echo "LENDER TYPE"; $bucket_name = LENDER_BUCKET_NAME_PREFIX.$entity_id; $bucket_status = $this->aws_s3->createNewBucket($bucket_name); //print_r($bucket_status); } } if($entity_id != '' || $entity_id != null) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['record'] = $entity_id; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } public function saveExistEntity_post() { $records = ""; $entity_child = ""; $entity_id = ""; if($this->post('records')){ $records = $this->post('records'); } if(array_key_exists('entity_child',$records)) { $entity_child = $records['entity_child']; unset($records['entity_child']); } if($records != "") { $where_condition_array = array('entity_id' => $records['entity_id']); $entity_id = $this->Entity_Management_Model->updateRecords($records,ENTITY,$where_condition_array); } if($entity_child != "") { foreach($entity_child as $child) { if($child['entity_child_id'] != "" || $child['entity_child_id'] != null) { $entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'updatedon'=>$records['updatedon'],'fk_updatedby'=>$records['fk_updatedby'],'isactive'=>$child['isactive']); $where_condition_array = array('entity_child_id'=>$child['entity_child_id']); $this->Entity_Management_Model->updateRecords($entity_child_array,ENTITYCHILD,$where_condition_array); } else { $entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$records['entity_id'],'createdon'=>$records['updatedon'],'fk_createdby'=>$records['fk_updatedby']); $this->Entity_Management_Model->saveRecords($entity_child_array,ENTITYCHILD); } } } if($entity_id != '' || $entity_id != null) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['record'] = $entity_id; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } /* * Get Location Hierarchy as Region,state,city, and branch - wrapped as one array */ public function getLocationHierarchy_get() { $fields = array('region_id','name as region_name'); $where_condition_array = array('isactive' => 1); $region_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,REGIONS); if(count($region_data)) { foreach($region_data as $region_key => $region) { $fields = array('state_id','name as state_name','code'); $where_condition_array = array('isactive' => 1,'fk_region_id'=>$region['region_id']); $state_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,STATE); if(count($state_data)) { foreach($state_data as $state_key => $state) { $fields = array('city_id','name as city_name'); $where_condition_array = array('isactive' => 1,'fk_state_id' => $state['state_id']); $city_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,CITY); if(count($city_data)) { foreach($city_data as $city_key => $city) { $fields = array('branch_id','name as branch_name'); $where_condition_array = array('isactive' => 1,'fk_city_id' => $city['city_id']); $branch_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,BRANCH); $city_data[$city_key]['branch_data'] = $branch_data; } $state_data[$state_key]['city_data'] = $city_data; } } $region_data[$region_key]['state_data'] = $state_data; } } } if(count($region_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $region_data; $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); } } /****** Get All Entity Billing Info and it's contact info @param entity id******/ public function getEntityBillingInfo_get() { $entity_id = ""; if($this->get('eid')) { $entity_id = $this->get('eid'); } if( $entity_id != "" || $entity_id != null) { $result = $this->Entity_Management_Model->getEntityBillingInfo($entity_id); if(count($result)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } } public function getEntityMasterInfo_get() { $entity_id = ""; if($this->get('eid')) { $entity_id = $this->get('eid'); } if( $entity_id != "" || $entity_id != null) { // $columns = array('ENTITY.entity_id, ENTITY.full_name, ENTITY.short_name'); // $table = array(''); // $joins = array(); // $where_condition_array = array(); $result = $this->Entity_Management_Model->listAllEntities(0,0,0,0,$entity_id); if(count($result)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } } }