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/medlocqr_com/admin/application/controllers/Home.php
<?php 
/**********************************************************
	   Filename: Home
	Description: Chart view and Chart control logic developed, highchart integration based on role.
		 Author: Jaffer Sathik
	 Created on: 10-DEC-2018
	Reviewed by: Udhayakumar Anandhan (REVIEW PENDING)
	Reviewed on:
	Approved by:
	Approved on:
	-------------------------------------------------------
	Modification Details: HIGHCHARTS
	Modification Date: 06/12/2019
	Changed by: SVK AND NEHA
	Change Info: HIGHCHARTS
	-------------------------------------------------------
***********************************************************/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once("Action_controller.php");
class Home extends Action_controller {
	public function __construct(){		
		parent::__construct();
		$this->load->model("Homemodel");		
		$this->logged_id       = $this->session->userdata('logged_id');
		$this->logged_role     = $this->session->userdata('logged_role');
		$this->collect_base_info();
	}
	
	public function logout(){
		$this->session->sess_destroy();
		redirect('login');
	}
	
	public function index(){		
		if(!$this->Appconfig->isAppvalid()){			
			redirect('config');
		}		
		$data = "";
		$this->load->view('home',$data);
	}	
	public function material_wise_chart(){
		$start_date   = date("Y-m-d",strtotime($this->input->post('start_date')));
		$end_date     = date("Y-m-d",strtotime($this->input->post('end_date')));
		$material_query    = 'select IFNULL(count(*),0) as sts_count,prime_medlocker_id,cw_medlocker.trans_created_date,material_name from cw_medlocker inner join cw_material_type on cw_material_type.prime_material_type_id = cw_medlocker.material_type where cw_medlocker.trans_status = 1 and DATE_FORMAT(cw_medlocker.trans_created_date, "%Y-%m-%d") between "'.$start_date.'" and "'.$end_date.'" GROUP BY prime_material_type_id';
		$material_info   = $this->db->query("CALL sp_a_run ('SELECT','$material_query')");
		$material_result = $material_info->result();
		$material_info->next_result();
		$rows         = array();
		$rows['name'] = "Status";
		foreach($material_result as $key => $rlst){
			$prime_medlocker_id  = $rlst->prime_medlocker_id;
			$material_name		 = $rlst->material_name;
			$count             = $rlst->sts_count;
			$rows['data'][] = array("name"=>$material_name,"y"=>$count);
		}
		$sts_array = array();
		array_push($sts_array,$rows);	
		echo json_encode(array('series' => $sts_array),JSON_NUMERIC_CHECK);
	}
	public function registration_details_chart(){
		$start_date   = date("Y-m-d",strtotime($this->input->post('start_date')));
		$end_date     = date("Y-m-d",strtotime($this->input->post('end_date')));
		$patient_query    = 'select (select count(*) as ordered from cw_medlocker where ordered =1) as ordered,(select count(*) as deliverd from cw_medlocker where deliverd =1) as deliverd,(select count(*) as shipped from cw_medlocker where shipped =1) as shipped,(select count(*) as intransit from cw_medlocker where intransit =1) as intransit,prime_medlocker_id from cw_medlocker where cw_medlocker.trans_status = 1 and DATE_FORMAT(cw_medlocker.trans_created_date, "%Y-%m-%d") between "'.$start_date.'" and "'.$end_date.'"';
		$patient_info   = $this->db->query("CALL sp_a_run ('SELECT','$patient_query')");
		$patient_result = $patient_info->result();
		$patient_info->next_result();
		if($patient_result){
			$rows         = array();
			$rows['name'] = "Status";		
			$rows['data'] = array(array("name"=>"ordered","y"=>$patient_result[0]->ordered),array("name"=>"shipped","y"=>$patient_result[0]->shipped),array("name"=>"intransit","y"=>$patient_result[0]->intransit),array("name"=>"deliverd","y"=>$patient_result[0]->deliverd));
			$sts_array = array();
			array_push($sts_array,$rows);	
			echo json_encode(array('series' => $sts_array),JSON_NUMERIC_CHECK);
		}		
	}	
}

?>