<?php
	class Inform_model extends CI_Model {
		
		function __construct()
		{
			parent::__construct();
			
			// DETERMINE DB
			$this->dbhost=$this->load->database('khanza', TRUE);
			//$this->nm_db = array('1' => 'jobs', 'db_hro', '');
			//$this->user_admin = 'user_admin';
		}	
		
		public function getSettingPerusahaan()
		{			
			$q=$this->dbhost->get_where('setting', array('aktifkan' => 'Yes'));
			//return $q->result();
			if($q->num_rows() > 0)
			{
				foreach($q->result() as $i)
				{
					$h[] = $i;
				}
				return $h;
			}
		}
		
		function get_grupuser($nip)
        {
            $this->db->select('id_grup');
            $q = $this->db->get_where('grup_user', array('nik' => $nip));
            if($q->num_rows() > 0)
			{
				foreach($q->result() as $i)
				{
					$h[] = $i->id_grup;
				}
				
			}else{
				$h[]='0';
			}
			
			return $h;
        }
		
		function getQtyXByDokterNow($dokterid)
		{
			$tglnow= date('Y-m-d',time());
			$q=$this->dbhost
				->select('b.`nm_dokter`,a.`kd_dokter`, a.`tgl_registrasi`,c.`kd_poli`,c.`nm_poli`, COUNT(a.`no_rawat`) AS jml_x')
				->from('`reg_periksa` AS a')
				->join('dokter AS b','a.`kd_dokter`=b.`kd_dokter`','left')
				->join('poliklinik AS c','a.`kd_poli`=c.`kd_poli`','left')
				->where('a.`kd_dokter`',$dokterid)
				->where('a.`tgl_registrasi`',$tglnow)
				//->where('b.`ID` <>','125')
				->group_by('a.`kd_dokter`, a.`kd_poli`')
				->get();
				
			return $q->result();
		} 
		
		function getDokter()
		{
			$q=$this->dbhost->get_where('dokter', array('status' => '1'));
			
			return $q->result();
		}
	}
