<?php
class MDL_kurs extends CI_Model
{
	function __construct()
    {
     $CI =& get_instance(); 
	 $CI->db = $CI->load->database('default', TRUE);
	 $CI->db_pasi = $CI->load->database('pasi', TRUE);
	}

	function headerkurs($limit,$start,$sidx,$sord, $where){
		$this->db_pasi->select("
			[id]
			,[no_skep]
			,[startdate]
			,[enddate]
			,[create_date]
			,[create_by]
			,[update_date]
			,[update_by]
		");
		$this->db_pasi->from("[view_kurs_header]");
        $this->db_pasi->where($where);
        $this->db_pasi->limit($limit,$start);
        $this->db_pasi->order_by($sidx,$sord);
        $result = $this->db_pasi->get()->result(); 
        //die($this->db_pasi->last_query());
        return $result;
	
	}
	function headerkurs_CountAll($where){
		$this->db_pasi->select("*");
        $this->db_pasi->from("[view_kurs_header]");
        $this->db_pasi->where($where);
        $result = $this->db_pasi->count_all_results(); 
        return $result;
	}	
	
	function detailkurs($limit,$start,$sidx,$sord, $where){
		$this->db_pasi->select("
			[id]
			,[currenciesid]
			,[headerid]
			,[no_skep]
			,[currenciescode]
			,[rate]
			,[startdate]
			,[enddate]
			,[create_date]
			,[create_by]
			,[update_date]
			,[update_by]
		");
		$this->db_pasi->from("[view_kurs_detail]");
        $this->db_pasi->where($where);
        $this->db_pasi->limit($limit,$start);
        $this->db_pasi->order_by($sidx,$sord);
        $result = $this->db_pasi->get()->result(); 
        //die($this->db_pasi->last_query());
        return $result;
	
	}
	
	function detailkurs_CountAll($where){
		$this->db_pasi->select("*");
        $this->db_pasi->from("[view_kurs_detail]");
        $this->db_pasi->where($where);
        $result = $this->db_pasi->count_all_results(); 
        return $result;
	}	
	
	function masterkurs(){
		$this->db_pasi->select("
			[id]
			,[currenciescode]
			
		");
		$this->db_pasi->from("[dt_currencies_master]");
        $this->db_pasi->order_by('currenciescode asc');
        $result = $this->db_pasi->get()->result(); 
        //die($this->db_pasi->last_query());
        return $result;
	
	}
}
	
