<?php
/*
Fungsi : Model untuk modul admin
*/
class List_ba_model extends CI_Model {

	function List_ba_model()
	{
		parent::__construct();
		$this->default2 = $this->load->database('default2', TRUE);
	}

	function viewBA($limit, $offset, $search)
	{
		$this->db->where('status !=', '');
		if(!empty($search))
		{
			$this->db->like('idba', $search);
		}
		$this->db->order_by('idqa','DESC');
		$this->db->limit($limit, $offset);
  		return $this->db->get('t_qa');
	}

	function countBA($search)
	{	
		$this->db->where('status !=', '');
		if(!empty($search))
		{
			$this->db->like('idba', $search);
		}
		$this->db->order_by('idqa','DESC');
		return $this->db->count_all_results('t_qa');
	}

	function viewBAok($limit, $offset, $search)
	{
		$this->db->where('status', 'DITERIMA');
		if(!empty($search))
		{
			$this->db->like('idba', $search);
		}
		$this->db->order_by('idqa','DESC');
		$this->db->limit($limit, $offset);
  		return $this->db->get('t_qa');
	}

	function countBAok($search)
	{	
		$this->db->where('status', 'DITERIMA');
		if(!empty($search))
		{
			$this->db->like('idba', $search);
		}
		$this->db->order_by('idqa','DESC');
		return $this->db->count_all_results('t_qa');
	}

	function viewBAtolak($limit, $offset, $search)
	{
		$this->db->where('status', 'DITOLAK');
		if(!empty($search))
		{
			$this->db->like('idba', $search);
		}
		$this->db->order_by('idqa','DESC');
		$this->db->limit($limit, $offset);
  		return $this->db->get('t_qa');
	}

	function countBAtolak($search)
	{	
		$this->db->where('status', 'DITOLAK');
		if(!empty($search))
		{
			$this->db->like('idba', $search);
		}
		$this->db->order_by('idqa','DESC');
		return $this->db->count_all_results('t_qa');
	}

	function viewAllBATolak()
	{
		$this->db->where('status', 'DITOLAK');
		$this->db->order_by('idba','DESC');
  		return $this->db->get('t_qa');	
	}

	function viewBATolakWithRange($awal, $akhir)
	{
		$this->db->where('status', 'DITOLAK');
		$this->db->where('adddate >=', $awal);
		$this->db->where('adddate <=', $akhir);
		$this->db->order_by('idba','DESC');
  		return $this->db->get('t_qa');
	}

	function viewBAOkWithRange($awal, $akhir)
	{
		$this->db->where('status', 'DITERIMA');
		$this->db->where('adddate >=', $awal);
		$this->db->where('adddate <=', $akhir);
		$this->db->order_by('idba','DESC');
  		return $this->db->get('t_qa');
	}
}