From d77df52983191b9e6055b6f6a3e1eea4bbfa8cab Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 16 Oct 2018 18:20:43 +0530 Subject: [PATCH] TEMPLATE --- api/application/config/constants.php | 2 +- api/application/config/routes.php | 1 + api/application/controllers/PD_Controller.php | 7 ++- .../Template_Management_Controller.php | 24 +++++++- api/application/controllers/Welcome.php | 6 ++ api/application/models/PD_Model.php | 7 ++- .../models/Template_Management_Model.php | 56 +++++++++++++++++++ 7 files changed, 98 insertions(+), 5 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index b34f2e18..a50ae377 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', 'loadFullTemplate'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getQuestionsForTemplateCreation'); // 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 6546b4f5..85f5715c 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -102,6 +102,7 @@ $route['getTemplateLenders'] = 'Template_Management_Controller/getTemplateLender $route['getTemplateCategories'] = 'Template_Management_Controller/getTemplateCategories'; $route['getTemplateQuestionAnswers'] = 'Template_Management_Controller/getTemplateQuestionAnswers'; $route['getListOfCategories'] = 'Template_Management_Controller/getListOfCategories'; +$route['getQuestionsForTemplateCreation'] = 'Template_Management_Controller/getQuestionsForTemplateCreation'; //QUESTION MANAGEMENT $route['(listAllQuestions/:any)'] = 'Question_Management_Controller/listAllQuestions/'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 26475195..2a4de417 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -22,7 +22,8 @@ class PD_Controller extends REST_Controller { $this->load->library('AWS_SNS'); } - /***********************Get get List Of Lenders Details for PD Trigger Page************************/ + +/***********************Get get List Of Lenders Details for PD Trigger Page************************/ public function getListOfLenders_get() { @@ -724,15 +725,17 @@ class PD_Controller extends REST_Controller { public function listLessPDDetails_get() { $page = 0;$limit = 50;$sort = 'DESC';$pdofficerid = "";$datetype = "";$fdate ="";$tdate =""; + $lenderid = ""; if($this->get('page')) { $page = $this->get('page'); } if($this->get('limit')){ $limit = $this->get('limit'); } if($this->get('sort')) { $sort = $this->get('sort'); } if($this->get('pdofficerid')) { $pdofficerid = $this->get('pdofficerid'); } + if($this->get('lenderid')) { $lenderid = $this->get('lenderid'); } if($this->get('datetype')) { $datetype = $this->get('datetype'); } if($this->get('fdate')) { $fdate = $this->get('fdate'); } if($this->get('tdate')) { $tdate = $this->get('tdate'); } - $result_data = $this->PD_Model->listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate); + $result_data = $this->PD_Model->listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid); if($result_data['data_status'] == true) { diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index d6bddbe1..5c65fcd4 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -376,5 +376,27 @@ class Template_Management_Controller extends REST_Controller { } } - + public function getQuestionsForTemplateCreation_post() + { + $template_id = "";$category_id = ""; + + if($this->post('template_id')){ $template_id = $this->post('template_id'); } + if($this->post('category_id')){ $category_id = $this->post('category_id'); } + + $questions = $this->Template_Management_Model->getListOfQuestions($template_id,$category_id); + if(count($questions)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $questions; + $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); + + } + } } \ No newline at end of file diff --git a/api/application/controllers/Welcome.php b/api/application/controllers/Welcome.php index 9213c0cf..df8b7c0c 100644 --- a/api/application/controllers/Welcome.php +++ b/api/application/controllers/Welcome.php @@ -20,6 +20,12 @@ class Welcome extends CI_Controller { */ public function index() { + // require_once APPPATH . '/controllers/PD_Controller.php'; + // require_once APPPATH . '/libraries/REST_Controller.php'; $this->load->view('welcome_message'); + //$this->load->library('../controllers/PD_Controller'); + // $PD_Controller = new PD_Controller(); + //echo $PD_Controller->index(); + } } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 396fcbd7..1569e444 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -11,7 +11,7 @@ class PD_Model extends SPARQ_Model { } - public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate)// $page represents mysql offset + 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'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); @@ -36,6 +36,11 @@ class PD_Model extends SPARQ_Model { $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficerid); } + if($lenderid != "" || $lenderid != null) + { + $this->db->WHERE('PDTRIGGER.fk_lender_id',$lenderid); + } + if($datetype != "" || $datetype != null) { if($datetype == 1) diff --git a/api/application/models/Template_Management_Model.php b/api/application/models/Template_Management_Model.php index 6bfe2461..a0b21ecb 100644 --- a/api/application/models/Template_Management_Model.php +++ b/api/application/models/Template_Management_Model.php @@ -143,5 +143,61 @@ class Template_Management_Model extends SPARQ_Model { return $categories; } + + + public function getListOfQuestions($template_id,$category_id) + { + $questions = array(); + if(($template_id != "" || $template_id != null) && ($category_id != "" || $category_id != null)) + { + $fields = array('fk_question_id'); + $where_condition_array = array('fk_template_question_category_id' => $category_id,'fk_template_id' => $template_id); + $result_data = $this->selectCustomRecords($fields,$where_condition_array,TEMPLATEQUESTION); + + if(count($result_data)) + { + $temp_array = array(); + foreach($result_data as $res) + { + array_push($temp_array,$res['fk_question_id']); + } + + // $this->db->SELECT('question_id,question'); + // $this->db->FROM(QUESTIONS); + // $this->db->WHERE('fk_question_category',$category_id); + // $this->db->WHERE_NOT_IN('question_id',$temp_array); + // $questions = $this->db->get()->result_array(); + + $this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question,TEMPLATEQUESTION.template_question_id, TEMPLATEQUESTION.fk_template_id, TEMPLATEQUESTION.fk_question_id, TEMPLATEQUESTION.question_weightage, TEMPLATEQUESTION.question_answerable_by,TEMPLATEQUESTION.fk_template_question_category_id, TEMPLATEQUESTION.isactive'); + //$this->db->FROM(TEMPLATEQUESTION.' as TEMPLATEQUESTION'); + $this->db->FROM(QUESTIONS.' as QUESTIONS'); + $this->db->JOIN(TEMPLATEQUESTION.' as TEMPLATEQUESTION','QUESTIONS.question_id = TEMPLATEQUESTION.fk_question_id','LEFT'); + // $this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATEQUESTION.fk_createdby = USERPROFILE.userid','LEFT'); + // $this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATEQUESTION.fk_updatedby = USERPROFILE1.userid','LEFT'); + $this->db->WHERE('QUESTIONS.fk_question_category',$category_id); + $this->db->WHERE_NOT_IN('QUESTIONS.question_id',$temp_array); + $questions = $this->db->GET()->result_array(); + + + if(count($questions)) + { + + foreach($questions as $answer_key => $question) + { + $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage_id, TEMPLATEANSWERWEIGHTAGE.fk_template_question_id, TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id, TEMPLATEANSWERWEIGHTAGE.template_answer_weightage, TEMPLATEANSWERWEIGHTAGE.isactive'); + $this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS'); + $this->db->JOIN(TEMPLATEANSWERWEIGHTAGE.' as TEMPLATEANSWERWEIGHTAGE','QUESTIONANSWERS.question_answer_id = TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id','LEFT'); + $this->db->WHERE('QUESTIONANSWERS.fk_question_id',$question['question_id']); + $answers = $this->db->GET()->result_array(); + $questions[$answer_key]['answers'] = $answers; + } + } + //$questions['answers'] = $questions; + + } + + } + return $questions; + } } \ No newline at end of file