<?php
class finance_model extends CI_Model {
public function add_finance($data){
	$this->db->insert('finance', $data);
 }
public function get_finance($uid){
	$this->db->where("uid",$uid);
	$result = $this->db->get('finance');
    return $result->result();
}
public function get_finance_bdate($uid,$sdate,$edate){
	$this->db->where("uid",$uid);
	$this->db->where('submit_date >=', $sdate);
	$this->db->where('submit_date <=', $edate);
	$result = $this->db->get('finance');
    return $result->result();
}
public function search_finance($uid,$name){
	$this->db->where("uid",$uid);
	$this->db->like('client_name', $name);
	$result = $this->db->get('finance');
    return $result->result();
}
public function set_finance_main($data){
	$this->db->insert('finance_main', $data);
}
public function get_finance_main($uid,$date="null"){
	$this->db->where("uid",$uid);
	if($date != "null"){
	$this->db->where("date",$date);	
	}
	$result = $this->db->get('finance_main');
    return $result->result();	
}
public function get_shokra_bazaryab($type){
	$this->db->where("type",$type);
	$result = $this->db->get('shuraka_bazayab_data');
	return $result->result();	
}
public function get_bazaryab_byid($id){
	$this->db->where("id",$id);
	$result = $this->db->get('shuraka_bazayab_data');
	return $result->result();	
}
public function add_shokra_bazaryab($data){
	$this->db->insert('shuraka_bazayab_data', $data);
}
public function clear_shokra_bazaryab($type){
	$this->db->where("type",$type);
	$this->db->delete('shuraka_bazayab_data');
}
public function get_finance_byname($uid,$name){
	$this->db->where("uid",$uid);
	$this->db->where("client_name",$name);
	$result = $this->db->get('finance');
	return $result->result();	
}
public function get_khadamat($uid){
	$this->db->where("uid",$uid);
	$result = $this->db->get('khdamat');
	return $result->result();	
}
public function set_khadamat($data){
	$this->db->insert('khdamat', $data);
}
public function delete_khadamat($uid){
	$this->db->where("uid",$uid);
	$this->db->delete('khdamat');
}
}
?>