From 21dd6543fff2d7a4db07e16b7b78ef3f580830f3 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 31 Oct 2018 19:45:37 +0530 Subject: [PATCH] FREETEXT --- api/application/config/constants.php | 2 +- .../Entity_Management_Controller.php | 2 +- api/application/controllers/PD_Controller.php | 27 +++++++++++-------- api/application/models/PD_Model.php | 6 +++-- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 3cebd201..5d9b3336 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -87,7 +87,7 @@ 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', '(listAllTemplates/:any)'); // no errors -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getListPDOfficers'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'savePDQuestions'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); diff --git a/api/application/controllers/Entity_Management_Controller.php b/api/application/controllers/Entity_Management_Controller.php index 03a4fbb1..097c5d6b 100644 --- a/api/application/controllers/Entity_Management_Controller.php +++ b/api/application/controllers/Entity_Management_Controller.php @@ -416,7 +416,7 @@ class Entity_Management_Controller extends REST_Controller { public function getEntityRegionCityMap_get() { $entity_id = $this->get('entityid'); - $fields = array('fk_region_id','fk_city_id','fk_entity_id','entity_region_map_id'); + $fields = array('fk_region_id','fk_city_id','fk_entity_id','entity_region_map_id','isactive'); $where_condition_array = array('fk_entity_id' => $entity_id); $records = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,ENTITYREGION); if($records != null || $records != "") diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index cc8af66e..304da522 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -483,7 +483,7 @@ class PD_Controller extends REST_Controller { // Template Re assign Functionality $fields = array('fk_lender_id','fk_product_id','fk_customer_segment','pd_status'); - $where_condition_array = array('pd_id'=>$pdid); + $where_condition_array = array('pd_id'=>$pd_details['pd_id']); $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); /***********************CHOOSE PD TEMPALATE*********************/ @@ -1163,6 +1163,7 @@ class PD_Controller extends REST_Controller { public function saveActualPDQuestions_post() { //$records = json_decode($this->post('records'),true); + //echo "hi"; $records = $this->post('records'); $pd_detail_id = ""; $pd_detail_answer_id = ""; @@ -1170,11 +1171,13 @@ class PD_Controller extends REST_Controller { $answer_count = ""; $images_array = array(); $answers_array = array(); - //print_r($records); - text,options,checkbox + foreach($records as $record_key => $record) - { + { + if($record['pd_detail_id'] != "" || $record['pd_detail_id'] != null) { + if($record['answers'] != "" || $record['answers'] != null) { $answers_array = $record['answers']; @@ -1193,16 +1196,12 @@ class PD_Controller extends REST_Controller { // ANSWERS SAVE - pd_detail_answer_id, fk_pd_id, fk_pd_detail_id, pd_answer_id, pd_answer, pd_answer_weightage, pd_answer_remark if(count($answers_array)) { - foreach($answers_array as $answer_key => $answer) - { - if($answer['pd_detail_answer_id'] == "" || $answer['pd_detail_answer_id'] == null) - { - + + //Deactivate Old Answers $fields = array('pd_detail_answer_id'); - $where_condition_array = array('fk_pd_id' => $answer['fk_pd_id'],'fk_pd_detail_id' => $answer['fk_pd_detail_id']); + $where_condition_array = array('fk_pd_id' => $record['fk_pd_id'],'fk_pd_detail_id' => $record['pd_detail_id']); $old_answers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDANSWER); - foreach($old_answers as $old) { $where_condition_array = array('pd_detail_answer_id'=>$old['pd_detail_answer_id']); @@ -1210,6 +1209,11 @@ class PD_Controller extends REST_Controller { $pd_detail_answer_id = $this->PD_Model->updateRecords($temp_array,PDANSWER,$where_condition_array); } + foreach($answers_array as $answer_key => $answer) + { + if($answer['pd_detail_answer_id'] == "" || $answer['pd_detail_answer_id'] == null) + { + //INsert New Answers $answer['fk_pd_detail_id'] = $record['pd_detail_id']; $pd_detail_answer_id = $this->PD_Model->saveRecords($answer,PDANSWER); @@ -1300,6 +1304,7 @@ class PD_Controller extends REST_Controller { else { + if($record['answers'] != "" || $record['answers'] != null) { @@ -1312,7 +1317,7 @@ class PD_Controller extends REST_Controller { $images_array = $record['images']; unset($record['images']); } - + //print_r($record);die(); $pd_detail_id = $this->PD_Model->saveRecords($record,PDDETAIL); // ANSWERS SAVE - pd_detail_answer_id, fk_pd_id, fk_pd_detail_id, pd_answer_id, pd_answer, pd_answer_weightage, pd_answer_remark diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 8b760e06..b3735791 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -359,7 +359,7 @@ class PD_Model extends SPARQ_Model { */ public function getPDMasterDetails($pdid) { - $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 %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") 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,concat(USERPROFILE3.first_name," ",USERPROFILE3.last_name) as pd_executive,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 %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") 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'); @@ -371,6 +371,7 @@ class PD_Model extends SPARQ_Model { $this->db->JOIN(USERPROFILE.' as USERPROFILE1','PDTRIGGER.fk_updatedby = USERPROFILE1.userid','LEFT'); $this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDTRIGGER.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE2','PDTRIGGER.fk_pd_allocated_to = USERPROFILE2.userid','LEFT'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE3','PDTRIGGER.executive_id = USERPROFILE3.userid','LEFT'); $this->db->JOIN(TEMPLATE.' as TEMPLATE','PDTRIGGER.fk_pd_template_id = TEMPLATE.template_id','LEFT'); $this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDTRIGGER.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id','LEFT'); $this->db->JOIN(ENTITY.' as AGENCY','PDTRIGGER.pd_agency_id = AGENCY.entity_id','LEFT'); @@ -508,7 +509,7 @@ class PD_Model extends SPARQ_Model { { $overalldata =array(); $pd_master_detials = $this->getPDMasterDetails($pd_id); - $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.pd_detail_answer_id,PDANSWER.isactive,PDANSWER.fk_pd_detail_id'); + $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,PDANSWER.pd_answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.pd_detail_answer_id,PDANSWER.isactive,PDANSWER.fk_pd_detail_id'); $this->db->FROM(TEMPLATEANSWERWEIGHTAGE.' as TEMPLATEANSWERWEIGHTAGE'); $this->db->JOIN(TEMPLATEQUESTION." as TEMPLATEQUESTION","TEMPLATEANSWERWEIGHTAGE.fk_template_question_id = TEMPLATEQUESTION.template_question_id AND TEMPLATEQUESTION.fk_template_question_category_id = $category_id AND TEMPLATEQUESTION.fk_template_id = $template_id AND TEMPLATEQUESTION.fk_question_id = $question_id"); $this->db->JOIN(QUESTIONANSWERS.' as QUESTIONANSWERS','TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id = QUESTIONANSWERS.question_answer_id'); @@ -522,6 +523,7 @@ class PD_Model extends SPARQ_Model { //$this->db->WHERE('TEMPLATEANSWERWEIGHTAGE.fk_template_id',$template_id); // $this->db->WHERE('PDDETAIL.fk_pd_id',$pdid); $answers = $this->db->GET()->result_array(); + $overalldata['answers'] = $answers; //Get PD Detail ID From PD DETAILS table using pd_id and question_id