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/application/controllers/Scheduler.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Scheduler  extends Action_controller{	
	public function __construct(){
		parent::__construct('scheduler');
	}
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		$process_status['']     = '--Select Status--';       
		$data['encKey']          = $this->generateKey();
		$data['process_status'] = $process_status + $this->sched_status_fun();
		$this->load->view("$this->control_name/manage",$data);
	}
	public function sched_status_fun(){
		$sched_stat_qry  = 'select scheduler_id,scheduler_status from cw_scheduler_status where cw_scheduler_status.trans_status = 1'; 
		$sched_stat_info = $this->db->query("CALL sp_a_run ('SELECT','$sched_stat_qry')");
		$sched_stat_rslt = $sched_stat_info->result_array();
		$sched_stat_info->next_result();
		$sched_stat_arr  = array_reduce($sched_stat_rslt ?? [], function($result, $arr){	
			$result[$arr['scheduler_id']] = $arr['scheduler_status'];
			return $result;
		}, array());
		return $sched_stat_arr;
	}
	public function search(){
		$dec_data         = $this->cryptoDecrypt($_POST['encrypted_data']);
		$_POST            = $dec_data['d'];
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..'));
			exit(0);
		}
		$draw               = $this->input->post('draw');
		$start              = $this->input->post('start');
		$per_page           = $this->input->post('length');
		$order              = $this->input->post('order');
		$order_col          = $this->input->post('columns');
		$search             = $this->input->post('search');
		$html_sts           = $this->input->post('html_sts');
		$pdf_sts            = $this->input->post('pdf_sts');
		$merge_sts          = $this->input->post('merge_sts');
		$process_month      = $this->input->post('process_month');
		$column             = $order[0]['column'];
		$order_sor          = $order[0]['dir'];
		$order_col          = $order_col[$column]['data'];
		$search             = trim($search['value']);
		//FILTER
		$filter_query       = "";
		if($html_sts !== ''){
			$filter_query  .= ' AND cw_combine_process_list.html_sts = "'.$html_sts.'"';
		}
		if($pdf_sts !== ''){
			$filter_query  .= ' AND cw_combine_process_list.pdf_sts = "'.$pdf_sts.'"';
		}
		if($merge_sts !== ''){
			$filter_query  .= ' AND cw_combine_process_list.merge_sts = "'.$merge_sts.'"';
		}
		$common_search      = "";
		if($search){
			$common_search .= ' or cw_combine_process_list.project_id like "'.$search.'%" or cw_combine_process_list.wbs_element like "'.$search.'%" or cw_combine_process_list.personal_code like "'.$search.'%" or cw_combine_process_list.process_month like "'.$search.'%"';
			$common_search  = ltrim($common_search,' or ');
			$common_search  = " and ($common_search)";
			$common_search  = str_replace("(,","(",$common_search);
			$common_search  = str_replace("()","(0)",$common_search);
		}
		$search_query       = 'SELECT * FROM cw_combine_process_list ';
		$search_query      .= ' where cw_combine_process_list.trans_status = 1 AND cw_combine_process_list.process_month = "'.$process_month.'" '.$filter_query.''.$common_search.' ';
		$search_query      .= " ORDER BY $order_col $order_sor";
		if((int)$per_page !== -1){
			$search_query  .= " LIMIT $start,$per_page";
		}	
		$count_all_query    = 'SELECT count(*) as allcount FROM cw_combine_process_list where trans_status = 1 AND cw_combine_process_list.process_month = "'.$process_month.'"';
		$count_query        = 'SELECT count(*) as allcount FROM cw_combine_process_list where trans_status = 1 AND cw_combine_process_list.process_month = "'.$process_month.'"'.$filter_query.' '.$common_search.'' ;
		$search_pro_qry     = [];
		$search_pro_qry[]   = array("return"=>"total_count","qry"=>$count_all_query);
		$search_pro_qry[]   = array("return"=>"filtered_count","qry"=>$count_query);
		$search_pro_qry[]   = array("return"=>"search_result","qry"=>$search_query);
		$search_info_rslt   = $this->run_multi_qry($search_pro_qry);
		$total_count        = $search_info_rslt->rslt->total_count[0]->allcount;
		$filtered_count     = $search_info_rslt->rslt->filtered_count[0]->allcount;
		$search_result      = json_decode(json_encode($search_info_rslt->rslt->search_result),true);
		if($search_result === null || $search_result === ''){
			$search_result  = [];
		}
		//SCHEDULER
		$scheduler_qry      = 'SELECT scheduler_id,scheduler_status FROM cw_scheduler_status where trans_status = 1';
		$scheduler_data     = $this->db->query("CALL sp_a_run ('SELECT','$scheduler_qry')");
		$scheduler_rslt     = $scheduler_data->result_array();
		$scheduler_data->next_result();
		$scheduler_map = [];
		foreach($scheduler_rslt as $scheduler){
		    $scheduler_map[$scheduler['scheduler_id']] = $scheduler['scheduler_status'];
		}
		//REPLACE
		foreach($search_result as &$search){
		    $html_sts  = (int)$search['html_sts'];
		    $pdf_sts   = (int)$search['pdf_sts'];
		    $merge_sts = (int)$search['merge_sts'];
		    if(isset($scheduler_map[$html_sts])){
		        $search['html_sts']  = $scheduler_map[$html_sts];
		    }
		    if(isset($scheduler_map[$pdf_sts])){
		        $search['pdf_sts']   = $scheduler_map[$pdf_sts];
		    }
		    if(isset($scheduler_map[$merge_sts])){
		        $search['merge_sts'] = $scheduler_map[$merge_sts];
		    }
		}
		unset($search); 
		echo json_encode(array("draw" => intval($draw),"recordsTotal" => $total_count,"recordsFiltered" => $filtered_count,"data" => $search_result));
	}
}
?>