USER MGMT UPDATE
This commit is contained in:
parent
6b9f126901
commit
e17eb56767
@ -146,6 +146,119 @@ class User_Management_Controller extends REST_Controller {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function updateExistUser_post()
|
||||
{
|
||||
$roles = "";
|
||||
$lender_hierarchy = "";
|
||||
|
||||
if($this->post('roles')){ $roles = $this->post('roles'); }
|
||||
|
||||
if($this->post('lender_hierarchy')){ $lender_hierarchy = $this->post('lender_hierarchy'); }
|
||||
|
||||
|
||||
$records = $this->post('records');
|
||||
$roles = $this->post('roles');
|
||||
|
||||
$lender_hierarchy = $this->post('lender_hierarchy');
|
||||
|
||||
if($_FILES['profilepic']['tmp_name'])
|
||||
{
|
||||
|
||||
|
||||
$profilepic = $_FILES['profilepic']['tmp_name'];
|
||||
$profilepicname = $_FILES['profilepic']['name'];
|
||||
$profilepicname = strtolower($profilepicname);
|
||||
$profilepics3path = "";
|
||||
|
||||
if(array_key_exists('fk_entity_id'),$records)
|
||||
{
|
||||
$entity_id = $records['fk_entity_id'];
|
||||
if($entity_id == 1) //1 means sine_edge Profile
|
||||
{
|
||||
$profilepics3path = 'sineedge/'.$profilepicname;
|
||||
}
|
||||
else if($entity_id == 2)//1 means lender Profile
|
||||
{
|
||||
$profilepics3path = 'lender/'.$profilepicname;
|
||||
}
|
||||
else // else or 3 means vendor Profile
|
||||
{
|
||||
$profilepics3path = 'vendor/'.$profilepicname;
|
||||
}
|
||||
}
|
||||
|
||||
$bucketname = PROFILEPICTUREBUCKETNAME;
|
||||
$key = $profilepics3path;
|
||||
$sourcefile = $profilepic;
|
||||
|
||||
$data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
|
||||
$s3result= $this->aws_s3->uploadFileToS3Bucket($data);
|
||||
|
||||
if(is_object($s3result) && $s3result['ObjectURL'] != '' && [$s3result'@metadata']['statusCode'] == 200)
|
||||
{
|
||||
$records['profilepic'] = $profilepicname;
|
||||
}
|
||||
else
|
||||
{
|
||||
$records['profilepic'] = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
$where_condition_array = array('userid'=>$records['userid']);
|
||||
$modified = $this->User_Management_Model->updateRecords($recordrs,USERPROFILE,$where_condition_array);//insert user records and get userid
|
||||
|
||||
if($roles != "")
|
||||
{
|
||||
foreach($roles as $role)
|
||||
{
|
||||
|
||||
$this->User_Management_Model->updateRecords(array('isactive'=>0),USERPROFILEROLES,array('userid'=>$records['userid']));
|
||||
$role_array = array('user_role'=>$role['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('userid'=>$records['userid']));
|
||||
$hierarchy = array('fk_hierarchy_id'=>$hierarchy['fk_hierarchy_id'],'fk_user_id'=>$user_id);//insert hierarchy againest lender type users
|
||||
$this->User_Management_Model->saveRecords($hierarchy,USERPROFILEHIERARCHY);
|
||||
}
|
||||
}
|
||||
|
||||
if($modified != '' || $modified != null || $modified != 0)
|
||||
{
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['record'] = $modified;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
||||
$this->response($data,REST_Controller::HTTP_NOT_MODIFIED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,6 +22,9 @@ class User_Management_Model extends SPARQ_Model {
|
||||
$this->db->join(CITY.'as CITY','USERPROFILE.fk_city = CITY.city_id and CITY.isactive = 1');
|
||||
$this->db->join(USERPROFILE.'as USERPROFILE1','USERPROFILE.fk_createdby = USERPROFILE1.userid and USERPROFILE1.isactive = 1');
|
||||
$this->db->join(USERPROFILE.'as USERPROFILE2','USERPROFILE.fk_updatedby = USERPROFILE2.userid and USERPROFILE2.isactive = 1');
|
||||
$this->db->join(USERPROFILEHIERARCHY.'as USERPROFILEHIERARCHY','USERPROFILE.userid = USERPROFILEHIERARCHY.fk_user_id and LENDERHIERARCHY.isactive = 1');
|
||||
$this->db->join(LENDERHIERARCHY.'as LENDERHIERARCHY','USERPROFILEHIERARCHY.user_lender_hierarchy_id = LENDERHIERARCHY.lender_hierarchy_id and LENDERHIERARCHY.isactive = 1');
|
||||
$this->db->join(USERPROFILEROLES.'as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_user_id and USERPROFILEROLES.isactive = 1');
|
||||
//$this->db->where('USERPROFILE.isactive = 1');
|
||||
$result = $this->db->get()->result_array();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user