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/.trash/application.1/controllers/Form_16_view.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Form_16_view  extends Action_controller{	
	public function __construct(){
		parent::__construct('form_16_view');
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		$data['key'] = $this->generateKey();
		//PAGE INFO FUNCTION
		$this->page_info();
		$data['module_sts']    = (int)$this->module_sts;
		$data['quick_link']    = $this->quick_link;
		$data['pick_list']     = $this->pick_list;
		$data['table_head']    = $this->table_head;
		$data['fliter_list']   = $this->fliter_list;
		
		$employee_info_query = 'SELECT employee_code,emp_name FROM `cw_employees` where trans_status = 1 and prime_employees_id !=1 '.$this->role_condition;
		$employee_info   = $this->db->query("CALL sp_a_run ('SELECT','$employee_info_query')");
		$employee_result = $employee_info->result();
		$employee_info->next_result();
		$employee_list[""] = "---- Select Employee ----";
		foreach($employee_result as $for){
			$emp_code    = $for->employee_code;
			$emp_name    = $for->emp_name;
			$employee_list[$emp_code] = $emp_code." - ".$emp_name;
		}
		$data['employee_list'] = $employee_list;
		$startDate = "2020-04-01";
		$endDate   = date("Y-m-d",strtotime('+1 years'));

		$fin_rslt = $this->calcFY($startDate,$endDate);
		$fy_list[""] = "---- Select FY ----";
		foreach($fin_rslt as $key => $value){
			$fy_list[$key] = $value;
		}
		$data['fy_list'] = $fy_list;
		$this->load->view("$this->control_name/manage",$data);
	}
	public function calcFY($startDate,$endDate) {
    $ts1    = strtotime($startDate);
    $ts2    = strtotime($endDate);
    $year1  = date('Y', $ts1);
    $year2  = date('Y', $ts2);
    $month1 = date('m', $ts1);
    $month2 = date('m', $ts2);
    //get months
    $diff = (($year2 - $year1) * 12) + ($month2 - $month1);
    /**
     * if end month is greater than april, consider the next FY
     * else dont consider the next FY
     */
    $total_years = ($month2 > 4)?ceil($diff/12):floor($diff/12);
    $fy          = array();
    $i           = 0;
    while($total_years >= 0) {
        $prevyear = $year1 - 1;
        //We dont need 20 of 20** (like 2014)
        if($i === 0){
        	$unset = $prevyear.'-'.substr($year1,-2);
        }
        $fy[$prevyear.'-'.substr($year1,-2)] = $prevyear.'-'.substr($year1,-2);
        $year1 += 1;
        $total_years--;
        $i++;
    }
    /**
     * If start month is greater than or equal to april, 
     * remove the first element
     */
    if($month1 >= 4) {
        unset($fy[$unset]);
    }
    /* Concatenate the array with ',' */
    return $fy;
}
	public function check_form_16(){
		$encString         = file_get_contents('php://input');
		$_POST             = $this->cryptoDecrypt($encString);
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
			exit(0);
		}
		$emp_code          = $this->session->userdata('logged_emp_code'); // [MS 09-11-2024]
		$financial_year    = $this->input->post('financial_year');
		$tble_line         = "";
		$pan_num_qry       ='select pan_number from cw_employees where employee_code="'.$emp_code.'"';
		$pan_num_info      = $this->db->query("CALL sp_a_run ('SELECT','$pan_num_qry')");
		$pan_number_rslt   = $pan_num_info->result();
		$pan_num_info->next_result();
		$pan_number        = $pan_number_rslt[0]->pan_number; 
		$db_name           = $this->config->item("db_name");

		if($db_name === "hare_hrms_db"){
			$month_year     =  date('Y', $financial_year);
			$check_month    = "2022-23";
			if($financial_year <= $check_month){
		       $file_path   = "form_16/form_16_$financial_year/".strtoupper($pan_number).".pdf";
			}else{
				$file_path  = "form_16B/form_16B_$financial_year/".$emp_code.".pdf";
			}				
		}else{
			$file_path      = "form_16B/form_16B_$financial_year/".$emp_code.".pdf";
		}	
		
		if(file_exists($file_path)){
			$file_path      = base_url().$file_path;
			$filename       = dirname(__FILE__).$file_path;
			//FOR PATH ENCODE
			$enc_path       = base64_encode($file_path);
			$filename       = str_replace("application\controllers","",$filename);
			$tble_line     .= "	<tr class='gradeU'>
								<td>$emp_code _ $financial_year</td>
									<td>
									<a class='btn btn-primary btn-sm' onclick=pdf_viewer('$enc_path')><span class='fa fa-eye' >&nbsp;</span> view </a>
									<a class='btn btn-primary btn-sm' id='download_$emp_code' onclick=download_form16('download_$emp_code','$enc_path') download '><span class='fa fa-download' download>&nbsp;</span> Download </a>
									</td>
								</tr>";
		}else{
			$tble_line = "<tr class='gradeU'>
						<td colspan='2' style='text-align:center;'>No data found</td>
						</tr>";
		}		
		$table_data = "<table class='table table-striped table-bordered' id='emp_details'>
						<thead>
							<tr>
							<th>Financial Year</th>
							<th>Action</th>
							</tr>
						</thead>
						<tbody>
							$tble_line
						</tbody>
					</table>";
	echo json_encode(array('success' => true,'table_data' => $table_data));
	}		
}
?>