This commit is contained in:
velz 2018-10-09 19:30:40 +05:30
commit db6aa08461
2 changed files with 47 additions and 88 deletions

View File

@ -49,13 +49,14 @@ class User_Management_Controller extends REST_Controller {
$roles = "";
$lender_hierarchy = "";
$pdofficer = "";
if($this->post('roles')){ $roles = json_decode($this->post('roles'),true); }
if($this->post('pdofficer')){ $pdofficer = json_decode($this->post('pdofficer'),true);}
if($this->post('lender_hierarchy')){ $lender_hierarchy = json_decode($this->post('lender_hierarchy'),true); }
if($this->post('pdofficer')){ $pdofficer = json_decode($this->post('pdofficer'),true); }
$records = json_decode($this->post('records'),true);
if(!empty($_FILES['profilepic']['tmp_name']))
{
@ -66,9 +67,9 @@ class User_Management_Controller extends REST_Controller {
$profilepicname = strtolower($profilepicname);
$profilepics3path = "";
if(array_key_exists('fk_entity_id',$records))
if(array_key_exists('fk_entity_type_id',$records))
{
$entity_id = $records['fk_entity_id'];
$entity_id = $records['fk_entity_type_id'];
if($entity_id == 1) //1 means sine_edge Profile
{
$profilepics3path = 'sineedge/'.$profilepicname;
@ -109,24 +110,24 @@ class User_Management_Controller extends REST_Controller {
if($roles != "")
{
foreach($roles as $role)
{
$role_array = array('user_role'=>$role['user_role'],'fk_userid'=>$user_id);//insert roles againest user
// foreach($roles as $role)
// {
$role_array = array('user_role'=>$roles['user_role'],'fk_userid'=>$user_id);//insert roles againest user
$this->User_Management_Model->saveRecords($role_array,USERPROFILEROLES);
}
// }
}
if($lender_hierarchy != "")
{
// if($lender_hierarchy != "")
// {
foreach($lender_hierarchy as $hierarchy)
{
$hierarchy = array('fk_hierarchy_id'=>$hierarchy['lender_hierarchy_id'],'fk_user_id'=>$user_id);
$this->User_Management_Model->saveRecords($hierarchy,USERPROFILEHIERARCHY);
}
}
// foreach($lender_hierarchy as $hierarchy)
// {
// $hierarchy = array('fk_hierarchy_id'=>$hierarchy['lender_hierarchy_id'],'fk_user_id'=>$user_id);
// $this->User_Management_Model->saveRecords($hierarchy,USERPROFILEHIERARCHY);
// }
// }
//print_r($pdofficer);die;
if($pdofficer != ""){
$pdofficer['fk_user_id'] = $user_id;
//print_r($pdofficer);
@ -158,12 +159,13 @@ class User_Management_Controller extends REST_Controller {
$roles = "";
$lender_hierarchy = "";
$pdofficer = "";
if($this->post('roles')){ $roles = $this->post('roles'); }
if($this->post('pdofficer')){ $pdofficer = json_decode($this->post('pdofficer'),true);}
if($this->post('lender_hierarchy')){ $lender_hierarchy = json_decode($this->post('lender_hierarchy'),true); }
$records = json_decode($this->post('records'),true);
// $records = array_filter($recordsData);
$roles = json_decode($this->post('roles'),true);
// $lender_hierarchy = json_decode($this->post('lender_hierarchy'),true);
@ -177,9 +179,9 @@ class User_Management_Controller extends REST_Controller {
$profilepicname = strtolower($profilepicname);
$profilepics3path = "";
if(array_key_exists('fk_entity_id',$records))
if(array_key_exists('fk_entity_type_id',$records))
{
$entity_id = $records['fk_entity_id'];
$entity_id = $records['fk_entity_type_id'];
if($entity_id == 1) //1 means sine_edge Profile
{
$profilepics3path = 'sineedge/'.$profilepicname;
@ -220,39 +222,21 @@ class User_Management_Controller extends REST_Controller {
if($roles != "")
{
foreach($roles as $role)
{
$this->User_Management_Model->updateRecords(array('isactive'=>0),USERPROFILEROLES,array('fk_userid'=>$records['userid']));
}
foreach($roles as $role)
{
$role_array = array('user_role'=>$role['user_role'],'fk_userid'=>$records['userid']);
$role_array = array('user_role'=>$roles['user_role'],'fk_userid'=>$records['userid']);
$this->User_Management_Model->saveRecords($role_array,USERPROFILEROLES);
}
}
if($lender_hierarchy != "")
{
foreach($lender_hierarchy as $hierarchy)
{
$this->User_Management_Model->updateRecords(array('isactive'=>0),USERPROFILEHIERARCHY,array('fk_user_id'=>$records['userid']));
$hierarchy = array('fk_hierarchy_id'=>$hierarchy['lender_hierarchy_id'],'fk_user_id'=>$records['userid']);//insert hierarchy againest lender type users
}
foreach($lender_hierarchy as $hierarchy)
{
//insert hierarchy againest lender type users
$this->User_Management_Model->saveRecords($hierarchy,USERPROFILEHIERARCHY);
}
}
if($pdofficer != ""){
$this->User_Management_Model->updateRecords($pdofficer,PDOFFICIERSDETAILS,$pdofficer['fk_user_id']);
@ -341,4 +325,5 @@ class User_Management_Controller extends REST_Controller {
}
}

View File

@ -15,38 +15,23 @@ class User_Management_Model extends SPARQ_Model {
$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.alt_email, USERPROFILE.mobile_no, USERPROFILE.alt_mobile_no, USERPROFILE.addressline1, USERPROFILE.addressline2, 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_designation,DESIGNATION.name, USERPROFILE.addressline3, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, USERPROFILE.pincode,USERPROFILEHIERARCHY.fk_hierarchy_id,PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_product_id,PDOFFICIERSDETAILS.fk_customer_segment,PDOFFICIERSDETAILS.fk_team_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');
$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(DESIGNATION.' as DESIGNATION','USERPROFILE.fk_designation = DESIGNATION.designation_id and DESIGNATION.isactive = 1','left');
$this->db->join(STATE.' as STATE','USERPROFILE.fk_state = STATE.state_id and STATE.isactive = 1','LEFT');
$this->db->join(CITY.' as CITY','USERPROFILE.fk_city = CITY.city_id and CITY.isactive = 1','LEFT');
$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(USERPROFILEHIERARCHY.' as USERPROFILEHIERARCHY','USERPROFILE.userid = USERPROFILEHIERARCHY.fk_user_id and USERPROFILEHIERARCHY.isactive = 1','LEFT');
$this->db->join(LENDERHIERARCHY.' as LENDERHIERARCHY','USERPROFILEHIERARCHY.user_lender_hierarchy_id = LENDERHIERARCHY.lender_hierarchy_id and LENDERHIERARCHY.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(PDOFFICIERSDETAILS.' as PDOFFICIERSDETAILS','PDOFFICIERSDETAILS.fk_user_id = USERPROFILE.userid and PDOFFICIERSDETAILS.isactive = 1','LEFT');
//$this->db->where('USERPROFILE.userid = 99');
// $this->db->join(PRODUCTS.' as PRODUCTS','PRODUCTS.product_id = PDOFFICERSDETAILS.fk_product_id and PRODUCTS.isactive = 1','LEFT');
// $this->db->join(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','CUSTOMERSEGMENT.customer_segment_id = PDOFFICIERSDETAILS.fk_customer_segment and CUSTOMERSEGMENT.isactive = 1','LEFT');
// $this->db->join(PDTEAM.' as PDTEAM','PDTEAM.pdteam_id = PDOFFICIERSDETAILS.fk_team_id and PDTEAM.isactive = 1','LEFT');
// $this->db->join(PDTYPE.' as PDTYPE','PDTYPE.pd_type_id = PDOFFICIERSDETAILS.fk_pd_type_id and PDTYPE.isactive = 1','LEFT');
//$this->db->where('USERPROFILE.isactive = 1');
$result = $this->db->get()->result_array();
//print_r($result);die;
if($result !=''){
foreach($result as $key =>$roles){
$role = $this->db->get_where(USERPROFILEROLES.' as USERPROFILEROLES',array('fk_userid'=>$roles['userid'],'isactive'=>1))->result_array();
array_push($result[$key], $role);
}
}
// print_r($result);die;
if(count($result) > 0 )
{
@ -68,34 +53,23 @@ 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.alt_email, USERPROFILE.mobile_no, USERPROFILE.alt_mobile_no, USERPROFILE.addressline1, USERPROFILE.addressline2, 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_designation,DESIGNATION.name, USERPROFILE.addressline3, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, USERPROFILE.pincode,USERPROFILEHIERARCHY.fk_hierarchy_id,PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_product_id,PDOFFICIERSDETAILS.fk_customer_segment,PDOFFICIERSDETAILS.fk_team_id');
$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(DESIGNATION.' as DESIGNATION','USERPROFILE.fk_designation = DESIGNATION.designation_id and DESIGNATION.isactive = 1','left');
$this->db->join(STATE.' as STATE','USERPROFILE.fk_state = STATE.state_id and STATE.isactive = 1');
$this->db->join(CITY.' as CITY','USERPROFILE.fk_city = CITY.city_id and CITY.isactive = 1','LEFT');
$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(USERPROFILEHIERARCHY.' as USERPROFILEHIERARCHY','USERPROFILE.userid = USERPROFILEHIERARCHY.fk_user_id and USERPROFILEHIERARCHY.isactive = 1','LEFT');
$this->db->join(LENDERHIERARCHY.' as LENDERHIERARCHY','USERPROFILEHIERARCHY.user_lender_hierarchy_id = LENDERHIERARCHY.lender_hierarchy_id and LENDERHIERARCHY.isactive = 1','LEFT');
$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->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->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');
$this->db->join(CITY.' as CITY','USERPROFILE.fk_city = CITY.city_id and CITY.isactive = 1','LEFT');
$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(PDOFFICIERSDETAILS.' as PDOFFICIERSDETAILS','PDOFFICIERSDETAILS.fk_user_id = USERPROFILE.userid and PDOFFICIERSDETAILS.isactive = 1','LEFT');
$this->db->where('USERPROFILE.userid',$userid);
$result = $this->db->get()->result_array();
if($result !=''){
foreach($result as $key =>$roles){
$role = $this->db->get_where(USERPROFILEROLES.' as USERPROFILEROLES',array('fk_userid'=>$roles['userid'],'isactive'=>1))->result_array();
array_push($result[$key], $role);
}
}
if(count($result) != 0 )
{
$result_data['data_status'] = true;