From d5fc15dd4ab6648a43ed5501909cab8a742264f8 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 27 Sep 2018 15:51:29 +0530 Subject: [PATCH] QUES MASTER FUNC ADDED --- api/application/config/constants.php | 2 +- api/application/config/routes.php | 6 ++ api/application/controllers/PD_Controller.php | 4 +- .../Question_Management_Controller.php | 66 +++++++++++++++---- 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index d6b0dad2..499e1bba 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -86,7 +86,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', 'triggerNewPD'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getListOfProducts'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index f8cb6d71..105f5c6b 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -93,6 +93,7 @@ $route['saveTemplateCategoryDetails'] = 'Template_Management_Controller/saveTemp $route['(listAllQuestions/:any)'] = 'Question_Management_Controller/listAllQuestions/'; $route['saveNewQuestion'] = 'Question_Management_Controller/saveNewQuestion'; $route['saveExistQuestion'] = 'Question_Management_Controller/saveExistQuestion'; +$route['updateAnswerStatus'] = 'Question_Management_Controller/updateAnswerStatus'; //ENTITY MANAGEMENT $route['listAllEntites'] = 'Entity_Management_Controller/listAllEntites'; @@ -103,4 +104,9 @@ $route['saveExistEntity'] = 'Entity_Management_Controller/saveExistEntity'; $route['triggerNewPD'] = 'PD_Controller/triggerNewPD'; $route['updateExistPD'] = 'PD_Controller/updateExistPD'; $route['(listLessPDDetails/:any)'] = 'PD_Controller/listLessPDDetails/'; +$route['getListOfProducts'] = 'PD_Controller/getListOfProducts'; +$route['getListOfLenders'] = 'PD_Controller/getListOfLenders'; +$route['getListOfCustomerSegments'] = 'PD_Controller/getListOfCustomerSegments'; +$route['getListOfPDAllocationTypes'] = 'PD_Controller/getListOfPDAllocationTypes'; +$route['getListOfStatesAndCities'] = 'PD_Controller/getListOfStatesAndCities'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 7f4061e6..a843a0b9 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -172,10 +172,10 @@ class PD_Controller extends REST_Controller { /********For Save New PD while Trigger****/ public function triggerNewPD_post() { - echo "TRIGGER"; + //echo "TRIGGER"; //$this->aws_ses->verifyEmailIdentity('raro@spindl-e.com'); //$this->aws_ses->sendMail('raro@spindl-e.com'); - die(); + //die(); $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); diff --git a/api/application/controllers/Question_Management_Controller.php b/api/application/controllers/Question_Management_Controller.php index 9ffdab80..4e6eb702 100644 --- a/api/application/controllers/Question_Management_Controller.php +++ b/api/application/controllers/Question_Management_Controller.php @@ -64,13 +64,16 @@ class Question_Management_Controller extends REST_Controller { if($question_id != '' || $question_id != null) { //$count++; - foreach($answers as $answer) + if(count($answers)) { - - - $temp_answers = array('fk_question_id' => $question_id, 'answer' =>$answer['answer'] , 'createdon' =>$records['createdon'] , 'fk_createdby' =>$records['fk_createdby']); - $child_id = $this->Question_Management_Model->saveRecords($temp_answers,QUESTIONANSWERS); - + foreach($answers as $answer) + { + + + $temp_answers = array('fk_question_id' => $question_id, 'answer' =>$answer['answer'] , 'createdon' =>$records['createdon'] , 'fk_createdby' =>$records['fk_createdby']); + $child_id = $this->Question_Management_Model->saveRecords($temp_answers,QUESTIONANSWERS); + + } } } @@ -107,14 +110,27 @@ class Question_Management_Controller extends REST_Controller { } $where_condtion_array = array('question_id'=>$records['question_id']); - $affected_rows = $this->db->updateRecords($records,QUESTIONS,$where_condtion_array); + $affected_rows = $this->Question_Management_Model->updateRecords($records,QUESTIONS,$where_condtion_array); $affected_rows_child = 0; - foreach($answers as $answer) - { - $where_condtion_array = array('question_answer_id'=>$answer['question_answer_id']); - $affected_rows_child = $this->db->updateRecords($answer,QUESTIONANSWERS,$where_condtion_array); - } + if(count($answers)) + { + foreach($answers as $answer) + { + if($answer['question_answer_id'] != null || $answer['question_answer_id'] != '') + { + $where_condtion_array = array('question_answer_id'=>$answer['question_answer_id']); + $answer['updatedon'] = $records['updatedon']; + $answer['fk_updatedby'] = $records['fk_updatedby']; + $affected_rows_child = $this->Question_Management_Model->updateRecords($answer,QUESTIONANSWERS,$where_condtion_array); + } + else + { + $temp_answers = array('fk_question_id' => $records['question_id'], 'answer' =>$answer['answer'] , 'createdon' =>$records['updatedon'] , 'fk_createdby' =>$records['fk_updatedby']); + $child_id = $this->Question_Management_Model->saveRecords($temp_answers,QUESTIONANSWERS); + } + } + } if($affected_rows == 1) //&& (count($answers) == $affected_rows_child)) { $data['dataStatus'] = true; @@ -133,6 +149,32 @@ class Question_Management_Controller extends REST_Controller { } } + /* ******** For Updated isActive status of ansewrs only ******/ + public function updateAnswerStatus() + { + $records = $this->post('records'); + + $where_condtion_array = array('question_answer_id' => $records['question_answer_id']); + $affected_rows = $this->Question_Management_Model->updateRecords($records,QUESTIONANSWERS,$where_condtion_array); + + if($affected_rows == 1) //&& (count($answers) == $affected_rows_child)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['record'] = $affected_rows; + $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); + + + } + } + }