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

class Poli_rajal extends MBELINK_Controller {
	
	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('rajal/rajal_model');		
		$this->load->model('ranap/ranap_model');		
		
		
		//inisialisasi
		$this->data['poli']=$this->rajal_model->getPintuMasuk();
		
	}
	
	public function index()
	{
		//print_r($_POST);
		if(isset($_POST['bProses'])){
		$xpol=$this->input->post('pintumasuk');
		$pol=explode("|",$xpol);
		$this->data['tglawal']=$this->input->post('tglawal');
		$this->data['tglakhir']=$this->input->post('tglakhir');
		$this->data['idpintumasuk']=$pol[0];
		$this->data['poliklinik']=$pol[1];
		
		$this->data['dtregist']=$this->rajal_model->getDataRegistrasi($this->data['tglawal'],$this->data['tglakhir'],$this->data['idpintumasuk']);
		}
		
		$this->load->view('rajal/pasien_registrasi', $this->data);
	}
	
	function simpanUpdateKamar()
	{
		//print_r($_POST);exit();
		$idK=$this->input->post('idkamar');
		
		$update=array(
			'Kapasitas'=>$this->input->post('kapasitas'),
			'terisi'=>$this->input->post('terisi'),
			'Kelas'=>$this->input->post('kelas'),
			'petugas'=>$this->session->userdata('nik'),
			'tgl_update'=> date('Y-m-d H:i:s',time()),			
		);
		//print_r($update);
		//echo $idK;
		$que=$this->ranap_model->saveUpdateKamar($update, $idK);
		if($que){
			$this->session->set_flashdata('pesan', 'Update Berhasil Disimpan');
			
		}else{
			$this->session->set_flashdata('eror', 'Update Gagal dilakukan');	
			
		}
		
			redirect(base_url('kelola-kamar.html')); 
		
	}
}
