<?php

Doo::loadCore('db/DooModel');

class receipt extends DooModel {

    public $rid;
    public $accountItem;
    
    public $loanItem;
    
    public $staff;
    
    public $sum;
    public $date;
    public $pastDate;
    public $executeDate;
    public $loanDate;
    
    
    public $cid;
    public $status;
    public $Rtype;
    public $isBK;
    
    public $loanSum;
    public $loanRid;
    
    public $reviseDetail;
    public $revisePrice;
    public $receiptOrder;
    public $verify;
   	public $verifyStaff;
   	
   	public $executeCopy;
   	public $executeStaff;
   	
   	public $verifyBreakup;
   	
   	public $nowStaff;
   	
    public $explanation;
    public $implementOpinions;
    public $notice;
    public $amount;
    
    public $_table = 'CLD_receipt';
    public $_primarykey = 'rid';
    
    public $_fields = array('aid', 'accountItem', 'staff', 'sum', 'date','pastDate' ,'cid', 'status', 'reviseDetail', 'revisePrice', 'verify','verifyStaff',
    'nowStaff','receiptOrder','explanation','notice','Rtype','loanItem','loanRid','loanSum','implementOpinions','isBK','executeCopy','executeStaff','verifyBreakup','executeDate'
    		,'amount','loanDate');

	function receiptByYear($dateCondition,$sid){
    	//
    	$sql = "select sum(sum) as sum from " . $this->_table . " where staff= '".$sid."' ".$dateCondition." and status=2 ";
    	//echo '<div style="display:none">'.$sql.'</div>';
    	$query = Doo::db ()->query ( $sql );
		$result = $query->fetch ();
		
		return $result;
    }
    
    /*
    function getClientByCid($cid){
    	$sql = "select * from " . $this->_table . " as a left join CLD_staff as b on (a.sid=b.sid)  where a.cid= '".$cid."' " ;
		
    	$query = Doo::db ()->query ( $sql );
		
		$result = $query->fetch ();
		
		return $result;
    }
    
    public function getProjectByIdList($projectid){
    	return $this->find ( array ('where' => "pid= '".$projectid."'", 'asArray' => TRUE ) );
    }
    */
}

?>