<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Laporan extends CI_Controller {

	function __construct(){
		parent::__construct();
			$this->load->library('session');
			$this->load->library('form_validation');
			$this->load->model('m_laporan');		
			if($this->session->userdata('username') =='' OR $this->session->userdata('token') !=md5('100%Madiun'.date('Ymd')) ){
				redirect(base_url("login"));
			}			
	}
	public function index()
	{	
	$data['alert']='';
	$data['pesan']='';
	$this->load->view('admin/laporan', $data);			
	}
	function tampillaporan()
	{
	if(isset($_POST['button'])){
	$status=$this->security->xss_clean($this->input->post('status'));	
	$bln=$this->security->xss_clean($this->input->post('bln'));	
	$thn=$this->security->xss_clean($this->input->post('thn'));
	if($status == 0 OR $status == 2 OR $status == 3){
	$data['tampil'] = $this->m_laporan->tampillaporan($status, $bln, $thn);
	}
	if($status == 3){
	$data['tampil'] = $this->m_laporan->tampillaporanLunas($status, $bln, $thn);
	}		
	if($status == 4){
	$data['tampil'] = $this->m_laporan->tampillaporanBelumLunas($status, $bln, $thn);
	}
	if($status == 5){
	$data['tampil'] = $this->m_laporan->tampillaporanLunasAll($status, $bln, $thn);
	}	
	if($status == 6){
	$data['tampil'] = $this->m_laporan->tampillaporanBelumLunasAll($status, $bln, $thn);
	}		
	$data['alert']='';
	$data['status_det']=$status;
	$data['bulan']=$bln;
	$data['thn']=$thn;

	$this->load->view('admin/laporanstatus', $data);
	}	
	}	

	function tampillaporan2()
	{
	if(isset($_POST['button'])){
	$status=$this->security->xss_clean($this->input->post('status'));	
	$bln1=$this->security->xss_clean($this->input->post('bln1'));	
	$bln2=$this->security->xss_clean($this->input->post('bln2'));	
	$thn=$this->security->xss_clean($this->input->post('thn'));

	if($status == 3){
	$data['tampil'] = $this->m_laporan->tampillaporanLunasSampai($status, $bln1, $bln2, $thn);
	}		
	if($status == 4){
	$data['tampil'] = $this->m_laporan->tampillaporanBelumLunasSampai($status, $bln1, $bln2, $thn);
	}	
	$data['alert']='';
	$data['status_det']=$status;
	$data['bulan']=$bln;
	$data['thn']=$thn;

	$this->load->view('admin/laporanstatus', $data);
	}	
	}	
	
	function grafik()
	{
	if(isset($_POST['button'])){
	$thn=$this->security->xss_clean($this->input->post('thn'));		
	$data['fasilitas'] = $this->m_laporan->fasilitas();	
	$data['thn'] = $thn;
	$data['alert']='';
	$data['pesan']='';
	$this->load->view('admin/laporangrafik', $data);
	}	
	}	
}