MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/hrms_allyindian_com/application/controllers/Twenty_four_q_mapping.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Twenty_four_q_mapping  extends Action_controller{
	
	public function __construct(){
		parent::__construct('twenty_four_q_mapping');
		if(!$this->Appconfig->isAppvalid()){
			redirect('config');
		}
	}	
	// LOAD PAGE WITH TABLE DATA
	public function index(){
		$financial_info           = $this->get_financial_year();
        $fin_set_id               = $financial_info[0]->prime_financial_setting_id;
		$form_sixteen_head_qry    = 'select * from  cw_form_sixteen where trans_status = 1';
		$form_sixteen_head_info   = $this->db->query("CALL sp_a_run ('SELECT','$form_sixteen_head_qry')");
		$form_sixteen_head_result = $form_sixteen_head_info->result();
		$form_sixteen_head_info->next_result();
		$data['form_sixteen_head_result'] = $form_sixteen_head_result;
		
		$tax_sec_10_qry    = 'select cw_tax_section.tax_section,tax_act_details,tax_subsection_column from cw_tax_section inner join cw_tax_sub_section on cw_tax_sub_section.tax_section =cw_tax_section.prime_tax_section_id where cw_tax_sub_section.trans_status = 1 and cw_tax_sub_section.tax_section = 1 and cw_tax_sub_section.financial_setting_id = "'.$fin_set_id.'" order by subsection_order';
		$tax_sec_10_info   = $this->db->query("CALL sp_a_run ('SELECT','$tax_sec_10_qry')");
		$tax_sec_10_result = $tax_sec_10_info->result();
		$tax_sec_10_info->next_result();
		$data['tax_sec_10_result'] = $tax_sec_10_result;
		
		$tax_sec_16_qry    = 'select cw_tax_section.tax_section,tax_act_details,tax_subsection_column from cw_tax_section inner join cw_tax_sub_section on cw_tax_sub_section.tax_section =cw_tax_section.prime_tax_section_id where cw_tax_sub_section.trans_status = 1 and cw_tax_sub_section.tax_section = 2 and cw_tax_sub_section.financial_setting_id = "'.$fin_set_id.'" order by subsection_order';
		$tax_sec_16_info   = $this->db->query("CALL sp_a_run ('SELECT','$tax_sec_16_qry')");
		$tax_sec_16_result = $tax_sec_16_info->result();
		$tax_sec_16_info->next_result();
		$data['tax_sec_16_result'] = $tax_sec_16_result;

		$tax_sec_80_qry    = 'select cw_tax_section.tax_section,tax_act_details,tax_subsection_column from cw_tax_section inner join cw_tax_sub_section on cw_tax_sub_section.tax_section =cw_tax_section.prime_tax_section_id where cw_tax_sub_section.trans_status = 1 and cw_tax_sub_section.tax_section = 3 and cw_tax_sub_section.financial_setting_id = "'.$fin_set_id.'" order by subsection_order';
		$tax_sec_80_info   = $this->db->query("CALL sp_a_run ('SELECT','$tax_sec_80_qry')");
		$tax_sec_80_result = $tax_sec_80_info->result();
		$tax_sec_80_info->next_result();
		$data['tax_sec_80_result'] = $tax_sec_80_result;
		
		$tax_sec_6a_qry    = 'select cw_tax_section.tax_section,tax_act_details,tax_subsection_column from cw_tax_section inner join cw_tax_sub_section on cw_tax_sub_section.tax_section =cw_tax_section.prime_tax_section_id where cw_tax_sub_section.trans_status = 1 and cw_tax_sub_section.tax_section = 4 and cw_tax_sub_section.financial_setting_id = "'.$fin_set_id.'" order by subsection_order';
		$tax_sec_6a_info   = $this->db->query("CALL sp_a_run ('SELECT','$tax_sec_6a_qry')");
		$tax_sec_6a_result = $tax_sec_6a_info->result();
		$tax_sec_6a_info->next_result();
		$data['tax_sec_6a_result'] = $tax_sec_6a_result;
		
		$oth_sec_qry       = 'select cw_income_type.income_type,income_description,other_income_column from cw_other_income inner join cw_income_type on cw_income_type.prime_income_type_id =cw_other_income.income_type where cw_other_income.trans_status = 1 and prime_income_type_id in (1,2) order by cw_income_type.income_type';
		$oth_sec_info      = $this->db->query("CALL sp_a_run ('SELECT','$oth_sec_qry')");
		$oth_sec_result    = $oth_sec_info->result();
		$oth_sec_info->next_result();
		$data['oth_sec_result'] = $oth_sec_result;
		
		
		$form24q_temp_qry    = 'select prime_form_sixteen_id,form24q_value,form24q_mapping from cw_form24q_template where fin_set_id ="'.$fin_set_id.'"';		
		$form24q_temp_info   = $this->db->query("CALL sp_a_run ('SELECT','$form24q_temp_qry')");
		$form24q_temp_result = $form24q_temp_info->result();
		$form24q_temp_info->next_result();
		$data['form24q_temp_result'] = $form24q_temp_result; 
		$data['key']		 = $this->generateKey();
		$this->load->view("$this->control_name/manage",$data);
	}	
	public function save_mapping_data(){
		$encString        	 = file_get_contents('php://input');
		$_POST            	 = $this->cryptoDecrypt($encString);
		if(!$_POST){	
			echo json_encode(array('success' => false,'message' => 'Url Expired.. Please refresh the page and try again....','table_data' => ""));
			exit(0);
		}
		$form_24q_data        = json_decode($this->input->post('form_24q_data'));
		$form_24q_mapping     = $this->input->post('form_24q_mapping'); 
		$created_on           = date("Y-m-d H:i:s");
		$create_by            = $this->logged_id;
		$financial_info       = $this->get_financial_year();
        $fin_set_id           = $financial_info[0]->prime_financial_setting_id;
		$exit_form_tmp_qry    = 'select count(*) as rslt_count from cw_form24q_template where fin_set_id ="'.$fin_set_id.'"';
		$exit_form_tmp_info   = $this->db->query("CALL sp_a_run ('SELECT','$exit_form_tmp_qry')");
		$exit_form_tmp_result = $exit_form_tmp_info->result();
		$exit_form_tmp_info->next_result();
		$form_count = $exit_form_tmp_result[0]->rslt_count;
		if((int)$form_count === 0){
			if(!empty($form_24q_data)){
				$i = 0;
				foreach($form_24q_data as $entry_data){
					$form24q_key      = $entry_data->name;
					$form24q_value    = rtrim($entry_data->value,"+");
					
					$form24q_key_arr  = explode("_",$form24q_key);
					$prime_form16_id  = $form24q_key_arr[2];
					$form24q_mapping  = $form_24q_mapping[$i];
					if($form24q_key !== "form_24q_mapping[]"){
						$form_tmp_qry = 'INSERT INTO cw_form24q_template (fin_set_id,prime_form_sixteen_id,form24q_key,form24q_value,form24q_mapping,trans_created_by,trans_created_date) value ("'.$fin_set_id.'","'.$prime_form16_id.'","'.$form24q_key.'","'.$form24q_value.'","'.$form24q_mapping.'","'.$create_by.'","'.$created_on.'")';
						$form_tmp_info   = $this->db->query("CALL sp_a_run ('INSERT','$form_tmp_qry')");
						$form_tmp_result = $form_tmp_info->result();
						$form_tmp_info->next_result();
						$i++;
					}					
				}
				$msg = "Form 24Q template is Mapped successfully";
			}
		}else{
			$truncate_qry = 'TRUNCATE TABLE cw_form24q_template';
			$this->db->query("CALL sp_a_run ('RUN','$truncate_qry')");
			$i = 0;
			foreach($form_24q_data as $entry_data){
				$form24q_key      = $entry_data->name;
				$form24q_value    = rtrim($entry_data->value,"+");
				$form24q_key_arr  = explode("_",$form24q_key);
				$prime_form16_id  = $form24q_key_arr[2];
				$form24q_mapping  = $form_24q_mapping[$i];
				if($form24q_key !== "form_24q_mapping[]"){
					$form_tmp_qry = 'INSERT INTO cw_form24q_template(fin_set_id,prime_form_sixteen_id,form24q_key,form24q_value,form24q_mapping,trans_created_by,trans_created_date) value ("'.$fin_set_id.'","'.$prime_form16_id.'","'.$form24q_key.'","'.$form24q_value.'","'.$form24q_mapping.'","'.$create_by.'","'.$created_on.'")';
					$form_tmp_info   = $this->db->query("CALL sp_a_run ('INSERT','$form_tmp_qry')");
					$form_tmp_result = $form_tmp_info->result();
					$form_tmp_info->next_result();
					$i++;
				}
			}
			$msg = "Form 24Q template is Updated successfully";
		}
		echo json_encode(array('success' => TRUE,'msg'=>$msg));
	}

	public function fetch_data(){
		$template_qry    = 'SELECT form24q_key,form24q_value,form24q_mapping FROM cw_form24q_template WHERE trans_status = 1';
		$template_info   = $this->db->query("CALL sp_a_run ('SELECT','$template_qry')");
		$template_result = $template_info->result();
		$template_info->next_result();
		if($template_result){
			echo json_encode(array('success' => TRUE,'msg'=>'ok proceed','form24'=>$template_result));
		}
	}
}
?>