From 7f320b01380fa1738eb392ad307303f707ddfc6b Mon Sep 17 00:00:00 2001 From: venbaSriram Date: Mon, 22 Oct 2018 18:22:54 +0530 Subject: [PATCH] PD OTP API --- api/application/config/routes.php | 1 + api/application/controllers/PD_Controller.php | 40 +++++++++++++++++++ api/application/models/PD_Model.php | 30 +++++++++++++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 4d13ce6c..8c554983 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -135,4 +135,5 @@ $route['getListPDOfficers'] = 'PD_Controller/getListPDOfficers'; $route['loadFullTemplate'] = 'PD_Controller/loadFullTemplate'; $route['allbase'] = 'PD_Controller/base'; $route['savePDQuestions'] = 'PD_Controller/saveActualPDQuestions'; +$route['checkOTP'] = 'PD_Controller/checkOTP'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index a49222e8..5909ac93 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -450,7 +450,21 @@ class PD_Controller extends REST_Controller { public function updatePDMaster_post() { $pd_details = $this->post('records'); + // print_r($pd_details);die; //print_r($pd_details); + + // OTP Generate Condition + if($pd_details['pd_status'] == STARTED) + { + $string2 = str_shuffle('1234567890'); + $OTP = substr($string2,0,6); + $msg = "Code for starting your personal discussions with the verification officer is ".$OTP .". Pls share this only when the officer has reached your place in person"; + $no = (string)$pd_details['mobile_no']; + unset($pd_details['mobile_no']); + $pd_details['OTP'] = $OTP; + $this->aws_sns->sendSMS($msg,$no); + + } $where_condition_array = array('pd_id' => $pd_details['pd_id']); $pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array); @@ -459,6 +473,7 @@ class PD_Controller extends REST_Controller { // Create entries on `t_pd_category_weightage` table from Template Category weightage } + if($pd_id_modified != null || $pd_id_modified != '' && $count != 0) { PDALERTS::pdnotification($pd_details['pd_id']); @@ -476,6 +491,31 @@ class PD_Controller extends REST_Controller { } + /** + * Pd Discussion OTP Checking function + * sriram + */ + + public function checkOTP_post() + { + $pdotp = $this->post('records'); + + $pdotpStatus = $this->PD_Model->checkotp($pdotp); + if($pdotpStatus != 0 || $pdotpStatus != '' && count($pdotpStatus) != 0) + { + + $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_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_OK); + } + } /* * diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 0bb334c6..aeb08a23 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -13,7 +13,7 @@ class PD_Model extends SPARQ_Model { public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid)// $page represents mysql offset { - $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y") as completed_on'); + $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y ") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y") as completed_on'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); $this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT'); @@ -70,7 +70,7 @@ class PD_Model extends SPARQ_Model { $this->db->ORDER_BY('PDTRIGGER.pd_id',$sort); $this->db->LIMIT($limit,$page); $result_array = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); + if(count($result_array) != 0) { foreach($result_array as $key => $result) @@ -330,5 +330,31 @@ class PD_Model extends SPARQ_Model { return $categories; } + + /** + * Check OTP PDTRIGGER TABLE + * param OTP AND pd_id + *sriram + */ + + public function checkotp($pddata) + { + $this->db->select('OTP'); + $this->db->where('pd_id',$pddata['pd_id']); + $result = $this->db->get(PDTRIGGER.' as PDTRIGGER')->first_row(); + + if(count($result) !='0') + { + if($result->OTP == $pddata['OTP']) + { + $result = true; + }else + { + $result = false; + } + } + + return $result; + } } \ No newline at end of file