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

class Jasmed extends MBELINK_Controller {
	
	function __construct(){
		
		parent::__construct();
		date_default_timezone_set('Asia/Jakarta');	
		
		$this->load->library(array('session'));
		$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('duite/jasmed_model');		
		$this->load->model('inform_model');		
				
		//inisialisasi
		//$this->data['kamar']=$this->ranap_model->getDataKamar();
		
		function setTglSql($str_tgl){
			$tglaja=strtotime($str_tgl);
			$bulan=date('m', $tglaja);
			$tahun=date('Y', $tglaja);
			$tglok=$tahun.'-'.$bulan.'-01';
			
			return $tglok;
		}
		
		$this->data['dokter']=$this->inform_model->getDokter();
	}
	
	public function index()
	{
		//$time= date("Y-d-m");
		//$this->data['tglawal']= date('Y-m-d');//date('Y').'-'.date('m').'01';
		//$this->data['tglakhir']=date('Y-m-d');
		
		//echo $this->data['tglawal'];exit();
		//if(isset($_POST['bProses'])){			
			$this->data['tglawal']=$this->input->post('tglawal');
			$this->data['tglakhir']=$this->input->post('tglakhir');
			$this->data['kddokter']=$this->input->post('dokter');
			
		
		
		
			//$this->data['result']=$this->jasmed_model->getDataVisiteDokter($this->data['tglawal'],$this->data['tglakhir']);
			$this->data['result']=$this->jasmed_model->getPasienVisite($this->data['kddokter'],$this->data['tglawal'],$this->data['tglakhir']);
			
			$this->load->view('duite/jasmed_visite_bydokter', $this->data);
		//}	
	}
	
	function getRekapDetailVisitByDokterPerPasien()
	{
		$this->data['dokter']= $this->input->get('nm');
		$this->data['kode']= $this->input->get('key');
		$this->data['tglawal']= $this->input->get('tga');
		$this->data['tglakhir']= $this->input->get('tgk');
				
				
		$this->data['result']=$this->jasmed_model->getRekapDataVisiteDokterDetail($this->data['kode'],$this->data['tglawal'],$this->data['tglakhir']);
		
		$this->load->view('duite/jasmed_visite_bydokter_detailpasien', $this->data);
	}
	
	function getRekapDetailVisitDokterPasienPertgl()
	{
		$this->data['norawat']= $this->input->get('nrw');
		$this->data['kode']= $this->input->get('key');
		$this->data['dokter']= $this->input->get('dk');				
		$this->data['pasien']= $this->input->get('ps');	
		$this->data['tglawal']= $this->input->get('tga');
		$this->data['tglakhir']= $this->input->get('tgk');		
				
		$this->data['result']=$this->jasmed_model->getRekapDataVisiteDokterPasienDetailTgl($this->data['kode'],$this->data['norawat'],$this->data['tglawal'],$this->data['tglakhir']);
		
		$this->load->view('duite/jasmed_visite_bydokterpasien_detailTgl', $this->data);
	}	
	
}
