<?php
class M_laporan extends CI_Model{

		function tamuhariini(){
		$date = date('Y-m-d');
		$query = $this->db->query("SELECT * FROM tamu as a 		
															JOIN kategori as b ON b.idkategori = a.idkategori 
															JOIN bidang as c ON c.idbidang = b.idbidang 
                                                            WHERE DATE(a.tanggal) = '$date'
															ORDER BY  a.tanggal  DESC ");		
		$row = $query->row();
		return $cek = $query->num_rows();
		}

		function tamubulanini(){
		$date = date('m');
		$query = $this->db->query("SELECT * FROM tamu as a 		
															JOIN kategori as b ON b.idkategori = a.idkategori 
															JOIN bidang as c ON c.idbidang = b.idbidang 
                                                            WHERE MONTH(a.tanggal) = '$date'
															ORDER BY  a.tanggal  DESC ");		
		$row = $query->row();
		return $cek = $query->num_rows();
		}
 
		function tamutahunini(){
		$date = date('Y');
		$query = $this->db->query("SELECT * FROM tamu as a 		
															JOIN kategori as b ON b.idkategori = a.idkategori 
															JOIN bidang as c ON c.idbidang = b.idbidang 
                                                            WHERE YEAR(a.tanggal) = '$date'
															ORDER BY  a.tanggal  DESC ");		
		$row = $query->row();
		return $cek = $query->num_rows();
		} 

		function exportexcel($bulan, $tahun){
		//echo $bulan.$tahun;
		$query = $this->db->query("SELECT * 
										FROM tamu AS a 		
										JOIN kategori AS b ON b.idkategori = a.idkategori 
										JOIN bidang AS c ON c.idbidang = b.idbidang 
										WHERE YEAR(a.tanggal) = '$tahun' AND MONTH(a.tanggal) = '$bulan'
										ORDER BY a.tanggal ASC  ");		
		//$row = $query->row();
		return $query ;
		}
		
}