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/controllers/Date_wise_in_out.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Date_wise_in_out  extends Action_controller{	
	public function __construct(){
		parent::__construct('date_wise_in_out');
	}
	
	// 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['form_info']     = $this->form_info;
		$data['table_head']    = $this->table_head;
		$data['fliter_list']   = $this->fliter_list;
		$data['freeze_list']   = $this->freeze_list;
		$data['key']           = $this->generateKey();
		$this->load->view("$this->control_name/manage",$data);
	}
	// FUNCTION TO GET EMPLOYEE CODE
	public function emp_code_list(){
		$emp_qry  = 'SELECT cw_employees.employee_code,cw_employees.emp_name FROM cw_employees WHERE  cw_employees.trans_status = 1';
		$emp_info   = $this->db->query("CALL sp_a_run ('SELECT','$emp_qry')");
		$emp_rslt   = $emp_info->result();
		$emp_info->next_result();
		$emp_list   = "<option value= ''>---- Select Employees----</option>";
		foreach($emp_rslt as $for){
			$employee_code  = $for->employee_code;
			$emp_name       = $for->emp_name;
			$emp_list      .= "<option value= '".$employee_code."'>".$employee_code." - ".$emp_name."</option>";
		}
		echo json_encode(array('success' => TRUE,  'emp_list' => $emp_list));
	}

	// FUNCTION TO GET DEVICE_CODE
	public function dev_code_list(){
		$device_qry   = 'SELECT cw_device.device_id,cw_device.device_name from cw_device';
		$device_info  = $this->db->query("CALL sp_a_run ('SELECT','$device_qry')");
		$device_rslt  = $device_info->result();
		$device_info->next_result();
		$device_list  = "";
		foreach($device_rslt as $for){
			$device_code  = $for->device_id;
			$device_name  = $for->device_name;
			$device_list .= "<option value= '".$device_code."'>".$device_code." - ".$device_name."</option>";
		}
		echo json_encode(array('success' => TRUE,  'device_list' => $device_list));
	}

	// FUNCTION TO GET TABLE DATA
	public function get_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);
		}
		$employee_type  	= (int)$this->input->post('employee_type');  
		$employee_code 		= $this->input->post('employee_code');  
		$selective_employee = $this->input->post('selective_employee'); 
		$device_code		= $this->input->post('device_code');
		$start_date 		= $this->input->post('start_date');  
		$end_date 			= $this->input->post('end_date');  
		$start_date 		= date('Y-m-d', strtotime($this->input->post('start_date')));
		$end_date   		= date('Y-m-d', strtotime($this->input->post('end_date')));
		$selective_employee = '"' . implode('", "', $selective_employee) . '"';
		$device_code		= '"' . implode('", "', $device_code) . '"';

		if($employee_type === 1){
			$filter_condition = ' AND cw_employees.employee_code="'.$employee_code.'" GROUP BY DATE(cw_time_log.log_date) ,cw_employees.employee_code ORDER BY cw_employees.employee_code';
		}else
		if($employee_type === 2){
		$filter_condition = ' GROUP BY DATE(cw_time_log.log_date) ORDER BY cw_employees.employee_code';
		}else{
			$filter_condition =' AND cw_employees.employee_code IN ('.$selective_employee.') GROUP BY DATE(cw_time_log.log_date) ,cw_employees.employee_code ORDER BY cw_employees.employee_code' ;
		}
		$in_out_qry='SELECT cw_employees.employee_code,cw_employees.emp_name,cw_employees.date_of_joining,cw_device.attn_device,cw_vendor_details.vendor_name,cw_shift_master.shift_name,cw_time_log.device_id,cw_category.category_name,cw_section.section_name,cw_department.department,cw_user_role.role_name,DATE_FORMAT(cw_time_log.log_date, "%d-%m-%Y") AS log_date_only,MIN(TIME(cw_time_log.log_date)) AS min_time,MAX(TIME(cw_time_log.log_date)) AS max_time FROM cw_time_log INNER JOIN cw_employees ON cw_time_log.user_id = cw_employees.device_code INNER JOIN cw_category ON cw_category.prime_category_id = cw_employees.role INNER JOIN cw_department ON cw_department.prime_department_id = cw_employees.department INNER JOIN cw_user_role ON cw_user_role.prime_user_role_id = cw_employees.user_right INNER JOIN cw_device ON cw_device.device_id = cw_time_log.device_id INNER JOIN cw_section ON cw_section.prime_section_id=cw_employees.section INNER JOIN cw_shift_import ON cw_shift_import.employee_code= cw_employees.employee_code INNER JOIN cw_shift_master ON cw_shift_master.prime_shift_master_id=cw_shift_import.shift_name INNER JOIN cw_vendor_details ON cw_vendor_details.prime_vendor_details_id=cw_employees.vendor_name WHERE DATE(cw_time_log.log_date) BETWEEN  "'.$start_date.'" AND "'.$end_date.'" AND cw_time_log.device_id IN ('.$device_code.') '.$filter_condition.'';
		$in_out_qry_info	= $this->db->query("CALL sp_a_run ('SELECT','$in_out_qry')");
		$in_out_qry_rslt 	= $in_out_qry_info->result_array();    
		$in_out_qry_info->next_result();
		$in_out_qry_tr_line	= "";
		foreach($in_out_qry_rslt as $value){
			$employee_code 			= $value['employee_code'];
			$employee_name 			= $value['emp_name'];
			$vendor 				= $value['vendor_name'];
			$section 				= $value['section_name'];
			$shift_name 			= $value['shift_name'];
			$category 				= $value['category_name'];
			$department 			= $value['department'];
			$date					= $value['log_date_only'];
			$device_id				= $value['device_id'];
			$in_time 				= $value['min_time'];
			$out_time 				= $value['max_time'];
			$date_of_join			= date('d-m-Y', strtotime($value['date_of_joining']));
			$formatted_total_hours  = gmdate("H:i:s", strtotime($out_time) - strtotime($in_time));

			$in_out_qry_tr_line .= "<tr><td style='text-align:center'>$employee_code</td><td style='text-align:center'>$employee_name</td><td style='white-space: nowrap;'>$date_of_join</td><td style='text-align:center'>$department</td><td style='text-align:center'>$section</td><td style='text-align:center'>$category</td><td style='text-align:center'>$vendor</td><td style='text-align:center'>$shift_name</td><td style='white-space: nowrap;'>$date</td><td style='text-align:center'>$device_id</td><td style='text-align:center'>$in_time</td><td style='text-align:center'>$out_time</td></td><td style='text-align:center'>$formatted_total_hours</td></tr>";
		} 
		$thead="<thead>
					<tr>
						<th style='text-align:center'>Employee Code</th>
						<th style='text-align:center'>Employee Name</th>
						<th style='text-align:center'>DOJ</th>
						<th style='text-align:center'>Department</th>
						<th style='text-align:center'>Section</th>
						<th style='text-align:center'>Category</th>
						<th style='text-align:center'>Vendor</th>
						<th style='text-align:center'>Shift</th>
						<th style='text-align:center'>Date</th>
						<th style='text-align:center'>Device Code</th>
						<th style='text-align:center'>In Time</th>
						<th style='text-align:center'>Out Time</th>
						<th style='text-align:center'>Total Work Time</th>
					</tr>
				</thead>";
		if($in_out_qry_tr_line){
			$message = "Data Available";
			$in_out_table_content = "<table class='table table-striped table-bordered' id='in_out_table'>
										$thead
										<tbody>
											$in_out_qry_tr_line
										</tbody>
									</table>";
		}else{
			$message = "No Data Available";
			$in_out_table_content = "<table class='table table-striped table-bordered' id='in_out_table'>	
										$thead
										<tbody>
											<tr><td colspan='12' style='text-align:center';>No Data Availible</td></tr>
										</tbody>
									</table>";
		}
		echo json_encode(array('success' => $in_out_qry_tr_line ? TRUE : FALSE, 'message' => $message, 'in_out_table_content' => $in_out_table_content));
	}

	// FUNCTION TO GET EMPLOYEE LIST AUTOCOMPLETE SINGLE EMPLOYEE INPUT
	public function autocomplete(){
		$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('term'); 
		$emp_qry           = 'SELECT cw_employees.employee_code,cw_employees.emp_name FROM cw_employees  WHERE  cw_employees.trans_status = 1 AND  cw_employees.emp_name LIKE "%'.$search_term.'%" ';
		$emp_info          = $this->db->query($emp_qry);
		$emp_rslt          = $emp_info->result();
		$emp_info->next_result();
		$emp_list          = array();
		foreach ($emp_rslt as $for) {
			$employee_code = $for->employee_code;
			$emp_name 	   = $for->emp_name;
			$emp_list[]    = [
				'label' => $employee_code . ' - ' . $emp_name, 
				'value' => $employee_code, 
			];
		}
		echo json_encode($emp_list);
	}	
}

?>