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/uds.cafsinfotech.in/smart_hrms_dev/application/controllers/Time_entry_log.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Time_entry_log  extends Action_controller{	
	public function __construct(){
		parent::__construct('time_entry_log');
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		$data['encKey']  = $this->generateKey();
		$emp_info_qry    = 'select employee_code,emp_name from cw_employees where trans_status = 1 and prime_employees_id !=1';
		$emp_info_data   = $this->db->query("CALL sp_a_run ('SELECT','$emp_info_qry')");
		$emp_info_result = $emp_info_data->result();
		$emp_info_data->next_result();
		$employee_list[""] = "---- Select Employee ----";
		foreach($emp_info_result as $emp_rslt){
			$emp_code  = $emp_rslt->employee_code;
			$emp_name  = $emp_rslt->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 check_log_details(){
		//Encryption
		$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);
		}
		$process_by        = $this->input->post('process_by');
		$employee_code     = $this->input->post('employee_code');
		$start_date        = str_replace("/","-",$this->input->post('start_date'));
		$end_date          = str_replace("/","-",$this->input->post('end_date'));
		$from_date         = date('Y-m-d',strtotime($start_date));
		$to_date           = date('Y-m-d',strtotime($end_date));
		$financial_info    = $this->get_leave_financial_details();
		$starting_date     = $financial_info[0]->starting_date;
		$ending_date       = $financial_info[0]->ending_date;
		
		//changed by employee details
		$time_entry_qry    = 'select prime_time_entry_id,employee_code,att_date from cw_time_entry where trans_status = 1 and att_date between "'.$starting_date.'" and "'.$ending_date.'"';
		$time_entry_info   = $this->db->query("CALL sp_a_run ('SELECT','$time_entry_qry')");
		$time_entry_result = $time_entry_info->result_array();
		$time_entry_info->next_result();

		$time_entry_arr = array();
		foreach ($time_entry_result as $key => $value) {
			$time_entry_arr[$value['prime_time_entry_id']] = $value['employee_code'];
		}
		
		//form setting for view name details
		$form_view_qry    = 'select label_name,view_name from cw_form_setting where prime_module_id="time_entry" and trans_status=1';
		$form_view_data   = $this->db->query("CALL sp_a_run ('SELECT','$form_view_qry')");
		$form_view_result = $form_view_data->result_array();
		$form_view_data->next_result();
		$form_view_rslt = array_reduce($form_view_result, function ($result, $arr) {
		    $result[$arr['label_name']] = $arr['view_name'];
		    return $result;
		}, array());
		
		$qry ="";
		if((int)$process_by === 1){
			$qry = ' and employee_code="'.$employee_code.'"';
		}else
		if((int)$process_by === 2){
			$qry = ' and DATE_FORMAT(trans_created_date, "%Y-%m-%d") between "'.$from_date.'" and "'.$to_date.'"';
		}
		$time_entry_log_qry    = 'select employee_code,att_date,label_name,old_value,new_value,trans_created_by,trans_created_date from cw_time_entry_log where trans_status=1' .$qry;
		$time_entry_log_info   = $this->db->query("CALL sp_a_run ('SELECT','$time_entry_log_qry')");
		$time_entry_log_result = $time_entry_log_info->result();
		$time_entry_log_info->next_result();
		if($time_entry_log_result){
			$tr_line = "";
			$i       = 1;
			foreach($time_entry_log_result as $time_entry_log_rslt){
				$employee_code = $time_entry_log_rslt->employee_code;
				$att_date      = date('d-m-Y',strtotime($time_entry_log_rslt->att_date));
				$label_name    = $time_entry_log_rslt->label_name;
				$old_value     = $time_entry_log_rslt->old_value;
				$new_value     = $time_entry_log_rslt->new_value;
				$change_date   = date('d-m-Y',strtotime($time_entry_log_rslt->trans_created_date));
				$change_by     = $time_entry_log_rslt->trans_created_by;
				$change_name   = $time_entry_arr[$change_by];
				$view_name     = $form_view_rslt[$label_name];
				$tr_line         .="<tr><td>$i</td><td>$employee_code</td><td>$att_date</td><td>$view_name</td><td>$old_value</td><td>$new_value</td><td>$change_date</td><td>$change_name</td></tr>";
				$i++;
			}
			$table_content = "<div style='background-color: #f2f2f2;'>
								<table class='table table-striped table-bordered' id='details_list'>
										<thead>
											<tr>
												<th>Si.No</th>
												<th>Employee Code</th>
												<th>Attendance Date</th>
												<th>Field Name</th>
												<th>Old Value</th>
												<th>New Value</th>
												<th>Changed On</th>
												<th>Changed By</th>
											</tr>
										</thead>
										<tbody>
											$tr_line
										</tbody>
									</table>
									</div>";
			echo json_encode(array('success' => TRUE, 'message' => "See employee log list details",'table_content'=>$table_content));
		}else{
			echo json_encode(array('success' => FALSE, 'message' => "No data is available"));
		}
	}
}
?>