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_bk/controllers/Tds_statement.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Tds_statement  extends Action_controller{	
	public function __construct(){
		parent::__construct('tds_statement');
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		$this->save_info();
		$role_info   = $this->db->query("CALL sp_a_run ('SELECT','SELECT * FROM `cw_category` where trans_status = 1 and prime_category_id !=1')");
		$role_result = $role_info->result();
		$role_info->next_result();
		$process_role = array();
		foreach($role_result as $for){
			$role_id   = $for->prime_category_id;
			$category_name = $for->category_name;
			$process_role[$role_id] = $category_name;
		}
		$data['process_role'] = $process_role;
		$data['key'] = $this->generateKey();
		$this->load->view("$this->control_name/manage",$data);
	}
	//AUTO COMPLETE FUNCTION
	public function emp_suggest(){
		$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);
		}
		$search_term  = $this->input->post_get('term');
		$final_qry    = 'select employee_code,emp_name from cw_employees where trans_status = 1 and prime_employees_id !=1  and (employee_code like ("%'.$search_term.'%")  OR emp_name LIKE ("%'.$search_term.'%"))' ;
		$final_data   = $this->db->query("CALL sp_a_run ('SELECT','$final_qry')");
		$final_result = $final_data->result();
		$final_data->next_result();
		foreach($final_result as $rslt){
			$employee_code = $rslt->employee_code;
			$emp_name      = $rslt->emp_name;
			$suggestions[] = array('value' => "$employee_code", 'label' => "$employee_code - $emp_name");
		}
		if(empty($suggestions)){
			$suggestions[] = array('value' => "0", 'label' => "No data found for this search");
		}
		echo json_encode($suggestions);
	}
		//TABLE DISPLAY
	public function get_table_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);
		}
		$this->save_info();
		$process_type   = $this->input->post('process_type');
		$process_emp_id = $this->session->userdata('logged_emp_code');
		$process_role   = implode(',', $this->input->post('process_role'));
		$effective_month= $this->input->post('effective_month');

		if($process_type == '1'){
			$tax_where_query = 'cw_tax_calculation.emp_code ="'.$process_emp_id.'" and cw_tax_calculation.process_month = "'.$effective_month.'" ';
		}else
		if($process_type == '2'){
			$tax_where_query = 'cw_tax_calculation.emp_role in ('.$process_role.') and cw_tax_calculation.process_month = "'.$effective_month.'" ';
		}
		$end_date       = $this->financial_info[0]->end_date;
		$process_month    = $effective_month;

		//EMPLOYEE NAME AND CO
		$emp_qry 	= 'select employee_code,emp_name from cw_employees where trans_status = 1';
        $emp_info   = $this->db->query("CALL sp_a_run ('SELECT','$emp_qry')");
        $emp_rslt   = $emp_info->result_array();
        $emp_info->next_result();
        $emp_rslt = array_reduce($emp_rslt, function($result, $arr){			
	    	$result[$arr['employee_code']] = $arr['emp_name'];
	    	return $result;
		}, array());

       	$section_dec_query 	 = 'SELECT *,t.income_tax_type as income_tax_type FROM cw_tax_calculation JOIN cw_income_tax_type AS t ON cw_tax_calculation.income_tax_type = t.prime_income_tax_type_id where ' .$tax_where_query. '';
        $section_dec_data    = $this->db->query("CALL sp_a_run ('SELECT','$section_dec_query')");
        $section_dec_result  = $section_dec_data->result_array();
        $section_dec_data->next_result();
		foreach ($section_dec_result as $key => $val) {
			$newFormat       = DateTime::createFromFormat('m-Y', $val['process_month']);
			$date2           = $newFormat->format('Y-m') . '-01';
			$ts1             = strtotime($end_date);
			$ts2             = strtotime($date2);
			$diff            = abs((date('Y',$ts2)-date('Y',$ts1))*12+(date('m',$ts2)-date('m', $ts1)));
			$income_tax_type = $val['income_tax_type'];
			$process_month   = $val['process_month'];
			$total_income    = $val['total_tax'];
			$tax_amt         = $val['tax_amt'];
			$tax_deducted    = $val['tax_deducted'];
			$Rem_pay_Amt     = ($val['tax_amt'] - $val['tax_deducted']);
		    $final_tax_amt   = $val['final_tax_amt'];
		    $emp_code	     = $val['emp_code'];
		    $emp_name        = $emp_rslt[$val['emp_code']] ;

		    $tbl_line .="<tr><td>$emp_code</td><td>$emp_name</td><td>$income_tax_type</td><td>$process_month</td><td>$total_income</td><td>$tax_amt</td><td>$tax_deducted</td><td>$Rem_pay_Amt</td><td>$final_tax_amt</td><td>$diff</td></tr>";
		}
        $view_content = "<table class='table table-striped table-bordered' id='role'>
							<thead>
								<tr>
									<th scope='col'>Employee Code</th>
									<th scope='col'>Employee Name</th>
									<th scope='col'>Income Tax Type</th>
									<th scope='col'>Process Month</th>
									<th scope='col'>Total Income</th>
									<th scope='col'>Overall Tax</th>
									<th scope='col'>Already Paid</th>
									<th scope='col'>Remaining Payable Amount</th>
									<th scope='col'>Monthly Tds</th>
									<th scope='col'>Remaining Months</th>
								</tr>
							</thead>
							    $tbl_line
						</table>";
		echo json_encode(array("success" => TRUE,'message' => $view_content));
	}
}
?>