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/Present_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Present_report  extends Action_controller{	
	public function __construct(){
		parent::__construct('present_report');
		
	}
	
	// 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;

		$category_qry 	= 'select prime_category_id,category_name from cw_category where trans_status = 1 and prime_category_id != 1';
		$category_info  = $this->db->query("CALL sp_a_run ('SELECT','$category_qry')");
		$category_rslt 	= $category_info->result_array();
		$category_info->next_result();
		$pick_key   = array_column($category_rslt, 'prime_category_id');
		$pick_val   = array_column($category_rslt, 'category_name');
		$final_pick = array_combine( $pick_key, $pick_val);
		$data['category_list'] = array("" => "---- label_name ----") + $final_pick;

		$this->load->view("$this->control_name/manage",$data);
	}

	public function present_days(){
		//SEARCH INFO FUNCTION
		$this->search_info();
		$category 			= $this->input->post("category");
		$attendance_month 	= $this->input->post("attendance_month");
		$minimum_count 		= $this->input->post("minimum_count");

		$month_day_arr 		= $this->salary_start_end_info($category,$attendance_month);
		if($month_day_arr){
			$day_start		= date('Y-m-d',strtotime($month_day_arr['salary_start_date']));
			$day_end		= date('Y-m-d',strtotime($month_day_arr['salary_end_date']));
		}
		$role_condition   = "";
		if($this->role_condition){
			$role_condition = $this->role_condition;
		}
		$present_report_qry = 'SELECT cw_employees.emp_name,cw_time_entry.employee_code,att_date,prime_time_entry_id,cw_department.department from cw_time_entry inner join cw_employees on cw_employees.employee_code = cw_time_entry.employee_code inner join cw_department on cw_employees.department = cw_department.prime_department_id where cw_time_entry.trans_status = 1 and cw_time_entry.att_date >= "'.$day_start.'" and cw_time_entry.att_date <= "'.$day_end.'"  and cw_employees.role = "'.$category.'" and total_work_hours > 0 '.$role_condition.' order by att_date ASC';
		$present_report_info   	= $this->db->query("CALL sp_a_run ('SELECT','$present_report_qry')");
		$present_report_rslt    = $present_report_info->result_array();
		$present_report_info->next_result();

		$present_report_arr = array_reduce($present_report_rslt, function($result, $arr){			
	    	$result[$arr['employee_code']][] = $arr;
	    	return $result;
		}, array());
        $td_line = "";        
        foreach ($present_report_arr as $emp_data){
        	$x = 0;
        	$emp_arr = array();
        	foreach ($emp_data as $value){
        		$att_date       = date('d-m-Y',strtotime($value['att_date']));
        		$employee_code  = $value['employee_code'];
        		$emp_name       = $value['emp_name'];
        		$department     = $value['department'];
        		if($x === 0){
        			$prev       = $att_date;
        		}        			
				if($prev  === $att_date){
					$x = $x+1; 
					$emp_arr[] =  $value['prime_time_entry_id'];
				}else{
					$x = 0;
					$emp_arr = array();
				}	
				$prev = date('d-m-Y', strtotime($value['att_date'] . ' +1 day'));
        	}
        	if($x >= $minimum_count){
        		$ids = implode(",",$emp_arr);       		
				$td_line       .="<tr onclick=get_data('$ids','$day_start','$day_end')><td>$employee_code</td><td>$emp_name</td><td>$department</td><td>$x</td></tr>";
			}
        }
        if($present_report_rslt){
			$table_data = "<table class='table table-striped table-bordered' id='emp_details'>
				<thead>
					<tr>
					 	<th>Employee Code</th>
					 	<th>Employee name</th>
					 	<th>Department</th>
					 	<th>Total Present Count</th>
					</tr>
				</thead>
				<tbody>
					$td_line
				</tbody>
			</table>";
		  echo json_encode(array('success'=>TRUE,'message'=>"",'table_data' => $table_data));
	    }else{
		  echo json_encode(array('success'=>false,'message'=>'NO DATA AVAILABLE','table_data'=>$table_data));

	    }
	}
}
?>