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

class Casemix 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('casemix/casemix_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->load->view('mutu/indikator_bor');
		//$this->data['tanggal']=setTglSql($this->input->post('tglawal'));
		
		$this->data['result']=$this->casemix_model->getDataKamarTersedia();
		$this->load->view('casemix/report_kamar_isi', $this->data);
		
		//echo setTglSql($_POST['tglawal']);
		/* $tgl=explode(" ",$_POST['tglawal']);
		print_r($tgl);
		$str_tgl = strtotime($_POST['tglawal']);		
		$bulan = date('Y', $str_tgl);
		echo $bulan; */
	}
	
	
}
