|  | @@ -193,6 +193,9 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	public $printTime;
 | 
	
		
			
				|  |  |  	public $postTime;
 | 
	
		
			
				|  |  | +	public $settlementType;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  	public $_table = 'CLD_invoice';
 | 
	
		
			
				|  |  |  	public $_primarykey = 'iid';
 | 
	
		
			
				|  |  |  	public $_fields = array (
 | 
	
	
		
			
				|  | @@ -251,7 +254,8 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  			'updateTime',
 | 
	
		
			
				|  |  |  			'printTime',
 | 
	
		
			
				|  |  |  			'postTime',
 | 
	
		
			
				|  |  | -			'bindTime' 
 | 
	
		
			
				|  |  | +			'bindTime',
 | 
	
		
			
				|  |  | +			'settlementType' 
 | 
	
		
			
				|  |  |  	);
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * 根据发票ID获取一条发票数据
 | 
	
	
		
			
				|  | @@ -403,11 +407,18 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$detail ['expressCompany'] = '';
 | 
	
		
			
				|  |  |  		$detail ['expressCom'] = '';
 | 
	
		
			
				|  |  | +		$detail ['invoiceTraining'] = array ();
 | 
	
		
			
				|  |  |  		if (! empty ( $detail ['expressCompany'] )) {
 | 
	
		
			
				|  |  |  			$express = explode ( ":", $detail ['expressCompany'] );
 | 
	
		
			
				|  |  |  			$detail ['expressCompany'] = $express [0];
 | 
	
		
			
				|  |  |  			$detail ['expressCom'] = $express [1];
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | +		// 培训班
 | 
	
		
			
				|  |  | +		if ($detail ['settlementType'] == 1) {
 | 
	
		
			
				|  |  | +			Doo::loadModel ( 'invoiceTraining' );
 | 
	
		
			
				|  |  | +			$invoiceTraining = new invoiceTraining ();
 | 
	
		
			
				|  |  | +			$detail ['invoiceTraining'] = $invoiceTraining->getInvoiceTrainingByItid ( $detail ['trainId'] );
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$detail ['iidKeyXD'] = $this->authcode ( $detail ['iid'], '' );
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -433,13 +444,12 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  		$query = Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  |  		return $result = $query->fetchAll ();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	function getInvoiceByTrainingCount($itid=0){
 | 
	
		
			
				|  |  | -		if (empty($itid))
 | 
	
		
			
				|  |  | +	function getInvoiceByTrainingCount($itid = 0) {
 | 
	
		
			
				|  |  | +		if (empty ( $itid ))
 | 
	
		
			
				|  |  |  			return 0;
 | 
	
		
			
				|  |  |  		$detail = $this->count ( array (
 | 
	
		
			
				|  |  |  				'where' => "trainId= '" . $itid . "' and untreadStatus!=2", // and sid=".$sid,
 | 
	
		
			
				|  |  | -				'asArray' => TRUE
 | 
	
		
			
				|  |  | +				'asArray' => TRUE 
 | 
	
		
			
				|  |  |  		) );
 | 
	
		
			
				|  |  |  		return $detail;
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -557,7 +567,7 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  			$list = $this->find ( array (
 | 
	
		
			
				|  |  |  					'where' => "status=2 and printStatus=" . $status . " and untreadStatus=0 and moldManage like '%[\"" . $sid . "\",%'",
 | 
	
		
			
				|  |  |  					'desc' => 'approvalTime',
 | 
	
		
			
				|  |  | -					'limit'=>10,
 | 
	
		
			
				|  |  | +					'limit' => 10,
 | 
	
		
			
				|  |  |  					'asArray' => TRUE 
 | 
	
		
			
				|  |  |  			) );
 | 
	
		
			
				|  |  |  		elseif (! empty ( $sid ) && ! empty ( $iid ))
 | 
	
	
		
			
				|  | @@ -672,7 +682,7 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  	 * @param integer $postStatus 0为获取需要邮寄的发票,1为获取已经邮寄的发票
 | 
	
		
			
				|  |  |  	 * @return array|array() 返回相关数据
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  | -	public function getPostByInvoice($postStatus = 0,$desc="desc") {
 | 
	
		
			
				|  |  | +	public function getPostByInvoice($postStatus = 0, $desc = "desc") {
 | 
	
		
			
				|  |  |  		Doo::loadClass ( 'XDeode' );
 | 
	
		
			
				|  |  |  		$XDeode = new XDeode ( 5 );
 | 
	
		
			
				|  |  |  		$list = $this->find ( array ( // and untreadStatus=0
 | 
	
	
		
			
				|  | @@ -706,7 +716,7 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  		if (empty ( $iid )) {
 | 
	
		
			
				|  |  |  			$list = $this->find ( array ( // printStatus=1 and
 | 
	
		
			
				|  |  |  					'where' => " untreadStatus=" . $untreadStatus . " and status=2 ",
 | 
	
		
			
				|  |  | -					'limit'=>10,
 | 
	
		
			
				|  |  | +					'limit' => 10,
 | 
	
		
			
				|  |  |  					'asArray' => TRUE 
 | 
	
		
			
				|  |  |  			) );
 | 
	
		
			
				|  |  |  			
 | 
	
	
		
			
				|  | @@ -785,7 +795,7 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  				'limit' => $limit,
 | 
	
		
			
				|  |  |  				$desc => 'approvalTime',
 | 
	
		
			
				|  |  |  				'asArray' => TRUE 
 | 
	
		
			
				|  |  | -		) );//echo $con;
 | 
	
		
			
				|  |  | +		) ); // echo $con;
 | 
	
		
			
				|  |  |  		Doo::loadClass ( 'XDeode' );
 | 
	
		
			
				|  |  |  		$XDeode = new XDeode ( 5 );
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceReceivables' );
 | 
	
	
		
			
				|  | @@ -820,9 +830,9 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  			$list [$key] ['sumPrice'] = 0;
 | 
	
		
			
				|  |  |  			if (! empty ( $list [$key] ['irList'] ))
 | 
	
		
			
				|  |  |  				$list [$key] ['sumPrice'] = $list [$key] ['irList'] [0] ['sumPrice'];
 | 
	
		
			
				|  |  | -				$list [$key] ['diffPrice'] = $list [$key]['invoicePrice'];
 | 
	
		
			
				|  |  | -				if(!empty($list [$key] ['irList'] [0] ['sumPrice']))
 | 
	
		
			
				|  |  | -					$list [$key] ['diffPrice'] = $list [$key]['invoicePrice']-$list [$key] ['irList'] [0] ['sumPrice'];
 | 
	
		
			
				|  |  | +			$list [$key] ['diffPrice'] = $list [$key] ['invoicePrice'];
 | 
	
		
			
				|  |  | +			if (! empty ( $list [$key] ['irList'] [0] ['sumPrice'] ))
 | 
	
		
			
				|  |  | +				$list [$key] ['diffPrice'] = $list [$key] ['invoicePrice'] - $list [$key] ['irList'] [0] ['sumPrice'];
 | 
	
		
			
				|  |  |  				// $list [$key] ['operationLog'] = $invoiceOperationLog->getInvoiceOperationLogByIid ( $value ['iid'], 'desc' );
 | 
	
		
			
				|  |  |  			$list [$key] ['lossDetail'] = array ();
 | 
	
		
			
				|  |  |  			if ($value ['lossIid'] != 0) {
 | 
	
	
		
			
				|  | @@ -847,38 +857,41 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  	 * 公司应收款汇总
 | 
	
		
			
				|  |  |  	 * @param unknown $con
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  | -	function getInvoiceCompanyStatistics($con=''){
 | 
	
		
			
				|  |  | -		if(empty($con))
 | 
	
		
			
				|  |  | -			return array();
 | 
	
		
			
				|  |  | +	function getInvoiceCompanyStatistics($con = '') {
 | 
	
		
			
				|  |  | +		if (empty ( $con ))
 | 
	
		
			
				|  |  | +			return array ();
 | 
	
		
			
				|  |  |  		$sql = 'select  invoicePrice,iid 
 | 
	
		
			
				|  |  |  				from ' . $this->_table . '
 | 
	
		
			
				|  |  | -						where '.$con.'
 | 
	
		
			
				|  |  | +						where ' . $con . '
 | 
	
		
			
				|  |  |  						 ';
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  |  		$query = Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  |  		$result = $query->fetchAll ();
 | 
	
		
			
				|  |  | -		$iidlist=array();
 | 
	
		
			
				|  |  | -		$invoicePrice=0;
 | 
	
		
			
				|  |  | -		foreach ($result as $value){
 | 
	
		
			
				|  |  | -			array_push($iidlist, $value['iid']);
 | 
	
		
			
				|  |  | -			$invoicePrice+=$value['invoicePrice'];
 | 
	
		
			
				|  |  | +		$iidlist = array ();
 | 
	
		
			
				|  |  | +		$invoicePrice = 0;
 | 
	
		
			
				|  |  | +		foreach ( $result as $value ) {
 | 
	
		
			
				|  |  | +			array_push ( $iidlist, $value ['iid'] );
 | 
	
		
			
				|  |  | +			$invoicePrice += $value ['invoicePrice'];
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		$iidString=implode(',', $iidlist);
 | 
	
		
			
				|  |  | +		$iidString = implode ( ',', $iidlist );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		//获得已收款发票
 | 
	
		
			
				|  |  | -		if (!empty($iidString)){
 | 
	
		
			
				|  |  | -		$sql = 'select sum(receivablesPrice) as receivablesPrice 
 | 
	
		
			
				|  |  | +		// 获得已收款发票
 | 
	
		
			
				|  |  | +		if (! empty ( $iidString )) {
 | 
	
		
			
				|  |  | +			$sql = 'select sum(receivablesPrice) as receivablesPrice 
 | 
	
		
			
				|  |  |  				from CLD_invoiceReceivables 
 | 
	
		
			
				|  |  |  				where iid in (' . $iidString . ')  and bindStatus=1
 | 
	
		
			
				|  |  |  				GROUP BY bindStatus';
 | 
	
		
			
				|  |  | -		$query = Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  | -		$result = $query->fetch ();
 | 
	
		
			
				|  |  | -		}else{
 | 
	
		
			
				|  |  | -			$result['receivablesPrice']=0;
 | 
	
		
			
				|  |  | +			$query = Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  | +			$result = $query->fetch ();
 | 
	
		
			
				|  |  | +		} else {
 | 
	
		
			
				|  |  | +			$result ['receivablesPrice'] = 0;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		return array('invoicePrice'=>$invoicePrice,'receivablesPrice'=>$result['receivablesPrice'],'diffPrice'=>$invoicePrice-$result['receivablesPrice']);
 | 
	
		
			
				|  |  | +		return array (
 | 
	
		
			
				|  |  | +				'invoicePrice' => $invoicePrice,
 | 
	
		
			
				|  |  | +				'receivablesPrice' => $result ['receivablesPrice'],
 | 
	
		
			
				|  |  | +				'diffPrice' => $invoicePrice - $result ['receivablesPrice'] 
 | 
	
		
			
				|  |  | +		);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/**
 | 
	
	
		
			
				|  | @@ -908,7 +921,7 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  				'asArray' => TRUE 
 | 
	
		
			
				|  |  |  		) );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		if ($recordCount==0)
 | 
	
		
			
				|  |  | +		if ($recordCount == 0)
 | 
	
		
			
				|  |  |  			return 0;
 | 
	
		
			
				|  |  |  		return $recordCount / $allCount;
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -918,32 +931,32 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	function getInvoiceScheduleByCidGroupSid($cid = 0) {
 | 
	
		
			
				|  |  |  		if (empty ( $cid ))
 | 
	
		
			
				|  |  | -			return array();
 | 
	
		
			
				|  |  | +			return array ();
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -		//完成发票
 | 
	
		
			
				|  |  | +			// 完成发票
 | 
	
		
			
				|  |  |  		$recordCount = $this->find ( array (
 | 
	
		
			
				|  |  | -				'select'=>'count(*) as count,sid',
 | 
	
		
			
				|  |  | +				'select' => 'count(*) as count,sid',
 | 
	
		
			
				|  |  |  				'where' => " status=2 and printStatus=1 and untreadStatus=3  and cid =" . $cid,
 | 
	
		
			
				|  |  | -				'groupby'=>'sid',
 | 
	
		
			
				|  |  | +				'groupby' => 'sid',
 | 
	
		
			
				|  |  |  				'asArray' => TRUE 
 | 
	
		
			
				|  |  |  		) );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		//当月创建的发票
 | 
	
		
			
				|  |  | +		// 当月创建的发票
 | 
	
		
			
				|  |  |  		$allCount = $this->find ( array (
 | 
	
		
			
				|  |  | -				'select'=>'count(*) as count,sid',
 | 
	
		
			
				|  |  | +				'select' => 'count(*) as count,sid',
 | 
	
		
			
				|  |  |  				'where' => " isDelete=0  and cid =" . $cid,
 | 
	
		
			
				|  |  | -				'groupby'=>'sid',
 | 
	
		
			
				|  |  | +				'groupby' => 'sid',
 | 
	
		
			
				|  |  |  				'asArray' => TRUE 
 | 
	
		
			
				|  |  |  		) );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$list=array();
 | 
	
		
			
				|  |  | -		foreach ($recordCount as $key=>$value){
 | 
	
		
			
				|  |  | -			foreach ($allCount as $k=>$v){
 | 
	
		
			
				|  |  | -				if ($value['sid']==$v['sid']){
 | 
	
		
			
				|  |  | -					if ($value['count']==0)
 | 
	
		
			
				|  |  | -						$list[$value['sid']]=0;
 | 
	
		
			
				|  |  | -					else 
 | 
	
		
			
				|  |  | -						$list[$value['sid']]=(int)(($value['count'] / $v['count'])*100);
 | 
	
		
			
				|  |  | +		$list = array ();
 | 
	
		
			
				|  |  | +		foreach ( $recordCount as $key => $value ) {
 | 
	
		
			
				|  |  | +			foreach ( $allCount as $k => $v ) {
 | 
	
		
			
				|  |  | +				if ($value ['sid'] == $v ['sid']) {
 | 
	
		
			
				|  |  | +					if ($value ['count'] == 0)
 | 
	
		
			
				|  |  | +						$list [$value ['sid']] = 0;
 | 
	
		
			
				|  |  | +					else
 | 
	
		
			
				|  |  | +						$list [$value ['sid']] = ( int ) (($value ['count'] / $v ['count']) * 100);
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -952,6 +965,21 @@ class invoice extends DooModel {
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  | +	 * 获得个人最新发票信息
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function getInvoiceByNew($sid = 0) {
 | 
	
		
			
				|  |  | +		if (empty ( $sid ))
 | 
	
		
			
				|  |  | +			return array ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$Detail = $this->getOne ( array (
 | 
	
		
			
				|  |  | +				'where' => "sid=" . $sid,
 | 
	
		
			
				|  |  | +				'desc' => 'iid',
 | 
	
		
			
				|  |  | +				'asArray' => TRUE 
 | 
	
		
			
				|  |  | +		) );
 | 
	
		
			
				|  |  | +		return $Detail;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  |  	 * 加密或解密指定字符串
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  |  	 * @param string $string 要加密或解密的字符串
 |