<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of accountmodel
 *
 * @author BusyMan
 */
class CommissionReferenceModel extends CI_Model {

    //put your code here
    private $_tbl_CR = 'tbl_commissionreference';
    public function saveCommission_ReferenceInfo($data) {
        $data['date']=date('Y-m-d',strtotime($data['date']));
        $this->db->insert($this->_tbl_CR, $data);
        return $this->db->insert_id();
    }

    public function getCommissionReference(){
    	$query=$this->db->get($this->_tbl_CR);
    	$result=$query->result_array();
    	if(!empty($result)){
    		return $result;
    	}
    }

    public function getCommissionReferenceInfoByid($id){
    	$query=$this->db->get_where($this->_tbl_CR,array('id'=>$id));
    	$result=$query->row_array();
    	if(!empty($result)){
    		return $result;
    	}
    }

    public function delete_commissionreference($id){
    	$query=$this->db->delete($this->_tbl_CR,array('id'=>$id));
    	return $this->db->affected_rows();
    }

    public function updateCommissionReference($data,$id)
    {
    	$data['date']=date('Y-m-d',strtotime($data['date']));
    	//print_r($data);die();
    	$query=$this->db->update($this->_tbl_CR,$data,array('id'=>$id));
    	return $this->db->affected_rows();
    }

}