diff --git a/api/application/config/routes.php b/api/application/config/routes.php index b08b690a..6c2cac2b 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -68,6 +68,9 @@ $route['getListOfState'] = 'Common_Masters_Controller/getListOfState'; $route['getListOfCity'] = 'Common_Masters_Controller/getListOfCity'; $route['getPDNotificationsList'] = 'Common_Masters_Controller/getPDNotificationsList'; $route['getListOfPDTeam'] = 'Common_Masters_Controller/getListOfPDTeam'; +$route['getPdManage'] = 'Common_Masters_Controller/getPdManage'; +$route['savePdTeamManage'] = 'Common_Masters_Controller/savePdTeamManage'; + $route['getListOfPDTeamMap'] = 'Common_Masters_Controller/getListOfPDTeamMap'; $route['getListOfMaster'] = 'Common_Masters_Controller/getListOfMaster'; $route['saveMaster'] = 'Common_Masters_Controller/saveMaster'; diff --git a/api/application/controllers/Common_Masters_Controller.php b/api/application/controllers/Common_Masters_Controller.php index c1308238..0ee7c36c 100644 --- a/api/application/controllers/Common_Masters_Controller.php +++ b/api/application/controllers/Common_Masters_Controller.php @@ -235,6 +235,118 @@ class Common_Masters_Controller extends REST_Controller { /* End of State Listing */ /* For City Listing */ + /** + * Get PD Manage Function + * sriram + */ + public function getPdManage_get() + { + + + + + $columns = array("*"); + $table = PDTEAM. ' as PDTEAM'; + $joins = array( + array('table'=>ENTITY.' as ENTITY', + 'condition'=>'ENTITY.entity_id = PDTEAM.fk_lender_id and PDTEAM.isactive =1','jointype'=>'JOIN'), + ); + $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); + + if(count($result) !=0){ + foreach($result as $index=>$res){ + /**CUSTOMERSEGMENT */ + $columns = array("CUSTOMERSEGMENT.*"); + $table = PDTEAMCUSTOMERSEGMENT. ' as PDTEAMCUSTOMERSEGMENT'; + $joins = array( + array('table'=>CUSTOMERSEGMENT.' as CUSTOMERSEGMENT', + 'condition'=>'PDTEAMCUSTOMERSEGMENT.fk_cs_id = CUSTOMERSEGMENT.customer_segment_id and CUSTOMERSEGMENT.isactive =1','jointype'=>'JOIN'), + ); + $where_condition_array = array('PDTEAMCUSTOMERSEGMENT.fk_pdteam_id'=>$res['pdteam_id']); + $result[$index]['CUSTOMERSEGMENT'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + /**CITY */ + $columns = array("CITY.name"); + $table = PDTEAMCITY.' as PDTEAMCITY'; + $joins = array( + array('table'=>CITY.' as CITY','condition'=>'PDTEAMCITY.fk_city_id = CITY.city_id and CITY.isactive = 1','jointype'=>'JOIN') + ); + $where_condition_array = array('PDTEAMCITY.fk_pdteam_id'=>$res['pdteam_id']); + $result[$index]['CITYMAP'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + /**PRODUCT */ + $columns = array("PRODUCTS.name"); + $table = PDTEAMPRODUCT.' as PDTEAMPRODUCT'; + $joins = array( + array('table'=>PRODUCTS.' as PRODUCTS', + 'condition'=>'PDTEAMPRODUCT.fk_product_id = PRODUCTS.product_id and PRODUCTS.isactive =1','jointype'=>'JOIN') + + ); + $where_condition_array = array('PDTEAMPRODUCT.fk_pdteam_id'=>$res['pdteam_id']); + $result[$index]['PRODUCTS'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + /**USERPROFILE */ + + $columns = array("USERPROFILE.userid,concat(USERPROFILE.first_name,' ',USERPROFILE.last_name)as user_full_name"); + $table = USERPROFILE.' as USERPROFILE'; + $joins = array( + array('table'=>PDOFFICIERSDETAILS.' as PDOFFICIERSDETAILS','condition'=>'USERPROFILE.userid = PDOFFICIERSDETAILS.fk_user_id and USERPROFILE.isactive =1','jointype'=>'JOIN') + ); + $where_condition_array = array('PDOFFICIERSDETAILS.fk_team_id'=>$res['pdteam_id']); + $result[$index]['USERPROFILE'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + } + + } + + if(count($result) > 0) + { + $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); + } + } + /** + * Save PD Team Manage + * by sriram + */ + + public function savePdTeamManage_post() + { + $records = $this->post('records'); + // print_r($records);die; + if(!empty($records)) + { + foreach($records['teamDetails'] as $users) + { + $record['fk_user_id'] = $users['userid']; + $record['fk_team_id'] = $users['newTeamName']; + $record['updatedon'] = $records['updatedon']; + $record['fk_updatedby'] = $records['fk_updatedby']; + $where_condition_array = array('fk_user_id' => $record['fk_user_id']); + $result = $this->Common_Masters_Model->updateRecords($record,PDOFFICIERSDETAILS,$where_condition_array); + } + } + if(count($result) > 0) + { + $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); + } + } + /** + * End of the Function + */ public function getListOfCity_get(){ $columns = array('m_states.name as state_name','CITY.*'); $table = CITY.' as CITY'; diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php index 5d6321f9..25ff2284 100644 --- a/api/application/controllers/User_Management_Controller.php +++ b/api/application/controllers/User_Management_Controller.php @@ -25,7 +25,7 @@ class User_Management_Controller extends REST_Controller { public function listAllUsers_get() { //echo "function"; - + $result = $this->User_Management_Model->listAllUsers(); //echo "result"; if($result['data_status']) @@ -128,10 +128,24 @@ class User_Management_Controller extends REST_Controller { // } // } //print_r($pdofficer);die; - if($pdofficer != ""){ + if(array_key_exists('fk_entity_type_id',$records)) + { + $entity_id = $records['fk_entity_type_id']; + $roles = $roles['user_role']; + if($entity_id ==1 && $roles == 5 || $roles ==4){ + if($roles == 5) + { + $pdofficer['fk_pd_type_id'] = 1; + }else if($roles == 4) + { + $pdofficer['fk_pd_type_id'] = 2; + } + $pdofficer['fk_user_id'] = $user_id; //print_r($pdofficer); $this->User_Management_Model->saveRecords($pdofficer,PDOFFICIERSDETAILS); + + } } if($user_id != '' || $user_id != null) { @@ -237,10 +251,28 @@ class User_Management_Controller extends REST_Controller { - - if($pdofficer != ""){ - $this->User_Management_Model->updateRecords($pdofficer,PDOFFICIERSDETAILS,$pdofficer['fk_user_id']); + // print_r($records); + // print_r($roles);die; + if(array_key_exists('fk_entity_type_id',$records)) + { + + $entity_id = $records['fk_entity_type_id']; + $roles = $roles['user_role']; + + if($entity_id ==1 && $roles == 5 || $roles ==4){ + if($roles == 5) + { + $pdofficer['fk_pd_type_id'] = 1; + }else if($roles == 4) + { + $pdofficer['fk_pd_type_id'] = 2; + } + //print_r($pdofficer);die; + //print_r($pdofficer);die; + $arr = array('fk_user_id'=>$pdofficer['fk_user_id']); + $this->User_Management_Model->updateRecords($pdofficer,PDOFFICIERSDETAILS,$arr); } + } if($modified != '' || $modified != null || $modified != 0) { diff --git a/api/application/libraries/SPARQ_Model.php b/api/application/libraries/SPARQ_Model.php index 72b128bf..ce896237 100644 --- a/api/application/libraries/SPARQ_Model.php +++ b/api/application/libraries/SPARQ_Model.php @@ -39,6 +39,7 @@ class SPARQ_Model extends CI_Model { { $data = $this->db->update($table_name,$record_data,$where_condition_array); + if($print_query == 1) { print_r($this->db->last_query()); diff --git a/api/application/models/Common_Masters_Model.php b/api/application/models/Common_Masters_Model.php index 6840b1eb..b8816978 100644 --- a/api/application/models/Common_Masters_Model.php +++ b/api/application/models/Common_Masters_Model.php @@ -19,20 +19,20 @@ class Common_Masters_Model extends SPARQ_Model { /** * This Function is used to Get The PD Team Related Datas for Listing */ - public function pdteamlist(){ + // public function pdteamlist(){ - $result = $this->db->get(PDTEAM)->result_array(); + // $result = $this->db->get(PDTEAM)->result_array(); - if(count($result) !=0){ - foreach($result as $key=> $r){ + // if(count($result) !=0){ + // foreach($result as $key=> $r){ - $cities = $this->db->get_where(PDTEAMMAP,array('fk_team_id'=>$r['pdteam_id']))->result_array(); - array_push($result[$key],$cities); - } - } + // $cities = $this->db->get_where(PDTEAMMAP,array('fk_team_id'=>$r['pdteam_id']))->result_array(); + // array_push($result[$key],$cities); + // } + // } - return $result; - } + // return $result; + // } /** * This Function is used to Delete The Datas diff --git a/api/application/models/User_Management_Model.php b/api/application/models/User_Management_Model.php index 70aacaa0..5dad00eb 100644 --- a/api/application/models/User_Management_Model.php +++ b/api/application/models/User_Management_Model.php @@ -12,10 +12,10 @@ class User_Management_Model extends SPARQ_Model { public function listAllUsers() { - + $result_data = array(); - $this->db->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no, USERPROFILE.profilepic, USERPROFILE.createdon, USERPROFILE.fk_createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as created_full_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name)as update_full_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_team_id,USERPROFILEROLES.user_role,USERPROFILE.fk_entity_type_id'); + $this->db->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no, USERPROFILE.profilepic, USERPROFILE.createdon, USERPROFILE.fk_createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as created_full_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name)as update_full_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_team_id,USERPROFILEROLES.user_role,USERPROFILE.fk_entity_type_id,ENTITYTYPE.name as entitytypename,ROLES.role_name'); $this->db->from(USERPROFILE.' as USERPROFILE'); $this->db->join(ENTITY.' as ENTITY','USERPROFILE.fk_entity_id = ENTITY.entity_id and ENTITY.isactive = 1','LEFT'); $this->db->join(STATE.' as STATE','USERPROFILE.fk_state = STATE.state_id and STATE.isactive = 1','LEFT'); @@ -23,9 +23,9 @@ class User_Management_Model extends SPARQ_Model { $this->db->join(USERPROFILE.' as USERPROFILE1','USERPROFILE.fk_createdby = USERPROFILE1.userid and USERPROFILE1.isactive = 1','LEFT'); $this->db->join(USERPROFILE.' as USERPROFILE2','USERPROFILE.fk_updatedby = USERPROFILE2.userid and USERPROFILE2.isactive = 1','LEFT'); $this->db->join(USERPROFILEROLES. ' as USERPROFILEROLES','USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive =1'); - $this->db->join(ENTITYTYPE.' as ENTITYTYPE','ENTITY.fk_entity_type_id = ENTITYTYPE.entity_type_id and ENTITYTYPE.isactive = 1','LEFT'); + $this->db->join(ENTITYTYPE.' as ENTITYTYPE','USERPROFILE.fk_entity_type_id = ENTITYTYPE.entity_type_id and ENTITYTYPE.isactive = 1','LEFT'); $this->db->join(PDOFFICIERSDETAILS.' as PDOFFICIERSDETAILS','PDOFFICIERSDETAILS.fk_user_id = USERPROFILE.userid and PDOFFICIERSDETAILS.isactive = 1','LEFT'); - + $this->db->join(ROLES.' as ROLES','ROLES.role_id = USERPROFILEROLES.user_role'); @@ -53,7 +53,7 @@ class User_Management_Model extends SPARQ_Model { public function getUserDetails($userid){ - $this->db->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no, USERPROFILE.profilepic, USERPROFILE.createdon, USERPROFILE.fk_createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as created_full_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name)as update_full_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_team_id,USERPROFILE.fk_entity_type_id,USERPROFILEROLES.user_role'); + $this->db->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no, USERPROFILE.profilepic, USERPROFILE.createdon, USERPROFILE.fk_createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as created_full_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name)as update_full_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_team_id,USERPROFILE.fk_entity_type_id,USERPROFILEROLES.user_role,ENTITYTYPE.name as entitytypename,ROLES.role_name'); $this->db->from(USERPROFILE.' as USERPROFILE'); $this->db->join(ENTITY.' as ENTITY','USERPROFILE.fk_entity_id = ENTITY.entity_id and ENTITY.isactive = 1','LEFT'); $this->db->join(STATE.' as STATE','USERPROFILE.fk_state = STATE.state_id and STATE.isactive = 1','LEFT'); @@ -63,7 +63,7 @@ class User_Management_Model extends SPARQ_Model { $this->db->join(USERPROFILEROLES. ' as USERPROFILEROLES','USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive =1'); $this->db->join(ENTITYTYPE.' as ENTITYTYPE','ENTITY.fk_entity_type_id = ENTITYTYPE.entity_type_id and ENTITYTYPE.isactive = 1','LEFT'); $this->db->join(PDOFFICIERSDETAILS.' as PDOFFICIERSDETAILS','PDOFFICIERSDETAILS.fk_user_id = USERPROFILE.userid and PDOFFICIERSDETAILS.isactive = 1','LEFT'); - + $this->db->join(ROLES.' as ROLES','ROLES.role_id = USERPROFILEROLES.user_role'); $this->db->where('USERPROFILE.userid',$userid);