 <?php
 class CekData {

public static function dateNow(){
	return date("Y-m-d h:i:sa");
}

public static function nisn($nisn,$table)
{
		$cd = get_instance();
	

	 // cek dari table register
        $cek = $cd->db->get_where($table, ['nisn' => $nisn])->num_rows();
		if($cek >0){
			 return true;
		}else{
			 return false;
		}
       
}

	public static function cekEmail($email){
		$cd = get_instance();


        $cek = $cd->db->get_where('register', ['email' => trim($email)])->num_rows();

		 $cek = $cd->db->get_where('register', ['email' => trim($email)])->num_rows();

		 if($cek >0){
			 return true;
		}else{
			 return false;
		}
		
	}

	// cekdataOr
	public static function cekDataOr(string $table,array $kondisi){
		$cd = get_instance();
		 $cd->db->select('*');
		 $cd->db->from($table);
		 $cd->db->or_where($kondisi);
		$hasil= $cd->db->get()->num_rows();
		if($hasil > 0){
			 return true;
		}else{
			 return false;
		}
	}

	public static function tanggalIndo($tanggal){
		 
			$bulan = array (
			1 =>   'Januari',
			'Februari',
			'Maret',
			'April',
			'Mei',
			'Juni',
			'Juli',
			'Agustus',
			'September',
			'Oktober',
			'November',
			'Desember'
			);
			
			$pecahkan = explode('-', $tanggal);
		
			
			// variabel pecahkan 0 = tahun
			// variabel pecahkan 1 = bulan
			// variabel pecahkan 2 = tanggal
	 
			return $pecahkan[2] . ' ' . $bulan[ (int)$pecahkan[1] ] . ' ' . $pecahkan[0];
		}
	



	// cekUpdate data
	public static function cekUpdateData($table,array $condisi){
		$cd = get_instance();

		$cek = $cd->db->get_where($table, $condisi)->num_rows();

		if($cek > 0){
			 return true;
		}
		else{
			 return false;
		}
	}

	public static function getData(String $table, array $condisi){
		$cd = get_instance();
		return $cd->db->get_where($table, $condisi)->row_array();
	}

	public static function getInfoJalur($id_jalur){
		$cd = get_instance();
		return $cd->db->get_where('jalur_ppdb',['id'=>$id_jalur])->row_array();
	}
 }
