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/cloud_cafsinfotech_in/application/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(){
		//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(){
		$emp_code       = $this->input->post('emp_code');
		$financial_year = $this->input->post('financial_year');
		$tble_line    = "";
		$tble_no_line = "";
		$i = 0;
		$j = 0;
		$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;
			$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('$file_path')><span class='fa fa-eye' >&nbsp;</span> view </a>
							<a class='btn btn-primary btn-sm' id='download_$emp_code' href='$file_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));
	}		
}
?>