TEMPLATE ACTIONS

This commit is contained in:
velz 2018-10-11 19:22:59 +05:30
parent 89d6a4880d
commit 061e7d3179
4 changed files with 185 additions and 17 deletions

View File

@ -86,7 +86,8 @@ 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', '(listAllTemplates/:any)'); // no errors
defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'saveTemplateQuestionAnswers'); // no errors
/*********************AWS resources Constants*************************************************/
defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic');

View File

@ -93,6 +93,11 @@ $route['(listAllTemplates/:any)'] = 'Template_Management_Controller/listAllTempl
$route['saveNewTemplateName'] = 'Template_Management_Controller/saveNewTemplateName';
$route['saveTemplateLenderDetails'] = 'Template_Management_Controller/saveTemplateLenderDetails';
$route['saveTemplateCategoryDetails'] = 'Template_Management_Controller/saveTemplateCategoryDetails';
$route['saveTemplateQuestionAnswers'] = 'Template_Management_Controller/saveTemplateQuestionAnswers';
$route['getTemplateMaster'] = 'Template_Management_Controller/getTemplateMaster';
$route['getTemplateLenders'] = 'Template_Management_Controller/getTemplateLenders';
$route['getTemplateCategories'] = 'Template_Management_Controller/getTemplateCategories';
$route['getTemplateQuestionAnswers'] = 'Template_Management_Controller/getTemplateQuestionAnswers';
//QUESTION MANAGEMENT
$route['(listAllQuestions/:any)'] = 'Question_Management_Controller/listAllQuestions/';

View File

@ -43,9 +43,9 @@ class Template_Management_Controller extends REST_Controller {
public function saveNewTemplateName_post()
{
$records = $this->post('records');
if($records['template_id'] == null || $records['template_id'] == "")
{
$template_id = $this->Template_Management_Model->saveRecords($records,TEMPLATE);
if($template_id != "" || $template_id != null)
{
@ -64,9 +64,10 @@ class Template_Management_Controller extends REST_Controller {
}
else
{
$where_condition_array = array('template_id'=>$records['template_id']);
$modified = $this->db->updateRecords($records,TEMPLATE,$where_condition_array);
if($template_id != "" || $template_id != null)
$modified = $this->Template_Management_Model->updateRecords($records,TEMPLATE,$where_condition_array);
if($modified != "" || $modified != null)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@ -91,12 +92,12 @@ class Template_Management_Controller extends REST_Controller {
$count = 0;
$template_lender_details = $this->post('records');
//print_r($template_lender_details);die();
foreach($template_lender_details as $template_lender_detail)
{
if($template_lender_detail['template_lender_map_id'] != null || $template_lender_detail['template_lender_map_id'] != "")
{
$where_condition_array = array('fk_template_id'=>$template_lender_detail['fk_template_id']);
$where_condition_array = array('template_lender_map_id'=>$template_lender_detail['template_lender_map_id']);
$modified = $this->Template_Management_Model->updateRecords($template_lender_detail,LENDERTEMPLATE,$where_condition_array);
if($modified != "" || $modified != null){ $count++; }
}
@ -132,7 +133,7 @@ class Template_Management_Controller extends REST_Controller {
$count = 0;
$template_category_details = $this->post('records');
//print_r($template_category_details);die();
foreach($template_category_details as $template_category_detail)
{
if($template_category_detail['template_catagory_weightage_id'] != null || $template_category_detail['template_catagory_weightage_id'] != "")
@ -144,12 +145,12 @@ class Template_Management_Controller extends REST_Controller {
else
{
$id = $this->Template_Management_Model->saveRecords($template_lender_detail,TEMPLATECATAGORYWEIGHTAGE);
$id = $this->Template_Management_Model->saveRecords($template_category_detail,TEMPLATECATAGORYWEIGHTAGE);
if($id != "" || $id != null){ $count++; }
}
}
if($count == count($template_lender_details))
if($count == count($template_category_details))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@ -172,16 +173,16 @@ class Template_Management_Controller extends REST_Controller {
{
$count = 0;
$template_question_answers_details = $this->post('records');
print_r($template_question_answers_details);
foreach($template_question_answers_details as $key => $template_question_answers_detail)
{
$answers_array = array();
if($template_question_answers_detail['template_question_id'] != null || $template_question_answers_detail['template_question_id'] != "")
{
if(isset($template_question_answers_detail['answers_details']))
if(isset($template_question_answers_detail['answers']))
{
$answers_array = $template_question_answers_detail['answers_details'];
unset($template_question_answers_detail['answers_details']);
$answers_array = $template_question_answers_detail['answers'];
unset($template_question_answers_detail['answers']);
}
$where_condition_array = array('template_question_id' => $template_question_answers_detail['template_question_id']);
@ -224,10 +225,10 @@ class Template_Management_Controller extends REST_Controller {
}
else
{
if(isset($template_question_answers_detail['answers_details']))
if(isset($template_question_answers_detail['answers']))
{
$answers_array = $template_question_answers_detail['answers_details'];
unset($template_question_answers_detail['answers_details']);
$answers_array = $template_question_answers_detail['answers'];
unset($template_question_answers_detail['answers']);
}
$question_id = $this->Template_Management_Model->saveRecords($template_question_answers_detail,TEMPLATEQUESTION);
@ -236,6 +237,7 @@ class Template_Management_Controller extends REST_Controller {
{
foreach($answers_array as $key => $answer)
{
$answer['fk_template_question_id'] = $question_id;
$answer_inserted = $this->Template_Management_Model->saveRecords($answer,TEMPLATEANSWERWEIGHTAGE);
if($answer_inserted != "" || $answer_inserted != null) {$count++;}
}
@ -261,6 +263,85 @@ class Template_Management_Controller extends REST_Controller {
}
}
public function getTemplateMaster_post()
{
$template_id = $this->post('template_id');
$template_master = $this->Template_Management_Model->getTemplateMaster($template_id);
if(count($template_master))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $template_master;
$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);
}
}
public function getTemplateLenders_post()
{
$template_id = $this->post('template_id');
$template_lenders = $this->Template_Management_Model->getTemplateLenders($template_id);
if(count($template_lenders))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $template_lenders;
$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);
}
}
public function getTemplateCategories_post()
{
$template_id = $this->post('template_id');
$template_categories = $this->Template_Management_Model->getTemplateCategories($template_id);
if(count($template_categories))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $template_categories;
$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);
}
}
public function getTemplateQuestionAnswers_post()
{
$template_id = $this->post('template_id');
$template_questionanswers = $this->Template_Management_Model->getTemplateQuestionAnswers($template_id);
if(count($template_questionanswers))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $template_questionanswers;
$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);
}
}
}

View File

@ -12,7 +12,14 @@ class Template_Management_Model extends SPARQ_Model {
public function listAllTemplates($page,$limit,$sort)
{
$templates = $this->selectRecords(TEMPLATE,array(),$limit,$page,$sort);
$this->db->SELECT('TEMPLATE.template_id, TEMPLATE.template_name, DATE_FORMAT(TEMPLATE.createdon,"%d/%m/%Y") as createdon, TEMPLATE.fk_createdby,TEMPLATE.updatedon, TEMPLATE.fk_updatedby, TEMPLATE.isactive,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
$this->db->FROM(TEMPLATE.' as TEMPLATE');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATE.fk_createdby = USERPROFILE.userid');
$this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATE.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->ORDER_BY('TEMPLATE.template_id',$sort);
$this->db->LIMIT($limit,$page);
$templates = $this->db->GET()->result_array();
if(count($templates))
{
@ -43,5 +50,79 @@ class Template_Management_Model extends SPARQ_Model {
}
}
public function getTemplateMaster($template_id)
{
$this->db->SELECT('TEMPLATE.template_id, TEMPLATE.template_name, DATE_FORMAT(TEMPLATE.createdon,"%d/%m/%Y") as createdon, TEMPLATE.fk_createdby,TEMPLATE.updatedon, TEMPLATE.fk_updatedby, TEMPLATE.isactive,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
$this->db->FROM(TEMPLATE.' as TEMPLATE');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATE.fk_createdby = USERPROFILE.userid');
$this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATE.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('TEMPLATE.template_id',$template_id);
$template = $this->db->GET()->result_array();
return $template;
}
public function getTemplateLenders($template_id)
{
$this->db->SELECT('LENDERTEMPLATE.template_lender_map_id, LENDERTEMPLATE.fk_template_id, LENDERTEMPLATE.fk_lender_id,ENTITY.full_name,ENTITY.short_name, LENDERTEMPLATE.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, LENDERTEMPLATE.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name, CUSTOMERSEGMENT.abbr as customer_segment_abbr,DATE_FORMAT(LENDERTEMPLATE.createdon, "%d/%m/%Y") as createdon,LENDERTEMPLATE.fk_createdby, DATE_FORMAT(LENDERTEMPLATE.updatedon,"%d/%m/%Y") as updatedon, LENDERTEMPLATE.isactive,LENDERTEMPLATE.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
$this->db->FROM(LENDERTEMPLATE.' as LENDERTEMPLATE');
$this->db->JOIN(ENTITY.' as ENTITY','LENDERTEMPLATE.fk_lender_id = ENTITY.entity_id');
$this->db->JOIN(PRODUCTS.' as PRODUCTS','LENDERTEMPLATE.fk_product_id = PRODUCTS.product_id');
$this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','LENDERTEMPLATE.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','LENDERTEMPLATE.fk_createdby = USERPROFILE.userid');
$this->db->JOIN(USERPROFILE.' as USERPROFILE1','LENDERTEMPLATE.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('LENDERTEMPLATE.fk_template_id',$template_id);
$data = $this->db->GET()->result_array();
return $data;
}
public function getTemplateCategories($template_id)
{
$this->db->SELECT('TEMPLATECATAGORYWEIGHTAGE.template_catagory_weightage_id, TEMPLATECATAGORYWEIGHTAGE.fk_question_catagory_id, TEMPLATECATAGORYWEIGHTAGE.fk_template_id, TEMPLATECATAGORYWEIGHTAGE.weigthage, DATE_FORMAT(TEMPLATECATAGORYWEIGHTAGE.createdon,"%d/%m/%Y") as createdon, TEMPLATECATAGORYWEIGHTAGE.fk_createdby, DATE_FORMAT(TEMPLATECATAGORYWEIGHTAGE.updatedon, "%d/%m/%Y") as updatedon, TEMPLATECATAGORYWEIGHTAGE.isactive, TEMPLATECATAGORYWEIGHTAGE.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
$this->db->FROM(TEMPLATECATAGORYWEIGHTAGE.' as TEMPLATECATAGORYWEIGHTAGE');
$this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','TEMPLATECATAGORYWEIGHTAGE.template_catagory_weightage_id = QUESTIONCATEGORY.question_categroy_id');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATECATAGORYWEIGHTAGE.fk_createdby = USERPROFILE.userid');
$this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATECATAGORYWEIGHTAGE.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('TEMPLATECATAGORYWEIGHTAGE.fk_template_id',$template_id);
$data = $this->db->GET()->result_array();
return $data;
}
// public function getTemplateQuestionAnswers($template_id)
// {
// $this->db->SELECT('TEMPLATECATAGORYWEIGHTAGE.template_catagory_weightage_id, TEMPLATECATAGORYWEIGHTAGE.fk_question_catagory_id, TEMPLATECATAGORYWEIGHTAGE.fk_template_id, TEMPLATECATAGORYWEIGHTAGE.weigthage, DATE_FORMAT(TEMPLATECATAGORYWEIGHTAGE.createdon,"%d/%m/%Y") as createdon, TEMPLATECATAGORYWEIGHTAGE.fk_createdby, DATE_FORMAT(TEMPLATECATAGORYWEIGHTAGE.updatedon, "%d/%m/%Y") as updatedon, TEMPLATECATAGORYWEIGHTAGE.isactive, TEMPLATECATAGORYWEIGHTAGE.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
// $this->db->FROM(TEMPLATECATAGORYWEIGHTAGE.' as TEMPLATECATAGORYWEIGHTAGE');
// $this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','TEMPLATECATAGORYWEIGHTAGE.template_catagory_weightage_id = QUESTIONCATEGORY.question_categroy_id');
// $this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATECATAGORYWEIGHTAGE.fk_createdby = USERPROFILE.userid');
// $this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATECATAGORYWEIGHTAGE.fk_updatedby = USERPROFILE1.userid','LEFT');
// $this->db->WHERE('TEMPLATECATAGORYWEIGHTAGE.fk_template_id',$template_id);
// $categories = $this->db->GET()->result_array();
// if(count($categories))
// {
// foreach($categories as $key => $category)
// {
// $this->db->SELECT('TEMPLATEQUESTION.template_question_id, TEMPLATEQUESTION.fk_template_id, TEMPLATEQUESTION.fk_question_id, TEMPLATEQUESTION.question_weightage, TEMPLATEQUESTION.question_answerable_by, DATE_FORMAT(TEMPLATEQUESTION.createdon,"%d/%m/%Y") as createdon, TEMPLATEQUESTION.fk_createdby, DATE_FORMAT(TEMPLATEQUESTION.updatedon,"%d/%m/%Y") as updatedon, TEMPLATEQUESTION.fk_updatedby, TEMPLATEQUESTION.isactive,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
// $this->db->FROM(TEMPLATEQUESTION.' as TEMPLATEQUESTION');
// $this->db->JOIN(QUESTIONS.' as QUESTIONS','TEMPLATEQUESTION.fk_question_id = QUESTIONS.question_id');
// $this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATEQUESTION.fk_createdby = USERPROFILE.userid');
// $this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATEQUESTION.fk_updatedby = USERPROFILE1.userid','LEFT');
// $this->db->WHERE('TEMPLATEQUESTION.fk_template_id',$template_id);
// $questions = $this->db->GET()->result_array();
// if(count($questions))
// {
// foreach($questions as $key => $question)
// {
// }
// }
// }
// }
// }
}