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/cpaqua.cafsinfotech.in/application/controllers/Time_card.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Time_card  extends Action_controller{	
	public function __construct(){
		parent::__construct('time_card');
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		$data['key']     = $this->generateKey();
		$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;
		
		$this->load->view("$this->control_name/manage",$data);
	}
	
	public function time_card(){
		$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);
		}
		$process_month     = $this->input->post('process_month');
		$emp_code          = $this->session->userdata('logged_emp_code'); // [MS 09-11-2024]
		$category_qry 	   = 'SELECT category_name FROM cw_employees inner join cw_category on cw_category.prime_category_id = cw_employees.role where employee_code = "'.$emp_code.'"';
		$category_info     = $this->db->query("CALL sp_a_run ('SELECT','$category_qry')");
		$category_rslt     = $category_info->result();
		$category_info->next_result();
		$category_name     = $category_rslt[0]->category_name;
		$category_name     = strtolower(str_replace(" ","_",$category_name));
		$file_path         = "./timecard/$category_name/$process_month/$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>$process_month</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_$payslip_month' 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>Timecard Month</th>
								<th>Action</th>
								</tr>
							</thead>
							<tbody>
								$tble_line
							</tbody>
						</table>";
		echo json_encode(array('success' => true,'table_data' => $table_data));
	}
}
?>