caipin 5 years ago
parent
commit
c60e690202
1 changed files with 26 additions and 16 deletions
  1. 26 16
      protected/model/invoiceReceivables.php

+ 26 - 16
protected/model/invoiceReceivables.php

@@ -538,18 +538,18 @@ class invoiceReceivables extends DooModel {
 		}
 		
 		$sql='select * from '.$this->_table.' as a '.$con.' ORDER BY '.$descField.' '.$desc.' limit '.$limit;
-		
-		
 		$query = Doo::db ()->query ( $sql );
 		$list = $query->fetchAll ();
-		$iidList=array();
-		$iidString='';
+		
+		//获得收款关联的发票数据
+		$iidList=array();$iidString='';
 		foreach ($list as $key=>$value){
 			array_push($iidList, $value['iid'].$value['iidExtend']);
 		}
-		$iidString=array_unique(implode(',', $iidList));
-		echo $iidString;
-		//print_r($list);
+		$iidString=implode(',', $iidList);
+		$sql='select invoiceSerial,iid,irid from cld_invoice where iid in ('.$iidString.') ';
+		$query = Doo::db ()->query ( $sql );
+		$invoiceList = $query->fetchAll ();
 		
 		Doo::loadClass ( 'XDeode' );
 		$XDeode = new XDeode ( 5 );
@@ -557,21 +557,31 @@ class invoiceReceivables extends DooModel {
 		$invoiceROLog = new invoiceROLog ();
 		
 		foreach ( $list as $key => $value ) {
+			$tem=array();
+			foreach ($invoiceList as $ilK=>$ilv){
+				if($value['irid']==$ilv['irid']){
+					
+					$tem[$ilv['iid']]=$ilv['invoiceSerial'];
+					
+					unset($invoiceList[$ilk]);
+				}
+			}
+			$list [$key] ['invoiceList']=$tem;
 			
 			$invoiceSerial = explode ( ',', $value ['invoiceSerial'] );
 			$invoiceId = explode ( ",", $value ['invoiceId'] );
 			
 			
 			
-			if (empty ( $invoiceSerial [0] ))
-				$list [$key] ['invoiceList'] = array ();
-			else {
-				foreach ( $invoiceId as $k => $v ) {
-					if (! empty ( $v ))
-						$invoiceId [$k] = $XDeode->encode ( $v );
-				}
-				$list [$key] ['invoiceList'] = array_combine ( $invoiceId, $invoiceSerial );
-			}
+// 			if (empty ( $invoiceSerial [0] ))
+// 				$list [$key] ['invoiceList'] = array ();
+// 			else {
+// 				foreach ( $invoiceId as $k => $v ) {
+// 					if (! empty ( $v ))
+// 						$invoiceId [$k] = $XDeode->encode ( $v );
+// 				}
+// 				$list [$key] ['invoiceList'] = array_combine ( $invoiceId, $invoiceSerial );
+// 			}