From 2f2416d8ea04a702172b0d330947a9a3aac2344f Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 25 Sep 2018 14:46:40 +0530 Subject: [PATCH] PD QUES CHANGED --- api/application/config/autoload.php | 2 +- api/application/config/constants.php | 42 ++- api/application/config/routes.php | 2 +- .../controllers/Common_Masters_Controller.php | 7 +- api/application/controllers/PD_Controller.php | 289 +++++++++++++++++- .../Question_Management_Controller.php | 39 +-- .../User_Management_Controller.php | 54 +++- api/application/helpers/pdalerts_helper.php | 39 +++ api/application/libraries/SPARQ_Model.php | 20 +- api/application/models/PD_Model.php | 9 + .../models/Question_Management_Model.php | 8 +- .../models/User_Management_Model.php | 44 +-- 12 files changed, 480 insertions(+), 75 deletions(-) create mode 100644 api/application/helpers/pdalerts_helper.php diff --git a/api/application/config/autoload.php b/api/application/config/autoload.php index a0804199..a3d5aebe 100644 --- a/api/application/config/autoload.php +++ b/api/application/config/autoload.php @@ -89,7 +89,7 @@ $autoload['drivers'] = array(); | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array('url', 'form', 'jwt', "authorization", "date","mylog","myocr","mydb"); +$autoload['helper'] = array('url', 'form', 'jwt', 'authorization', 'date','mylog','myocr','mydb','pdalerts'); /* | ------------------------------------------------------------------- diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 68f55acd..d6b0dad2 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -86,11 +86,31 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto // define login route name for token verification //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getListOfUsers'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'triggerNewPD'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); -/*********************AWS resources Constants*************************************************/ +/*********************END of AWS resources Constants*************************************************/ + +/*******************Constants PD status*********************************/ +defined('TRIGGERED') OR define('TRIGGERED','1'); //First time PD Trigger. +defined('ALLOCATED') OR define('ALLOCATED','2'); //PD Allocated to PD officer +defined('ACCEPTED') OR define('ACCEPTED','3'); // PD Accepted PD officer after Allocation +defined('BOUNCED') OR define('BOUNCED','4'); // PD Not accepted by PD Officer +defined('SCHEDULED') OR define('SCHEDULED','5'); //PD Scheduled by PD Officer +defined('INITIATED') OR define('INITIATED','6'); // PD Initiated or Ready to go a PD +defined('STARTED') OR define('STARTED','7'); // PD started by PD officer +defined('INPROGRESS') OR define('INPROGRESS','8'); // PD inprogress +defined('COMPLETED') OR define('COMPLETED','9'); // PD Completed +defined('QC_INPROGRESS') OR define('QC_INPROGRESS','10'); // QC_INPROGRESS +defined('QC_COMPLETED') OR define('QC_COMPLETED','11'); // QC_COMPLETED +defined('PD_REPORT_ACCEPTED') OR define('PD_REPORT_ACCEPTED','12'); //PD_REPORT_ACCEPTED by Lender +defined('PD_CHNAGE_REQUEST') OR define('PD_CHNAGE_REQUEST','13'); // From Lender side requesting change of PD report +defined('ALLOCATED_TO_PARTNER') OR define('ALLOCATED_TO_PARTNER','14'); // PD Allocated to PD agency not for PD officer +defined('ARCHIVED') OR define('ARCHIVED','15'); +defined('CANCELLED') OR define('CANCELLED','16'); + +/*******************End Of Constants PD status**************************/ /*******************Define Constants for Table Names and Primarykeys**************************/ @@ -141,7 +161,7 @@ defined('CITYID') OR define('CITYID','city_id'); defined('BRANCH') OR define('BRANCH','m_branch'); defined('BRANCHID') OR define('BRANCHID','branch_id'); -defined('PDALLOCATIONTYPE') OR define('PDALLOCATIONTYPE','m_pd_allocation_type'); +defined('PDALLOCATIONTYPE') OR define('PDALLOCATIONTYPE','c_pd_allocation_type'); defined('PDALLOCATIONTYPEID') OR define('PDALLOCATIONTYPEID','pd_allocation_type_id'); defined('PDLOCATIONAPPROACH') OR define('PDLOCATIONAPPROACH','m_pd_location_approach'); @@ -219,9 +239,23 @@ defined('PDTRIGGERID') OR define('PDTRIGGERID','pd_id'); defined('PDAPPLICANTSDETAILS') OR define('PDAPPLICANTSDETAILS','t_pd_co_applicants_details'); defined('PDAPPLICANTSDETAILSID') OR define('PDAPPLICANTSDETAILSID','pd_co_applicant_id'); -defined('PDSTATUS') OR define('PDSTATUS','m_pd_status'); +defined('PDSTATUS') OR define('PDSTATUS','c_pd_status'); defined('PDSTATUSID') OR define('PDSTATUSID','pd_status_id'); +defined('PDTEAM') OR define('PDTEAM','m_pdteam'); +defined('PDTEAMID') OR define('PDTEAMID','pdteam_id'); + +defined('PDTEAMCITYMAP') OR define('PDTEAMCITYMAP','m_pdteam_city_mapping'); +defined('PDTEAMCITYMAPID') OR define('PDTEAMCITYMAPID','pdteam_city_mapping_id'); + +defined('PDOFFICIERSDETAILS') OR define('PDOFFICIERSDETAILS','m_pd_officiers_details'); +defined('PDOFFICIERSDETAILSID') OR define('PDOFFICIERSDETAILSID','pd_officier_id'); + +defined('PDNOTIFICATION') OR define('PDNOTIFICATION','m_pdnotification'); +defined('PDNOTIFICATIONID') OR define('PDNOTIFICATIONID','pdnotification_id'); + +defined('PDDOCUMENTS') OR define('PDDOCUMENTS','t_pd_documents'); +defined('PDDOCUMENTSID') OR define('PDDOCUMENTSID','pd_document_id'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 684a1188..9e41aa10 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -87,7 +87,7 @@ $route['saveTemplateLenderDetails'] = 'Template_Management_Controller/saveTempla $route['saveTemplateCategoryDetails'] = 'Template_Management_Controller/saveTemplateCategoryDetails'; //QUESTION MANAGEMENT -$route['listAllQuestions'] = 'Question_Management_Controller/listAllQuestions'; +$route['(listAllQuestions/:any)'] = 'Question_Management_Controller/listAllQuestions/'; $route['saveNewQuestion'] = 'Question_Management_Controller/saveNewQuestion'; $route['saveExistQuestion'] = 'Question_Management_Controller/saveExistQuestion'; diff --git a/api/application/controllers/Common_Masters_Controller.php b/api/application/controllers/Common_Masters_Controller.php index a26122ec..adbce3ee 100644 --- a/api/application/controllers/Common_Masters_Controller.php +++ b/api/application/controllers/Common_Masters_Controller.php @@ -999,12 +999,9 @@ class Common_Masters_Controller extends REST_Controller { public function saveMaster_post() { - echo 'dfsf'; + $records = $this->post('records'); $table_name = $this->post('master_name'); - print_r($records); - //die(); - if(false !== array_key_exists(constant($table_name.'ID'),$records)) //Update Record { @@ -1057,7 +1054,7 @@ class Common_Masters_Controller extends REST_Controller { /* For Branch Listing */ public function getListOfBranches_get(){ - $columns = array('m_city.name as cityname','BRANCH.*'); + $columns = array('m_city.name as city_name','BRANCH.*'); $table = BRANCH.' as BRANCH'; $joins = array( array( diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 9424b1ea..7a5f0a40 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -18,20 +18,297 @@ class PD_Controller extends REST_Controller { // Construct the parent class parent::__construct(); $this->load->model('PD_Model'); + $this->load->library('AWS_S3'); } - + /***********************Get get List Of Lenders Details for PD Trigger Page************************/ + public function getListOfLenders_get() + { + $fields = array('entity_id','full_name','short_name'); + $where_condition_array = array('isactive' => 1,'fk_entity_type_id' => 2); + $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITY); + if(count($result_data)) + { + + + $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); + + } + } + + /********************Get get List Of Products and SubProducts Name Details for PD Trigger Page*********/ + + public function getListOfProducts_get() + { + $fields = array('product_id','name as product_name','abbr as product_abbr'); + $where_condition_array = array('isactive' => 1); + $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PRODUCTS); + if(count($result_data)) + { + foreach($result_data as $key => $product) + { + $fields = array('subproduct_id','name as subproduct_name','abbr as subproduct_abbr'); + $where_condition_array = array('isactive' => 1,'fk_product_id' => $product['product_id']); + $subproducts = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,SUBPRODUCTS); + array_push($result_data[$key],$subproducts); + } + + $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); + + } + } + + + /********************Get get List Of CustomerSegments Details for PD Trigger Page*********/ + + public function getListOfCustomerSegments_get() + { + $fields = array('customer_segment_id','name as customer_segment','abbr'); + $where_condition_array = array('isactive' => 1); + $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CUSTOMERSEGMENT); + if(count($result_data)) + { + + + $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); + + } + } + + /********************Get get List Of Both PD Allocation Types and PD Types Details for PD Trigger Page*********/ + + public function getListOfPDAllocationTypes_get() + { + $fields = array('pd_allocation_type_id','pd_allocation_type_name','pd_allocation_type_name','default'); + $where_condition_array = array('isactive' => 1); + $result_data['pd_allocation_type'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDALLOCATIONTYPE); + + $fields1 = array('pd_type_id','type_name'); + $where_condition_array1 = array('isactive' => 1); + $result_data['pd_type'] = $this->PD_Model->selectCustomRecords($fields1,$where_condition_array1,PDTYPE); + if(count($result_data)) + { + + + $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); + + } + } + + + /********************Get get List Of States and Cities Name Details for PD Trigger Page*********/ + + public function getListOfStatesAndCities_get() + { + $fields = array('state_id','name as state_name','code'); + $where_condition_array = array('isactive' => 1); + $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE); + if(count($result_data)) + { + foreach($result_data as $key => $state) + { + $fields = array('city_id','name as city_name','abbr as subproduct_abbr'); + $where_condition_array = array('isactive' => 1,'fk_state_id' => $state['fk_state_id']); + $cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY); + array_push($result_data[$key],$cities); + } + + $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); + + } + } + + + + + + /********For Save New PD while Trigger****/ public function triggerNewPD_post() { - $pd_details = $this->post('pd_details'); - $pd_applicant_details = $this->post('pd_applicant_details'); - $count = 0; + $pd_details = json_decode($this->post('pd_details'),true); + $pd_applicant_details = json_decode($this->post('pd_applicant_details'),true); + $pd_document_titles = json_decode($this->post('pd_document_titles'),true); + $pd_documents = array(); + if(!empty($_FILES['pddocuments'])) + { + + } + $count = 0; + /***********************CHOOSE PD TEMPALATE*********************/ + $fields = array('fk_template_id'); + + $where_condition_array = array('fk_lender_id'=>1 ,'fk_product_id'=> 1,'fk_customer_segment'=> 1,'isactive' => 1); + + $table = LENDERTEMPLATE; + + $choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table); + + if(count($choosed_template_id)) + { + $pd_details['fk_template_id'] = $choosed_template_id[0]['fk_template_id']; + } + + + /***********************PD ALLOCATION TYPE PROCESS **********/ + + + $where_condition_array = array('fk_city_id' => $pd_details['fk_city']); + $temp_city_id = $this->PD_Model->selectRecords(PDTEAMCITYMAP,$where_condition_array,$limit=0,$offset=0); + if(count($temp_city_id)) + { + if($temp_city_id[0]['type'] == 0) // Allocate to Vendor + { + $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id']; + $pd_details['fk_pd_allocated_to'] = ALLOCATED_TO_PARTNER; + } + else //Allocate to SineEdge Team with allocation logics + { + $local_pd_allocation_type = $pd_details['fk_pd_allocation_type']; + if($local_pd_allocation_type == 1)// AUTO - Load Balance Allocation + { + + //1.select list pd officers from lender_pd offices map table and choose minimun allocated one + $fields = array('fk_user_id'); + $where_condition_array = array('fk_lender_id'=>$pd_details['fk_lender_id'],'isactive' => 1); + $lender_specific_pdofficers_list = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); + + if(count($lender_specific_pdofficers_list)) + { + //select currently allocated PD values from PDOFFICIERSDETAILS table to find min value + $lender_specific_pdofficer_list_and_allocated_values = $this->PD_Model->getLenderSpecificPDOfficersListAndAllocatedValues($lender_specific_pdofficers_list); + + if(count($lender_specific_pdofficer_list_and_allocated_values)) + { + $allocated_values = array_column($lender_specific_pdofficer_list_and_allocated_values,'allocated'); + + $min_allocated = min($allocated_values); + $key = array_search($min_allocated,$allocated_values); + $final_pd_officer_to_allocate = $lender_specific_pdofficer_list_and_allocated_values[$key]['fk_user_id']; + $pd_details['fk_pd_allocated_to'] = $final_pd_officer_to_allocate; + $pd_details['fk_pd_status'] = ALLOCATED; + } + + } + else + { + //select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED + $fields = array('fk_user_id,allocated'); + + $where_condition_array = array('fk_pd_type_id' => $pd_details['fk_pd_type'],'fk_team_id' => $temp_city_id[0]['fk_team_id'],'fk_customer_segment' => $pd_details['fk_customer_segment'],'fk_product_id' => $pd_details['fk_product_id'],'isactive' => 1); + + $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); + + $allocated_values = array_column($list_of_pd_officers,'allocated'); + + $min_allocated = min($allocated_values); + $key = array_search($min_allocated,$allocated_values); + $final_pd_officer_to_allocate = $list_of_pd_officers[$key]['fk_user_id']; + + //For Random Allocaiton not in use + // $key = mt_rand(0, count($list_of_pd_officers) - 1); + // $final_pd_officer_to_allocate = isset($list_of_pd_officers[$key])? $list_of_pd_officers[$key]: null; + + $pd_details['fk_pd_allocated_to'] = $final_pd_officer_to_allocate; + $pd_details['fk_pd_status'] = ALLOCATED; + } + + } + else if($local_pd_allocation_type == 2) // AUTO - NEAREST Allocation + { + + } + else // Manual Allocation + { + // Do nothing, cause fk_pd_allocated_to value comes from front end. + } + + } + } + + + + + /***********************END OF PD ALLOCATION TYPE AND PROCESS***********/ $pd_id = $this->PD_Model->saveRecords(PDTRIGGER,$pd_details); + + /***********************PD DOCUMENTS UPLOAD SECTION ***********/ if($pd_id != null || $pd_id != '') { + if(!empty($_FILES['pddocuments'])) + { + + foreach($_FILES['pddocuments'] as $key => $file) + { + $tempdoc = $file['pddocuments']['tmp_name']; + $tempdocname = $file['pddocuments']['name']; + $bucketname = $pd_details['fk_lender_id'].$pd_id; + $key = $pd_id ; + $sourcefile = $tempdoc; + + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$pd_document_titles[$key],'pd_document_name'=>$tempdocname); + $this->saveRecords($record_data,PDDOCUMENTS); + } + + } + } + } + /***********************END OF PD DOCUMENTS UPLOAD SECTION ***********/ + if($pd_id != null || $pd_id != '') + { + foreach($pd_applicant_details as $pd_applicant_detail) { $pd_applicant_detail['fk_pd_id'] = $pd_id; @@ -43,8 +320,12 @@ class PD_Controller extends REST_Controller { } } + if($pd_id != null || $pd_id != '' && $count != 0) { + // CALL pdnotification Helper function to send pd alerts @ params pdid,pdstatus + //PDALERTS::pdnotification($pd_id,$pd_details['fk_pd_status']); + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $template_id; diff --git a/api/application/controllers/Question_Management_Controller.php b/api/application/controllers/Question_Management_Controller.php index 735b5239..c9696ebe 100644 --- a/api/application/controllers/Question_Management_Controller.php +++ b/api/application/controllers/Question_Management_Controller.php @@ -23,8 +23,13 @@ class Question_Management_Controller extends REST_Controller { public function listAllQuestions_get() { + $page = 0;$limit = 50;$sort = 'ASC'; - $result = $this->User_Management_Model->$listAllQuestions(); + if($this->get('page')) { $page = $this->get('page'); } + if($this->get('limit')){ $limit = $this->get('limit'); } + if($this->get('sort')) { $sort = $this->get('sort'); } + + $result = $this->User_Management_Model->$listAllQuestions($page,$limit,$sort); if($result['data_status']) { $data['dataStatus'] = true; @@ -40,47 +45,47 @@ class Question_Management_Controller extends REST_Controller { } } - public function saveNewQuestion_post()// Save Array of question and it's answers(Single too) + public function saveNewQuestion_post()// Save single question and it's answers { $records = $this->post('records'); $count = 0; - foreach($records as $record) - { + $answers = array(); - if(array_key_exists('answers',$record)) + if(array_key_exists('answers',$records)) { - $answers = $record['answers']; - unset($record['ansewrs']); + $answers = $records['answers']; + unset($records['ansewrs']); } - $question_id = $this->db->saveRecords($record,QUESTIONS); + $question_id = $this->db->saveRecords($records,QUESTIONS); if($question_id != '' || $question_id != null) { - $count++; + //$count++; foreach($answers as $answer) { - $temp_answers = array('fk_question_id' => $question_id, 'answer' =>$answer , 'createdon' =>$record['createdon'] , 'fk_createdby' =>$record['fk_createdby'] , 'updatedon' =>$record['updatedon'], 'fk_updatedby' =>$record['fk_updatedby']); - $this->db->saveRecords($temp_answers,QUESTIONANSWERS); + $temp_answers = array('fk_question_id' => $question_id, 'answer' =>$answer , 'createdon' =>$records['createdon'] , 'fk_createdby' =>$records['fk_createdby']); + $child_id = $this->db->saveRecords($temp_answers,QUESTIONANSWERS); + } } - } - if($count != 0 && $count == count($records)) + + if($question_id != '' || $question_id != null) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['record'] = $entity_id; + $data['record'] = $question_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_NOT_MODIFIED); + $this->response($data,REST_Controller::HTTP_OK); } } @@ -107,7 +112,7 @@ class Question_Management_Controller extends REST_Controller { $affected_rows_child = $this->db->updateRecords($answer,QUESTIONANSWERS,$where_condtion_array); } - if($affected_rows == 1 && (count($answers) == $affected_rows_child)) + if($affected_rows == 1) //&& (count($answers) == $affected_rows_child)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; @@ -119,7 +124,7 @@ class Question_Management_Controller extends REST_Controller { { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_NOT_MODIFIED); + $this->response($data,REST_Controller::HTTP_OK); } diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php index 275ed13b..3e2ae2e0 100644 --- a/api/application/controllers/User_Management_Controller.php +++ b/api/application/controllers/User_Management_Controller.php @@ -18,7 +18,7 @@ class User_Management_Controller extends REST_Controller { // Construct the parent class parent::__construct(); $this->load->model('User_Management_Model'); - + $this->load->library('AWS_S3'); } public function listAllUsers_get() @@ -44,13 +44,9 @@ class User_Management_Controller extends REST_Controller { public function saveNewUser_post() { - $this->load->library('AWS_S3'); - //print_r($this->post('roles'));die; - //print_r($this->post());die; - //print_r($_FILES['profilepic']['name']);die; + $roles = ""; $lender_hierarchy = ""; - //print_r($this->post('roles'));die; if($this->post('roles')){ $roles = $this->post('roles'); } if($this->post('lender_hierarchy')){ $lender_hierarchy = json_decode($this->post('lender_hierarchy'),true); } @@ -191,7 +187,7 @@ class User_Management_Controller extends REST_Controller { } } - $bucketname = PROFILEPICTUREBUCKETNAME; + $bucketname = PROFILE_PICTURE_BUCKET_NAME; $key = $profilepics3path; $sourcefile = $profilepic; @@ -276,4 +272,48 @@ class User_Management_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_NO_CONTENT); } } + + /* Get Signed URL for profile picture + @params userid , entity id, profilepic name + URL expires 5 min + */ + public function getSingedProfilePicURL() + { + $userid = $this->post('userid'); + $entityid = $this->post('entityid'); + $profilepic = $this->post('profilepic'); + + $profilepics3path = ''; + if($entityid == 1) //1 means sine_edge Profile + { + $profilepics3path = 'sineedge/'.$profilepic; + } + else if($entityid == 2)//1 means lender Profile + { + $profilepics3path = 'lender/'.$profilepic; + } + else // else or 3 means vendor Profile + { + $profilepics3path = 'vendor/'.$profilepic; + } + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI(PROFILE_PICTURE_BUCKET_NAME, $profilepics3path,'+5 minutes'); + + if($singed_uri != null || $singed_uri != '') + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $singed_uri; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Profile URL Available'; + $this->response($data,REST_Controller::HTTP_OK); + + } + + + } } \ No newline at end of file diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php new file mode 100644 index 00000000..c70d0898 --- /dev/null +++ b/api/application/helpers/pdalerts_helper.php @@ -0,0 +1,39 @@ +db->insert($table_name,$record_data); + echo "FROM HELPER-PD_ID -" . $pdid; + //1.Get Notification Configuration by using pd staus idate + + //$pd_notification_configs = + $CI->db->SELECT("PDNOTIFICATION.pdnotification_id, PDNOTIFICATION.fk_pd_status_id, PDSTATUS.pd_status_name,PDNOTIFICATION.sms_lender, PDNOTIFICATION.sms_pdofficer, PDNOTIFICATION.sms_pdincharge, PDNOTIFICATION.mail_lender, PDNOTIFICATION.mail_pdincharge, PDNOTIFICATION.mail_pdofficer"); + $CI->db->FROM(PDNOTIFICATION." as PDNOTIFICATION"); + $CI->db->JOIN(PDSTATUS." as PDSTATUS","PDNOTIFICATION.fk_pd_status_id = PDSTATUS.pd_status_id AND PDSTATUS.isactive = 1"); + $CI->db->WHERE("PDNOTIFICATION.fk_pd_status_id = $pdstatus"); + $pd_notification_configs = $CI->db->get()->result_array(); + print_r($pd_notification_configs); + } + + + } + + + + + + +} + +?> \ No newline at end of file diff --git a/api/application/libraries/SPARQ_Model.php b/api/application/libraries/SPARQ_Model.php index d983a542..d4ea0233 100644 --- a/api/application/libraries/SPARQ_Model.php +++ b/api/application/libraries/SPARQ_Model.php @@ -25,12 +25,10 @@ class SPARQ_Model extends CI_Model { } - public function selectRecords($table_name,$where_condition_array = array(),$print_query = '',$limit = 50,$offset = 0,$order = 'ASC',$order_by_colum_name = '') + public function selectRecords($table_name,$where_condition_array = array(),$limit = 50,$offset = 0,$order = 'ASC',$order_by_colum_name = '',$print_query = '') { $data = $this->db->order_by($order_by_colum_name,$order)->get_where($table_name,$where_condition_array,$limit,$offset)->result_array();//only AND condition - - - if($print_query == 1) + if($print_query == '1') { print_r($this->db->last_query()); } @@ -48,22 +46,20 @@ class SPARQ_Model extends CI_Model { return $data; } - public function selectCustomRecords($fields = '', $where = array(), $or_where_total = array(),$table = '', $limit = '', $order_by_colum_name = '', $order_by = 'ASC', $group_by = '',$print_query = '') { + public function selectCustomRecords($fields = '', $where_condition_array = array(),$table = '', $or_where_total = array(), $limit = '', $order_by_colum_name = '', $order_by = 'ASC', $group_by = '',$print_query = '') { - - //$data = array(); - if ($fields != '') { + if ($fields != '') { $this->db->select($fields); } - if (count($where)) { - $this->db->where($where); + if (count($where_condition_array)) { + $this->db->where($where_condition_array); } if (count($or_where_total)) { - - foreach($or_where_total as $or_where) + + foreach($or_where_total as $or_where) { $this->db->or_where($or_where); } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 10c61c54..4ec89373 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -63,4 +63,13 @@ class PD_Model extends SPARQ_Model { } } + + // get Lender Specific PDOfficers List And Currently Allocated PD Values form PDOFFICIERSDETAILS table + public function getLenderSpecificPDOfficersListAndAllocatedValues($lender_specific_pdofficers_list) + { + $this->db->SELECT('fk_user_id,allocated'); + $this->db->FROM(PDOFFICIERSDETAILS); + $this->db->WHERE_IN('fk_user_id',$lender_specific_pdofficers_list); + $result = $this->db->get()->result_array(); + } } \ No newline at end of file diff --git a/api/application/models/Question_Management_Model.php b/api/application/models/Question_Management_Model.php index bc06f29e..5ace9256 100644 --- a/api/application/models/Question_Management_Model.php +++ b/api/application/models/Question_Management_Model.php @@ -10,18 +10,20 @@ class Question_Management_Model extends SPARQ_Model { } - public function listAllQuestions() + public function listAllQuestions($page,$limit,$sort) { - + $this->db->SELECT('QUESTIONS.question_id, QUESTIONS.question, QUESTIONS.description, QUESTIONS.fk_question_catagory,QUESTIONCATEGORY.category_name, QUESTIONS.fk_question_answertype,QUESTIONANSWERTYPE.answer_type_name,QUESTIONS.isactive, QUESTIONS.createdon, QUESTIONS.fk_createdby, QUESTIONS.updatedon, QUESTIONS.fk_updatedby,concat(USERPROFILE.first_name,' ',USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name,' ',USERPROFILE1.last_name) as updatedby'); $this->db->FROM(QUESTIONS.' as QUESTIONS'); $this->db->JOIN(QUESTIONANSWERTYPE.' as QUESTIONANSWERTYPE','QUESTIONS.fk_question_answertype = QUESTIONANSWERTYPE.question_answer_type_id AND QUESTIONANSWERTYPE.isactive = 1'); $this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','QUESTIONS.fk_question_catagory = QUESTIONCATEGORY.question_categroy_id AND QUESTIONCATEGORY.isactive = 1'); $this->db->JOIN(USERPROFILE.' as USERPROFILE','QUESTIONS.fk_createdby = USERPROFILE.userid AND USERPROFILE.isactive = 1'); $this->db->JOIN(USERPROFILE.' as USERPROFILE1','QUESTIONS.fk_updatedby = USERPROFILE1.userid AND USERPROFILE1.isactive = 1'); + $this->db->ORDER_BY('QUESTIONS.question_id',$sort); + $this->db->LIMIT($page,$limit); - $result = $this->db->get()->result_array(); + $result = $this->db->GET()->result_array(); foreach($result as $key => $r) { diff --git a/api/application/models/User_Management_Model.php b/api/application/models/User_Management_Model.php index 8d2a9771..3060137b 100644 --- a/api/application/models/User_Management_Model.php +++ b/api/application/models/User_Management_Model.php @@ -33,29 +33,29 @@ class User_Management_Model extends SPARQ_Model { $result = $this->db->get()->result_array(); - foreach($result as $key => $pics) - { - if($pics['profilepic'] != '' || $pics['profilepic'] != null) - { - $profilepics3path = ''; - if($pics['fk_entity_id'] == 1) //1 means sine_edge Profile - { - $profilepics3path = 'sineedge/'.$pics['profilepic']; - } - else if($pics['fk_entity_id'] == 2)//1 means lender Profile - { - $profilepics3path = 'lender/'.$pics['profilepic']; - } - else // else or 3 means vendor Profile - { - $profilepics3path = 'vendor/'.$pics['profilepic']; - } - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI(PROFILE_PICTURE_BUCKET_NAME, $profilepics3path,'+5 minutes'); + // foreach($result as $key => $pics) + // { + // if($pics['profilepic'] != '' || $pics['profilepic'] != null) + // { + // $profilepics3path = ''; + // if($pics['fk_entity_id'] == 1) //1 means sine_edge Profile + // { + // $profilepics3path = 'sineedge/'.$pics['profilepic']; + // } + // else if($pics['fk_entity_id'] == 2)//1 means lender Profile + // { + // $profilepics3path = 'lender/'.$pics['profilepic']; + // } + // else // else or 3 means vendor Profile + // { + // $profilepics3path = 'vendor/'.$pics['profilepic']; + // } + // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI(PROFILE_PICTURE_BUCKET_NAME, $profilepics3path,'+5 minutes'); - $result[$key]['profilepic_singed_url'] = $singed_uri; + // $result[$key]['profilepic_singed_url'] = $singed_uri; - } - } + // } + // } if($result != '' ){ @@ -81,6 +81,8 @@ class User_Management_Model extends SPARQ_Model { } } + + public function getUserDetails($userid){