caipin vor 5 Jahren
Ursprung
Commit
01787b3bac

+ 762 - 40
protected/class/receipt.func.php

@@ -2,14 +2,14 @@
 /**
  * 获得借款单详情
  */
-function _getReceiptLoanHtml($receiptDetail,$verifylist,$extendHtml='') {
+function _getReceiptLoanHtml($receiptDetail, $verifylist, $extendHtml = '') {
 	$receiptDetail ['loanItem'] = json_decode ( $receiptDetail ['loanItem'], true );
 	$receiptDetail ['sumCN'] = num_to_rmb ( $receiptDetail ['sum'] );
 	$receiptDetail ['loanSumCN'] = num_to_rmb ( $receiptDetail ['loanSum'] );
 	$receiptDetail ['amountCN'] = num_to_rmb ( $receiptDetail ['amount'] );
 	
-	$executeCopy=getExecuteStaff($receiptDetail);
-	//print_r ( $executeCopy );
+	$executeCopy = getExecuteStaff ( $receiptDetail );
+	// print_r ( $executeCopy );
 	
 	$html = '<div class="saeaList">
 							<div class="entry loan-list" style="margin-bottom: 50px">
@@ -85,64 +85,64 @@ function _getReceiptLoanHtml($receiptDetail,$verifylist,$extendHtml='') {
 										<ul>
 											<li class="post">
 												<div class="avtra">
-													<img src="' . $receiptDetail ['staffDetail']['avatar'] . '_2.jpg" width="32">
+													<img src="' . $receiptDetail ['staffDetail'] ['avatar'] . '_2.jpg" width="32">
 												</div>
 												<div class="comment">
 													<p>
-														<span class="fR">' . $receiptDetail ['date'] . '</span>' . $receiptDetail ['staffDetail']['username'] . '
+														<span class="fR">' . $receiptDetail ['date'] . '</span>' . $receiptDetail ['staffDetail'] ['username'] . '
 													</p>
 													<p>提交审批</p>
 												</div>
 											</li>';
-											foreach ($verifylist as $key=>$value){
-											$html.='<li ';
-											if ($value['status']==1){
-												$html.='class="done"';
-											}elseif($value['status']==3){
-												$html.='class="undone"';
-											}
-											$html.='>
+	foreach ( $verifylist as $key => $value ) {
+		$html .= '<li ';
+		if ($value ['status'] == 1) {
+			$html .= 'class="done"';
+		} elseif ($value ['status'] == 3) {
+			$html .= 'class="undone"';
+		}
+		$html .= '>
 												<div class="avtra">
-													<img src="'.$value[2].'_2.jpg" width="32">
+													<img src="' . $value [2] . '_2.jpg" width="32">
 												</div>
 												<div class="comment">
 													<p class="colGray">
-														<span class="fR">'.$value['date'].'</span>'.$value[1].'';
-											if(isset($value['rolename'])){
-												$html.='('.$value['rolename'].')';
-											}
-													$html.='</p>
-													<p>'.$value['opinion'].'</p>
+														<span class="fR">' . $value ['date'] . '</span>' . $value [1] . '';
+		if (isset ( $value ['rolename'] )) {
+			$html .= '(' . $value ['rolename'] . ')';
+		}
+		$html .= '</p>
+													<p>' . $value ['opinion'] . '</p>
 												</div>
 											</li>';
-											}
-											
-											foreach ($executeCopy as $key=>$value){
-											$html.='<li ';
-											if ($value['status']==1){
-												$html.='class="done"';
-											}elseif($value['status']==3){
-												$html.='class="undone"';
-											}	
-											$html.='>
+	}
+	
+	foreach ( $executeCopy as $key => $value ) {
+		$html .= '<li ';
+		if ($value ['status'] == 1) {
+			$html .= 'class="done"';
+		} elseif ($value ['status'] == 3) {
+			$html .= 'class="undone"';
+		}
+		$html .= '>
 												<div class="avtra">
-													<img src="'.$value[2].'_2.jpg" width="32">
+													<img src="' . $value [2] . '_2.jpg" width="32">
 												</div>
 												<div class="comment">
 													<p class="colGray">
-														<span class="fR">'.$value['date'].'</span>'.$value[1].'(费用执行)
+														<span class="fR">' . $value ['date'] . '</span>' . $value [1] . '(费用执行)
 													</p>
-													<p>'.$value['opinion'].'</p>
+													<p>' . $value ['opinion'] . '</p>
 												</div>
 											</li>';
-											}
-										$html.='
+	}
+	$html .= '
 										</ul>
 									</div>
 								</div>
 							</div>
 												
-							'.$extendHtml.'
+							' . $extendHtml . '
 							
 			</div>';
 	return $html;
@@ -1331,8 +1331,7 @@ function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
 			'sum' => $sum 
 	);
 }
-
-function getExecuteStaff($receiptDetail){
+function getExecuteStaff($receiptDetail) {
 	// 费用执行人相关数据
 	$executeCopy = json_decode ( $receiptDetail ['executeCopy'], true );
 	$executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );
@@ -1351,9 +1350,8 @@ function getExecuteStaff($receiptDetail){
 			}
 	}
 	$receiptDetail ['executeCopy'] = $executeCopy;
-	return $receiptDetail['executeCopy'];
+	return $receiptDetail ['executeCopy'];
 }
-
 function num_to_rmb($num) {
 	$c1 = "零壹贰叁肆伍陆柒捌玖";
 	$c2 = "分角元拾佰仟万拾佰仟亿";
@@ -1547,4 +1545,728 @@ function exportExcel($title = array(), $data = array(), $fileName = '', $savePat
 	return $savePath . $fileName . '.xlsx';
 }
 
+function cellColor($cells,$color,$obj){
+	
+
+	$obj->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
+			'type' => PHPExcel_Style_Fill::FILL_SOLID,
+			'startcolor' => array(
+					'rgb' => $color
+			)
+	));
+}
+
+/*
+ * 处理Excel导出
+ *  @param $datas array 
+ *  设置表格数据
+ *   @param $titlename string 
+ *   设置head @param $title string 设置表头
+ */
+function excelData($trainData, $receiptDetail, $summary, $aiList,$receiptLoanDetail,$invoiceList,$RItemList,$lecturerList,$invoiceTrainingDetail) {
+	Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
+	$obj = new PHPExcel ();
+	
+	
+	//设置合并单元格
+	$obj->getActiveSheet()->mergeCells('A1:D1');
+	//设置居中--//字体加粗
+	$obj->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	$i=2;
+	for(;$i<=20;$i++){
+		$obj->getActiveSheet()->getStyle('A'.$i.':J'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+		//$obj->getActiveSheet()->getStyle('A'.$i)->getFont()->setName('宋体')->setBold(true);
+		//$obj->getActiveSheet()->getStyle('C'.$i)->getFont()->setName('宋体')->setBold(true);
+	}
+	
+$styleThinBlackBorderOutline = array(
+        'borders' => array(
+            'allborders' => array( //设置全部边框
+                'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+            ),
+
+        ),
+    );
+    $obj->getActiveSheet()->getStyle( 'A1:D9')->applyFromArray($styleThinBlackBorderOutline);
+    for ($i=1;$i<=9;$i++){
+    	cellColor('A'.$i, 'ddebf7',$obj);
+    }
+    cellColor('C2', 'ddebf7',$obj);cellColor('C3', 'ddebf7',$obj);
+    cellColor('C4', 'ddebf7',$obj);cellColor('C8', 'ddebf7',$obj);
+    cellColor('C6', 'ddebf7',$obj);cellColor('C7', 'ddebf7',$obj);
+    
+	//设置单元格宽
+	$obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
+	$obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
+	
+	$obj->getActiveSheet()->getStyle('A1')->getFont()->setName('宋体')->setBold(true);
+	
+	$obj->getactivesheet()->setCellValue ( 'A1','培训班信息' );
+	
+	$obj->getactivesheet()->setCellValue ( 'A2','培训班名称' );
+	$obj->getactivesheet()->setCellValue ( 'B2',$trainData['trainName'] );
+	$obj->getactivesheet()->setCellValue ( 'C2','所在办事处' );
+	$obj->getactivesheet()->setCellValue ( 'D2',$trainData['categoryName'] );
+	
+	$obj->getactivesheet()->setCellValue ( 'A3','开班时间' );
+	$obj->getactivesheet()->setCellValue ( 'B3',$trainData['trainStartDate'] );
+	$obj->getactivesheet()->setCellValue ( 'C3','结束时间' );
+	$obj->getactivesheet()->setCellValue ( 'D3',$trainData['trainEndDate'] );
+	
+	$obj->getactivesheet()->setCellValue ( 'A4','参加人数' );
+	$obj->getactivesheet()->setCellValue ( 'B4',$trainData['participants'] );
+	$obj->getactivesheet()->setCellValue ( 'C4','培训班地址' );
+	autoCellsWidth($obj,'D',$trainData ['trainAddress']);
+	$obj->getactivesheet()->setCellValue ( 'D4',$trainData['trainAddress'] );
+	
+	$obj->getactivesheet()->setCellValue ( 'A5','备注' );
+	$obj->getActiveSheet()->mergeCells('B5:D5');
+	$obj->getactivesheet()->setCellValue ( 'B5',$trainData['trainRemarks'] );
+	
+	$obj->getActiveSheet()->mergeCells('A6:D6');
+	$obj->getActiveSheet()->getStyle('A6:D6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	$obj->getactivesheet()->setCellValue ( 'A6','汇款信息' );
+	
+	$obj->getactivesheet()->setCellValue ( 'A7','汇款人户名' );
+	$obj->getactivesheet()->setCellValue ( 'B7',$receiptDetail['remittanceName'] );
+	$obj->getactivesheet()->setCellValue ( 'C7','汇款银行' );
+	if(0==$receiptDetail['remittanceBankType']){
+		$obj->getactivesheet()->setCellValue ( 'D7','广发银行' );
+	}else{
+		$obj->getactivesheet()->setCellValue ( 'D7',其他 );
+	}
+	
+	$obj->getactivesheet()->setCellValue ( 'A8','汇款开户银行名称' );
+	
+	autoCellsWidth($obj,'B',$receiptDetail ['bankName']);
+	
+	$obj->getactivesheet()->setCellValue ( 'B8',$receiptDetail['bankName'] );
+	$obj->getactivesheet()->setCellValue ( 'C8','汇款帐号' );
+	$obj->getActiveSheet()->setCellValueExplicit('D8',$receiptDetail['bankNumber'],PHPExcel_Cell_DataType::TYPE_STRING);
+	//$obj->getactivesheet()->setCellValue ( 'D7',$receiptDetail['bankNumber'].'' );
+	
+	if(0==$receiptDetail['remittanceBankType']){
+		$obj->getactivesheet()->setCellValue ( 'A9','联行号' );
+		$obj->getActiveSheet()->mergeCells('B9:D9');
+		$obj->getactivesheet()->setCellValue ( 'B9',$receiptDetail['coupletNumber'] );
+	}
+	$obj->setActiveSheetIndex(0);
+	$obj->getActiveSheet ()->setTitle ( '信息' );
+	
+	//------------------------------------------------------------------------------------------
+	$obj->createSheet();
+	$obj->setActiveSheetIndex(1);
+	makeSummaryData($obj,$summary,$aiList);
+	
+	//------------------------------------------------------------------------------------------
+	//绘制借款
+	$obj->createSheet();
+	$obj->setActiveSheetIndex(2);
+	makeReceiptLoanData($obj,$receiptLoanDetail);
+	
+	//------------------------------------------------------------------------------------------
+	//绘制收入
+	$obj->createSheet();
+	$obj->setActiveSheetIndex(3);
+	makeInvoiceData($obj,$invoiceList,$invoiceTrainingDetail);
+	
+	//------------------------------------------------------------------------------------------
+	//绘制支出
+	$obj->createSheet();
+	$obj->setActiveSheetIndex(4);
+	makeItemData($obj,$RItemList);
+	
+	//------------------------------------------------------------------------------------------
+	//绘制讲师
+	$obj->createSheet();
+	$obj->setActiveSheetIndex(5);
+	makeLecturerData($obj,$lecturerList);
+	
+	$objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
+	header ( 'pragma:public' );
+	header ( "Content-Disposition:attachment;filename=".$trainData['trainName'].".xlsx" );
+	header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
+	$objWrite->save ( 'php://output' );
+	exit ();
+}
+
+
+function makeLecturerData($obj,$lecturerList){
+
+	//整体字体位置
+	$invoiceCount=count($lecturerList)+2;
+
+	for($i=1;$i<=$invoiceCount;$i++){
+		$obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
+		$obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
+		$obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
+	}
+	$obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
+
+	//边框
+	$styleThinBlackBorderOutline = array(
+			'borders' => array(
+					'allborders' => array( //设置全部边框
+							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+					),
+			),);
+	$obj->getActiveSheet()->getStyle( 'A1:E'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
+
+	cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
+	cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);cellColor('E1', 'ddebf7',$obj);
+
+	$obj->getactivesheet()->setCellValue ( 'A1','类型' );
+	$obj->getactivesheet()->setCellValue ( 'B1','讲师姓名' );
+	$obj->getactivesheet()->setCellValue ( 'C1','授课日数' );
+	$obj->getactivesheet()->setCellValue ( 'D1','日授课费' );
+	$obj->getactivesheet()->setCellValue ( 'E1','合计应发授课费' );
+
+	$i=2;$sumPrice=0;
+	foreach ($lecturerList as $key=>$value){
+		$lecturerName='';
+		if($value['ltype']=='OUTSIDE'){
+			$lecturerName.='外聘';
+			if($value['taxation']==0){
+				$lecturerName.='(不计税)';
+			}else{
+				$lecturerName.='(计税)';
+			}
+		}else{
+			$lecturerName.='员工';
+		}
+		
+		$obj->getactivesheet()->setCellValue ( 'A'.$i,$lecturerName );
+		
+		$obj->getactivesheet()->setCellValue ( 'B'.$i,$value['lecturerName'] );
+		
+		$obj->getactivesheet()->setCellValue ( 'C'.$i,$value['schoolDay'] );
+		$obj->getactivesheet()->setCellValue ( 'D'.$i,$value['price'] );
+		$obj->getactivesheet()->setCellValue ( 'E'.$i,$value['sum'] );
+		$sumPrice+=$value['sum'];
+		$i++;
+	}
+	$obj->getactivesheet()->setCellValue ( 'C'.$i,'合计' );
+	$obj->getactivesheet()->setCellValue ( 'D'.$i,$sumPrice );
+	$obj->getActiveSheet ()->setTitle ( '讲师' );
+}
+
+function makeItemData($obj,$itemList){
+
+	//整体字体位置
+	$invoiceCount=count($itemList)+2;
+
+	for($i=1;$i<=$invoiceCount;$i++){
+		$obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
+		$obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
+		$obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
+	}
+	$obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
+	
+
+	//边框
+	$styleThinBlackBorderOutline = array(
+			'borders' => array(
+					'allborders' => array( //设置全部边框
+							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+					),
+			),);
+	$obj->getActiveSheet()->getStyle( 'A1:E'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
+
+	cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
+	cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);
+	cellColor('E1', 'ddebf7',$obj);
+
+	$obj->getactivesheet()->setCellValue ( 'A1','日期' );
+	$obj->getactivesheet()->setCellValue ( 'B1','类别' );
+	$obj->getactivesheet()->setCellValue ( 'C1','金额' );
+	$obj->getactivesheet()->setCellValue ( 'D1','经手人' );
+	$obj->getactivesheet()->setCellValue ( 'E1','支出描述' );
+
+	$i=2;$maxArray=array();$sumPrice=0;
+	foreach ($itemList as $key=>$value){
+		$obj->getactivesheet()->setCellValue ( 'A'.$i,$value['date'] );
+		$obj->getactivesheet()->setCellValue ( 'B'.$i,$value['item'] );
+		$obj->getactivesheet()->setCellValue ( 'C'.$i,$value['price'] );
+		
+		$obj->getactivesheet()->setCellValue ( 'D'.$i,$value['inputer'] );
+		$obj->getactivesheet()->setCellValue ( 'E'.$i,$value['describe'] );
+		array_push($maxArray, strlen($value['describe']));
+		$sumPrice+=$value['price'];
+		$i++;
+	}
+	
+	$obj->getactivesheet()->setCellValue ( 'B'.$i,'合计' );
+	$obj->getactivesheet()->setCellValue ( 'C'.$i,$sumPrice );
+	$max=max($maxArray)-10;$fontlenght=25;
+	
+	if($max>25){
+		$fontlenght=$max;
+	}
+	$obj->getActiveSheet()->getColumnDimension('E')->setWidth($fontlenght);
+	
+	$obj->getActiveSheet ()->setTitle ( '支出' );
+}
+
+function makeInvoiceData($obj,$invoiceList,$invoiceTrainingDetail){
+	
+	//整体字体位置
+	$invoiceCount=count($invoiceList)+4;
+	
+	for($i=1;$i<=$invoiceCount;$i++){
+		$obj->getActiveSheet()->getStyle('A'.$i.':I'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
+		$obj->getActiveSheet()->getStyle('A'.$i.':I'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
+		$obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
+	}
+	$obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('F')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('G')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('H')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('I')->setWidth(25);
+	
+	//边框
+	$styleThinBlackBorderOutline = array(
+			'borders' => array(
+					'allborders' => array( //设置全部边框
+							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+					),
+			),);
+	$obj->getActiveSheet()->getStyle( 'A1:I2')->applyFromArray($styleThinBlackBorderOutline);
+	
+	cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
+	cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);
+	cellColor('E1', 'ddebf7',$obj);cellColor('F1', 'ddebf7',$obj);
+	cellColor('H1', 'ddebf7',$obj);cellColor('G1', 'ddebf7',$obj);cellColor('I1', 'ddebf7',$obj);
+	
+	$obj->getactivesheet()->setCellValue ( 'A1','培训班名称' );
+	$obj->getactivesheet()->setCellValue ( 'B1','办事处' );
+	$obj->getactivesheet()->setCellValue ( 'C1','创建' );
+	$obj->getactivesheet()->setCellValue ( 'D1','开班时间' );
+	$obj->getactivesheet()->setCellValue ( 'E1','包含发票' );
+	$obj->getactivesheet()->setCellValue ( 'F1','开票金额合计' );
+	$obj->getactivesheet()->setCellValue ( 'G1','入账金额合计' );
+	$obj->getactivesheet()->setCellValue ( 'H1','公司已收款' );
+	$obj->getactivesheet()->setCellValue ( 'I1','办事处已收款' );
+	
+	$obj->getactivesheet()->setCellValue ( 'A2',$invoiceTrainingDetail['trainName'] );
+	$obj->getactivesheet()->setCellValue ( 'B2',$invoiceTrainingDetail['category'][0]['title'] );
+	$obj->getactivesheet()->setCellValue ( 'C2',$invoiceTrainingDetail['staff']['username'] );
+	$obj->getactivesheet()->setCellValue ( 'D2',$invoiceTrainingDetail['trainDate'] );
+	$obj->getactivesheet()->setCellValue ( 'E2',$invoiceTrainingDetail['invoiceTotal'] );
+	$obj->getactivesheet()->setCellValue ( 'F2',$invoiceTrainingDetail['invoiceTotalAmount'] );
+	$obj->getactivesheet()->setCellValue ( 'G2',$invoiceTrainingDetail['invoiceArriveAmount'] );
+	$obj->getactivesheet()->setCellValue ( 'H2',$invoiceTrainingDetail['invoiceCompanyAmount'] );
+	$obj->getactivesheet()->setCellValue ( 'I2',$invoiceTrainingDetail['RIAmount'] );
+	
+	//边框
+	$styleThinBlackBorderOutline = array(
+			'borders' => array(
+					'allborders' => array( //设置全部边框
+							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+					),
+			),);
+	$obj->getActiveSheet()->getStyle( 'A4:H'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
+	
+	cellColor('A4', 'ddebf7',$obj);cellColor('B4', 'ddebf7',$obj);
+	cellColor('C4', 'ddebf7',$obj);cellColor('D4', 'ddebf7',$obj);
+	cellColor('E4', 'ddebf7',$obj);cellColor('F4', 'ddebf7',$obj);
+	cellColor('H4', 'ddebf7',$obj);cellColor('G4', 'ddebf7',$obj);
+	
+	
+	$obj->getactivesheet()->setCellValue ( 'A4','开票流水' );
+	$obj->getactivesheet()->setCellValue ( 'B4','开票单位(抬头)' );
+	$obj->getactivesheet()->setCellValue ( 'C4','发票号' );
+	$obj->getactivesheet()->setCellValue ( 'D4','总额' );
+	$obj->getactivesheet()->setCellValue ( 'E4','状态' );
+	$obj->getactivesheet()->setCellValue ( 'F4','办事处收款' );
+	$obj->getactivesheet()->setCellValue ( 'G4','收款流水号' );
+	$obj->getactivesheet()->setCellValue ( 'H4','收款银行到账' );
+	
+	$i=5;$maxArray=array();
+	foreach ($invoiceList as $key=>$value){
+		$obj->getactivesheet()->setCellValue ( 'A'.$i,$value['invoiceSerial'] );
+		
+		$title='';
+		if(!empty($value['invoiceType'])){
+			$title=$value['invoiceCompany'];
+		}else{
+			$title=$value['invoiceTitle'];
+		}
+		$obj->getactivesheet()->setCellValue ( 'B'.$i,$title );
+		
+		$obj->getactivesheet()->setCellValue ( 'C'.$i,$value['invoiceNo'] );
+		if(!empty($value['invoiceType'])){
+			$obj->getactivesheet()->setCellValue ( 'D'.$i,'专'.$value['invoicePrice'] );
+		}else{
+			$obj->getactivesheet()->setCellValue ( 'D'.$i,$value['invoicePrice'] );
+		}
+		
+		if($value['untreadStatus']==3){
+			$obj->getactivesheet()->setCellValue ( 'E'.$i,'已入账' );
+		}else{
+			$obj->getactivesheet()->setCellValue ( 'E'.$i,'已出票' );
+		}
+		
+		if($value['untreadStatus']==3){
+			if($value['RIstatus']==1){
+				$obj->getactivesheet()->setCellValue ( 'F'.$i,'已收款' );
+			}
+		}else{
+			if($value['RIstatus']==1){
+				$obj->getactivesheet()->setCellValue ( 'F'.$i,'已收款' );
+			}
+		}
+		$receivablesSerial='';
+		$receivablesDate='';$hang=0;
+		if($value['untreadStatus']==3){
+			foreach ($value['irDetail'] as $k=>$v){
+				$receivablesSerial.=$v['receivablesSerial']."\r\n";
+				$receivablesDate.=$v['receivablesDate']."\r\n";
+				$hang+=8;
+			}
+			if($hang>8){
+				$obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18+$hang);
+			}
+			
+		}
+		$obj->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setWrapText(true);
+		$obj->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setWrapText(true);
+		
+		$obj->getactivesheet()->setCellValue ( 'G'.$i,$receivablesSerial );
+		$obj->getactivesheet()->setCellValue ( 'H'.$i,$receivablesDate );
+		
+		
+		//按字体多少自动拉长单元格
+		array_push($maxArray, strlen($title));
+		
+		$i++;
+	}
+	
+	$max=max($maxArray)-10;$fontlenght=25;
+	if($max>25){
+		$fontlenght=$max;
+	}
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth($fontlenght);
+	
+	
+	$obj->getActiveSheet ()->setTitle ( '收入' );
+}
+
+function makeReceiptLoanData($obj,$receiptLoanDetail){
+	if (empty($receiptLoanDetail)){
+		$obj->getActiveSheet ()->setTitle ( '借款' );
+		return ;
+	}
+	
+	$receiptLoanDetail ['loanItem'] = json_decode ( $receiptLoanDetail ['loanItem'], true );
+	$receiptLoanDetail ['sumCN'] = num_to_rmb ( $receiptLoanDetail ['sum'] );
+	$receiptLoanDetail ['loanSumCN'] = num_to_rmb ( $receiptLoanDetail ['loanSum'] );
+	$receiptLoanDetail ['amountCN'] = num_to_rmb ( $receiptLoanDetail ['amount'] );
+	//整体字体位置
+	for($i=1;$i<=34;$i++){
+		$obj->getActiveSheet()->getStyle('A'.$i.':B'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
+		$obj->getActiveSheet()->getStyle('A'.$i.':B'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
+		$obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
+	}
+	//整体边框大小
+	$obj->getActiveSheet()->getColumnDimension('A')->setWidth(35);
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth(35);
+	//$obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
+	
+	//边框
+	$styleThinBlackBorderOutline = array(
+			'borders' => array(
+					'allborders' => array( //设置全部边框
+							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+					),
+			),);
+	$obj->getActiveSheet()->getStyle( 'A1:B14')->applyFromArray($styleThinBlackBorderOutline);
+	//绘制颜色
+	cellColor('A1', 'ddebf7',$obj);cellColor('A3', 'ddebf7',$obj);
+	cellColor('A2', 'ddebf7',$obj);cellColor('A6', 'ddebf7',$obj);
+	cellColor('A7', 'ddebf7',$obj);cellColor('A8', 'ddebf7',$obj);
+	cellColor('A8', 'ddebf7',$obj);cellColor('A9', 'ddebf7',$obj);
+	cellColor('A10', 'ddebf7',$obj);
+	cellColor('A5', 'ddebf7',$obj);cellColor('A11', 'ddebf7',$obj);
+	
+	$obj->getActiveSheet()->mergeCells('A1:B1');
+	$obj->getactivesheet()->setCellValue ( 'A1','借款费用' );
+	$obj->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	$obj->getActiveSheet()->mergeCells('A3:B3');
+	$obj->getactivesheet()->setCellValue ( 'A3','产生费用所在办事处' );
+	$obj->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	$obj->getActiveSheet()->mergeCells('A5:B5');
+	$obj->getactivesheet()->setCellValue ( 'A5','汇款信息' );
+	$obj->getActiveSheet()->getStyle('A5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	$obj->getActiveSheet()->mergeCells('A11:B11');
+	$obj->getactivesheet()->setCellValue ( 'A11','费用说明' );
+	$obj->getActiveSheet()->getStyle('A11')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	
+	$obj->getactivesheet()->setCellValue ( 'A2','借款费用' );
+	$obj->getactivesheet()->setCellValue ( 'B2',$receiptLoanDetail ['loanItem'] ['借款费用'] [0] ['price'] );
+	
+	$obj->getActiveSheet()->mergeCells('A4:B4');
+	$obj->getactivesheet()->setCellValue ( 'A4',$receiptLoanDetail ['category'] [0] ['title'] );
+	
+	$obj->getactivesheet()->setCellValue ( 'A6','汇款人户名' );
+	$obj->getactivesheet()->setCellValue ( 'A7','汇款银行' );
+	$obj->getactivesheet()->setCellValue ( 'A8','汇款开户银行名称' );
+	$obj->getactivesheet()->setCellValue ( 'A9','汇款帐号' );
+	$obj->getactivesheet()->setCellValue ( 'A10','联行号' );
+	
+	$obj->getactivesheet()->setCellValue ( 'B6',$receiptLoanDetail ['remittanceName'] );
+	if ($receiptLoanDetail ['remittanceBankType'] == 0){
+		$obj->getactivesheet()->setCellValue ( 'B7','广发银行' );
+	}elseif ($receiptLoanDetail ['remittanceBankType'] == 1){
+		$obj->getactivesheet()->setCellValue ( 'B7','其他' );
+	}
+	
+	
+	autoCellsWidth($obj,'B',$receiptLoanDetail ['bankName']);
+	
+	$obj->getactivesheet()->setCellValue ( 'B8',$receiptLoanDetail ['bankName'] );
+	$obj->getActiveSheet()->setCellValueExplicit('B9',$receiptLoanDetail ['bankNumber'],PHPExcel_Cell_DataType::TYPE_STRING);
+	//$obj->getactivesheet()->setCellValue ( 'B9',$receiptLoanDetail ['bankNumber'] );
+	if ($receiptLoanDetail ['remittanceBankType'] == 1){
+		$obj->getactivesheet()->setCellValue ( 'B10',$receiptLoanDetail ['coupletNumber'] );
+	}else{
+		$obj->getactivesheet()->setCellValue ( 'B10','' );
+	}
+	
+	$obj->getActiveSheet()->mergeCells('A12:B12');
+	$obj->getactivesheet()->setCellValue ( 'B12',$receiptLoanDetail ['explanation'] );
+	
+	
+	$obj->getActiveSheet()->getStyle('A13:B13')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+	$obj->getActiveSheet()->getStyle('A14:B14')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+	$obj->getactivesheet()->setCellValue ( 'A13','(' . $receiptLoanDetail ['receiptOrder'] . ')本次费用合计' );
+	$obj->getActiveSheet()->getStyle('B13')->getAlignment()->setWrapText(true);
+	$obj->getactivesheet()->setCellValue ( 'B13',"¥" . $receiptLoanDetail ['sum'] . "\r\n" . $receiptLoanDetail ['sumCN']  );
+	$obj->getActiveSheet()->getRowDimension(13)->setRowHeight(36);
+	
+	$obj->getactivesheet()->setCellValue ( 'A14','汇款金额');
+	$obj->getActiveSheet()->getStyle('B14')->getAlignment()->setWrapText(true);
+	$obj->getactivesheet()->setCellValue ( 'B14',"¥" . $receiptLoanDetail ['amount'] . "\r\n" . $receiptLoanDetail ['amountCN']  );
+	$obj->getActiveSheet()->getRowDimension(14)->setRowHeight(36);
+	
+	$obj->getActiveSheet ()->setTitle ( '借款' );
+}
+
+
+
+//绘制汇总
+function makeSummaryData($obj,$summary,$aiList){
+	//设置居中
+	//$obj->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+	for($i=1;$i<=35;$i++){
+		$obj->getActiveSheet()->getStyle('A'.$i.':J'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+		if ($i>=19){
+			$obj->getActiveSheet()->getStyle('A'.$i.':B'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
+		}
+	}
+	
+	//设置单元格宽
+	$obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
+	$obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
+	$obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
+	
+	$obj->getActiveSheet()->mergeCells('A1:A2');
+	$obj->getActiveSheet()->mergeCells('B1:C1');
+	$obj->getActiveSheet()->mergeCells('D1:E1');
+	$obj->getActiveSheet()->mergeCells('C2:C3');
+	$obj->getActiveSheet()->mergeCells('E2:E3');
+	$obj->getActiveSheet()->mergeCells('A6:E6');
+	$obj->getActiveSheet()->mergeCells('A10:E10');
+	$obj->getActiveSheet()->mergeCells('A15:E15');
+	$obj->getActiveSheet()->mergeCells('A16:E16');
+	//支出详情
+	$obj->getActiveSheet()->mergeCells('A18:C18');
+	$obj->getActiveSheet()->mergeCells('A19:A35');
+	
+	cellColor('A1', 'ddebf7',$obj);cellColor('A2', 'ddebf7',$obj);
+	cellColor('B1', 'ddebf7',$obj);cellColor('B2', 'ddebf7',$obj);
+	cellColor('C2', 'ddebf7',$obj);cellColor('E2', 'ddebf7',$obj);
+	cellColor('D1', 'ddebf7',$obj);cellColor('D2', 'ddebf7',$obj);
+	cellColor('E3', 'ddebf7',$obj);cellColor('C3', 'ddebf7',$obj);
+	for ($i=3;$i<=15;$i++){
+		cellColor('A'.$i, 'ddebf7',$obj);
+	}
+	//支出详情
+	cellColor('A18', 'ddebf7',$obj);cellColor('D18', 'ddebf7',$obj);
+	cellColor('E18', 'ddebf7',$obj);cellColor('A19', 'ddebf7',$obj);
+	
+	for ($i=19;$i<=35;$i++){
+		cellColor('B'.$i, 'ddebf7',$obj);
+	}
+	
+	//边框
+	$styleThinBlackBorderOutline = array(
+			'borders' => array(
+					'allborders' => array( //设置全部边框
+							'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
+					),
+	
+			),
+	);
+	$obj->getActiveSheet()->getStyle( 'A1:E16')->applyFromArray($styleThinBlackBorderOutline);
+	//支出详情
+	$obj->getActiveSheet()->getStyle( 'A18:E35')->applyFromArray($styleThinBlackBorderOutline);
+	
+	$obj->getactivesheet()->setCellValue ( 'A1','汇总项目' );
+	$obj->getactivesheet()->setCellValue ( 'B1','收入按开票金额计算' );
+	$obj->getactivesheet()->setCellValue ( 'D1','收入按入账金额计算' );
+	$obj->getactivesheet()->setCellValue ( 'B2','金额' );
+	$obj->getactivesheet()->setCellValue ( 'C2','占比' );
+	$obj->getactivesheet()->setCellValue ( 'D2','金额' );
+	$obj->getactivesheet()->setCellValue ( 'E2','占比' );
+	
+	$obj->getactivesheet()->setCellValue ( 'A3','收入' );
+	$obj->getactivesheet()->setCellValue ( 'A4','支出' );
+	$obj->getactivesheet()->setCellValue ( 'A5','利润' );
+	$obj->getactivesheet()->setCellValue ( 'A6','收入-支出=利润' );
+	
+	$obj->getactivesheet()->setCellValue ( 'A7','公司利润' );
+	$obj->getactivesheet()->setCellValue ( 'A8','办事处利润' );
+	$obj->getactivesheet()->setCellValue ( 'A9','公司收款' );
+	$obj->getactivesheet()->setCellValue ( 'A10','收入×40%=办事处利润   收入×60%=公司利润' );
+	
+	$obj->getactivesheet()->setCellValue ( 'A11','备用金(借款)' );
+	$obj->getactivesheet()->setCellValue ( 'A12','办事处收款' );
+	$obj->getactivesheet()->setCellValue ( 'A13','办事处实际支出' );
+	$obj->getactivesheet()->setCellValue ( 'A14','付总部款' );
+	$obj->getactivesheet()->setCellValue ( 'A15','备用金+办事处收款-办事处实际支出=付总部款' );
+	
+	//支出详情
+	$obj->getactivesheet()->setCellValue ( 'A18','项目' );
+	$obj->getactivesheet()->setCellValue ( 'D18','金额' );
+	$obj->getactivesheet()->setCellValue ( 'E18','占入账金额比例' );
+	$obj->getactivesheet()->setCellValue ( 'A19','支出明细' );
+	
+	$startKey=19;
+	foreach ($aiList as $key=>$value){
+		$obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+		$obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+		if($value['name']=='讲课费'){
+			$obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
+			$obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+2));
+			$obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'外聘' );
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['outsideTaxPrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['outsideTaxProportion'].'%' );
+			$startKey+=1;
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'外聘(不计税)' );
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['outsideNoTaxPrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['outsideNoTaxProportion'].'%' );
+			$startKey+=1;
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'员工' );
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['insidePrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['insideProportion'].'%' );
+			
+		}elseif($value['name']=='办公费'){
+			$obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
+			$obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+1));
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'办事处支出' );
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['categoryPrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['categoryProportion'].'%' );
+			$startKey=$startKey+1;
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['companyPrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['companyProportion'].'%' );
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'公司支出' );
+			
+		}elseif($value['name']=='邮寄费'){
+			$obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
+			$obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+1));
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'办事处支出' );
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['categoryPrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['categoryProportion'].'%' );
+			$startKey=$startKey+1;
+			$obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+			$obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['companyPrice'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['companyProportion'].'%' );
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,'公司支出' );
+		}else{
+			$obj->getActiveSheet()->mergeCells('C'.$startKey.':D'.$startKey);
+			$obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
+			$obj->getactivesheet()->setCellValue ( 'C'.$startKey,$value['priceFormat'] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['proportion'].'%' );
+		}
+		$startKey++;
+	}
+	//小计
+	$obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+	$obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+	$obj->getActiveSheet()->mergeCells('C'.$startKey.':D'.$startKey);
+	$obj->getactivesheet()->setCellValue ( 'B'.$startKey,'小计' );
+	$obj->getactivesheet()->setCellValue ( 'C'.$startKey,$summary[11]['total'] );
+	$obj->getactivesheet()->setCellValue ( 'E'.$startKey,$summary[11]['totalProportion'].'%' );
+	
+	$startKey=3;
+	//内容
+	foreach ($summary as $key=>$value){
+		$k=$key+$startKey;
+		if($k==3){
+			$obj->getactivesheet()->setCellValue ( 'B'.$k,$value['invoiceTotalAmount'] );
+			$obj->getactivesheet()->setCellValue ( 'D'.$k,$value['invoiceArriveAmount'] );
+		}elseif($k==15){
+			$k+=1;
+			$obj->getactivesheet()->setCellValue ( 'A'.$k,'学员:'.$value['participants'].'人   讲师:'.$value['lectureCount'].' 人' );
+		}elseif($k==16){
+			
+		}elseif($k==6||$k==10){
+			$k+=1;
+			$startKey+=1;
+			$obj->getactivesheet()->setCellValue ( 'B'.$k,$value[1] );
+			$obj->getactivesheet()->setCellValue ( 'C'.$k,$value[2] );
+			$obj->getactivesheet()->setCellValue ( 'D'.$k,$value[3] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$k,$value[4] );
+		}else{
+			$obj->getactivesheet()->setCellValue ( 'B'.$k,$value[1] );
+			$obj->getactivesheet()->setCellValue ( 'C'.$k,$value[2] );
+			$obj->getactivesheet()->setCellValue ( 'D'.$k,$value[3] );
+			$obj->getactivesheet()->setCellValue ( 'E'.$k,$value[4] );
+				
+		}
+	
+	}
+	
+	$obj->getActiveSheet ()->setTitle ( '汇总表' );
+}
+
+function autoCellsWidth($obj,$cellsNub,$str){
+	$max=strlen($str)-10;$fontlenght=35;
+	if($max>35){
+		$fontlenght=$max;
+	}
+	$obj->getActiveSheet()->getColumnDimension($cellsNub)->setWidth($fontlenght);
+}
+
 ?>

+ 2 - 0
protected/config/acl.conf.php

@@ -485,6 +485,8 @@ $acl ['RECEIPTSEXTEND'] ['allow'] = array (
 				'receiptTrainAssistEdi',
 				'receiptTrainAssistAddDo',
 				'receiptTrainAssistDelDo',
+				'exportReceiptTrainExcel',
+				'receiptTrainItemEdiDo',
 		)
 );
 $acl ['RECEIPTSAJAX'] ['allow'] = array (

+ 8 - 1
protected/config/routes.conf.php

@@ -255,6 +255,10 @@ $route['*']['/receiptTrainItemAddDo'] = array('ReceiptController', 'receiptTrain
 $route['*']['/receiptTrainItemAddDo/:payType'] = array('ReceiptController', 'receiptTrainItemAddDo');
 $route['*']['/receiptTrainItemDelDo/:riidKey/:ridKey'] = array('ReceiptExtendController', 'receiptTrainItemDelDo');
 
+$route['*']['/receiptTrainItemEdiDo'] = array('ReceiptExtendController', 'receiptTrainItemEdiDo');
+$route['*']['/receiptTrainItemEdiDo/:payType'] = array('ReceiptExtendController', 'receiptTrainItemEdiDo');
+
+
 $route['*']['/receiptTrainAssistEdi/:rid'] = array('ReceiptExtendController', 'receiptTrainAssistEdi','extension'=>'.html');
 $route['*']['/receiptTrainAssistAddDo'] = array('ReceiptExtendController', 'receiptTrainAssistAddDo');
 $route['*']['/receiptTrainAssistDelDo/:aidKey/:ridKey'] = array('ReceiptExtendController', 'receiptTrainAssistDelDo');
@@ -289,6 +293,7 @@ $route['*']['/receiptWasteBook'] = array('ReceiptExtendController', 'receiptWast
 
 $route['*']['/receiptWasteBookAddDo'] = array('ReceiptExtendController', 'receiptWasteBookAddDo');
 
+$route['*']['/exportReceiptTrainExcel'] = array('ReceiptExtendController', 'exportReceiptTrainExcel');
 
 
 
@@ -462,7 +467,8 @@ $route['post']['/ajaxGetInvoiceReceivables'] = array('InvoiceController', 'ajaxG
 
 $route['post']['/ajaxGetInvoice'] = array('InvoiceAjaxController', 'ajaxGetInvoice');
 
-
+//发票信息库获得数据
+$route['*']['/autoFillInIFB'] = array('InvoiceAjaxController', 'autoFillInIFB');
 
 
 
@@ -491,6 +497,7 @@ $route['post']['/ajaxReceivablesRemove'] = array('InvoiceController', 'ajaxRecei
 $route['post']['/invoiceEnterReceivables'] = array('InvoiceController', 'invoiceEnterReceivables');
 
 //发票审批
+
 $route['*']['/invoiceApproval'] = array('InvoiceController', 'invoiceApproval');
 $route['*']['/invoiceDetail/:iid'] = array('InvoiceController', 'invoiceDetail','extension'=>'.html');
 $route['*']['/invoiceApprovalDo'] = array('InvoiceController', 'invoiceApprovalDo');

+ 3 - 3
protected/controller/HumanResourceController.php

@@ -3309,17 +3309,17 @@ target="_blank">反面(照片)</a>
 						<table class="table table-bordered table-condensed">
 						<tr><th class="taC" colspan="4">报销收款帐号</th></tr>
 							<tr>
-								<th class="taC" width="150">款人户名</th>
+								<th class="taC" width="150">款人户名</th>
 								<td width="210"><input type="text"  name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
 								<th class="taC" width="150">联行号</th>
 								<td colspan="3"><input type="text"  name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
 							</tr>
 							<tr>
-								<th class="taC" width="150">款开户银行名称</th>
+								<th class="taC" width="150">款开户银行名称</th>
 								<td width="210">
 									<input type="text"  name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
 								</td>
-								<th class="taC" width="150">款帐号</th>
+								<th class="taC" width="150">款帐号</th>
 								<td><input type="text"  name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
 							</tr>
 							

Datei-Diff unterdrückt, da er zu groß ist
+ 153 - 65
protected/controller/InvoiceController.php


+ 3 - 2
protected/controller/MainController.php

@@ -2703,7 +2703,8 @@ class MainController extends DooController {
 			if (! empty ( $clientCount ) && ! empty ( $lv2 )) {
 				$CC2 = 0;
 				foreach ( $clientCount as $key => $value ) {
-					if (strpos ( $value ['district'], $lv2 )) {
+					if (strpos ( $value ['district'], ','.$lv2.',' )) {
+						//echo $value ['district'].'<br/>';
 						$CC2 ++;
 					}
 				}
@@ -2712,7 +2713,7 @@ class MainController extends DooController {
 			if (! empty ( $clientCount ) && ! empty ( $lv3 )) {
 				$CC3 = 0;
 				foreach ( $clientCount as $key => $value ) {
-					if (strpos ( $value ['district'], $lv3 )) {
+					if (strpos ( $value ['district'], ','.$lv3 )) {
 						$CC3 ++;
 					}
 				}

+ 60 - 92
protected/controller/ReceiptController.php

@@ -13,6 +13,8 @@ class ReceiptController extends DooController {
 	public $TRAVEL = "差旅相关费用";
 	public $TRAIN = "培训班费用";
 	public $OTHER = "其他";
+	public $INTTRAIN='内部培训费用';
+	
 	private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
 	private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
 	private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
@@ -2822,19 +2824,16 @@ class ReceiptController extends DooController {
 			$RItem = new RItem ();
 			
 			$rid = $XDeode->decode ( $ridKey );
-			if (! is_numeric ( $rid ))
+			if (! is_numeric ( $rid )){
 				die ( 'illegal request' );
+			}
 			
-			if($payType=='company'){
-				$RItem->payType = 1;
-			}	
-			$RItem->rid = $rid;
-			$RItem->item = $item;
-			
-			$RItem->price = $price;
-			$RItem->date = $date;
-			$RItem->inputer = $inputer;
 			
+			Doo::loadModel ( 'receiptDetail' );
+			$receiptDetail = new receiptDetail ();
+			Doo::loadModel ( 'receipt' );
+			$receipt = new receipt ();
+				
 			$order = array (
 					"\r\n",
 					"\n",
@@ -2842,86 +2841,26 @@ class ReceiptController extends DooController {
 			);
 			$replace = '<br/>';
 			$describe = str_replace ( $order, $replace, $describe );
-			$RItem->describe = $describe;
-			
-			$RItem->creater=$this->staff['0']['username'];
-			$RItem->createrId=$this->staff['0']['sid'];
-			$RItem->creatDate=date ( "Y-m-d H:i:s" ) ;
-			
-			$RItem->insert ();
-			
-			// 添加公司汇总
-			// 报销详情
-			Doo::loadModel ( 'receiptDetail' );
-			$receiptDetail = new receiptDetail ();
-			Doo::loadModel ( 'receipt' );
-			$receipt = new receipt ();
-			
-			$rInfo = $receipt->getReceiptByRid ( $rid );
-			$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' );
-			if (empty ( $rdInfo )) {
-				$receiptDetail = new receiptDetail ();
-				$receiptDetail->staff = $rInfo ['staff'];
-				$receiptDetail->item = $item;
-				$receiptDetail->itemCategory = '培训班费用';
-				$receiptDetail->price =  $price;
-				$receiptDetail->date = date ( "Y-m-d" );
-				$receiptDetail->cid = $rInfo ['cid'];
-				$receiptDetail->rid = $rid;
-				$receiptDetail->status = 4;
-				$receiptDetail->insert ();
-			} else {
-				$receiptDetail = new receiptDetail ();
-				$rdInfo ['price'] +=  $price;
-				$receiptDetail->price = $rdInfo ['price'];
-				$receiptDetail->update ( array (
-						'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"' 
-				) );
-			}
-			//更新费用合计金额
-			$receipt = new receipt ();
-			$receipt->sum=$rInfo['sum']+ $price;
-			$receipt->update ( array (
-					'where' => 'rid=' . $rid 
-			) );
-			
-			
-			//汇总金额--提交审批之后有 支出项时 需要更新汇总
+			$itemData = array (
+					'rid' => $rid,
+					'item' => $item,
+					'price' => $price,
+						
+					'date' => $date,
+					'inputer' => $inputer,
+						
+					'describe' => $describe,
+					'creater' => $this->staff['0']['username'],
+					'createrId' => $this->staff['0']['sid'],
+					'creatDate' => date ( "Y-m-d H:i:s" )
+			);
 			if($payType=='company'){
-				Doo::loadModel ( "statistics" );
-				$statistics = new statistics ();
-				
-				
-				$dateArray = explode ( "-", $rInfo ['date'] );
-				$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
-				
-				$stat = $statistics->getOne ( array (
-						'where' => 'staff=' . $rInfo ['staff'] . $dateCondition,
-						'asArray' => true
-				) );
-				if (!empty($stat)){
-					//$statistics->agPrice = $stat ['agPrice'] + $price;
-					$statistics->rePrice = $stat ['rePrice'] + $price;
-					
-					$statistics->update ( array (
-							'where' => 'sid=' . $stat ['sid']
-					) );
-				}
-				
-// 				Doo::loadModel ( "itemStatistics" );
-// 				$itemStatistics = new itemStatistics ();
-// 				$iStatistics = $itemStatistics->getOne ( array (
-// 						'where' => 'staff=' . $rInfo ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
-// 						'asArray' => true
-// 				) );
-// 				if (!empty($iStatistics)){
-// 					$itemStatistics->price = $iStatistics ['price']+$price;
-// 					$itemStatistics->update ( array (
-// 							'where' => 'sid=' . $iStatistics ['sid']
-// 					) );
-// 				}
-				
+				$itemData += array (
+						'payType' => 1
+				);
 			}
+			$RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
+			
 			
 			
 			$XDeode = new XDeode ( 7 );
@@ -7405,8 +7344,6 @@ class ReceiptController extends DooController {
 		) );
 		$veList = $verify->getVerifyBySubordinate('RECEIPT');
 		
-		
-		
 		$data ['category'] = $lCategory->find ( array (
 				'asArray' => true 
 		) );
@@ -7426,6 +7363,9 @@ class ReceiptController extends DooController {
 		$travel = $this->get_args ( 'travel' );
 		$train = $this->get_args ( 'train' );
 		$other = $this->get_args ( 'other' );
+		
+		$inttrain = $this->get_args ( 'inttrain' );
+		
 		$verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
 		$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
 		$explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
@@ -7468,8 +7408,8 @@ class ReceiptController extends DooController {
 					'asArray' => true 
 			) );
 			$accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
-			$ag = $tr = $ta = $ot = 0;
-			$sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
+			$ag = $tr = $ta = $ot= $it = 0;
+			$sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
 			
 			foreach ( $aItem as $key => $value ) {
 				if ($value ['category'] == $this->AGENCY) {
@@ -7511,6 +7451,20 @@ class ReceiptController extends DooController {
 					$ta ++;
 				}
 				
+				if ($value ['category'] == $this->INTTRAIN) {
+					if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
+						array_push ( $accountJson [$this->INTTRAIN], array (
+								'aid' => $value ['aid'],
+								'name' => $value ['name'],
+								'price' => number_format ( $inttrain [$it], 2, '.', '' )
+						) );
+						$sum += $inttrain [$it];
+						$inttrainSum += $inttrain [$it];
+					}
+					$it ++;
+				}
+				
+				
 				if ($value ['category'] == $this->OTHER) {
 					if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
 						array_push ( $accountJson [$this->OTHER], array (
@@ -7529,6 +7483,7 @@ class ReceiptController extends DooController {
 					'agencySum' => number_format ( $agencySum, 2, '.', '' ),
 					'travelSum' => number_format ( $travelSum, 2, '.', '' ),
 					'trainSum' => number_format ( $trainSum, 2, '.', '' ),
+					'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
 					'otherSum' => number_format ( $otherSum, 2, '.', '' ) 
 			);
 			
@@ -7616,6 +7571,19 @@ class ReceiptController extends DooController {
 				$receiptDetail->status = 4;
 				$receiptDetail->insert ();
 			}
+			//内训
+			foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
+				$receiptDetail = new receiptDetail ();
+				$receiptDetail->staff = $this->staff [0] ['sid'];
+				$receiptDetail->item = $value ['name'];
+				$receiptDetail->itemCategory = $this->INTTRAIN;
+				$receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
+				$receiptDetail->date = date ( "Y-m-d" );
+				$receiptDetail->cid = $cid;
+				$receiptDetail->rid = $rid;
+				$receiptDetail->status = 4;
+				$receiptDetail->insert ();
+			}
 			foreach ( $accountJson [$this->OTHER] as $key => $value ) {
 				$receiptDetail = new receiptDetail ();
 				$receiptDetail->staff = $this->staff [0] ['sid'];

+ 8 - 0
protected/model/invoice.php

@@ -321,8 +321,16 @@ class invoice extends DooModel {
 		$XDeode = new XDeode ( 5 );
 		Doo::loadModel ( 'invoiceReceivables' );
 		$invoiceReceivables = new invoiceReceivables ();
+		$isFinance=false;
 		foreach ($result as $key=>$value){
 			$result [$key] ['irDetail'] =$invoiceReceivables->getInvoiceReceivablesByIridList($value ['irid']);
+			foreach ($result [$key] ['irDetail'] as $k=>$v){
+				if($v['receivablesBank']=='财务录入'){
+					$isFinance=true;
+					break;
+				}
+			}
+			$result [$key] ['isFinance'] =$isFinance;
 			$result [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 		}
 		

+ 2 - 0
protected/model/invoiceTraining.php

@@ -403,6 +403,8 @@ class invoiceTraining extends DooModel {
 				}
 			}
 		}
+		$detail ['invoiceCompanyAmountM']=sprintf ( "%.2f", $detail ['invoiceCompanyAmount'] );
+		$detail ['invoiceArriveAmountM']=sprintf ( "%.2f", $detail ['invoiceArriveAmount'] );
 		//echo var_dump($detail ['invoiceTotalAmount'] ) ;
 		//print_r($detail);
 		return $detail;

+ 108 - 4
protected/view/admin/invoiceAdd.html

@@ -4,6 +4,11 @@
 <script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/zh-CN.js"></script>
 <script src="<?= invoiceValidator ?>"></script>
 
+<link rel="stylesheet" href="<?= WEB_SITE_GLOBAL ?>/js/jquery-ui.css" />
+<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery-ui.js"></script>
+
+<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery.ui.autocomplete.js"></script>
+
 <script>
 $(function() {
 	
@@ -127,6 +132,105 @@ $('button[invoiceDetalfn]').click(function() {
 });
 
 
+$("input[autoIFBTitle]").autocomplete({
+    source: function( request, response ) {
+        $.ajax({
+            url: "/autoFillInIFB",
+            dataType: "json",
+            data:{
+            	fill: request.term,
+            	fillType:'TITLE'
+            },
+            success: function( data ) {
+                response( $.map( data, function( item ) {
+                	
+                    return {
+                    	value: item.invoiceTitle,
+                    	
+                    	invoiceTitle:item.invoiceTitle,
+                    	TIN:item.TIN,
+                    	
+                    	address:item.address,
+                    	phone:item.phone,
+                    	bank:item.bank,
+                    	bankAccount:item.bankAccount
+//                        name:item.clientname+"-"+item.companyname,
+//                        value: item.clientname+"-"+item.companyname
+                    }
+                }));
+            }
+        });
+    },
+    minLength: 1,
+    select: function( event, ui ) {
+    	var invoiceType=$('input[name="invoiceType"]:checked').val();
+    	if(invoiceType==0){
+    		$("#TINT").val(ui.item.TIN);
+        	$("#addressT").val(ui.item.address);
+        	$("#phoneT").val(ui.item.phone);
+        	$("#bankT").val(ui.item.bank);
+            $("#bankAccountT").val(ui.item.bankAccount);
+    	}else{
+    		$("#TIN").val(ui.item.TIN);
+        	$("#address").val(ui.item.address);
+        	$("#phone").val(ui.item.phone);
+        	$("#bank").val(ui.item.bank);
+            $("#bankAccount").val(ui.item.bankAccount);
+    	}
+    	
+        
+    }
+});
+$("input[autoIFBTIN]").autocomplete({
+    source: function( request, response ) {
+        $.ajax({
+            url: "/autoFillInIFB",
+            dataType: "json",
+            data:{
+            	fill: request.term,
+            	fillType:'TIN'
+            },
+            success: function( data ) {
+                response( $.map( data, function( item ) {
+                	
+                    return {
+                    	value: item.TIN,
+                    	
+                    	invoiceTitle:item.invoiceTitle,
+                    	TIN:item.TIN,
+                    	
+                    	address:item.address,
+                    	phone:item.phone,
+                    	bank:item.bank,
+                    	bankAccount:item.bankAccount
+//                        name:item.clientname+"-"+item.companyname,
+//                        value: item.clientname+"-"+item.companyname
+                    }
+                }));
+            }
+        });
+    },
+    minLength: 1,
+    select: function( event, ui ) {
+    	var invoiceType=$('input[name="invoiceType"]:checked').val();
+    	if(invoiceType==0){
+    		$("#invoiceTitle").val(ui.item.invoiceTitle);
+        	$("#addressT").val(ui.item.address);
+        	$("#phoneT").val(ui.item.phone);
+        	$("#bankT").val(ui.item.bank);
+            $("#bankAccountT").val(ui.item.bankAccount);
+    	}else{
+    		$("#invoiceCompany").val(ui.item.invoiceTitle);
+        	$("#address").val(ui.item.address);
+        	$("#phone").val(ui.item.phone);
+        	$("#bank").val(ui.item.bank);
+            $("#bankAccount").val(ui.item.bankAccount);
+    	}
+    }
+});
+
+
+
 })
 
 </script>
@@ -235,10 +339,10 @@ $('button[invoiceDetalfn]').click(function() {
 								<tr>
 									<th class="taC" width="150"><span class="colRed">*</span>发票抬头</th>
 									<td >
-									<input type="text" name="invoiceTitle" id="invoiceTitle"  value="" >
+									<input type="text" name="invoiceTitle" id="invoiceTitle" autoIFBTitle value="" >
 									</td>
 									<th class="taC" width="150"><span class="colRed"></span>纳税人识别码</th>
-									<td><input type="text" name="TINT" id="TINT"></td>
+									<td><input type="text" name="TINT" id="TINT" autoIFBTIN ></td>
 								</tr>
 								
 								<tr>
@@ -264,9 +368,9 @@ $('button[invoiceDetalfn]').click(function() {
 								</tr>
 								<tr>
 									<th class="taC" width="150"><span class="colRed">*</span>单位名称</th>
-									<td><input type="text" name="invoiceCompany" id="invoiceCompany"></td>
+									<td><input type="text" name="invoiceCompany" autoIFBTitle id="invoiceCompany"></td>
 									<th class="taC" width="150"><span class="colRed">*</span>纳税人识别码</th>
-									<td><input type="text" name="TIN" id="TIN"></td>
+									<td><input type="text" name="TIN" autoIFBTIN id="TIN"></td>
 
 								</tr>
 								<tr>

+ 34 - 1
protected/view/admin/saea_create.html

@@ -3,7 +3,29 @@
 <script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/jquery.validator.min.js"></script>
 <script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/zh-CN.js"></script>
  <script src="<?= WEB_SITE_GLOBAL ?>js/receipt.js"></script>
-
+ <script >
+ $(function() {
+ 
+	 $("input[id^='inttrain_']").change(function() {
+			
+			$i=0;
+			$("input[id^='inttrain_']").each(function(i){
+				$i+=parseFloat(this.value);
+				
+			 });
+			$("#inttrainResult").html("¥"+$i.toFixed(2));
+			$("#inttrainR").val($i.toFixed(2));
+			
+			var agencyR=$("#agencyR").val();
+			var otherR=parseFloat($("#otherR").val());
+			var travelR=parseFloat($("#travelR").val());
+			var RS=parseFloat($i)+parseFloat(agencyR)+travelR+otherR;
+			
+			$("#RS").html("¥"+RS.toFixed(2));
+		});
+	 
+ })
+ </script>
  
  
 <body>
@@ -63,6 +85,17 @@
 	  						<tr><th class="taR">合计</th><td class="colGreen taR" id="travelResult">¥0.00</td></tr>
 	  						
 	  						
+	  						<tr><th colspan="2" class="taC">内部培训费用</th></tr>
+	  						<!-- loop acItem -->
+		  						<!-- if {{acItem' value.category}} =="内部培训费用" -->
+	  						<tr>
+	  						<th>{{acItem' value.name}}</th>
+	  						<td  width="200" class="taR">¥<input type="number" id="inttrain_{{acItem' value.aid}}" name="inttrain[]" value="0" placeholder="输入{{acItem' value.name}}" pattern="[0-9]" step="0.01" min="0" class="span2"></td>
+	  						</tr>
+	  							<!-- endif -->
+	  						<!-- endloop -->
+	  						<tr><th class="taR">合计</th><td class="colGreen taR" id="inttrainResult">¥0.00</td></tr>
+	  						
 	  						
 	  						
 	  						<tr><th colspan="2" class="taC">其他</th></tr>