diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 8cd2f240..d6635b8f 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -201,4 +201,21 @@ defined('QUESTIONANSWERSID') OR define('QUESTIONANSWERSID','question_answer_id') defined('QUESTIONCATEGORY') OR define('QUESTIONCATEGORY','m_question_category'); defined('QUESTIONCATEGORYID') OR define('QUESTIONCATEGORYID','question_categroy_id'); +defined('TEMPLATE') OR define('TEMPLATE','m_template'); +defined('TEMPLATEID') OR define('TEMPLATEID','template_id'); + +defined('LENDERTEMPLATE') OR define('LENDERTEMPLATE','m_lender_template'); +defined('LENDERTEMPLATEID') OR define('LENDERTEMPLATEID','lender_template_id'); + +defined('TEMPLATECATAGORYWEIGHTAGE') OR define('TEMPLATECATAGORYWEIGHTAGE','m_template_catagory_weightage'); +defined('TEMPLATECATAGORYWEIGHTAGEID') OR define('TEMPLATECATAGORYWEIGHTAGEID','template_catagory_weightage_id'); + +defined('TEMPLATEQUESTION') OR define('TEMPLATEQUESTION','m_template_question'); +defined('TEMPLATEQUESTIONID') OR define('TEMPLATEQUESTIONID','template_question_id'); + +defined('TEMPLATEANSWERWEIGHTAGE') OR define('TEMPLATEANSWERWEIGHTAGE','m_template_answer_weightage'); +defined('TEMPLATEANSWERWEIGHTAGEID') OR define('TEMPLATEANSWERWEIGHTAGEID','template_answer_weightage_id'); + + + diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 8def217a..cbe02c45 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -61,16 +61,14 @@ $route['translate_uri_dashes'] = FALSE; */ /* Routes regards Common Masters CRUD operations*/ -$route['saveNewUser'] = 'Common_Masters_Controller/saveNewUser'; -$route['listAllUsers'] = 'Common_Masters_Controller/listAllUsers'; - - $route['getListOfBranches'] = 'Common_Masters_Controller/getListOfBranches'; $route['saveBranch'] = 'Common_Masters_Controller/saveBranch'; $route['getListOfMaster'] = 'Common_Masters_Controller/getListOfMaster'; $route['saveMaster'] = 'Common_Masters_Controller/saveMaster'; +$route['login'] = 'Branch_Controller/testAWSS3'; + //USER MANAGEMENT $route['getListOfUsers'] = 'User_Management_Controller/listAllUsers'; @@ -78,3 +76,20 @@ $route['saveNewUser'] = 'User_Management_Controller/saveNewUser'; $route['updateExistUser'] = 'User_Management_Controller/updateExistUser'; $route['getUsersDetails'] = 'User_Management_Controller/getUsersDetails'; +// TEMPLATE MANAGEMENT +$route['listAllTemplates'] = 'Template_Management_Controller/listAllTemplates'; +$route['saveNewTemplateName'] = 'Template_Management_Controller/saveNewTemplateName'; +$route['saveTemplateLenderDetails'] = 'Template_Management_Controller/saveTemplateLenderDetails'; +$route['saveTemplateCategoryDetails'] = 'Template_Management_Controller/saveTemplateCategoryDetails'; + +//QUESTION MANAGEMENT +$route['listAllQuestions'] = 'Question_Management_Controller/listAllQuestions'; +$route['saveNewQuestion'] = 'Question_Management_Controller/saveNewQuestion'; +$route['saveExistQuestion'] = 'Question_Management_Controller/saveExistQuestion'; + +//ENTITY MANAGEMENT +$route['listAllEntites'] = 'Entity_Management_Controller/listAllEntites'; +$route['saveNewEntity'] = 'Entity_Management_Controller/saveNewEntity'; +$route['saveExistEntity'] = 'Entity_Management_Controller/saveExistEntity'; + + diff --git a/api/application/controllers/Branch_Controller.php b/api/application/controllers/Branch_Controller.php index b8875e83..703cdfed 100644 --- a/api/application/controllers/Branch_Controller.php +++ b/api/application/controllers/Branch_Controller.php @@ -73,7 +73,8 @@ class Branch_Controller extends REST_Controller { public function testAWSS3_post() { /* CREATE NEW BUCKETS*/ - // $b = $this->aws_s3->createNewBucket('thecucumber'); + // $b = $this->aws_s3->createNewBucket('lender1'); + // print_r($b); /* CREATE NEW BUCKETS*/ /* LIST OF BUCKETS*/ @@ -92,20 +93,20 @@ class Branch_Controller extends REST_Controller { /* STORE FILE TO S3*/ - $file = $_FILES['myfile']['tmp_name']; - $file2 = $_FILES['myfile']['name']; - //print_r($file); - //print_r($file2); + // $file = $_FILES['myfile']['tmp_name']; + // $file2 = $_FILES['myfile']['name']; + // print_r($file); + // print_r($file2); - $s3pathname = 'byapi/'.$file2; - $data = array('bucket_name'=>'thecucumber','key'=>$s3pathname,'sourcefile'=>$file); - $res = $this->aws_s3->uploadFileToS3Bucket($data); - //print_r($res); - echo is_object($res); - echo is_array($res); - echo "*********\n\n"; - echo $res['ObjectURL']; - echo $res['@metadata']['statusCode']; + // $s3pathname = 'pd2/'.$file2; + // $data = array('bucket_name'=>'lender1','key'=>$s3pathname,'sourcefile'=>$file); + // $res = $this->aws_s3->uploadFileToS3Bucket($data); + // print_r($res); + // echo is_object($res); + // echo is_array($res); + // echo "*********\n\n"; + // echo $res['ObjectURL']; + // echo $res['@metadata']['statusCode']; // foreach($res as $key => $value) // { // echo $key."\n\n"; @@ -113,17 +114,33 @@ class Branch_Controller extends REST_Controller { /* STORE FILE TO S3*/ - /* GET FILE FROM S3*/ - // $res = $this->aws_s3->getSingleObjectInaBucket(); - // //print_r($res); - // //echo "\n\n\n\n\n
"; - // //header("Content-Type:{$res['ContentType']}"); - // header("Content-Disposition:attachment; filename='woodgrass1.jpg'"); + // /* GET FILE FROM S3*/ + // $bucket_name = 'lender1'; + // $folder_name = 'pd2'; + // $file_name = ''; + // $res = $this->aws_s3->getSingleObjectInaBucket($bucket_name,$folder_name); + // print_r($res); + //echo "\n\n\n\n\n
"; + //header("Content-Type:{$res['ContentType']}"); + //header("Content-Disposition:attachment; filename='woodgrass1.jpg'"); - // echo $res['Body']; + // print_r($res); - /* GET FILE FROM S3*/ + /* GET FILES FROM S3*/ + $bucket_name = 'lender1'; + $folder_name = 'pd2'; + $r = $this->aws_s3->getAllObjectsInaBucket($bucket_name,$folder_name); + $s3_signed_urls = array(); + foreach($r as $k) + { + if($k['Key'] != $folder_name.'/') array_push($s3_signed_urls,$this->aws_s3->getSingleObjectInaBucket($bucket_name,$k['Key'])); + + } + print_r($s3_signed_urls); + + /* GET FILES FROM S3*/ + /* GET ALL FILES FROM IN A FOLDER WITHIN A BUCKET*/ /* $id = MYDB::saveRecords(array('city_name'=>'salem'),'t_city_master'); print_r($id); @@ -151,19 +168,24 @@ class Branch_Controller extends REST_Controller { print_r($id); */ - /* - $columns = array('city_name','state_name'); - $table = 't_states_master'; - $joins = array( - array( - 'table' => 't_city_master', - 'condition' => 't_city_master.fk_state_id = t_states_master.state_id', - 'jointype' => 'INNER' - ), - ); - $id = MYDB::getJoinRecords($columns,$table,$joins,$print_query = ''); - print_r($id); - */ + + // $columns = array('m_states.name as sname','BRANCH.name as bname','m_city.*'); + // $table = BRANCH.' as BRANCH'; + // $joins = array( + // array( + // 'table' => 'm_city', + // 'condition' => 'BRANCH.fk_city_id = m_city.city_id ', + // 'jointype' => 'INNER' + // ), + // array( + // 'table' => 'm_states', + // 'condition' => 'm_city.fk_state_id = m_states.state_id', + // 'jointype' => 'INNER' + // ) + // ); + // $id = MYDB::getJoinRecords($columns,$table,$joins,$print_query = ''); + // print_r($id); + } public function testPDF_get() diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 377e461f..1b22bf45 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -21,10 +21,10 @@ class Template_Management_Controller extends REST_Controller { } - public function listAllUsers_get() + public function listAllTemplates_get() { - $result = $this->User_Management_Model->$listAllUsers(); + $result = $this->User_Management_Model->$listAllTemplates(); if($result['data_status']) { $data['dataStatus'] = true; @@ -40,225 +40,145 @@ class Template_Management_Controller extends REST_Controller { } } - public function saveNewUser_post() + public function saveNewTemplateName_post() { - $roles = ""; - $lender_hierarchy = ""; + $template_name = $this->post('template_name'); - 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']) + if(array_key_exists('template_id',$template_name)) { - - - $profilepic = $_FILES['profilepic']['tmp_name']; - $profilepicname = $_FILES['profilepic']['name']; - $profilepicname = strtolower($profilepicname); - $profilepics3path = ""; - - if(array_key_exists('fk_entity_id'),$records) + $template_id = $this->Template_Management_Model->saveRecords($template_name,TEMPLATE); + if($template_id != "" || $template_id != null) { - $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; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $template_id; + $this->response($data,REST_Controller::HTTP_OK); } else { - $records['profilepic'] = null; + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } - - - - - } - - $user_id = $this->User_Management_Model->saveRecords($recordrs,USERPROFILE);//insert user records and get userid - - if($roles != "") + else + { + $where_condition_array = array('template_id'=>$template_name['template_id']); + $modified = $this->db->updateRecords($template_name,TEMPLATE,$where_condition_array); + if($template_id != "" || $template_id != null) { - foreach($roles as $role) - { - $role_array = array('user_role'=>$role['user_role'],'fk_userid'=>$user_id);//insert roles againest user - $this->User_Management_Model->saveRecords($role_array,USERPROFILEROLES); - } - } - - if($lender_hierarchy != "") - { - foreach($lender_hierarchy as $hierarchy) - { - $hierarchy = array('fk_hierarchy_id'=>$hierarchy['fk_hierarchy_id'],'fk_user_id'=>$user_id,'fk_createdby'=>$records['fk_createdby'],'createdon'=>$records['createdon']);//insert hierarchy againest lender type users - $this->User_Management_Model->saveRecords($hierarchy,USERPROFILEHIERARCHY); - } - } - - if($user_id != '' || $user_id != null) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['record'] = $user_id; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $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); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } - - - - - - - - + } } - public function updateExistUser_post() + public function saveTemplateLenderDetails_post() { - $roles = ""; - $lender_hierarchy = ""; + $template_id = ''; + $count = 0; - 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']) + if($this->post('template_id')) { - - - $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; - } - - - - - + $template_id = $this->post('template_id'); } - $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 != "") + + $template_lender_details = $this->post('template_lender_details'); + + foreach($template_lender_details as $template_lender_detail) + { + if(array_key_exists('lender_template_id',$template_lender_detail)) { - 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); + $where_condition_array = array('lender_template_id'=>$template_lender_detail['lender_template_id']); + $modified = $this->Template_Management_Model->updateRecords(template_lender_detail,LENDERTEMPLATE,$where_condition_array); + if($modified != "" || $modified != null){ $count++; } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + $template_lender_detail['fk_template_id'] = $template_id; + $id = $this->Template_Management_Model->saveRecords($template_lender_detail,LENDERTEMPLATE); + if($id != "" || $id != null){ $count++; } + } + } + + + if($count == count($template_lender_details)) + { + $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_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + } - - - - - - - - } - + + public function saveTemplateCategoryDetails_post() + { + $template_id = ''; + $count = 0; + + if($this->post('template_id')) + { + $template_id = $this->post('template_id'); + } + + $template_category_details = $this->post('template_category_details'); + + foreach($template_category_details as $template_category_detail) + { + if(array_key_exists('template_catagory_weightage_id',$template_category_detail)) + { + $where_condition_array = array('template_catagory_weightage_id'=>$template_category_detail['template_catagory_weightage_id']); + $modified = $this->Template_Management_Model->updateRecords($template_category_detail,TEMPLATECATAGORYWEIGHTAGE,$where_condition_array); + if($modified != "" || $modified != null){ $count++; } + } + else + { + $template_category_detail['fk_template_id'] = $template_id; + $id = $this->Template_Management_Model->saveRecords($template_lender_detail,TEMPLATECATAGORYWEIGHTAGE); + if($id != "" || $id != null){ $count++; } + } + } + + if($count == count($template_lender_details)) + { + $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_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_NO_CONTENT); + + } + + + } + + + } \ No newline at end of file diff --git a/api/application/libraries/AWS_S3.php b/api/application/libraries/AWS_S3.php index 38f69d8b..5110808d 100644 --- a/api/application/libraries/AWS_S3.php +++ b/api/application/libraries/AWS_S3.php @@ -44,7 +44,7 @@ class AWS_S3 { try { - $result = $this->S3->createBucket(['Bucket' => $BUCKET_NAME]); + $result = $this->S3->createBucket(['Bucket' => $BUCKET_NAME,'ACL' => 'authenticated-read']); print_r($result); } catch (AwsException $e) { @@ -65,7 +65,7 @@ class AWS_S3 'SourceFile' => $data['sourcefile'], 'ContentType' => '*/*', 'StorageClass' => 'STANDARD', - 'ACL'=>'public-read' + 'ACL'=>'authenticated-read' ]); } catch (AwsException $e) @@ -76,44 +76,56 @@ class AWS_S3 return $result; } - public function getSingleObjectInaBucket() + public function getSingleObjectInaBucketAsSignedURI($bucket_name,$folder_name)//get as singed url { $result = array(); try { - $result = $this->S3->getObject([ - 'Bucket' => 'thecucumber', - 'Key' => 'byapi/woodgrass1.jpg' - //'ResponseContentType' => 'image/png' - //'ResponseContentDisposition' => 'attachment; woodgrass1.jpg', - ]); + + // $result = $this->S3->getObject([ + // 'Bucket' => 'thecucumber', + // 'Key' => 'byapi/woodgrass1.jpg' + // //'ResponseContentType' => 'image/png' + // //'ResponseContentDisposition' => 'attachment; woodgrass1.jpg', + // ]); + + $cmd = $this->S3->getCommand('GetObject', [ + 'Bucket' => $bucket_name, + 'Key' => $folder_name + ]); + + $request = $this->S3->createPresignedRequest($cmd, '+60 seconds'); + $presignedUrl = (string) $request->getUri(); } catch(AwsException $e) { echo $e->getMessage(); } - return $result; + return $presignedUrl; } - public function getAllObjectsInaBucket() + public function getAllObjectsInaBucket($bucket_name,$folder_name) { + $objects = array(); try { - $objects = $this->S3->getIterator('ListObjects', [ - 'Bucket' => 'thecucumber', - 'Prefix' => '' - ]); + $objects = $this->S3->getIterator('ListObjects', [ + 'Bucket' => $bucket_name, + 'Prefix' => $folder_name + ]); - echo "Keys retrieved!" ; - //print_r($objects); - foreach ($objects as $object) { - print_r($object) ; - } + // echo "Keys retrieved!" ; + // //print_r($objects); + // foreach ($objects as $object) { + // print_r($object) ; + // } } catch (S3Exception $e) { echo $e->getMessage() . PHP_EOL; } + + return $objects; } diff --git a/api/application/models/Template_Management_Model.php b/api/application/models/Template_Management_Model.php index f8254606..78622fe0 100644 --- a/api/application/models/Template_Management_Model.php +++ b/api/application/models/Template_Management_Model.php @@ -10,22 +10,11 @@ class Template_Management_Model extends SPARQ_Model { } - public function listAllUsers() + public function listAllTemplates() { $result_data = array(); - $this->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name, USERPROFILE.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,USERPROFILE1.first_name,USERPROFILE1.last_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,USERPROFILE2.first_name,USERPROFILE2.last_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_designation,DESIGNATION.name, USERPROFILE.addressline3, USERPROFILE.fk_city,CITY.name, USERPROFILE.fk_state,STATE.name, USERPROFILE.pincode'); - $this->db->from(USERPROFILE.'as USERPROFILE'); - $this->db->join(ENTITY.'as ENTITY','USERPROFILE.fk_entity_id = ENTITY.entity_id and ENTITY.isactive = 1'); - $this->db->join(DESIGNATION.'as DESIGNATION','USERPROFILE.fk_designation = DESIGNATION.designation_id and DESIGNATION.isactive = 1'); - $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'); - $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','LEFT'); - $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(); if(count($result) > 0 )