<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Report_px extends MBELINK_Controller {
	
	public function __construct(){
		
		parent::__construct();
		date_default_timezone_set('Asia/Jakarta');
		$this->load->helper(array('rsonline'));
				 
		// User Login Information
		$this->data['user'] = user_info();
		$this->data['instansi'] = orgInfo();
		
		// Cek Sesi
		 if(! $this->session->userdata('userid')):
			redirect(base_url('login-system.html'), 'refresh');
		endif;
		
		//load Model
		$this->load->model('mutu/indikator_model');		
		$this->load->model('yanmed/reportpx_model');		
		
		function setTglSql($str_tgl){
			$tglaja=strtotime($str_tgl);
			$bulan=date('m', $tglaja);
			$tahun=date('Y', $tglaja);
			$tglok=$tahun.'-'.$bulan.'-01';
			
			return $tglok;
		}
		
		//inisialisasi
		$date=date_create(date('Y-m-d'));
		date_modify($date, '-1 day');
		$tglkemarin=date_format($date, 'Y-m-d');
		
		$this->data['enddate']=$tglkemarin;
		
		
	}
	
	public function index()
	{
		
		$this->data['tglawal']=$this->input->post('tglawal');
		$this->data['tglakhir']=$this->input->post('tglakhir');
		
		$this->data['result']=$this->reportpx_model->getRekapIGDPx($this->data['tglawal'],$this->data['tglakhir']);
		$this->load->view('yanmed/rekap_pasien_igdbydokter_periode', $this->data);
		
		
	}
	
	function setReportPxIGD()
	{
		if(isset($_POST['bProses'])){
			$this->data['tahun']=$this->input->post('tglawal');
		}else{
			$this->data['tahun']=date('Y');
		}
		
		$this->data['result']=$this->reportpx_model->getRekapPxIGD($this->data['tahun']);		
		//$x['data'] = json_encode($this->data['result']);
		
		$this->load->view('yanmed/report_pasien_igd1', $this->data);
	}
	
	public function rekapPxIGD()
	{
		
		$this->data['tglawal']=$this->input->post('tglawal');
		$this->data['tglakhir']=$this->input->post('tglakhir');
		
		$this->data['result']=$this->reportpx_model->getRekapPasienIGD($this->data['tglawal'],$this->data['tglakhir']);
		$this->load->view('yanmed/rekap_pasien_igd', $this->data);
				
	}
	
	function setRekapTransferPasienIGD()
	{
		$this->data['tglawal']= date('Y').'-'.date('m').'-01';
		$this->data['tglakhir']= date('Y-m-d');//date('Y').'-'.date('m').'01';
		
		if(isset($_POST['bProses'])){		
			$this->data['tglawal']= $this->input->post('tglawal');
			$this->data['tglakhir']= $this->input->post('tglakhir');			
		}	
		
		$this->data['result']=$this->reportpx_model->getDataTransferPasienIGD($this->data['tglawal'],$this->data['tglakhir']);
		$this->load->view('yanmed/transfer_pasien_igd', $this->data);
		
	}
	
	function excelRekapTransferPasienIGD()
	{
		/* $this->data['tglawal']= date('Y').'-'.date('m').'-01';
		$this->data['tglakhir']= date('Y-m-d');//date('Y').'-'.date('m').'01';
		
		if(isset($_POST['bProses'])){	 */	
			$this->data['tglawal']= $this->input->post('tglawal');
			$this->data['tglakhir']= $this->input->post('tglakhir');			
		//}	
		
		$this->data['result']=$this->reportpx_model->getDataTransferPasienIGD($this->data['tglawal'],$this->data['tglakhir']);
		$this->load->view('yanmed/transfer_pasien_igd_excel', $this->data);
		
	}
}
