<?php 

class Grafik extends CI_Controller{

	function __construct(){
		parent::__construct();
		$this->load->model('m_kontak');/* sesuaikan dengan nama file pada model */
		$this->load->model('m_login'); 
		$this->load->model('m_admin'); 
		$this->load->model('m_barang'); 
		$this->load->model('m_grafik'); 
		$this->load->library('session');
 		$this->load->helper(array('form', 'url','tanggal'));
		if($this->session->userdata('status') != "loginbro"  and empty($this->session->userdata('email')) ){
			$this->session->set_flashdata('msg','<div class="alert alert-danger alert-dismissible">
						<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
						<strong> Admin Bukan Admin </strong>Ulangi Kembali
						</div> ');

			redirect(base_url("")); 
			
		}
	 
	}

	 
	function index(){		
		$username = $this->session->userdata("username");  
		$this->db->where('username',$username);
		$query = $this->db->get('tb_admin');
		$row = $query->row();
		$data['id_admin']= $row->id;
		$data['nama_admin']= $row->nama_admin;
		$data['id_kantor']= $row->id_kantor;
		$id_admin = $row->id;
		$level = $row->level;
		$id_kantor = $row->id_kantor;
		
		$data['barang_expired'] = $this->m_barang->barang_expired($id_admin,$id_kantor,$level); 
		$data['barang_terjual'] = $this->m_barang->data_barang_jual($id_admin,$id_kantor,$level);

		$data['kontak'] = $this->m_kontak->kontak();
		$data['admin'] = $this->m_admin->data_admin(); 
		$data['admin_login'] = $this->m_admin->data_admin_login(); 
		
		$data['grafik_bulan']=$this->m_grafik->grafik_bulan();
		$data['grafik_tahun']=$this->m_grafik->grafik_tahun();
		$data['graphik'] = $this->m_grafik->graph();
		$data['graphik2'] = $this->m_grafik->graph2(); 
		$this->load->view('master/header',$data); 
		$this->load->view('master/grafik',$data);
		$this->load->view('master/footer',$data); 
	}
	
	 
	 
}