caipin 5 gadi atpakaļ
vecāks
revīzija
ae51c6a4d4

+ 61 - 4
protected/class/receipt.func.php

@@ -1720,10 +1720,14 @@ function cellColor($cells,$color,$obj){
 /**
  * 导出办事处全年汇中明细execl
  */
-function excelRCData($summaryData,$aiAllList,$year){
+function excelRCData($summaryData,$aiAllList,$cglist,$year){
 	Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
 	$obj = new PHPExcel ();
 	
+	//总行数计算
+	$onRow=4;
+	$maxRow=(count($cglist)*14)+1+$onRow;
+	
 	//表头计算
 	$cellCount=0;$sectionCount=array();$last=8;
 	foreach ($aiAllList as $key=>$value){
@@ -1733,7 +1737,7 @@ function excelRCData($summaryData,$aiAllList,$year){
 		$sectionCount[$key]=array($last,count($value)+1+$last-1);
 		$last=count($value)+1+$last;
 	}
-	$cellCount=$cellCount+7+count($aiAllList);
+	$cellCount=$cellCount+7;
 	//print_r($sectionCount);
 	//设置宽高
 	$colNum=1;$maxCol='ZZ';
@@ -1772,14 +1776,13 @@ function excelRCData($summaryData,$aiAllList,$year){
 					'allborders' => array( //设置全部边框
 							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
 					),),);
-	$obj->getActiveSheet()->getStyle( 'A1:'.$maxCol.'3')->applyFromArray($styleThinBlackBorderOutline);
+	$obj->getActiveSheet()->getStyle( 'A1:'.$maxCol.$maxRow)->applyFromArray($styleThinBlackBorderOutline);
 	
 	//设置合并单元格
 	$obj->getActiveSheet()->mergeCells('A1:A3');
 	$obj->getActiveSheet()->mergeCells('B1:G2');
 	$obj->getActiveSheet()->mergeCells('H1:'.$maxCol.'1');
 	
-	
 	//表头内容
 	$obj->getactivesheet()->setCellValue ( 'A1','费用项' );
 	$obj->getactivesheet()->setCellValue ( 'B1','收入' );
@@ -1809,6 +1812,60 @@ function excelRCData($summaryData,$aiAllList,$year){
 		}
 	}
 	
+	//数据填充
+	foreach ($cglist as $cgk=>$value){
+		for($month=1;$month<=12;$month++){			
+			$obj->getactivesheet()->setCellValue ( 'A'.$onRow,$value['title'].$month.'月合计' );
+			$col='H';
+			if(isset($dataSummary[$value['cid']])){
+				foreach ($aiAllList as $aiak=>$aiav){//总项目
+					
+					$obj->getactivesheet()->setCellValue ( 'A'.$onRow,$value['title'].$month.'月合计' );
+					
+					//$sectionCount[$aiak]['1'].$onRow
+					
+					$obj->getactivesheet()->setCellValue( $col.$onRow, '=SUM('.$sectionCount[$aiak]['0'].$onRow.':'.$sectionCount[$aiak]['0'].$onRow.')' );//公式
+					$col++;
+					foreach ($aiav as $k=>$v){//项目细则
+						foreach ($summaryData[$value['cid']][$month][$aiak] as $dsk=>$dsv){//数据实体
+							if($dsv['item']==$v['name']){
+								$obj->getactivesheet()->setCellValue ( $col.$onRow,$dsv['price']);
+								break;
+							}
+						}
+						
+						$col++;
+					}
+// 					$col++;
+					
+					
+// 					$yearPriceArray[$value['cid']][$aiak]+=$tempPrice;
+					
+// 					$itemHtml.='<td class="taR colRed">'.$tempPrice.'</td>';//每个月份 项目金额合计
+// 					$itemHtml.=$tempHtml;//每个月份项目细则金额
+					
+					
+					
+					
+					
+				}
+			}
+			
+			$onRow++;
+		}
+	}
+	
+	
+	/* foreach ($aiAllList as $key=>$value){
+		//栏目细则个数
+		$obj->getactivesheet()->setCellValue ( 'A1','费用项' );
+		$obj->getactivesheet()->setCellValue ( 'B1','收入' );
+		$obj->getactivesheet()->setCellValue ( 'B3','利润' );
+		$obj->getactivesheet()->setCellValue ( 'C3','利润占比' );
+		$obj->getactivesheet()->setCellValue ( 'D3','收入合计' );
+	} */
+	
+	
 // 	echo (int)($cellCount/26).'</br>';
 // 	echo ($cellCount%26).'</br>';
 	

+ 5 - 2
protected/controller/ReceiptExtendController.php

@@ -2768,19 +2768,22 @@ class ReceiptExtendController extends DooController {
     function exportReceiptSummaryExcel(){
     	$summaryData= $this->get_args ( 'summaryData' ) ? $this->get_args ( 'summaryData' ) : "";
     	$year= $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
+    	$cidIn = $this->get_args ( 'cidIn' ) ? $this->get_args ( 'cidIn' ) : '12,10,9';
     	
     	if(!empty($summaryData)){
     		
     		Doo::loadModel ( 'accountItem' );
     		$accountItem = new accountItem ();
+    		Doo::loadModel ( 'L_category' );
+    		$category = new L_category ();
     		
     		$aiAllList=$accountItem->getAccountItem();
-    		
+    		$cglist=$category->getCategoryInCid($cidIn);
     		
     		$summaryData=json_decode(urldecode($summaryData), true);
     		Doo::loadClass ( 'receipt.func' );
     		
-    		excelRCData($summaryData,$aiAllList,$year);
+    		excelRCData($summaryData,$aiAllList,$cglist,$year);
     	}
     	
     	die ( 'illegal request--excel Data null' );