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); } } }