1542 lines
64 KiB
PHP
1542 lines
64 KiB
PHP
<?php
|
|
/**
|
|
|
|
* User: velz
|
|
* This Controller deals with User Management CRUD Operations
|
|
*/
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
require_once APPPATH . '/libraries/REST_Controller.php';
|
|
|
|
|
|
class Template_Management_Controller extends REST_Controller {
|
|
|
|
function __construct()
|
|
{
|
|
// Construct the parent class
|
|
parent::__construct();
|
|
$this->load->model('PD_Model');
|
|
$this->load->model('Template_Management_Model');
|
|
|
|
}
|
|
|
|
public function listAllTemplates_get()
|
|
{
|
|
|
|
$page = "";$limit = ""; $sort = "asc";
|
|
$result = $this->Template_Management_Model->listAllTemplates($page,$limit,$sort);
|
|
if(count($result))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result;
|
|
$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);
|
|
}
|
|
}
|
|
|
|
|
|
/******** Save and Update Template Name ********/
|
|
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)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $template_id;
|
|
$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);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
$where_condition_array = array('template_id'=>$records['template_id']);
|
|
$modified = $this->Template_Management_Model->updateRecords($records,TEMPLATE,$where_condition_array);
|
|
if($modified != "" || $modified != null)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $modified;
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/******** save and Edit Template Lender,Product, and Customer Segments ********/
|
|
public function saveTemplateLenderDetails_post()
|
|
{
|
|
|
|
$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('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++; }
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
$id = $this->Template_Management_Model->saveRecords($template_lender_detail,LENDERTEMPLATE);
|
|
if($id != "" || $id != null){ $count++; }
|
|
}
|
|
}
|
|
|
|
|
|
if($count == count($template_lender_details))
|
|
{
|
|
$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_NO_CONTENT;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/******** Save and Update Template Categories ********/
|
|
public function saveTemplateCategoryDetails_post()
|
|
{
|
|
|
|
$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_category_weightage_id'] != null || $template_category_detail['template_category_weightage_id'] != "")
|
|
{
|
|
//$groups = $template_category_detail['groups'];
|
|
//unset($template_category_detail['groups']);
|
|
|
|
$where_condition_array = array('template_category_weightage_id'=>$template_category_detail['template_category_weightage_id']);
|
|
$modified = $this->Template_Management_Model->updateRecords($template_category_detail,TEMPLATECATEGORYWEIGHTAGE,$where_condition_array);
|
|
if($modified != "" || $modified != null){ $count++; }
|
|
|
|
//Groups insert/update
|
|
// foreach($groups as $group_key => $group)
|
|
// {
|
|
// if($group['template_group_id'] != null || $group['template_group_id'] != "")
|
|
// {
|
|
// $where_condition_array = array('template_group_id'=>$group['template_group_id']);
|
|
// $modified = $this->Template_Management_Model->updateRecords($group,TEMPLATEGROUP,$where_condition_array);
|
|
// }
|
|
// else
|
|
// {
|
|
// $template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP);
|
|
// }
|
|
// }
|
|
}
|
|
//Insert Categories
|
|
else
|
|
{
|
|
// $groups = $template_category_detail['groups'];
|
|
// unset($template_category_detail['groups']);
|
|
$id = $this->Template_Management_Model->saveRecords($template_category_detail,TEMPLATECATEGORYWEIGHTAGE);
|
|
if($id != "" || $id != null){ $count++; }
|
|
//Groups insert
|
|
// foreach($groups as $group_key => $group)
|
|
// {
|
|
|
|
// $template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP);
|
|
|
|
// }
|
|
}
|
|
}
|
|
|
|
if($count == count($template_category_details))
|
|
{
|
|
$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_NO_CONTENT;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/******** Save/update Template Question and Answers ********/
|
|
public function saveTemplateQuestionAnswers_post()
|
|
{
|
|
$question_count = 0;
|
|
$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)
|
|
{
|
|
//echo "FOr".$key;
|
|
$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']))
|
|
{
|
|
$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']);
|
|
unset($template_question_answers_detail['question_id']);
|
|
unset($template_question_answers_detail['question']);
|
|
$question_modified = $this->Template_Management_Model->updateRecords($template_question_answers_detail,TEMPLATEQUESTION,$where_condition_array);
|
|
if($question_modified){$question_count++;}
|
|
if(count($answers_array))
|
|
{
|
|
foreach($answers_array as $key => $answer)
|
|
{
|
|
if($answer['template_answer_weightage_id'] != "" || $answer['template_answer_weightage_id'] != null)
|
|
{
|
|
$where_condition_array = array('template_answer_weightage_id' => $answer['template_answer_weightage_id']);
|
|
unset($answer['answer']);
|
|
|
|
$answer_modified = $this->Template_Management_Model->updateRecords($answer,TEMPLATEANSWERWEIGHTAGE,$where_condition_array);
|
|
|
|
if($answer_modified != "" || $answer_modified != null) {$count++;}
|
|
}
|
|
else
|
|
{
|
|
unset($answer['answer']);
|
|
$answer_inserted = $this->Template_Management_Model->saveRecords($answer,TEMPLATEANSWERWEIGHTAGE);
|
|
|
|
//if($answer_inserted != "" || $answer_inserted != null) {$count++;}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
if(isset($template_question_answers_detail['answers']))
|
|
{
|
|
$answers_array = $template_question_answers_detail['answers'];
|
|
unset($template_question_answers_detail['answers']);
|
|
}
|
|
|
|
unset($template_question_answers_detail['question_id']);
|
|
unset($template_question_answers_detail['question']);
|
|
$question_id = $this->Template_Management_Model->saveRecords($template_question_answers_detail,TEMPLATEQUESTION);
|
|
if($question_id){$question_count++;}
|
|
if(count($answers_array))
|
|
{
|
|
foreach($answers_array as $key => $answer)
|
|
{
|
|
$answer['fk_template_question_id'] = $question_id;
|
|
unset($answer['answer']);
|
|
$answer_inserted = $this->Template_Management_Model->saveRecords($answer,TEMPLATEANSWERWEIGHTAGE);
|
|
//if($answer_inserted != "" || $answer_inserted != null) {$count++;}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(($question_count != "" || $question_id != null) )
|
|
{
|
|
$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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/******** Load Existed Template Master Details for Edit page @param template id ********/
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
/******** Load Existed Template Lender Mapping for Edit page @param template id ********/
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
/******** Load Existed Template Categories for Edit page @param template id ********/
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
/******** Load Existed Template Question and Answers for Edit page @param template id ********/
|
|
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);
|
|
}
|
|
}
|
|
|
|
/************** Get List of Categories to Template Add/Edit Page DropDown ***************/
|
|
public function getListOfCategories_get()
|
|
{
|
|
$fields = array('question_category_id','category_name');
|
|
$where_condition_array = array('isactive' => 1);
|
|
$result_data = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONCATEGORY);
|
|
if(count($result_data))
|
|
{
|
|
|
|
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_data;
|
|
$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 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);
|
|
|
|
}
|
|
}
|
|
|
|
//Get Categories and questions group compinations
|
|
public function getCategoryGroupCombinations_get()
|
|
{
|
|
$fields = array('question_category_id','category_name');
|
|
$where_condition_array = array('isactive' => 1);
|
|
$result_data = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONCATEGORY);
|
|
|
|
if(count($result_data))
|
|
{
|
|
foreach($result_data as $key => $result)
|
|
{
|
|
$groups = $this->Template_Management_Model->getCategoryGroupCombinations($result['question_category_id']);
|
|
$result_data[$key]['gropus'] = $groups;
|
|
}
|
|
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_data;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "No Categories Found!";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public function saveScoreCardQuestions_post()
|
|
{
|
|
$records = $this->post('records');
|
|
|
|
$id = "";
|
|
$count = 0;
|
|
|
|
foreach($records as $rec_key => $record)
|
|
{
|
|
$answers = $record['answers'];
|
|
unset($record['answers']);
|
|
unset($record['question_key_mapping_id']);
|
|
unset($record['question']);
|
|
if($record['score_question_id'] != null || $record['score_question_id'] != "")
|
|
{
|
|
$where_condition_array = array('score_question_id' => $record['score_question_id']);
|
|
$id = $this->Template_Management_Model->updateRecords($record,SCORECARDQUESTIONS,$where_condition_array);
|
|
if($id != null || $id != "")
|
|
{
|
|
$count++;
|
|
foreach($answers as $ans_key => $answer)
|
|
{
|
|
unset($answer['id']);
|
|
unset($answer['name']);
|
|
if($answer['score_answer_id'] != null || $answer['score_answer_id'] != "")
|
|
{
|
|
$where_condition_array = array('score_answer_id' => $answer['score_answer_id']);
|
|
$ans_id = $this->Template_Management_Model->updateRecords($answer,SCORECARDANSWERS,$where_condition_array);
|
|
}
|
|
else
|
|
{
|
|
$answer['fk_score_question_id'] = $record['score_question_id'];
|
|
$ans_id = $this->Template_Management_Model->saveRecords($answer,SCORECARDANSWERS);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$id = $this->Template_Management_Model->saveRecords($record,SCORECARDQUESTIONS);
|
|
|
|
if($id != null || $id != "")
|
|
{
|
|
$count++;
|
|
foreach($answers as $ans_key => $answer)
|
|
{
|
|
unset($answer['id']);
|
|
unset($answer['name']);
|
|
$answer['fk_score_question_id'] = $id;
|
|
$ans_id = $this->Template_Management_Model->saveRecords($answer,SCORECARDANSWERS);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if($count == count($records))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $id;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "Something Went Wrong!";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFormAndQuestionKeys_post()
|
|
{
|
|
$records = $this->post('records');
|
|
$formid = 0;
|
|
$templateid = $records['templateid'];
|
|
$formid = $records['formid'];
|
|
$categoryid = $records['categoryid'];
|
|
//*******************INTERNAL PURPOSE***************************************************
|
|
$master_tables_field_names = $this->config->item('master_tables_field_names');
|
|
|
|
$master_tables_pkid = $this->config->item('master_tables_pkid');
|
|
//*******************INTERNAL PURPOSE***************************************************
|
|
|
|
//get Alreday assigned ques and kys from template
|
|
$fields = array('fk_key');
|
|
$where_condition_array = array('fk_template_id' =>$templateid,'isactive' => 1,'fk_form_id' =>$formid );
|
|
$exits_questions = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,SCORECARDQUESTIONS);
|
|
$result_data = array();
|
|
//print_r();
|
|
if(!count($exits_questions))
|
|
{
|
|
|
|
$fields = array('question_key_mapping_id','fk_form_id','fk_category_id','question','key','ismaster','master_name');
|
|
$where_condition_array = array();
|
|
if($formid != 0)
|
|
{
|
|
$where_condition_array = array('isactive' => 1,'fk_form_id' => $formid,'fk_category_id' => $categoryid);
|
|
}
|
|
else
|
|
{
|
|
$where_condition_array = array('isactive' => 1);
|
|
}
|
|
$result_data = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONKEYMAPPING);
|
|
|
|
if(count($result_data))
|
|
{
|
|
foreach($result_data as $res_key => $result)
|
|
{
|
|
|
|
$result_data[$res_key]['score_question_id'] = null;
|
|
$result_data[$res_key]['fk_template_id'] = null;
|
|
$result_data[$res_key]['fk_key'] = null;
|
|
$result_data[$res_key]['weightage'] = null;
|
|
$result_data[$res_key]['calc_type'] = null;
|
|
if($result['master_name'] != null || $result['master_name'] != "")
|
|
{
|
|
//echo $result['master_name'];
|
|
$fields = array($master_tables_pkid[$result['master_name']].' as id',$master_tables_field_names[$result['master_name']].' as name');
|
|
|
|
$table = constant($result['master_name']);
|
|
$where_condition_array = array('isactive' => 1);
|
|
$answers = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,$table);
|
|
foreach($answers as $answer_key => $answer)
|
|
{
|
|
$answers[$answer_key]['answer'] = null;
|
|
$answers[$answer_key]['fk_score_question_id'] = null;
|
|
$answers[$answer_key]['score'] = null;
|
|
$answers[$answer_key]['score_answer_id'] = null;
|
|
}
|
|
$result_data[$res_key]['answers'] = $answers;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
$temp_array = array();
|
|
foreach($exits_questions as $res)
|
|
{
|
|
array_push($temp_array,$res['fk_key']);
|
|
}
|
|
//print_r($temp_array);
|
|
$this->db->SELECT('QUESTIONKEYMAPPING.question_key_mapping_id,QUESTIONKEYMAPPING.fk_form_id,QUESTIONKEYMAPPING.question,QUESTIONKEYMAPPING.key,QUESTIONKEYMAPPING.master_name,SCORECARDQUESTIONS.score_question_id,SCORECARDQUESTIONS.fk_template_id,SCORECARDQUESTIONS.fk_key,SCORECARDQUESTIONS.weightage,SCORECARDQUESTIONS.calc_type');
|
|
$this->db->FROM(QUESTIONKEYMAPPING.' as QUESTIONKEYMAPPING');
|
|
$this->db->JOIN(SCORECARDQUESTIONS.' as SCORECARDQUESTIONS','QUESTIONKEYMAPPING.fk_form_id = SCORECARDQUESTIONS.fk_form_id AND QUESTIONKEYMAPPING.key = SCORECARDQUESTIONS.fk_key AND SCORECARDQUESTIONS.isactive = 1','LEFT');
|
|
|
|
if($formid != 0)
|
|
{
|
|
$this->db->WHERE('QUESTIONKEYMAPPING.fk_form_id',$formid);
|
|
$this->db->WHERE('QUESTIONKEYMAPPING.fk_category_id',$categoryid);
|
|
}
|
|
$this->db->WHERE_NOT_IN('QUESTIONKEYMAPPING.key',$temp_array);
|
|
$this->db->WHERE('QUESTIONKEYMAPPING.isactive',1);
|
|
//$this->db->WHERE('SCORECARDQUESTIONS.isactive',1);
|
|
|
|
$result_data = $this->db->GET()->result_array();
|
|
if(count($result_data))
|
|
{
|
|
foreach($result_data as $res_key => $result)
|
|
{
|
|
if($result['master_name'] != null || $result['master_name'] != "")
|
|
{
|
|
//echo $result['master_name'];
|
|
$fields = array($master_tables_pkid[$result['master_name']].' as id',$master_tables_field_names[$result['master_name']].' as name');
|
|
|
|
$table = constant($result['master_name']);
|
|
$where_condition_array = array('isactive' => 1);
|
|
$answers = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,$table);
|
|
foreach($answers as $answer_key => $answer)
|
|
{
|
|
$answers[$answer_key]['answer'] = null;
|
|
$answers[$answer_key]['fk_score_question_id'] = null;
|
|
$answers[$answer_key]['score'] = null;
|
|
$answers[$answer_key]['score_answer_id'] = null;
|
|
}
|
|
$result_data[$res_key]['answers'] = $answers;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if(count($result_data))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_data;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "No Data Found!";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
public function getScorecardDetails_post()
|
|
{
|
|
$templateid = $this->post('templateid');
|
|
|
|
//*******************INTERNAL PURPOSE***************************************************
|
|
$master_tables_field_names = $this->config->item('master_tables_field_names');
|
|
|
|
$master_tables_pkid = $this->config->item('master_tables_pkid');
|
|
//*******************INTERNAL PURPOSE***************************************************
|
|
|
|
|
|
|
|
//Get Categories assigned to this template$template_id = $this->post('template_id');
|
|
$this->db->SELECT('QUESTIONCATEGORY.category_name,TEMPLATECATEGORYWEIGHTAGE.template_category_weightage_id, TEMPLATECATEGORYWEIGHTAGE.fk_question_category_id, TEMPLATECATEGORYWEIGHTAGE.fk_template_id, TEMPLATECATEGORYWEIGHTAGE.weightage, DATE_FORMAT(TEMPLATECATEGORYWEIGHTAGE.createdon,"%d/%m/%Y") as createdon, TEMPLATECATEGORYWEIGHTAGE.fk_createdby, DATE_FORMAT(TEMPLATECATEGORYWEIGHTAGE.updatedon, "%d/%m/%Y") as updatedon, TEMPLATECATEGORYWEIGHTAGE.isactive, TEMPLATECATEGORYWEIGHTAGE.fk_updatedby');
|
|
$this->db->FROM(TEMPLATECATEGORYWEIGHTAGE .' as TEMPLATECATEGORYWEIGHTAGE');
|
|
$this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','TEMPLATECATEGORYWEIGHTAGE.fk_question_category_id = QUESTIONCATEGORY.question_category_id');
|
|
$this->db->WHERE('TEMPLATECATEGORYWEIGHTAGE.fk_template_id',$templateid);
|
|
$template_categories = $this->db->GET()->result_array();
|
|
//print_r($template_categories);die();
|
|
foreach($template_categories as $cate_key => $category)
|
|
{
|
|
$this->db->SELECT('QUESTIONKEYMAPPING.question_key_mapping_id,QUESTIONKEYMAPPING.fk_form_id,QUESTIONKEYMAPPING.question,QUESTIONKEYMAPPING.key,QUESTIONKEYMAPPING.master_name,SCORECARDQUESTIONS.score_question_id,SCORECARDQUESTIONS.fk_template_id,SCORECARDQUESTIONS.fk_form_id,SCORECARDQUESTIONS.fk_key,SCORECARDQUESTIONS.weightage,SCORECARDQUESTIONS.calc_type');
|
|
$this->db->FROM(SCORECARDQUESTIONS.' as SCORECARDQUESTIONS');
|
|
$this->db->JOIN(QUESTIONKEYMAPPING.' as QUESTIONKEYMAPPING','SCORECARDQUESTIONS.fk_form_id = QUESTIONKEYMAPPING.fk_form_id AND QUESTIONKEYMAPPING.key = SCORECARDQUESTIONS.fk_key AND SCORECARDQUESTIONS.isactive = 1 AND QUESTIONKEYMAPPING.isactive = 1 AND SCORECARDQUESTIONS.fk_template_id ='.$templateid,'LEFT');
|
|
$this->db->WHERE('QUESTIONKEYMAPPING.fk_category_id',$category['fk_question_category_id']);
|
|
$ques_keys = $this->db->GET()->result_array();
|
|
//print_r($ques_keys);
|
|
foreach($ques_keys as $res_key => $result)
|
|
{
|
|
if($result['master_name'] != null || $result['master_name'] != "")
|
|
{
|
|
//echo $result['master_name'];
|
|
$fields = array($master_tables_pkid[$result['master_name']].' as id',$master_tables_field_names[$result['master_name']].' as name');
|
|
|
|
$table = constant($result['master_name']);
|
|
$where_condition_array = array('isactive' => 1);
|
|
$answers = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,$table);
|
|
//print_r($answers);
|
|
foreach($answers as $answer_key => $answer)
|
|
{
|
|
|
|
$this->db->SELECT('SCORECARDANSWERS.score_answer_id, SCORECARDANSWERS.fk_score_question_id, SCORECARDANSWERS.answer, SCORECARDANSWERS.score,SCORECARDANSWERS.isactive');
|
|
$this->db->FROM(SCORECARDANSWERS.' as SCORECARDANSWERS');
|
|
$this->db->WHERE('SCORECARDANSWERS.fk_score_question_id',$result['score_question_id']);
|
|
//$this->db->WHERE('SCORECARDANSWERS.isactive',1);
|
|
$this->db->WHERE('SCORECARDANSWERS.answer',$answer['id']);
|
|
$exact_answers = $this->db->GET()->result_array();
|
|
//print_r($this->db->last_query());
|
|
//print_r($exact_answers);
|
|
if(count($exact_answers))
|
|
{
|
|
$answers[$answer_key]['answer'] = $exact_answers[0]['answer'];
|
|
$answers[$answer_key]['fk_score_question_id'] = $exact_answers[0]['fk_score_question_id'];
|
|
$answers[$answer_key]['score'] = $exact_answers[0]['score'];
|
|
$answers[$answer_key]['score_answer_id'] = $exact_answers[0]['score_answer_id'];
|
|
$answers[$answer_key]['isactive'] = $exact_answers[0]['isactive'];
|
|
}
|
|
else
|
|
{
|
|
$answers[$answer_key]['answer'] = null;
|
|
$answers[$answer_key]['fk_score_question_id'] = null;
|
|
$answers[$answer_key]['score'] = null;
|
|
$answers[$answer_key]['score_answer_id'] = null;
|
|
$answers[$answer_key]['isactive'] = 1;
|
|
}
|
|
|
|
}
|
|
$ques_keys[$res_key]['answers'] = $answers;
|
|
}
|
|
}
|
|
$template_categories[$cate_key]['questions'] = $ques_keys;
|
|
}
|
|
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $template_categories;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
|
|
|
|
public function savePDReportTemplate_post()
|
|
{
|
|
$records = $this->post('records');
|
|
$pk_id = 0;
|
|
if($records['report_template_id'] != "" || $records['report_template_id'] != null)
|
|
{
|
|
//echo "update";die();
|
|
$where_condition_array = array('report_template_id' => $records['report_template_id']);
|
|
$pk_id = $this->Template_Management_Model->updateRecords($records,REPORTTEMPLATES,$where_condition_array);
|
|
}
|
|
else
|
|
{
|
|
|
|
$pk_id = $this->Template_Management_Model->saveRecords($records,REPORTTEMPLATES);
|
|
}
|
|
|
|
if($pk_id != 0)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $pk_id;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Not enough Data to Calculate Assessed Income';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
|
|
public function getPDReportTemplate_post()
|
|
{
|
|
$records = $this->post('records');
|
|
|
|
$fields = array('report_template_id', 'fk_template_id','content');
|
|
$where_condition_array = array('fk_template_id'=>$records['fk_template_id'],'isactive'=>1);
|
|
$result_array = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,REPORTTEMPLATES);
|
|
if(count($result_array))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_array;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Data Available';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
}
|
|
|
|
public function getTemplateForms_get()
|
|
{
|
|
|
|
$template_id = $this->get('template_id');
|
|
|
|
$fields = array('form_id');
|
|
$where_condition_array = array('fk_template_id'=>$template_id,'isactive'=>1);
|
|
$result_array = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATEFORMS);
|
|
//print_r($this->db->last_query());
|
|
$temp = array();
|
|
foreach($result_array as $r)
|
|
{
|
|
$formid = $r['form_id'];
|
|
$temp = array_merge($temp,array($formid));
|
|
}
|
|
|
|
if(count($result_array))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $temp;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Data Available';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public function saveTemplateForms_post()
|
|
{
|
|
$records = $this->post("records");
|
|
$template_id = $records['template_id'];
|
|
$forms = $records['forms'];
|
|
//print_r($forms);
|
|
|
|
|
|
$this->db->where('fk_template_id',$template_id);
|
|
$this->db->where_not_in('form_id',$forms);
|
|
$this->db->SET('isactive',0);
|
|
$this->db->UPDATE(TEMPLATEFORMS);
|
|
|
|
$fields = array('form_id');
|
|
$where_condition_array = array('fk_template_id'=>$template_id);
|
|
$result_array = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATEFORMS);
|
|
//print_r($result_array);
|
|
$insert_array = array();
|
|
$count = 0;
|
|
foreach($forms as $form)
|
|
{
|
|
$i = 0;
|
|
foreach($result_array as $result)
|
|
{
|
|
if($form == $result['form_id'])
|
|
{
|
|
$i++;
|
|
}
|
|
|
|
}
|
|
if($i == 0) {$insert_array[] = $form; }
|
|
}
|
|
|
|
foreach($insert_array as $newform)
|
|
{
|
|
$fields = array('isactive' => 1,'form_id' => $newform,'fk_template_id' => $template_id);
|
|
$pk_id = $this->Template_Management_Model->saveRecords($fields,TEMPLATEFORMS);
|
|
if($pk_id != "" || $pk_id != null) { $count++; }
|
|
}
|
|
|
|
if($count == count($insert_array))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $count;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Something Went Wrong! Try again Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//Module : Template V2.0 (Dynamic Form Template).
|
|
// API 1 Master Listing
|
|
public function getTemplateV2_get(){
|
|
$lender_id = $this->get('entity_id');
|
|
if(isset($lender_id) && !empty($lender_id)){
|
|
$result_array = $this->Template_Management_Model->getTemplateMappingDetailsV2($lender_id);
|
|
if(count($result_array)>0)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_array;
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Data Available';
|
|
}
|
|
}else{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Lender Id Not Found. Try Again!';
|
|
}
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
// API 2 Get Template with Form Details V2.0 : ps 20/12/2021
|
|
public function getTemplateFormsV2_get(){
|
|
// echo "i am @927";die();
|
|
if(isset($_GET['map_id']))
|
|
{
|
|
$records['map_id'] = $this->get("map_id");}
|
|
if(isset($_GET['entity_id']))
|
|
{
|
|
$records['entity_id'] = $this->get("entity_id");}
|
|
if(isset($_GET['product_id']))
|
|
{
|
|
$records['product_id'] = $this->get("product_id");}
|
|
if(isset($_GET['customer_segment_id']))
|
|
{
|
|
$records['customer_segment_id'] = $this->get("customer_segment_id");}
|
|
|
|
$result_array = $this->Template_Management_Model->getTemplateMappingDetailsV2($records);
|
|
if(!empty($result_array))
|
|
foreach($result_array as $inx => $arr)
|
|
{
|
|
if($arr['map_id'] != null || $arr['map_id'] != ""){
|
|
$result_array[$inx]["forms"] = $this->Template_Management_Model->getTemplateFormsV2($arr['map_id']);
|
|
}else{
|
|
$result_array[$inx]["forms"] = array();
|
|
}
|
|
array_push($result_array[$inx]["forms"],array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1","pd_form_order"=>"5","is_form_status"=>null,"template_id"=>null));
|
|
array_push($result_array[$inx]["forms"],array("form_id"=> "18","form_name"=> "General Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"2","is_form_status"=>null,"template_id"=>null));
|
|
array_push($result_array[$inx]["forms"],array("form_id"=> "26","form_name"=> "Photograph","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"24","is_form_status"=>null,"template_id"=>null));
|
|
// $buiness_arr = array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1");
|
|
// array_push($result_array[$inx]["forms"],$buiness_arr);
|
|
}
|
|
if(count($result_array)>0)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_array;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Data Available';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Save and Update Form Template Details V2.0 : ps 20/12/2021
|
|
// "entity_id": "42",
|
|
// "product_id": "24",
|
|
// "customer_segment_id": "5",
|
|
// "json": "{ \"section_id\":\"5\", \"section_name\":\"Address details\", \"onsubmit\":null, \"questions\":[ { \"question\":\"Address at which PD was initiated\", \"question_key\":\"initiated_address\", \"type\":\"7\", \"disable\":false, \"field_width\":\"100\", \"title\":\"Address Details\", \"answers\":true, \"api_properties\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"State\", \"question_key\":\"State_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"STATE\" }, \"fields\":[ \"state_id\", \"name\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"City\", \"question_key\":\"City_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfStatesAndCities\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"state_id\" }, \"fields\":[ \"city_id\", \"city_name\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Pincode\", \"question_key\":\"Pincode_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfStatesAndCities\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"pincode\" }, \"fields\":[ \"pincode\", \"pincode_id\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Is this the address where PD is done ?\", \"question_key\":\"is_pd_done_on_initiated_address\", \"type\":\"2\", \"disable\":false, \"field_width\":\"100\", \"onchange_properties\": [{ \"purpose\":\"FORM_CTRL\", \"form_controls\":[ { \"insert_index\":\"is_pd_done_on_initiated_address\", \"expression\":\"(String('is_pd_done_on_initiated_address') == String('No'))\", \"value_keys\":[ \"is_pd_done_on_initiated_address\" ], \"questions\":[ { \"question\":\"Reason for change in PD visit address\", \"question_key\":\"end_use\", \"type\":\"1\", \"field_width\":\"100\", \"api_properties\":null, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ ] }, { \"question\":\"Pincode\", \"question_key\":\"Pincode_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"COMMENTSONLOCALITY\" }, \"fields\":[ \"comments_on_locality_id\", \"rating\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"City\", \"question_key\":\"City_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"COMMENTSONLOCALITY\" }, \"fields\":[ \"comments_on_locality_id\", \"rating\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"State\", \"question_key\":\"State_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"STATE\" }, \"fields\":[ \"state_id\", \"name\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Enter actual PD address\", \"question_key\":\"actual_pd_address\", \"type\":\"1\", \"field_width\":\"100\", \"api_properties\":null, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ ] } ] } ] }], \"api_properties\":null, \"answers\":[ { \"answer_id\":\"Yes\", \"answer\":\"Yes\" }, { \"answer_id\":\"No\", \"answer\":\"No\" } ], \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Address Type\", \"question_key\":\"Address_Type\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"ADDRESSTYPE\" }, \"fields\":[ \"address_type_id\", \"address_type\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Locality\", \"question_key\":\"Locality\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"LOCALITY\" }, \"fields\":[ \"locality_id\", \"locality_name\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Approach to PD location*\", \"question_key\":\"Approach_to_PD_location\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"PDLOCATIONAPPROACH\" }, \"fields\":[ \"pd_location_approach_id\", \"description\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Comment on Locality\", \"question_key\":\"Comment_on_Locality\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"COMMENTSONLOCALITY\" }, \"fields\":[ \"comments_on_locality_id\", \"rating\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Unit of Measurement\", \"question_key\":\"Unit_of_Measurement\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"UOM\" }, \"fields\":[ \"uom_id\", \"name\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] },{ \"question\":\"Estimate area of the Residence\", \"question_key\":\"Estimate_area_of_the_Residence\", \"type\":\"1\", \"disable\":false, \"field_width\":\"45\", \"api_properties\": null, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] } ] }",
|
|
// "form_id": "5"
|
|
|
|
// public function saveTemplateFormsV2_post(){
|
|
// $records = $this->post("records");
|
|
// $json = json_encode($records['json'],true);
|
|
// $fields = array('id');
|
|
// $where_condition_array = array('entity_id'=>$records['entity_id'],'product_id'=>$records['product_id'],'customer_segment_id'=>$records['customer_segment_id'],"isactive"=>1);
|
|
// $mapping_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_MAP_V2);
|
|
// // print_r($mapping_table);die();
|
|
// if(count($mapping_table)>0){
|
|
// $map_id = $mapping_table[0]['id'];
|
|
// //in-active existing Entries here using Map ID and Form ID means
|
|
// $fields = array('id');
|
|
// $where_condition_array = array('map_id'=>$map_id,"form_id"=>$records['form_id'],"isactive"=>1);
|
|
// $json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
|
// if(count($json_table)>0){
|
|
// $this->db->where('id',$json_table[0]['id']);
|
|
// $this->db->set('isactive',0);
|
|
// $this->db->update(TEMPLATE_JSON_V2);
|
|
// }
|
|
// // insert json here.
|
|
// $fields = array('isactive' => 1,'form_id' => $records['form_id'],'json' => $json,'map_id'=>$map_id);
|
|
// $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
|
|
// }
|
|
// else{
|
|
// // insert map & its json here.
|
|
// $fields = array('entity_id'=>$records['entity_id'],'product_id'=>$records['product_id'],'customer_segment_id'=>$records['customer_segment_id'],"isactive"=>1);
|
|
// $map_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_MAP_V2);
|
|
// if($map_pk_id){
|
|
// $fields = array('isactive' => 1,'form_id' => $records['form_id'],'json' => $json,'map_id'=>$map_pk_id);
|
|
// $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
|
|
// }
|
|
// }
|
|
|
|
// if($json_pk_id)
|
|
// {
|
|
// $data['dataStatus'] = true;
|
|
// $data['status'] = REST_Controller::HTTP_OK;
|
|
// $data['records'] = "Sucessfully Inserted";
|
|
// $this->response($data,REST_Controller::HTTP_OK);
|
|
// }
|
|
// else
|
|
// {
|
|
// $data['dataStatus'] = false;
|
|
// $data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
// $data['msg'] = 'Something Went Wrong! Try again Later';
|
|
// $this->response($data,REST_Controller::HTTP_OK);
|
|
// }
|
|
|
|
// }
|
|
|
|
// API 3 : to save and Update the Mapping Details and return the Pkid
|
|
public function saveTemplateV2_post(){
|
|
// draft,approve,completed
|
|
// strtoupper(str_replace(' ', '', $form_status));
|
|
$records = $this->post("records");
|
|
// print_r($records);die();
|
|
if( (!isset($records['entity_id'])) || (!isset($records['product_id'])) || (!isset($records['customer_segment_id'])) )
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Key Missing! Try again Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}else{
|
|
$fields = array('id');
|
|
$where_condition_array = $records;
|
|
$where_condition_array['isactive'] = 1;
|
|
$map_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_MAP_V2);
|
|
if(count($map_table)>0){
|
|
// $this->db->where('id',$map_table[0]['id']);
|
|
// $this->db->set('isactive',0);
|
|
// $this->db->update(TEMPLATE_MAP_V2);
|
|
$map_pk_id = (int)$map_table[0]['id'];
|
|
$msg = "Data Already Available For Given Params";
|
|
}else{
|
|
$map_pk_id = $this->Template_Management_Model->saveTemplateMapping($records,TEMPLATE_MAP_V2);
|
|
$msg = "Sucessfully Inserted";
|
|
}
|
|
|
|
|
|
if($map_pk_id)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['map_id'] = $map_pk_id;
|
|
$data['msg'] = $msg;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Something Went Wrong! Try again Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
// API 4 : to save and Update the Mapping Details and return the Pkid
|
|
public function saveTemplateFormsV2_post(){
|
|
$records = $this->post("records");
|
|
if(!isset($records['json']) || !isset($records['form_id']) || !isset($records['map_id']))
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Key Missing! Try again Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}else{
|
|
$map_id = $records['map_id'];
|
|
$form_id = $records['form_id'];
|
|
$fields = array('id');
|
|
$status = strtoupper(str_replace(' ', '',$records['form_status']));
|
|
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1);
|
|
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
|
|
|
### Don't Delete Because First Requirement..... multiple draft mode and multiple approve mode but when completed means inactive the draft json and approve json
|
|
// foreach ($json_table as $value) $id_array[] = $value['id'];
|
|
// if(count($json_table)>0 && $status == "COMPLETED"){
|
|
// $this->db->where_in('id',$id_array);
|
|
// $this->db->set('isactive',0);
|
|
// $this->db->update(TEMPLATE_JSON_V2);
|
|
// }else if(count($json_table)>0 && ($status == "DRAFT" || $status == "APPROVED")){
|
|
// $this->db->where('is_form_status',"COMPLETED");
|
|
// $this->db->where_in('id',$id_array);
|
|
// $this->db->set('isactive',0);
|
|
// $this->db->update(TEMPLATE_JSON_V2);
|
|
// }
|
|
// $json = json_encode($records['json'],true);
|
|
// $fields = array('form_id' => $form_id,'json' => $json,'map_id'=>$map_id,'is_form_status'=>$status);
|
|
// $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
|
|
|
|
if($status == "DRAFT"){
|
|
if(count($json_table)>0 && $status == "COMPLETED"){
|
|
$this->db->where_in('id',$json_table[0]['id']);
|
|
$this->db->set('isactive',0);
|
|
$this->db->update(TEMPLATE_JSON_V2);
|
|
}
|
|
//draft means insert.
|
|
$json = json_encode($records['json'],true);
|
|
$fields = array('form_id' => $form_id,'json' => $json,'map_id'=>$map_id,'is_form_status'=>$status);
|
|
$json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
|
|
$msg = "Sucessfully Inserted";
|
|
}else if($status == "APPROVED" || $status == "COMPLETED"){
|
|
//approve and completed status means just update the status only.
|
|
$json_pk_id = $json_table[0]['id'];
|
|
$this->db->where('isactive',1);
|
|
$this->db->where('id',$json_pk_id);
|
|
$this->db->set('is_form_status',$status);
|
|
$this->db->update(TEMPLATE_JSON_V2);
|
|
$msg = "Sucessfully Updated";
|
|
}
|
|
|
|
if($json_pk_id)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['json_id'] = $json_pk_id;
|
|
$data['msg'] = $msg;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Something Went Wrong! Try again Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//API 5 : to Delete Template Details Using map id and its json's
|
|
public function deleteDynamicTemplateV2_get(){
|
|
$map_id = $this->get('map_id');
|
|
if(isset($map_id) && !empty($map_id)){
|
|
$flag = $this->Template_Management_Model->inactiveMappingDetailsandJSONV2($map_id);
|
|
if($flag)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['msg'] = 'Successfully Deleted';
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'Noting to Delete';
|
|
}
|
|
}else{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Map Id Not Found. Try Again!';
|
|
}
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
//API 6 :
|
|
public function loadFullTemplateV2_get()
|
|
{
|
|
|
|
$pd_id = "";
|
|
$client = "";
|
|
$random_string = "";
|
|
$api = "";
|
|
|
|
if($this->get('pd_id')) { $pd_id = $this->get('pd_id'); }
|
|
if($this->get('client')) { $client = $this->get('client'); }
|
|
if($this->get('random_string')) { $random_string = $this->get('random_string'); }
|
|
if($this->get('api')) { $api = $this->get('api'); }
|
|
|
|
if($pd_id != "" || $pd_id != null)
|
|
{
|
|
|
|
$template_details = $this->PD_Model->getTemplateForPDV2($pd_id,$client,$random_string,$api);
|
|
if(count($template_details))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $template_details;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'There is no Template for Given PD-ID'.$pd_id;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_BAD_REQUEST;
|
|
$data['msg'] = 'No Param Available';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
//API 7
|
|
public function formWiseJSONTemplateV2_get(){
|
|
if( (!isset($_GET['map_id'])) && (!isset($_GET['form_id'])) )
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Key Missing! Please Check again both map-id and form-id';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}else{
|
|
|
|
$map_id = $_GET['map_id'];
|
|
$form_id = $_GET['form_id'];
|
|
$form_id = $_GET['form_id'];
|
|
$template_id = isset($_GET['template_id'])?$_GET['template_id']:null;
|
|
$fields = array('id','json');
|
|
if($template_id){$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","id"=>$template_id);}
|
|
else{$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","isactive"=>1);$data['note'] = "Existing JSON..";}
|
|
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
|
if(count($json_table)>0){
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['json'] = $json_table[0]['json'];
|
|
$data['template_id'] = $json_table[0]['id'];
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'JSON Not Available! Try again Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function disableformV2_post(){
|
|
$record = $this->post("records");
|
|
if( (!isset($record['map_id'])) || (!isset($record['form_id'])) || (!isset($record['is_form_disabled'])) )
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Key Missing! Please Check again map-id,is_form_disabled and form-id';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
} else{
|
|
$map_id = $record['map_id'];
|
|
$form_id = $record['form_id'];
|
|
$is_form_disabled = $record['is_form_disabled'];
|
|
$fields = array('id');
|
|
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1,"is_form_status"=>"COMPLETED");
|
|
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
|
if(count($json_table)>0){
|
|
// $data['dataStatus'] = true;
|
|
// $data['status'] = REST_Controller::HTTP_OK;
|
|
// $data['json'] = $json_table[0]['json'];
|
|
// $this->response($data,REST_Controller::HTTP_OK);
|
|
$res = $this->Template_Management_Model->updateRecords(array('is_form_disabled' => $is_form_disabled),TEMPLATE_JSON_V2,$where_condition_array);
|
|
if($res){
|
|
$fields = array('pd_form_name');
|
|
$where_condition_array = array("pd_form_id"=>$form_id);
|
|
$form_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,PDFORMS);
|
|
if($is_form_disabled == 1) $msg = $form_table[0]['pd_form_name'].' Successfully Disabled' ;
|
|
if($is_form_disabled == 0) $msg = $form_table[0]['pd_form_name'].' Successfully Enabled' ;
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['msg'] = $msg;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}else{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'There is No Changes..';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'No Data Found for Given Map-id and Form-id';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
}
|
|
// analysing
|
|
public function getBuinessGroupFormsV2_get(){
|
|
// if((!isset($_GET['map_id'])))
|
|
// {
|
|
// $data['dataStatus'] = false;
|
|
// $data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
// $data['msg'] = 'Key Missing! Please Check again both map-id and form-id';
|
|
// $this->response($data,REST_Controller::HTTP_OK);
|
|
// }
|
|
// else{
|
|
if(isset($_GET['map_id']))
|
|
{
|
|
$records['map_id'] = $this->get("map_id");}
|
|
if(isset($_GET['entity_id']))
|
|
{
|
|
$records['entity_id'] = $this->get("entity_id");}
|
|
if(isset($_GET['product_id']))
|
|
{
|
|
$records['product_id'] = $this->get("product_id");}
|
|
if(isset($_GET['customer_segment_id']))
|
|
{
|
|
$records['customer_segment_id'] = $this->get("customer_segment_id");}
|
|
$result_array = $this->Template_Management_Model->getTemplateMappingDetailsV2($records);
|
|
if(!empty($result_array))
|
|
foreach($result_array as $inx => $arr)
|
|
{
|
|
if($arr['map_id'] != null || $arr['map_id'] != ""){
|
|
$result_array[$inx]["forms"] = $this->Template_Management_Model->getBuinessGroupForms($arr['map_id']);
|
|
}else{
|
|
$result_array[$inx]["forms"] = array();
|
|
}
|
|
}
|
|
if(count($result_array)>0)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result_array;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Data Available';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
}
|
|
|
|
public function JSONquestionFilterV2_get(){
|
|
if( (!isset($_GET['map_id'])) && (!isset($_GET['form_id'])) )
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'Key Missing! Please Check again both map-id and form-id';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}else{
|
|
$map_id = $_GET['map_id'];
|
|
$form_id = $_GET['form_id'];
|
|
// Using global keyword
|
|
// global $global_form_id;
|
|
$fields = array('json');
|
|
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1);
|
|
// "is_form_status"=>
|
|
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
|
if(count($json_table)>0){
|
|
$json = json_decode($json_table[0]['json'],true);
|
|
if(isset($json['questions'][0]['question_key']) ){
|
|
$quest = isset($json['questions'])?$json['questions']:$json['question'];
|
|
}else{
|
|
$quest = isset($json['questions'][0]['question'])?$json['questions'][0]['question']:$json['question'][0]['question'];
|
|
// s$quest = $json['questions'][0]['question'];
|
|
}
|
|
// re-check (1,2) // done (5,19,14,24,20,22) //ok-but-doubt (13,11)
|
|
// print_r($quest);die();
|
|
$filter_arr = array();
|
|
//try 4
|
|
if(!empty($quest)){
|
|
$arr1 = $this->call_arr1($quest);
|
|
$arr2 = $this->call_arr2($quest);
|
|
$filter_arr = $this->merged_arr($arr1,$arr2);
|
|
}
|
|
|
|
if(!empty($filter_arr)){
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['available_question'] = $filter_arr;
|
|
// $data['json'] = $quest;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}else{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'There is no JSON template. try again';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
|
$data['msg'] = 'No Data Found Given Map-id and Form-id';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Step 1 : Question Filter Only
|
|
public function call_arr1($quest){
|
|
$return_arr = array();
|
|
$i = 0 ;
|
|
// print_r($quest);
|
|
if((!empty($quest)) && (is_array($quest) || is_object($quest)) )
|
|
{
|
|
foreach ($quest as $key => $value) {
|
|
// $return_arr[$i] = array('question'=> $value['question'],'question_key'=>$value['question_key']);
|
|
// $return_arr[$i]['question'] = $value['question'];
|
|
// $return_arr[$i]['question_key'] = $value['question_key'];
|
|
|
|
if(isset($value['question'][0]['question_key'])){
|
|
$question = isset($value['question']) ? $value['question'] : array();
|
|
for($j = 0 ;$j<count($question);$j++){
|
|
$latest_quest = isset($question[$j]['question_key']) ? $question : $question[$j]['question'];
|
|
$temp[$i] = $this->call_arr1($latest_quest);
|
|
$arr2 = $this->call_arr2($latest_quest);
|
|
$return_arr[$i] = $this->merged_arr($temp[$i],$arr2);
|
|
$i++;
|
|
}
|
|
}else if(isset($value['questions'][0]['question_key'])){
|
|
$question = isset($value['questions']) ? $value['questions'] : array();
|
|
for($j = 0 ;$j<count($question);$j++){
|
|
$latest_quest = isset($question[$j]['question_key']) ? $question : $question[$j]['question'];
|
|
$temp[$i] = $this->call_arr1($latest_quest);
|
|
$arr2 = $this->call_arr2($latest_quest);
|
|
$return_arr[$i] = $this->merged_arr($temp[$i],$arr2);
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
else{
|
|
$return_arr[$i] = $value['question'];
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
return $return_arr;
|
|
}
|
|
|
|
//Step 2 : Onchange fns - Question Filter
|
|
public function call_arr2($quest){
|
|
$return_arr = array();
|
|
$i = 0 ;
|
|
if(!empty($quest) && is_array($quest) || is_object($quest)){
|
|
foreach ($quest as $key => $value) {
|
|
if((isset($value['onchange_properties'])) && (!empty($value['onchange_properties'])) && ($value['onchange_properties'] != null)){
|
|
for($h=0;$h<count($value['onchange_properties']);$h++){
|
|
$onchange_properties = isset($value['onchange_properties'][$h]['form_controls']) ? $value['onchange_properties'][$h]['form_controls'] : array();
|
|
$count = isset($onchange_properties) ? count($onchange_properties) : 0 ;
|
|
if($count>0 && !empty($onchange_properties)){
|
|
foreach ($onchange_properties as $key1 => $value1) {
|
|
// echo $value1['expression'];
|
|
// if($value1['question_key'] == 'Payment_Terms'){
|
|
// echo "I have step 1";
|
|
// echo($value['question_key']);
|
|
// echo $value1['question_key'];}
|
|
// if($value['question_key'] == 'Assets_Type'){
|
|
// }
|
|
if($value1['insert_index'] == $value['question_key']){
|
|
if(count($value1['questions']) > 0){
|
|
// echo " 8-i".$i;
|
|
for($j = 0 ;$j<count($value1['questions']);$j++){
|
|
// if($value['question_key'] == 'Assets_Type'){
|
|
// echo "**";
|
|
// }
|
|
// if($value['question_key'] == 'Payment_Terms'){
|
|
// print_r($value1['questions']);
|
|
// echo count($value1['questions']);
|
|
// print_r($this->call_arr1($value1['questions'],$fid)); run
|
|
// print_r($this->call_arr2($value1['questions'][$j]['question']));
|
|
// echo " <br> parent ".$value['question_key'];
|
|
$latest_quest = isset($value1['questions'][$j]['question_key']) ? $value1['questions'] : $value1['questions'][$j]['question'];
|
|
// $latest_quest = $value1['expression'] ? $latest_quest.$value1['expression'] : $latest_quest;
|
|
// echo " Key ".$value1['insert_index'];
|
|
$temp[$i] = $this->call_arr1($latest_quest);
|
|
$arr2 = $this->call_arr2($latest_quest);
|
|
$return_arr[$i] = $this->merged_arr($temp[$i],$arr2);
|
|
// }
|
|
// $temp[$i] = $this->call_arr1($value1['questions'][$j]['question'],$fid);
|
|
// $arr2 = $this->call_arr2($value1['questions'][$j]['question'],$fid);
|
|
// $return_arr[$i] = $this->merged_arr($temp[$i],$arr2);
|
|
}
|
|
}
|
|
// else{
|
|
// if(isset($value1['questions'][0]['question_key'])){
|
|
// $temp[$i] = $this->call_arr1($value1['questions'],$fid);
|
|
// $arr2 = $this->call_arr2($value1['questions'],$fid);
|
|
// // $arr1 = $this->call_arr1($value1['questions']);
|
|
// // $arr2[$i]['child'] = $this->call_arr2($temp[$i],$arr2);
|
|
// $return_arr[$i] = $this->merged_arr($temp[$i],$arr2);
|
|
// }else{
|
|
// $temp[$i] = $this->call_arr1($value1['questions'][0]['question'],$fid);
|
|
// $arr2 = $this->call_arr2($value1['questions'][0]['question'],$fid);
|
|
// $return_arr[$i] = $this->merged_arr($temp[$i],$arr2);
|
|
// }
|
|
// }
|
|
// foreach($value1['question'] as $key2 => $value2){
|
|
// $temp2[$i] = $this->call_arr1($value2['question']);
|
|
// $arr3 = $this->call_arr2($value2['question']);
|
|
// $return_arr[$i] = $this->merged_arr($temp2[$i],$arr3);
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$i++;
|
|
}
|
|
}
|
|
return $return_arr;
|
|
}
|
|
|
|
//Step 3 : Mapping Here for single-array using 2-array(arr1,arr2) ---- Short description is "array associate"
|
|
public function merged_arr($arr1,$arr2){
|
|
$final_result = array();
|
|
foreach($arr1 as $key=>$val){ // Loop though one array
|
|
if (array_key_exists($key, $arr2))
|
|
{
|
|
$val2 = $arr2[$key]; // Get the values from the other array
|
|
$final_result[$val] = $val2; // combine here (mapping as key)
|
|
// $final_result[$key] = $val + $val2;
|
|
// $final_result[$key][$val] = $val2;
|
|
}
|
|
else{
|
|
$final_result[$key] = $val; // combine here (mapping as key)
|
|
}
|
|
}
|
|
return $final_result;
|
|
}
|
|
|
|
//Step 4 : description - to get un-associated array.
|
|
// public function arr_formation_for_associate(){
|
|
// $return_arr = array();
|
|
// $i = 0 ;
|
|
// }
|
|
|
|
} |