浏览代码

培训班结算

caipin 6 年之前
父节点
当前提交
605131d6a1

+ 5 - 1
global/js/invoice.validator.js

@@ -65,6 +65,9 @@ $(function () {
 	        ,isMail: function() {
 	        	return $('#isMail').prop('checked');
 	        }
+	        ,isSettlementType: function() {console.log('ddd');
+	        	return $('#settlementType').prop('checked');
+	        }
 	    },
 	    fields: {//tel(invoiceCompany);digits(invoiceCompany)  
 	    	invoiceTitle: 'required(invoiceTitle);',
@@ -77,7 +80,8 @@ $(function () {
 	    	//invoicePrice: 'required; '
 	    	,invoiceQuantity: 'required; '
 	    	,invoiceUnitPrice: 'required; '
-	    		
+	    	
+	    	,trainId:'required(isSettlementType); '
 		    ,invoiceElement: 'required; '
 		    ,invoiceType: 'required'
 			,recipients: 'required(isMail); '

+ 50 - 0
global/js/receipt.js

@@ -511,7 +511,57 @@ $(function() {
 		}
 	});
 	
+	//培训班结算
+	$("form[name='receiptTrainAdd']").validator({
+		timely: 3,
+	    focusCleanup: true,
+	    theme:"yellow_top",
+	    rules: {
+	    	remittanceBankType: function() {
+	    		var rbt=$('select[node-rbt]').val();
+	    		if(rbt==0)
+	    			return false;
+	    		return true;
+	        }
+	    },
+	    fields: {
+	        'verify': 'required; ',
+	        'explanation':'required; ',
+	        
+	        'remittanceName':'required; ',
+	        'bankName':'required; ',
+	        'bankNumber':'required; ',
+	        'coupletNumber':'required(remittanceBankType); ',
+	        
+	        'trainName':'required; ',
+	        'trainStartDate':'required; ',
+	        'trainEndDate':'required; ',
+	        'participants':'required; ',
+	        'trainAddress':'required; ',
+	    }
+	});
 
+	$("a[getReceiptLoan]").click(function() {
+		$.ajax({
+			url:"/ajaxGetReceiptTrainLoan",
+			type: "post",
+			cache: false,
+			dataType: "json",
+			data: {
+				
+			},
+			global: true,
+			success: function(data){
+				var html='';
+				for(var i=0;i<data.receiptLoanList.length;i++){
+					html +='<option value="'+data.receiptLoanList[i].ridKey+'">'+data.receiptLoanList[i].receiptOrder+' ¥'+data.receiptLoanList[i].sum+'</option>';
+				}
+				$("select[receiptLoanSelect]").html(html);
+			},
+			error:function(err){}
+			});
+	});
+	
 })
 
 function selectToolTipCl(name){

+ 270 - 20
protected/class/receipt.func.php

@@ -1,4 +1,152 @@
 <?php
+/**
+ * 获得借款单详情
+ */
+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 );
+	
+	$html = '<div class="saeaList">
+							<div class="entry loan-list" style="margin-bottom: 50px">
+								<div class="seal"></div>
+								<div class="seTable">
+									<table class="table table-bordered table-condensed table-hover">
+										<tbody>
+											<tr>
+												<th colspan="2" class="taC">借款费用</th>
+											</tr>
+											<tr>
+												<th>借款费用</th>
+												<td class="taR" width="140">¥' . $receiptDetail ['loanItem'] ['借款费用'] [0] ['price'] . '</td>
+											</tr>
+											
+											<tr>
+												<th class="taC" colspan="2">产生费用所在办事处</th>
+											</tr>
+											<tr>
+												<th style="text-align: center" colspan="2">' . $receiptDetail ['category'] [0] ['title'] . '</th>
+											</tr>
+											<tr>
+												<th colspan="2" class="taC">汇款信息</th>
+											</tr>
+											<tr>
+												<th>汇款人户名</th>
+												<td>' . $receiptDetail ['remittanceName'] . '</td>
+											</tr>
+											<tr>
+												<th>汇款银行</th>';
+	
+	if ($receiptDetail ['remittanceBankType'] == 0)
+		$html .= '<td>广发银行</td>';
+	elseif ($receiptDetail ['remittanceBankType'] == 1)
+		$html .= '<td>其他</td>';
+	
+	$html .= '</tr>
+											<tr>
+												<th>汇款开户银行名称</th>
+												<td>' . $receiptDetail ['bankName'] . '</td>
+											</tr>
+											<tr>
+												<th>汇款帐号</th>
+												<td>' . $receiptDetail ['bankNumber'] . '</td>
+											</tr>';
+	if ($receiptDetail ['remittanceBankType'] == 1)
+		$html .= '<tr>
+												<th>联行号</th>
+												<td>' . $receiptDetail ['coupletNumber'] . '</td>
+											</tr>';
+	
+	$html .= '<tr>
+												<th class="taC" colspan="2">费用说明</th>
+											</tr>
+											<tr>
+												<td colspan="2">' . $receiptDetail ['explanation'] . '</td>
+											</tr>
+											
+											<tr class="warning">
+												<td class="taR"><b>(' . $receiptDetail ['receiptOrder'] . ')本次费用合计</b></td>
+												<td class="taR"><b style="font-size: 24px">¥' . $receiptDetail ['sum'] . '</b><br>' . $receiptDetail ['sumCN'] . '</td>
+											</tr>
+											<tr class="warning">
+												<td class="taR"><b>汇款金额</b></td>
+												<td class="taR" width="140"><b style="font-size: 24px">¥' . $receiptDetail ['amount'] . '</b><br>' . $receiptDetail ['amountCN'] . '</td>
+											</tr>
+										</tbody>
+									</table>
+								</div>
+								<div class="seCensor loan-censor">
+									<div class="title">' . $receiptDetail ['receiptOrder'] . '</div>
+									<div class="censorList clearfix censorHeight" style="height: 548px;">
+										<ul>
+											<li class="post">
+												<div class="avtra">
+													<img src="' . $receiptDetail ['staffDetail']['avatar'] . '_2.jpg" width="32">
+												</div>
+												<div class="comment">
+													<p>
+														<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.='>
+												<div class="avtra">
+													<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>
+												</div>
+											</li>';
+											}
+											
+											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">
+												</div>
+												<div class="comment">
+													<p class="colGray">
+														<span class="fR">'.$value['date'].'</span>'.$value[1].'(费用执行)
+													</p>
+													<p>'.$value['opinion'].'</p>
+												</div>
+											</li>';
+											}
+										$html.='
+										</ul>
+									</div>
+								</div>
+							</div>
+												
+							'.$extendHtml.'
+							
+			</div>';
+	return $html;
+}
 function _getPaymentsCollectPayByYearHtml($statisticsPay = array()) {
 	$html = '';
 	$subtotalSum = array (
@@ -162,7 +310,7 @@ function _getPaymentsCollectPayByYearHtml($statisticsPay = array()) {
 			else
 				$html .= '<td class="taR colRed">¥' . $sum . '</td>';
 			$html .= '</tr>';
-		}elseif ($i == 5) {
+		} elseif ($i == 5) {
 			
 			$html .= '<tr><th colspan="2" >保证金</th>';
 			$sum = 0;
@@ -170,9 +318,9 @@ function _getPaymentsCollectPayByYearHtml($statisticsPay = array()) {
 				$falg = true;
 				foreach ( $statisticsPay as $key => $value ) {
 					if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
-						$html .= '<td class="taR">¥' . abs($value ['payPrice']) . '</td>';
-						$sum += abs($value ['payPrice']);
-						$subtotalSum [$month] += abs($value ['payPrice']);
+						$html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
+						$sum += abs ( $value ['payPrice'] );
+						$subtotalSum [$month] += abs ( $value ['payPrice'] );
 						$falg = false;
 						break;
 					}
@@ -202,7 +350,10 @@ function _getPaymentsCollectPayByYearHtml($statisticsPay = array()) {
 	$html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
 	  						<td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
 	
-	return array('html'=>$html,'sum'=>$sum);
+	return array (
+			'html' => $html,
+			'sum' => $sum 
+	);
 }
 
 /**
@@ -306,10 +457,9 @@ function _getPaymentsCollectByYearHtml($statisticsIncome = array()) {
 			}
 			if ($sum == 0)
 				$html .= '<td class="taR">-</td>';
-				else
-					$html .= '<td class="taR">¥' . $sum . '</td>';
-					$html .= '</tr>';
-			
+			else
+				$html .= '<td class="taR">¥' . $sum . '</td>';
+			$html .= '</tr>';
 			
 			$html .= '<th width="90">个人借款</th>';
 			$sum = 0;
@@ -615,7 +765,10 @@ function _getPaymentsCollectByYearHtml($statisticsIncome = array()) {
 	$html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
 	  						<td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
 	
-	return array('html'=>$html,'sum'=>$sum);
+	return array (
+			'html' => $html,
+			'sum' => $sum 
+	);
 }
 
 /**
@@ -940,7 +1093,7 @@ function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
 			else
 				$html .= '<td class="taR colGreen">¥' . $sum . '</td>';
 			$html .= '</tr>';
-		}elseif ($i == 8) {
+		} elseif ($i == 8) {
 			
 			$html .= '<tr><th colspan="2" >保证金</th>';
 			
@@ -965,7 +1118,6 @@ function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
 				$html .= '<td class="taR colGreen">¥' . $sum . '</td>';
 			$html .= '</tr>';
 		}
-		
 	}
 	
 	$html .= '<tr><th class="taR" colspan="2">合计</th>';
@@ -983,7 +1135,10 @@ function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
 	$html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
 	  						<td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
 	
-	return array('html'=>$html,'sum'=>$sum);
+	return array (
+			'html' => $html,
+			'sum' => $sum 
+	);
 }
 function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
 	$html = '<tr><th class="taC" colspan="2">日常支出</th>';
@@ -1044,7 +1199,7 @@ function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
 			$html .= '</tr>';
 		} elseif ($i == 3) {
 			
-		for($d = 1; $d <= $day; $d ++) {
+			for($d = 1; $d <= $day; $d ++) {
 				$subtotal [$d] = 0;
 			}
 			$html .= '<tr><th rowspan="4" width="90">缴税</th>';
@@ -1130,7 +1285,7 @@ function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
 			else
 				$html .= '<td class="taR colRed">¥' . $sum . '</td>';
 			$html .= '</tr>';
-		}elseif ($i == 5) {
+		} elseif ($i == 5) {
 			
 			$html .= '<tr><th colspan="2" >保证金</th>';
 			$sum = 0;
@@ -1138,9 +1293,9 @@ function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
 				$falg = true;
 				foreach ( $statisticsPay as $key => $value ) {
 					if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
-						$html .= '<td class="taR">¥' . abs($value ['payPrice']) . '</td>';
-						$sum += abs($value ['payPrice']);
-						$subtotalSum [$month] += abs($value ['payPrice']);
+						$html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
+						$sum += abs ( $value ['payPrice'] );
+						$subtotalSum [$month] += abs ( $value ['payPrice'] );
 						$falg = false;
 						break;
 					}
@@ -1169,9 +1324,104 @@ function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
 	$html .= '</tr>';
 	$colspan = $day + 1;
 	$html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
-	  						<td class="colGreed taR" colspan="'.$colspan.'"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
+	  						<td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
 	
-	return array('html'=>$html,'sum'=>$sum);
+	return array (
+			'html' => $html,
+			'sum' => $sum 
+	);
+}
+
+function getExecuteStaff($receiptDetail){
+	// 费用执行人相关数据
+	$executeCopy = json_decode ( $receiptDetail ['executeCopy'], true );
+	$executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );
+	foreach ( $executeCopy as $k => $v ) {
+		$executeCopy [$k] ['date'] = '';
+		$executeCopy [$k] ['opinion'] = '';
+		$executeCopy [$k] ['status'] = '';
+		if (! empty ( $executeStaff ))
+			foreach ( $executeStaff as $m => $u ) {
+				if ($v [0] == $m) {
+					$executeCopy [$k] ['date'] = $u ['date'];
+					$executeCopy [$k] ['opinion'] = $u ['opinion'];
+					$executeCopy [$k] ['status'] = $u ['status'];
+					break;
+				}
+			}
+	}
+	$receiptDetail ['executeCopy'] = $executeCopy;
+	return $receiptDetail['executeCopy'];
+}
+
+function num_to_rmb($num) {
+	$c1 = "零壹贰叁肆伍陆柒捌玖";
+	$c2 = "分角元拾佰仟万拾佰仟亿";
+	// 精确到分后面就不要了,所以只留两个小数位
+	$num = round ( $num, 2 );
+	// 将数字转化为整数
+	$num = $num * 100;
+	if (strlen ( $num ) > 10) {
+		return "金额太大,请检查";
+	}
+	$i = 0;
+	$c = "";
+	while ( 1 ) {
+		if ($i == 0) {
+			// 获取最后一位数字
+			$n = substr ( $num, strlen ( $num ) - 1, 1 );
+		} else {
+			$n = $num % 10;
+		}
+		// 每次将最后一位数字转化为中文
+		$p1 = substr ( $c1, 3 * $n, 3 );
+		$p2 = substr ( $c2, 3 * $i, 3 );
+		
+		if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
+			$c = $p1 . $p2 . $c;
+		} else {
+			$c = $p1 . $c;
+		}
+		$i = $i + 1;
+		// 去掉数字最后一位了
+		
+		$num = $num / 10;
+		// echo $num.'</br>';
+		$num = ( int ) $num;
+		// $num =floor($num);
+		// $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
+		// echo $num.'</br>';
+		// 结束循环
+		if ($num == 0) {
+			break;
+		}
+	}
+	// echo $c.'</br>';
+	$j = 0;
+	$slen = strlen ( $c );
+	while ( $j < $slen ) {
+		// utf8一个汉字相当3个字符
+		$m = substr ( $c, $j, 6 );
+		// 处理数字中很多0的情况,每次循环去掉一个汉字“零”
+		if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
+			$left = substr ( $c, 0, $j );
+			$right = substr ( $c, $j + 3 );
+			$c = $left . $right;
+			$j = $j - 3;
+			$slen = $slen - 3;
+		}
+		$j = $j + 3;
+	}
+	// 这个是为了去掉类似23.0中最后一个“零”字
+	if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
+		$c = substr ( $c, 0, strlen ( $c ) - 3 );
+	}
+	// 将处理的汉字加上“整”
+	if (empty ( $c )) {
+		return "零元整";
+	} else {
+		return $c . "整";
+	}
 }
 
 /**

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

@@ -432,6 +432,19 @@ $acl ['RECEIPTS'] ['allow'] = array (
 				'wasteBookIncome',
 				'wasteBookExpenditure',
 				'ajaxGetWasteInvoice',
+				'receiptTrainAdd',
+				'receiptTrainAddDo',
+				'receiptTrainEdi',
+				'receiptTrainInfoEdiDo',
+				'receiptTrainLoanEdi',
+				'receiptTrainLoanEdiDo',
+				'receiptTrainLoanRemoveDo',
+				'receiptTrainInvoiceEdi',
+		)
+);
+$acl ['RECEIPTSAJAX'] ['allow'] = array (
+		'ReceiptAjaxController' => array (
+				'ajaxGetReceiptTrainLoan',
 		)
 );
 //人资

+ 19 - 0
protected/config/routes.conf.php

@@ -224,6 +224,19 @@ $route['*']['/ajaxGetWasteInvoice'] = array('ReceiptController', 'ajaxGetWasteIn
 $route['*']['/wasteBookIncome'] = array('ReceiptController', 'wasteBookIncome');
 $route['*']['/wasteBookExpenditure'] = array('ReceiptController', 'wasteBookExpenditure');
 
+//培训班结算
+$route['*']['/receiptTrainAdd'] = array('ReceiptController', 'receiptTrainAdd');
+$route['*']['/receiptTrainAddDo'] = array('ReceiptController', 'receiptTrainAddDo');
+$route['*']['/receiptTrainEdi/:rid'] = array('ReceiptController', 'receiptTrainEdi','extension'=>'.html');
+$route['*']['/receiptTrainInfoEdiDo'] = array('ReceiptController', 'receiptTrainInfoEdiDo');
+$route['*']['/receiptTrainLoanEdi/:rid'] = array('ReceiptController', 'receiptTrainLoanEdi','extension'=>'.html');
+$route['*']['/ajaxGetReceiptTrainLoan'] = array('ReceiptAjaxController', 'ajaxGetReceiptTrainLoan');
+
+$route['*']['/receiptTrainLoanEdiDo'] = array('ReceiptController', 'receiptTrainLoanEdiDo');
+$route['*']['/receiptTrainLoanRemoveDo/:ridKey/:ridLoanKey'] = array('ReceiptController', 'receiptTrainLoanRemoveDo','extension'=>'.html');
+
+$route['*']['/receiptTrainInvoiceEdi/:rid'] = array('ReceiptController', 'receiptTrainInvoiceEdi','extension'=>'.html');
+
 
 //邮件群发
 $route['*']['/eMailTask'] = array('MainController', 'eMailTask');
@@ -272,6 +285,9 @@ $route['*']['/deleteToolTip'] = array('MainController', 'deleteToolTip');
 $route['*']['/app'] = array('MainController', 'app');
 $route['*']['/avatar'] = array('MainController', 'avatar');
 
+
+
+
 //$route['*']['/synClient'] = array('MainController', 'synClient');
 $route['*']['/ajaxExamine'] = array('ReceiptController', 'ajaxExamine');
 $route['*']['/BUGFLAG'] = array('ReceiptController', 'BUGFLAG','authName' =>  'Hello', 'auth' => array('BF390' => 'BF390'));
@@ -646,6 +662,9 @@ $route['*']['/ajaxGetPositionByPid'] = array('HumanResourceController', 'ajaxGet
 
 
 
+
+
+
 //假期管理
 $route['*']['/myList'] = array('HolidayController', 'myList');
 $route['*']['/myList/:yearnum'] = array('HolidayController', 'myList');

+ 2 - 1
protected/controller/AdminController.php

@@ -790,7 +790,8 @@ class AdminController extends DooController {
 				'借款执行人' => '',
 				'借款费用执行人' => '',
 				'报销单执行人' => '',
-				'对公汇款执行人' => '' 
+				'对公汇款执行人' => '' ,
+				'培训班结算'=>''
 		);
 		foreach ( $list as $key => $value ) {
 			$name = json_decode ( $value ['staff'] );

+ 35 - 15
protected/controller/InvoiceController.php

@@ -267,7 +267,7 @@ class InvoiceController extends DooController {
 		
 		Doo::loadModel ( 'invoiceTraining' );
 		$invoiceTraining = new invoiceTraining ();
-		$itList = $invoiceTraining->getInvoiceTrainingByUnfinished ();
+		$itList = $invoiceTraining->getInvoiceTrainingByUnfinished ($this->staff [0] ['cid']);
 		$this->data ['itList'] = $itList;
 		
 		$this->data ['memu'] = "invoice";
@@ -292,7 +292,7 @@ class InvoiceController extends DooController {
 	
 		Doo::loadModel ( 'invoiceTraining' );
 		$invoiceTraining = new invoiceTraining ();
-		$itList = $invoiceTraining->getInvoiceTrainingByUnfinished ();
+		$itList = $invoiceTraining->getInvoiceTrainingByUnfinished ($this->staff [0] ['cid']);
 		$this->data ['itList'] = $itList;
 	
 		Doo::loadModel ( 'invoice' );
@@ -378,7 +378,7 @@ class InvoiceController extends DooController {
 		 */
 		
 		if (empty ( $this->staff [0] ))
-			die ( 'illegal request' );
+			die ( 'illegal request-Please login' );
 		
 		if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $settlementType )) {
 			Doo::loadModel ( 'invoice' );
@@ -422,13 +422,14 @@ class InvoiceController extends DooController {
 			$st = '';
 			if ($settlementType == 'SOFTWARE') {
 				$st = 0;
+				$trainId=0;
 			} elseif ($settlementType == 'TRAINING') {
 				$st = 1;
+				if (empty ( $trainId )&&!is_numeric($trainId)) {
+					die ( 'illegal request-trainingIdError' );
+				}
 			} else {
-				die ( 'illegal request' );
-			}
-			if (empty ( $trainId )) {
-				die ( 'illegal request' );
+				die ( 'illegal request-settlementError' );
 			}
 			
 			$item = array (
@@ -512,15 +513,15 @@ class InvoiceController extends DooController {
 							'remittance' => '' 
 					);
 				
-				$mailString = '发票x1,备注:' . $mailItems;
+				$mailString = '发票x1,备注:' . $mailItems;
 				if (! empty ( $softLock ))
-					$mailString .= ',软件锁x' . $softLockNum;
+					$mailString .= ',软件锁x' . $softLockNum.'个';
 				if (! empty ( $contract ))
-					$mailString .= ',合同x' . $contractNum;
+					$mailString .= ',合同x' . $contractNum.'份';
 				if (! empty ( $instructions ))
-					$mailString .= ',说明书x' . $instructionsNum;
+					$mailString .= ',说明书x' . $instructionsNum.'本';
 				if (! empty ( $remittance ))
-					$mailString .= ',汇款账号单';
+					$mailString .= ',汇款账号单(张)';
 				
 				$item += array (
 						'recipients' => $recipients,
@@ -534,7 +535,7 @@ class InvoiceController extends DooController {
 			$iid = $invoice->addInvoice ( $item );
 			
 			// 如果是培训班结算 创建培训班发票到培训班备份中
-			if (! empty ( $st )) {
+			if (! empty ( $st )&&$st==1) {
 				Doo::loadModel ( 'invoiceStore' );
 				$invoiceStore = new invoiceStore ();
 				Doo::loadModel ( 'invoiceTraining' );
@@ -821,8 +822,16 @@ class InvoiceController extends DooController {
 		$category = $lCategory->getCategory ();
 		
 		$itid = array ();
-		foreach ( $itTodoList as $value ) {
+		foreach ( $itTodoList as $key=>$value ) {
 			array_push ( $itid, $value ['itid'] );
+			//如果入账100%更新为已完成
+			if ($itTodoList [$key] ['arriveSchedule']>=100){
+				$invoiceTraining = new invoiceTraining ();
+				$invoiceTraining->itid = $value ['itid'];
+				$invoiceTraining->status = 2;
+				$invoiceTraining->update ();
+			}
+			
 		}
 		foreach ( $itedList as $value ) {
 			array_push ( $itid, $value ['itid'] );
@@ -1368,6 +1377,9 @@ class InvoiceController extends DooController {
 		$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
 		$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
 		
+		if (empty($trainKey)||empty($storeKey))
+			die ( 'illegal request-IdKey' );
+		
 		$tid = $XDeode->decode ( $trainKey );
 		if (! is_numeric ( $tid ) && ! empty ( $storeKey ))
 			die ( 'illegal request' );
@@ -1544,6 +1556,9 @@ class InvoiceController extends DooController {
 		$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
 		$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
 		
+		if (empty($trainKey)||empty($storeKey))
+			die ( 'illegal request-IdKey' );
+		
 		$trainId = $XDeode->decode ( $trainKey );
 		
 		$isidKeyList = explode ( ',', $storeKey );
@@ -1631,6 +1646,7 @@ class InvoiceController extends DooController {
 				'trainId' => $trainId,
 				'invoiceManage' => $invoiceManageDetail ['staff'],
 				'moldManage' => json_encode ( $moldManage ),
+				'settlementType'=>1,
 				'pendingApprovals' => $pendingApprovalsSid 
 		);
 		$invoice = new invoice ();
@@ -1801,6 +1817,9 @@ class InvoiceController extends DooController {
 		$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
 		$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
 		
+		if (empty($trainKey)||empty($storeKey))
+			die ( 'illegal request-IdKey' );
+		
 		$isidKeyList = explode ( ',', $storeKey );
 		$isidList = array ();
 		foreach ( $isidKeyList as $value ) {
@@ -2437,7 +2456,7 @@ class InvoiceController extends DooController {
 				'previous' => '' 
 		);
 		
-		$get .= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
+		$get .= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea )."&invoiceType=".urlencode ( $invoiceType )."&invoiceTrain=".urlencode ( $invoiceTrain )."";
 		
 		$sql = " (untreadStatus=0 or untreadStatus=3) and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
 		$action = "invoicePrintStayAchieve";
@@ -2458,6 +2477,7 @@ class InvoiceController extends DooController {
 		$this->data ['page'] = $pageinfo;
 		$this->data ['date'] = $date;
 		$this->data ['status'] = $status;
+		$this->data ['invoiceType'] = $invoiceType;
 		
 		$this->data ['memu'] = "invoice";
 		$this->data ['staff'] = $this->staff;

+ 478 - 87
protected/controller/ReceiptController.php

@@ -2086,6 +2086,407 @@ class ReceiptController extends DooController {
 		
 		$this->render ( "/admin/saeaLoanEdiReceipt", $data );
 	}
+	
+	/**
+	 * 培训班结算
+	 */
+	function receiptTrainAdd() {
+		Doo::loadModel ( 'accountItem' );
+		$accountItem = new accountItem ();
+		
+		$acItem = $accountItem->find ( array (
+				'asArray' => true 
+		) );
+		
+		// 审批组
+		Doo::loadModel ( 'verify' );
+		$verify = new verify ();
+		$veList = $verify->getVerifyByAll ();
+		// 办事处
+		Doo::loadModel ( 'L_category' );
+		$lCategory = new L_category ();
+		$data ['category'] = $lCategory->getCategory ();
+		$data ['veList'] = $veList;
+		$data ['memu'] = "receipt";
+		$data ['staff'] = $this->staff;
+		
+		$data ['acItem'] = $acItem;
+		
+		$data ['receiptMemu'] = 'saeaBorad';
+		$data ['verifyId'] = $this->verifyId;
+		$data ['executeId'] = $this->executeId;
+		
+		$this->render ( "/receipt/receiptTrainAdd", $data );
+	}
+	
+	/**
+	 * 添加培训班结算
+	 */
+	function receiptTrainAddDo() {
+		// 培训班信息
+		$trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
+		$trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
+		$trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
+		$participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
+		$trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
+		$trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
+		// 发票信息
+		$verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
+		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
+		$remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
+		$bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
+		$bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
+		$coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
+		$remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
+		
+		if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
+			
+			if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
+				header ( 'Content-Type:text/html;charset=utf-8' );
+				die ( '请填写联行号' );
+			}
+			Doo::loadModel ( 'execute' );
+			$execute = new execute ();
+			$executeDetail = $execute->getOne ( array (
+					'where' => 'mold="培训班结算"',
+					'asArray' => true 
+			) );
+			if (empty ( $executeDetail )) {
+				header ( 'Content-Type:text/html;charset=utf-8' );
+				die ( '未设置执行人' );
+			}
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			$cid = $XDeode->decode ( $cid );
+			
+			Doo::loadModel ( 'receipt' );
+			$receipt = new receipt ();
+			Doo::loadModel ( 'receiptTraining' );
+			$receiptTraining = new receiptTraining ();
+			
+			// 创建费用培训班
+			$item = array (
+					'cid' => $this->staff [0] ['cid'],
+					'categoryName' => $this->staff [0] ['category'],
+					'trainName' => $trainName,
+					'trainStartDate' => $trainStartDate,
+					'trainEndDate' => $trainEndDate,
+					'participants' => $participants,
+					'trainAddress' => $trainAddress,
+					'trainRemarks' => $trainRemarks,
+					'creator' => $this->staff [0] ['sid'],
+					'creatorDate' => date ( "Y-m-d H:i:s" ) 
+			);
+			$irid = $receiptTraining->addReceiptTraining ( $item );
+			
+			// 报销单
+			$receipt->status = 5;
+			$receipt->trainId = $irid;
+			$receipt->Rtype = 3;
+			$receipt->staff = $this->staff [0] ['sid'];
+			$receipt->cid = $cid;
+			$receipt->verify = $verify;
+			$receipt->date = date ( "Y-m-d" );
+			
+			$receipt->executeCopy = $executeDetail ['staff'];
+			$receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
+			
+			$receipt->remittanceName = $remittanceName;
+			$receipt->bankName = $bankName;
+			$receipt->bankNumber = $bankNumber;
+			$receipt->remittanceBankType = $remittanceBankType;
+			if ($remittanceBankType == 1)
+				$receipt->coupletNumber = $coupletNumber;
+			
+			$rid = $receipt->insert ();
+			$XDeode = new XDeode ( 7 );
+			return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
+		} else
+			die ( 'illegal request' );
+	}
+	
+	/**
+	 * 培训班编辑
+	 */
+	function receiptTrainEdi() {
+		$ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
+		$trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 7 );
+		$rid = $XDeode->decode ( $ridKey );
+		
+		if (! is_numeric ( $rid ))
+			die ( 'illegal request' );
+		
+		Doo::loadModel ( 'receipt' );
+		$receipt = new receipt ();
+		Doo::loadModel ( 'receiptTraining' );
+		$receiptTraining = new receiptTraining ();
+		
+		$receiptDetail = $receipt->getReceiptByRid ( $rid );
+		if ($receiptDetail ['status'] != 5)
+			die ();
+		
+		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
+		
+		// 审批组
+		Doo::loadModel ( 'verify' );
+		$verify = new verify ();
+		$veList = $verify->getVerifyByAll ();
+		
+		// 办事处
+		Doo::loadModel ( 'L_category' );
+		$lCategory = new L_category ();
+		$data ['category'] = $lCategory->getCategory ();
+		
+		$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
+		$data ['receiptDetail'] = $receiptDetail;
+		$data ['veList'] = $veList;
+		$data ['trainEdiType'] = $trainEdiType;
+		$data ['ridKey'] = $ridKey;
+		
+		$data ['memu'] = "receipt";
+		$data ['staff'] = $this->staff;
+		
+		$data ['receiptMemu'] = 'saeaBorad';
+		$data ['verifyId'] = $this->verifyId;
+		$data ['executeId'] = $this->executeId;
+		
+		$this->render ( "/receipt/receiptTrainEdi", $data );
+	}
+	
+	/**
+	 * 培训班借款编辑
+	 */
+	function receiptTrainLoanEdi() {
+		$ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 7 );
+		$rid = $XDeode->decode ( $ridKey );
+		
+		if (! is_numeric ( $rid ))
+			die ( 'illegal request' );
+		
+		Doo::loadModel ( 'receipt' );
+		$receipt = new receipt ();
+		Doo::loadModel ( 'receiptTraining' );
+		$receiptTraining = new receiptTraining ();
+		Doo::loadModel ( 'verify' );
+		$verify = new verify ();
+		
+		$receiptDetail = $receipt->getReceiptByRid ( $rid );
+		if ($receiptDetail ['status'] != 5)
+			die ();
+		
+		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
+		
+		//借款详情HTML
+		//获得借款信息
+		$receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail['trainLoanRid'] );
+		//获得某费用单审批信息
+		$verifylist=$verify->getVerifyByRid($receiptDetail['trainLoanRid']);
+		Doo::loadClass ( 'receipt.func' );
+		$extendHtml='<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
+		$receiptLoanHtml=_getReceiptLoanHtml($receiptLoanDetail,$verifylist,$extendHtml);
+		
+		$data ['receiptLoanHtml'] = $receiptLoanHtml;
+		$data ['receiptTrainingDetail'] = $receiptTrainingDetail;
+		$data ['receiptDetail'] = $receiptDetail;
+		$data ['trainEdiType'] = "LOAN";
+		$data ['ridKey'] = $ridKey;
+		$data ['memu'] = "receipt";
+		$data ['staff'] = $this->staff;
+		
+		$data ['receiptMemu'] = 'saeaBorad';
+		$data ['verifyId'] = $this->verifyId;
+		$data ['executeId'] = $this->executeId;
+		
+		$this->render ( "/receipt/receiptTrainLoanEdi", $data );
+	}
+	
+	/**
+	 * 更新培训班结算基本信息
+	 */
+	function receiptTrainInfoEdiDo() {
+		$rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
+		$rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
+		
+		// 培训班信息
+		$trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
+		$trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
+		$trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
+		$participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
+		$trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
+		$trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
+		// 发票信息
+		$verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
+		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
+		$remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
+		$bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
+		$bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
+		$coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
+		$remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
+		
+		if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
+			
+			if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
+				header ( 'Content-Type:text/html;charset=utf-8' );
+				die ( '请填写联行号' );
+			}
+			
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			$cid = $XDeode->decode ( $cid );
+			$rtid = $XDeode->decode ( $rtid );
+			$rid = $XDeode->decode ( $rid );
+			
+			if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
+				die ( 'illegal request-IdError' );
+			}
+			
+			Doo::loadModel ( 'receipt' );
+			$receipt = new receipt ();
+			Doo::loadModel ( 'receiptTraining' );
+			$receiptTraining = new receiptTraining ();
+			
+			// 更新费用培训班
+			$item = array (
+					'rtid' => $rtid,
+					'trainName' => $trainName,
+					'trainStartDate' => $trainStartDate,
+					'trainEndDate' => $trainEndDate,
+					'participants' => $participants,
+					'trainAddress' => $trainAddress,
+					'trainRemarks' => $trainRemarks 
+			);
+			$irid = $receiptTraining->setReceiptTrainByCondition ( $item );
+			
+			// 报销单
+			$receipt->rid = $rid;
+			$receipt->cid = $cid;
+			$receipt->verify = $verify;
+			
+			$receipt->remittanceName = $remittanceName;
+			$receipt->bankName = $bankName;
+			$receipt->bankNumber = $bankNumber;
+			$receipt->remittanceBankType = $remittanceBankType;
+			if ($remittanceBankType == 1)
+				$receipt->coupletNumber = $coupletNumber;
+			
+			$receipt->update ();
+			$XDeode = new XDeode ( 7 );
+			return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
+		} else
+			die ( 'illegal request' );
+	}
+	
+	/**
+	 * 编辑培训班结算借款
+	 */
+	function receiptTrainLoanEdiDo() {
+		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
+		$ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
+		if(!empty($ridKey)&&!empty($ridLoanKey)){
+			Doo::loadModel ( 'receipt' );
+			$receipt = new receipt ();
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$rid=$XDeode->decode ( $ridKey );
+			$ridLoan=$XDeode->decode ( $ridLoanKey );
+			if (!is_numeric($rid)||!is_numeric($ridLoan))
+				die ( 'illegal request-ridError' );
+			
+			$receiptDetail=$receipt->getReceiptByRid($rid);
+			$receiptLoanDetail=$receipt->getReceiptByRid($ridLoan);
+			//不合法的数据
+			if ($receiptDetail['status']!=3&&$receiptDetail['Rtype']!=3){
+				die ( 'illegal request-receiptError' );
+			}
+			if ($receiptLoanDetail['status']!=8&&$receiptLoanDetail['Rtype']!=1){
+				die ( 'illegal request-receipLoantError' );
+			}
+			//培训班结算挂钩借款
+			$receipt = new receipt ();
+			$item=array(
+					'rid'=>$rid,
+					'trainLoanRid'=>$ridLoan,
+			);
+			$receipt->setReceiptByCondition($item);
+			//更新借款状态变成已挂钩
+			$receipt = new receipt ();
+			$item=array(
+					'rid'=>$ridLoan,
+					'status'=>10,
+					'statusTrain'=>1
+			);
+			$receipt->setReceiptByCondition($item);
+			
+			$XDeode = new XDeode ( 7 );
+			return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
+		}else 
+			die ( 'illegal request' );
+	}
+	
+	/**
+	 * 移除挂钩的费用借款
+	 */
+	function receiptTrainLoanRemoveDo(){
+		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
+		$ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
+		
+		if (!empty($ridKey)||!empty($ridLoanKey)){
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$rid=$XDeode->decode ( $ridKey );
+			$ridLoan=$XDeode->decode ( $ridLoanKey );
+			echo $rid;
+			echo $ridLoan;
+		}
+		
+	}
+	
+	/**
+	 * 培训班结算挂钩发票
+	 */
+	function receiptTrainInvoiceEdi(){
+		$ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 7 );
+		$rid = $XDeode->decode ( $ridKey );
+		
+		if (! is_numeric ( $rid ))
+			die ( 'illegal request' );
+		
+			Doo::loadModel ( 'receipt' );
+			$receipt = new receipt ();
+			Doo::loadModel ( 'receiptTraining' );
+			$receiptTraining = new receiptTraining ();
+			
+		
+			$receiptDetail = $receipt->getReceiptByRid ( $rid );
+			if ($receiptDetail ['status'] != 5)
+				die ();
+		
+			$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
+		
+		$data ['receiptDetail'] = $receiptDetail;
+		$data ['trainEdiType'] = "INVOICE";
+		$data ['ridKey'] = $ridKey;
+		$data ['memu'] = "receipt";
+		$data ['staff'] = $this->staff;
+		
+		$data ['receiptMemu'] = 'saeaBorad';
+		$data ['verifyId'] = $this->verifyId;
+		$data ['executeId'] = $this->executeId;
+		
+		$this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
+	}
+	
 	function confirmation() {
 		$rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
 		
@@ -2737,7 +3138,7 @@ class ReceiptController extends DooController {
 		if (empty ( $status ))
 			$status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
 		
-		$page_size = 12;
+		$page_size = 2;
 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 		
 		$vidList = array ();
@@ -2950,9 +3351,9 @@ class ReceiptController extends DooController {
 		$mothHtml = "";
 		for($i = 1; $i <= 12; $i ++) {
 			if ($month == $i)
-				$mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
+				$mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
 			else
-				$mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
+				$mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
 		}
 		$data ['mothHtml'] = $mothHtml;
 		
@@ -2976,6 +3377,7 @@ class ReceiptController extends DooController {
 		$data ['receiptApprovalCount'] = count ( $rLRes );
 		$data ['status'] = $status;
 		$data ['year'] = $year;
+		$data ['month'] = $month;
 		$data ['categoryList'] = $categoryList;
 		$data ['staffList'] = $staffList;
 		$data ['cid'] = $cid;
@@ -4815,7 +5217,7 @@ class ReceiptController extends DooController {
 			
 			$abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
 			// 银行
-			if (empty ( $abDetail )&&!empty($amount)) {
+			if (empty ( $abDetail ) && ! empty ( $amount )) {
 				$item = array (
 						'dataID' => $rid,
 						'expensesType' => 2,
@@ -10137,11 +10539,10 @@ class ReceiptController extends DooController {
 	 * 日常收支
 	 */
 	function payments() {
-		//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
-		
+		// include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
 		Doo::loadModel ( "execute" );
 		$execute = new execute ();
-		if(!$execute->isPaymentsShow($this->staff [0] ['sid'])){
+		if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
 			die ( 'illegal request' );
 		}
 		
@@ -10301,13 +10702,12 @@ class ReceiptController extends DooController {
 						'name' => $this->staff [0] ['username'],
 						'sid' => $this->staff [0] ['sid'],
 						'inputDate' => date ( "Y-m-d H:i:s" ) 
-				)
-				;
+				);
 				$wasteBook->setAccountBookStatistics ( $itemWaste );
-			}elseif($accountType == 1){
+			} elseif ($accountType == 1) {
 				if ($receivedBank == '个人广发')
 					die ( 'illegal request' );
-				// 添加一条收入
+					// 添加一条收入
 				$accountBook = new accountBook ();
 				$accountBook->accountType = $accountType;
 				$accountBook->accountMsg = $accountMsg;
@@ -10330,30 +10730,31 @@ class ReceiptController extends DooController {
 						'accountType' => $abDetail ['accountType'],
 						'accountMsg' => $abDetail ['accountMsg'],
 						'aid' => $abDetail ['aid'],
-						'expensesType' => $abDetail ['expensesType']
+						'expensesType' => $abDetail ['expensesType'] 
 				);
 				if ($abDetail ['accountType'] == 8) {
 					$item += array (
-							'inComePrice' => $abDetail ['receivedPrice']
+							'inComePrice' => $abDetail ['receivedPrice'] 
 					);
 				} else {
 					$item += array (
-							'inComePrice' => $abDetail ['receivedPrice']
+							'inComePrice' => $abDetail ['receivedPrice'] 
 					);
 				}
 				$accountBookStatistics->setAccountBookStatistics ( $item );
 				
-				//流水存储方向
+				// 流水存储方向
 				$itemWaste = array (
-						'accountType' => 6, // 流水类型
-				);
-// 				if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
-						
-// 				}else
-				if($accountMsg=='活期理财收益'){
+						'accountType' => 6 
+				); // 流水类型
+				   
+				// if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
+				   
+				// }else
+				if ($accountMsg == '活期理财收益') {
 					$itemWaste = array (
-							'accountType' => 10, // 流水类型
-					);
+							'accountType' => 10 
+					); // 流水类型
 				}
 				// 添加收入流水
 				
@@ -10370,13 +10771,11 @@ class ReceiptController extends DooController {
 						'cid' => $this->staff [0] ['cid'],
 						'name' => $this->staff [0] ['username'],
 						'sid' => $this->staff [0] ['sid'],
-						'inputDate' => date ( "Y-m-d H:i:s" )
+						'inputDate' => date ( "Y-m-d H:i:s" ) 
 				);
 				$wasteBook->setAccountBookStatistics ( $itemWaste );
-				
-				
 			} else { // 普通日常收入处理
-			    // 添加一条收入
+			         // 添加一条收入
 				$accountBook = new accountBook ();
 				$accountBook->accountType = $accountType;
 				$accountBook->accountMsg = $accountMsg;
@@ -10633,8 +11032,7 @@ class ReceiptController extends DooController {
 						'name' => $this->staff [0] ['username'],
 						'sid' => $this->staff [0] ['sid'],
 						'inputDate' => date ( "Y-m-d H:i:s" ) 
-				)
-				;
+				);
 				$wasteBook->setAccountBookStatistics ( $itemWaste );
 			}
 		}
@@ -11280,11 +11678,10 @@ class ReceiptController extends DooController {
 			
 			$abDetail = $accountBook->getAccountBookByAid ( $aid );
 			
-			if(empty($abDetail))
+			if (empty ( $abDetail ))
 				die ( 'illegal request' );
-			
-			
-			// 删除收支
+				
+				// 删除收支
 			Doo::loadModel ( "accountBookStatistics" );
 			$accountBookStatistics = new accountBookStatistics ();
 			$item = array (
@@ -11292,10 +11689,9 @@ class ReceiptController extends DooController {
 					'aid' => $abDetail ['aid'] 
 			);
 			
-			
-			$accountType='';
+			$accountType = '';
 			if ($abDetail ['expensesType'] == 1) {
-				$accountType=6;
+				$accountType = 6;
 				
 				if ($abDetail ['accountType'] != 7) {
 					$item += array (
@@ -11309,7 +11705,7 @@ class ReceiptController extends DooController {
 					);
 				}
 			} elseif ($abDetail ['expensesType'] == 2) {
-				$accountType=5;
+				$accountType = 5;
 				if ($abDetail ['accountType'] != 7) {
 					$item += array (
 							'expensesType' => $abDetail ['expensesType'],
@@ -11323,22 +11719,21 @@ class ReceiptController extends DooController {
 				}
 			}
 			
-			
-			if (($abDetail ['expenditureType'] == 4||$abDetail ['expenditureType'] == 6)&&$abDetail ['expensesType'] == 2) {
-				if ($abDetail ['expenditureMsg']=='公司固定')
-				$accountType=9;
-				elseif($abDetail ['expenditureMsg']=='公司活期')
-				$accountType=10;
+			if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
+				if ($abDetail ['expenditureMsg'] == '公司固定')
+					$accountType = 9;
+				elseif ($abDetail ['expenditureMsg'] == '公司活期')
+					$accountType = 10;
 			}
-			if (($abDetail ['accountType'] == 7||$abDetail ['accountType'] == 9)&&$abDetail ['expensesType'] == 1) {
-				if ($abDetail ['accountMsg']=='公司固定')
-				$accountType=9;
-				elseif($abDetail ['accountMsg']=='公司活期')
-				$accountType=10;
+			if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
+				if ($abDetail ['accountMsg'] == '公司固定')
+					$accountType = 9;
+				elseif ($abDetail ['accountMsg'] == '公司活期')
+					$accountType = 10;
 			}
 			
-			if($abDetail['accountMsg']=='活期理财收益'){
-				$accountType=10;
+			if ($abDetail ['accountMsg'] == '活期理财收益') {
+				$accountType = 10;
 			}
 			
 			$accountBookStatistics->setAccountBookStatistics ( $item );
@@ -11348,23 +11743,22 @@ class ReceiptController extends DooController {
 					'limit' => 1 
 			) );
 			
-			//删除收入流水
-			if(!empty($accountType)){
-			Doo::loadModel ( 'wasteBook' );
-			$wasteBook = new wasteBook ();
-			$wasteBook->delete ( array (
-					'where' => 'dataID=' . $aid . ' and accountType='.$accountType,
-					'limit' => 1
-			) );
+			// 删除收入流水
+			if (! empty ( $accountType )) {
+				Doo::loadModel ( 'wasteBook' );
+				$wasteBook = new wasteBook ();
+				$wasteBook->delete ( array (
+						'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
+						'limit' => 1 
+				) );
 			}
 		}
 		return '/paymentsAchieve';
 	}
 	function paymentsCollect() {
-		
 		Doo::loadModel ( "execute" );
 		$execute = new execute ();
-		if(!$execute->isPaymentsShow($this->staff [0] ['sid'])){
+		if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
 			die ( 'illegal request' );
 		}
 		
@@ -11666,7 +12060,7 @@ class ReceiptController extends DooController {
 	function wasteBook() {
 		Doo::loadModel ( "execute" );
 		$execute = new execute ();
-		if(!$execute->isPaymentsShow($this->staff [0] ['sid'])){
+		if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
 			die ( 'illegal request' );
 		}
 		
@@ -11750,16 +12144,16 @@ class ReceiptController extends DooController {
 		Doo::loadClass ( 'XDeode' );
 		$XDeode = new XDeode ( 5 );
 		
-// 		echo $XDeode->encode(1).'<br>';
-// 		echo $XDeode->encode(2).'<br>';
-// 		echo $XDeode->encode(3).'<br>';
-// 		echo $XDeode->encode(4).'<br>';
-// 		echo $XDeode->encode(5).'<br>';
-// 		echo $XDeode->encode(6).'<br>';
-// 		echo $XDeode->encode(7).'<br>';
-// 		echo $XDeode->encode(8).'<br>';
-// 		echo $XDeode->encode(9).'<br>';
-// 		echo $XDeode->encode(10).'<br>';
+		// echo $XDeode->encode(1).'<br>';
+		// echo $XDeode->encode(2).'<br>';
+		// echo $XDeode->encode(3).'<br>';
+		// echo $XDeode->encode(4).'<br>';
+		// echo $XDeode->encode(5).'<br>';
+		// echo $XDeode->encode(6).'<br>';
+		// echo $XDeode->encode(7).'<br>';
+		// echo $XDeode->encode(8).'<br>';
+		// echo $XDeode->encode(9).'<br>';
+		// echo $XDeode->encode(10).'<br>';
 		
 		$dateArr = explode ( ':', $date );
 		$D1 = '';
@@ -11784,11 +12178,10 @@ class ReceiptController extends DooController {
 				$con .= ' and (accountType = 7 or accountType = 8)';
 			} elseif ($accountType == 'PAYMENTS') {
 				$con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
-				if($dailyIncomeType!='ALL'){
+				if ($dailyIncomeType != 'ALL') {
 					$dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
-					$con .= ' and dailyIncomeType =  '.$dailyIncomeType;
+					$con .= ' and dailyIncomeType =  ' . $dailyIncomeType;
 				}
-				
 			}
 		}
 		
@@ -11798,7 +12191,7 @@ class ReceiptController extends DooController {
 		foreach ( $incomeList as $key => $value ) {
 			$sum += $value ['accountPrice'];
 		}
-		//print_r($incomeList);
+		// print_r($incomeList);
 		
 		// 获得办事和部门
 		$categoryList = $L_category->getCategory ();
@@ -11861,23 +12254,22 @@ class ReceiptController extends DooController {
 				$con .= ' and accountType = 11';
 			} elseif ($accountType == 'PAYMENTS') {
 				$con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
-				if($dailyExpenditureType!='ALL'){
+				if ($dailyExpenditureType != 'ALL') {
 					$dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
-					$con .= ' and dailyExpenditureType =  '.$dailyExpenditureType;
+					$con .= ' and dailyExpenditureType =  ' . $dailyExpenditureType;
 				}
-			}elseif($accountType == 'RECEIPT'){
-				if ($receiptType=='ALL'){
-				$con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
-				}else{
+			} elseif ($accountType == 'RECEIPT') {
+				if ($receiptType == 'ALL') {
+					$con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
+				} else {
 					$receiptType = $XDeode->decode ( $receiptType );
 					echo $receiptType;
-					if ($receiptType==1){
+					if ($receiptType == 1) {
 						$con .= ' and (accountType =  1 or accountType=2)';
-					}else{
-						$con .= ' and accountType =  '.$receiptType;
+					} else {
+						$con .= ' and accountType =  ' . $receiptType;
 					}
 				}
-					
 			}
 		}
 		
@@ -12493,8 +12885,7 @@ class ReceiptController extends DooController {
 						'CGBDeposit' => 0,
 						'ICBCDeposit' => 0 
 				) 
-		)
-		;
+		);
 		
 		// 存款
 		foreach ( $waste ['bank'] as $key => $value ) {

+ 26 - 15
protected/model/invoice.php

@@ -194,8 +194,6 @@ class invoice extends DooModel {
 	public $printTime;
 	public $postTime;
 	public $settlementType;
-	
-	
 	public $_table = 'CLD_invoice';
 	public $_primarykey = 'iid';
 	public $_fields = array (
@@ -429,29 +427,42 @@ class invoice extends DooModel {
 	 * 统计培训班开票
 	 */
 	function sumOfinvoiceTrain($itidSql) {
-		$sql = 'select sum(invoicePrice) as invoicePrice ,trainId
-				from ' . $this->_table . ' 
-						where trainId in (' . $itidSql . ') and status=2 and printStatus=1 and (untreadStatus =0 or untreadStatus=3)
-						 GROUP BY trainId';
+		$sql = 'select sum(b.invoicePrice) as invoicePrice ,b.trainId as trainId
+				from CLD_invoiceStore as a left join  ' . $this->_table . '  as b on (a.iid=b.iid)
+				where b.trainId in (' . $itidSql . ') and b.status=2 and b.printStatus=1 and (b.untreadStatus =0 or b.untreadStatus=3)
+				GROUP BY b.trainId';
 		$query = Doo::db ()->query ( $sql );
 		return $result = $query->fetchAll ();
 	}
 	function sumOfInvoiceRecelvablesTrain($itidSql) {
-		$sql = 'select sum(b.receivablesPrice) as receivablesPrice ,a.trainId,count(*) as count
-				from ' . $this->_table . ' as a left join CLD_invoiceReceivables as b on find_in_set(a.irid,b.irid)
-				where a.trainId in (' . $itidSql . ') and a.status=2 and a.printStatus=1 and (a.untreadStatus =0 or a.untreadStatus=3) and a.irid!="" 
-				GROUP BY a.trainId';
+// 		$sql = 'select sum(b.receivablesPrice) as receivablesPrice ,a.trainId,count(*) as count
+// 				from ' . $this->_table . ' as a left join CLD_invoiceReceivables as b on find_in_set(a.irid,b.irid)
+// 				where a.trainId in (' . $itidSql . ') and a.status=2 and a.printStatus=1 and (a.untreadStatus =0 or a.untreadStatus=3) and a.irid!="" 
+// 				GROUP BY a.trainId';
+
+		$sql='select sum(b.receivablesPrice) as receivablesPrice ,a.trainId,count(*) as count
+ 				from ' . $this->_table . ' as a left join CLD_invoiceReceivables as b on (a.iid=b.iid)
+ 				where a.trainId in (' . $itidSql . ') and a.status=2 and a.printStatus=1 and (a.untreadStatus =0 or a.untreadStatus=3) and a.irid!="" 
+ 				GROUP BY a.trainId';
+		
 		$query = Doo::db ()->query ( $sql );
 		return $result = $query->fetchAll ();
 	}
+	// 获得培训班发票
 	function getInvoiceByTrainingCount($itid = 0) {
 		if (empty ( $itid ))
 			return 0;
-		$detail = $this->count ( array (
-				'where' => "trainId= '" . $itid . "' and untreadStatus!=2", // and sid=".$sid,
-				'asArray' => TRUE 
-		) );
-		return $detail;
+		$sql = 'select count(*) as count from CLD_invoiceStore as a left join ' . $this->_table . ' as b on (a.iid=b.iid)
+				where  a.trainId= ' . $itid . ' and b.untreadStatus!=2 and b.isDelete=0';
+		$query = Doo::db ()->query ( $sql );
+		$result = $query->fetchAll ();
+		return $result[0] ['count'];
+		
+		// $detail = $this->count ( array (
+		// 'where' => "trainId= '" . $itid . "' and untreadStatus!=2 and isDelete=0", // and sid=".$sid,
+		// 'asArray' => TRUE
+		// ) );
+		// return $detail;
 	}
 	
 	/**

+ 54 - 6
protected/model/invoiceTraining.php

@@ -142,7 +142,7 @@ class invoiceTraining extends DooModel {
 			$invoiceList = $invoice->sumOfinvoiceTrain ( $itidSql );
 			$invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidSql );
 		}
-		// print_r($invoiceRecelvablesList);
+		//print_r($invoiceRecelvablesList);
 		
 		foreach ( $list as $key => $value ) {
 			
@@ -160,8 +160,11 @@ class invoiceTraining extends DooModel {
 				if ($value ['itid'] == $o ['trainId']) {
 					$list [$key] ['invoiceArriveAmount'] = $o ['receivablesPrice'];
 					$list [$key] ['arriveSchedule'] = "0";
-					if ($value ['invoiceTotal'] != 0)
-						$list [$key] ['arriveSchedule'] = round ( $o ['count'] / $value ['invoiceTotal'] * 100, 2 );
+					if ($value ['invoiceTotal'] != 0){
+						$list [$key] ['arriveSchedule'] = round ( $list [$key] ['invoiceArriveAmount'] / $list [$key] ['invoiceTotalAmount'] * 100, 2 );
+						//$list [$key] ['arriveSchedule'] = round ( $o ['count'] / $value ['invoiceTotal'] * 100, 2 );
+					}
+						
 					
 					break;
 				}
@@ -218,11 +221,56 @@ class invoiceTraining extends DooModel {
 		
 		$list = $this->find ( $condition );
 		
+	Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		$itid = array ();
 		foreach ( $list as $key => $value ) {
+			$list [$key] ['trainingKey'] = $XDeode->encode ( $value ['itid'] );
 			$detail = $staff->getStaffBySid ( $value ['creator'] );
 			$list [$key] ['staff'] = $detail;
 			$detail = $lCategory->getCategoryById ( $value ['cid'] );
 			$list [$key] ['category'] = $detail;
+			array_push ( $itid, $value ['itid'] );
+		}
+		
+		// 获得开票金额合计 入账金额合计 入账完成度
+		Doo::loadModel ( 'invoice' );
+		$invoice = new invoice ();
+		
+		$invoiceList = $invoiceRecelvablesList = array ();
+		if (! empty ( $itid )) {
+			$itidSql = implode ( ',', $itid );
+			$invoiceList = $invoice->sumOfinvoiceTrain ( $itidSql );
+			$invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidSql );
+		}
+		//print_r($invoiceRecelvablesList);
+		
+		foreach ( $list as $key => $value ) {
+			
+			$countInvoice=$invoice->getInvoiceByTrainingCount($value['itid']);
+			$value ['invoiceTotal']=$countInvoice;
+			$list [$key] ['invoiceTotal'] =$countInvoice;
+			
+			foreach ( $invoiceList as $k => $v ) {
+				if ($value ['itid'] == $v ['trainId']) {
+					$list [$key] ['invoiceTotalAmount'] = $v ['invoicePrice'];
+					break;
+				}
+			}
+			foreach ( $invoiceRecelvablesList as $i => $o ) {
+				if ($value ['itid'] == $o ['trainId']) {
+					$list [$key] ['invoiceArriveAmount'] = $o ['receivablesPrice'];
+					$list [$key] ['arriveSchedule'] = "0";
+					if ($value ['invoiceTotal'] != 0){
+						
+						$list [$key] ['arriveSchedule'] = round ( $list [$key] ['invoiceArriveAmount'] / $list [$key] ['invoiceTotalAmount'] * 100, 2 );
+						
+						//$list [$key] ['arriveSchedule'] = round ( $o ['count'] / $value ['invoiceTotal'] * 100, 2 );
+					}
+					
+					break;
+				}
+			}
 		}
 		
 		return $list;
@@ -274,12 +322,12 @@ class invoiceTraining extends DooModel {
 	}
 	
 	/**
-	 * 获得未完成的培训班
+	 * 获得某办事处未完成的培训班
 	 * @return string
 	 */
-	function getInvoiceTrainingByUnfinished(){
+	function getInvoiceTrainingByUnfinished($cid=0){
 		$condition = array (
-				'where' => "(status= 0 or status=1)",
+				'where' => "(status= 0 or status=1) and cid=".$cid,
 				'asArray' => true 
 		);
 		

+ 59 - 2
protected/model/receipt.php

@@ -34,6 +34,10 @@ class receipt extends DooModel {
 	public $bankNumber;
 	public $coupletNumber;
 	public $remittanceBankType;
+	public $trainId;
+	public $trainLoanRid;
+	
+	
 	public $_table = 'CLD_receipt';
 	public $_primarykey = 'rid';
 	public $_fields = array (
@@ -69,7 +73,9 @@ class receipt extends DooModel {
 			'bankName',
 			'bankNumber',
 			'coupletNumber',
-			'remittanceBankType' 
+			'remittanceBankType',
+			'trainId',
+			'trainLoanRid'
 	);
 	function receiptByYear($dateCondition, $sid) {
 		$sql = "select sum(sum) as sum from " . $this->_table . " where staff= '" . $sid . "' " . $dateCondition . " and status=2 ";
@@ -117,13 +123,64 @@ class receipt extends DooModel {
 		) );
 		
 		$rinfo['ridKey']=$XDeode->encode ( $rinfo ['rid'] );
-		
+		$rinfo['trainLoanRidKey']=$XDeode->encode ( $rinfo ['trainLoanRid'] );
 		$rinfo['category']=$Lcategory->getCategoryById($rinfo['cid']);
 		$rinfo['staffDetail']=$staff->getStaffBySid($rinfo['staff']);
 		
 		return $rinfo;
 	}
 	
+	/**
+	 * 默认获得10条
+	 * @param unknown $sid
+	 * @param unknown $cid
+	 * @param unknown $limit
+	 */
+	function getReceiptLoanByStatus($sid,$cid,$status,$limit=10){
+		$sql='';
+		if ($sid!==false&&is_numeric($sid)){
+			$sql.=' and staff='.$sid;
+		}
+		if ($cid!==false&&is_numeric($cid)){
+			$sql.=' and cid='.$cid;
+		}
+		
+		$list = $this->find ( array (
+				'where' => 'Rtype=1 and status=' . $status.$sql,
+				'asArray' => true
+		) );
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ($list as $key=>$value){
+			$list[$key]['ridKey']=$XDeode->encode ( $list[$key] ['rid'] );
+		}
+		return $list;
+	}
+	
+	/**
+	 * 根据参数字段更新相应字段(主键ID必须传)
+	 * @param array $item 相关需要更新的字段信息
+	 * @return number 返回发票ID
+	 */
+	public function setReceiptByCondition($item = array(), $rid = "") {
+		$lid = 0;
+	
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+				
+			if (! empty ( $isid )) {
+				$condition = array (
+						'where' => "rid in (" . $rid . ")",
+						'asArray' => TRUE
+				);
+				$this->update ( $condition );
+			} else
+				$lid = $this->update ();
+		}
+		return $lid;
+	}
 	
 }
 

+ 146 - 1
protected/model/verify.php

@@ -12,7 +12,152 @@ class verify extends DooModel {
     public $_primarykey = 'vid';
     
     public $_fields = array('vid', 'description', 'staff');
-
+	
+    /**
+     * 获得所有审批组
+     */
+    function getVerifyByAll(){
+    	Doo::loadModel ( "role" );
+    	$role = new role ();
+    	$veList = $this->find ( array (
+    			'asArray' => true
+    	) );
+    	foreach ( $veList as $key => $value ) {
+    		$v = json_decode ( $value ['staff'] );
+    		$list = array ();
+    		foreach ( $v as $n => $m ) {
+    			if ($m ['1'] == 'ROLE') {
+    				$roleInfo = $role->getOne ( array (
+    						'where' => 'rid=' . $m [0],
+    						'asArray' => true
+    				) );
+    				$v [$n] [1] = $roleInfo ['name'];
+    				array_push ( $list, $roleInfo ['name'] );
+    			} else {
+    				array_push ( $list, $v [$n] [1] );
+    			}
+    		}
+    		$veList [$key] ['staff'] = implode ( '>', $list );
+    	}
+    	return $veList;
+    }
+    
+    /**
+     * 获得某费用单的审批信息
+     */
+    function getVerifyByRid($rid=0){
+    	
+    	if (empty($rid))
+    		return array();
+    	// 获得审批组
+    	Doo::loadModel ( 'role' );
+    	$role = new role ();
+    	Doo::loadModel ( 'loanReceipt' );
+    	$loanReceipt = new loanReceipt ();
+    	Doo::loadModel ( 'staff' );
+    	$staff = new staff ();
+    	Doo::loadModel ( 'receipt' );
+    	$receipt = new receipt ();
+    	
+    	$receiptDetail = $receipt->getReceiptByRid ( $rid );
+    	
+    	$loanList = $loanReceipt->find ( array (
+    			'where' => 'rid=' . $receiptDetail ['loanRid'],
+    			'desc' => 'rid',
+    			'asArray' => true
+    	) );
+    	if ($receiptDetail ['status'] == 3 || $receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9) {
+    		if ($receiptDetail ['status'] == 8 && $receiptDetail ['Rtype'] == 1)
+    			$verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
+    			else
+    				$verifyList ['staff'] = $receiptDetail ['verifyBreakup'];
+    	} else {
+    		$verifyList = $this->getOne ( array (
+    				'where' => 'vid=' . $receiptDetail ['verify'],
+    				'asArray' => true
+    		) );
+    	}
+    	$verifyList = json_decode ( $verifyList ['staff'], true );
+    	$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
+    	
+    	$roleArrayCopy = array ();
+    	$flag = true;
+    	
+    	foreach ( $verifyList as $k => $v ) {
+    		if ($v [1] == 'ROLE') {
+    			$roleVerify = json_decode ( $v [3], true );
+    			$roleKey = $k;
+    			$roleArray = array ();
+    			$rolename = $role->getOne ( array (
+    					'where' => 'rid=' . $v [0],
+    					'asArray' => true
+    			) );
+    			foreach ( $roleVerify as $o => $p ) {
+    				$staffID = explode ( '_', $p );
+    				$staffInfo = $staff->getOne ( array (
+    						'where' => 'sid=' . $staffID [0],
+    						'asArray' => true
+    				) );
+    				$exp = array (
+    						0 => $staffInfo ['sid'],
+    						1 => $staffID [1],
+    						2 => $staffInfo ['avatar'],
+    						'date' => '',
+    						'date' => '',
+    						'opinion' => '',
+    						'status' => '',
+    						'rolename' => $rolename ['name']
+    				);
+    				array_push ( $roleArray, $exp );
+    			}
+    			$roleArrayCopy [$v [0]] = $roleArray;
+    		}
+    		$verifyList [$k] ['date'] = "";
+    		$verifyList [$k] ['opinion'] = "";
+    		$verifyList [$k] ['status'] = "";
+    		if (empty ( $verifyStaff )) {
+    			$verifyList [$k] ['date'] = "";
+    			$verifyList [$k] ['opinion'] = "";
+    			if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
+    				$verifyList [$k] ['status'] = 4;
+    				$flag = false;
+    			}
+    		} else {
+    			foreach ( $verifyStaff as $m => $u ) {
+    				if ($v [0] == $m) {
+    					$verifyList [$k] ['date'] = $u ['date'];
+    					$verifyList [$k] ['opinion'] = $u ['opinion'];
+    					$verifyList [$k] ['status'] = $u ['status'];
+    					$flag = false;
+    					break;
+    				}
+    			}
+    		}
+    	}
+    	foreach ( $roleArrayCopy as $P => $A ) {
+    		foreach ( $A as $MKI => $AVL ) {
+    			foreach ( $verifyStaff as $m => $u ) {
+    				$AVLFK = $AVL [0] . '_R';
+    				if (strcmp ( $AVLFK, $m ) == 0) {
+    					$roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
+    					$roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
+    					$roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
+    					break;
+    				}
+    			}
+    		}
+    	}
+    	foreach ( $roleArrayCopy as $k => $v ) {
+    		foreach ( $verifyList as $m => $n ) {
+    			if ($n [0] == $k) {
+    				array_splice ( $verifyList, $m, 1, $v );
+    			}
+    		}
+    	}
+    	
+    	return $verifyList;
+    }
+    
 }
 
 ?>

+ 5 - 5
protected/view/admin/approvalExpenses.html

@@ -171,18 +171,18 @@
 	  							<!-- if {{page.previous}}==0 -->
 								<li><a href="javascript:void(0)" title="上一页">&lt;</a></li>
 								<!-- else -->
-								<li><a href="/approvalExpenses/{{status}}/{{page.previous}}" title="上一页">&lt;</a></li>
+								<li><a href="/approvalExpenses/{{status}}/{{page.previous}}?year={{year}}&month={{month}}&cid={{cid}}&sid={{sid}}" title="上一页">&lt;</a></li>
 								<!-- endif -->	
 	  							<!-- if {{page.on_page}}>=3 -->
-	  							<li><a href="/approvalExpenses/{{status}}/1" title="上一页">1</a></li>
+	  							<li><a href="/approvalExpenses/{{status}}/1?year={{year}}&month={{month}}&cid={{cid}}&sid={{sid}}" title="上一页">1</a></li>
 	  							<li class="point"><span>...</span></li>
 	  							<!-- endif -->
 	  							
 	  							{{page.page}}
 	  							
 	  							<!-- if {{page.on_page}}<3 && {{page.total_page}}>5 -->
-	  							<li><a href="/approvalExpenses/{{status}}/4" >4</a></li>
-	  							<li><a href="/approvalExpenses/{{status}}/5" >5</a></li>
+	  							<li><a href="/approvalExpenses/{{status}}/4?year={{year}}&month={{month}}&cid={{cid}}&sid={{sid}}" >4</a></li>
+	  							<li><a href="/approvalExpenses/{{status}}/5?year={{year}}&month={{month}}&cid={{cid}}&sid={{sid}}" >5</a></li>
 	  							<!-- endif -->
 	  							
 	  							<!-- if {{page.total_page}}>3 -->
@@ -192,7 +192,7 @@
 			  					<!-- if {{page.next}}=={{page.on_page}} -->
 								<li><a href="javascript:void(0)" title="下一页">&gt;</a></li>
 								<!-- else -->
-								<li><a href="/approvalExpenses/{{status}}/{{page.next}}" title="下一页">&gt;</a></li>
+								<li><a href="/approvalExpenses/{{status}}/{{page.next}}?year={{year}}&month={{month}}&cid={{cid}}&sid={{sid}}" title="下一页">&gt;</a></li>
 								<!-- endif -->
 			  					
 			  		</ul>

+ 12 - 8
protected/view/admin/invoiceAdd.html

@@ -79,15 +79,19 @@
 								
 								<tr>
 									<th class="taC"><span class="colRed">*</span>结算方式</th><td colspan="3">
-									<label class="radio inline"><input type="radio" checked onclick="settlementTypeShow()" name="settlementType" value="SOFTWARE" data-rule="checked">软件销售</label>
-									<label class="radio inline">		<input type="radio" onclick="settlementTypeShow()" name="settlementType" value="TRAINING">培训班</label>
+									<label class="radio inline"><input type="radio"  onclick="settlementTypeShow()" name="settlementType" value="SOFTWARE" data-rule="checked">软件销售</label>
+									
+									<!-- if !empty({{itList}}) -->
+									<label class="radio inline"><input type="radio" onclick="settlementTypeShow()" name="settlementType" id="settlementType" value="TRAINING">培训班</label>
 									<label class="radio inline" id='trainingSelect' style="display:none">
-									<select name='trainId'>
+									<select name='trainId' id='trainId' >
+									<option selected value="">请选择</option>
 									<!-- loop itList -->
 									<option value="{{itList' value.itidKey}}">{{itList' value.trainName}}</option>
 									<!-- endloop -->
 									</select>
 									</label>
+									<!-- endif -->
 									<p class="colGray">结算方式影响您的工资提成,请正确选择!</p>
 									</td>
 								</tr>
@@ -181,31 +185,31 @@
 									<div class="checkbox">
 									  <label>
 									    <input type="checkbox" name="softLock" value="1">
-									    软件锁 <br><input type="number" name="softLockNum" class="span1" placeholder="数量" value="1">
+									    软件锁 (个)<br><input type="number" name="softLockNum" class="span1" placeholder="数量" value="1">
 									  </label>
 									</div>
 									<div class="checkbox">
 									  <label>
 									    <input type="checkbox" checked disabled value="1">
-									    发票 <br>1
+									    发票 (张)<br>1
 									  </label>
 									</div>
 									<div class="checkbox">
 									  <label>
 									    <input type="checkbox" name="contract" value="1">
-									    合同 <br><input type="number" name="contractNum" class="span1" placeholder="数量" value="1">
+									    合同(份) <br><input type="number" name="contractNum" class="span1" placeholder="数量" value="1">
 									  </label>
 									</div>
 									<div class="checkbox">
 									  <label>
 									    <input type="checkbox" name="instructions" value="1">
-									    说明书 <br><input type="number" name="instructionsNum" class="span1" placeholder="数量" value="1">
+									    说明书 (本)<br><input type="number" name="instructionsNum" class="span1" placeholder="数量" value="1">
 									  </label>
 									</div>
 									<div class="checkbox">
 									  <label>
 									    <input type="checkbox" name="remittance" value="1">
-									    汇款账号单
+									    汇款账号单(张)
 									  </label>
 									</div>
 									<div class="checkbox">

+ 1 - 1
protected/view/admin/invoiceTraining.html

@@ -85,7 +85,7 @@
 										<td>¥{{itList' value.invoiceTotalAmount}}</td>
 										<td>¥{{itList' value.invoiceArriveAmount}}</td>
 										<td>{{itList' value.arriveSchedule}}%</td>
-										<td>
+										
 									</tr>
 									<!-- endloop -->
 									</tbody>

+ 8 - 2
protected/view/admin/saeaBorad.html

@@ -24,6 +24,7 @@
 						<div class="borad-menu">
 							<a href="/saeaLoanAdd" class="loan">申请借款</a>
 							<a href="/saeaCreate" class="receipt">申请报销</a>
+							<a href="/receiptTrainAdd" class="train">培训班结算</a>
 							<a href="/remitAdd" class="public">申请对公汇款</a>
 						</div>
 						<div class="borad-news">
@@ -40,6 +41,8 @@
 										<th>借款</th>
 										<!-- elseif {{receiptDetail' value.Rtype}}==2 -->
 										<th>对公汇款</th>
+										<!-- elseif {{receiptDetail' value.Rtype}}==3 -->
+										<th>培训班结算</th>
 										<!-- else -->
 										<th>报销单</th>
 										<!-- endif -->
@@ -75,8 +78,11 @@
 										<a class="button btn-gray  btn-inline" href="/remitEdit/{{receiptDetail' value.ridKey}}.html">返回编辑</a><a
 										 class="button btn-inline" href="/approvedReceipt/{{receiptDetail' value.rid}}">提交审批</a>
 										 <!-- elseif  ({{receiptDetail' value.status}}==4 or {{receiptDetail' value.status}}==7) and {{receiptDetail' value.Rtype}}==1 and {{receiptDetail' value.isBK}}==1 -->
-										 <a class="button btn-gray  btn-inline" href="/saeaLoanReceiptEdi/{{receiptDetail' value.ridKey}}.html">返回编辑</a><a
-										 class="button btn-inline" href="/approvedReceipt/{{receiptDetail' value.rid}}">提交审批</a>
+										 <a class="button btn-gray  btn-inline" href="/saeaLoanReceiptEdi/{{receiptDetail' value.ridKey}}.html">返回编辑</a>
+										 <a class="button btn-inline" href="/approvedReceipt/{{receiptDetail' value.rid}}">提交审批</a>
+										<!-- elseif {{receiptDetail' value.Rtype}}==3 and {{receiptDetail' value.status}}==5  -->
+										 <a class="button btn-gray  btn-inline" href="/receiptTrainEdi/{{receiptDetail' value.ridKey}}.html">返回编辑</a>
+										 <a class="button btn-inline" href="#">提交审批</a>
 										<!-- endif -->
 										</div>
 										</td>

+ 0 - 1
protected/view/admin/saeaLoanAdd.html

@@ -52,7 +52,6 @@
 								<th>选择办事处</th>
 								<td class="taR">
 								<select name="cid" class="span2">
-								
 								<!-- loop category -->
 								<option <!-- if {{category' value.cid}} == {{staff.0.cid}}  --> selected <!-- endif -->  value="{{category' value.cid}}" >{{category' value.title}}</option>
 								<!-- endloop -->

+ 1 - 1
protected/view/contacts_company.html

@@ -54,7 +54,7 @@ function deleteTagCompany(tid,cid,obj){
 			<div class="contactTab">
 				<a href="/contacts">我的客户</a><a href="/mycompany" class="now">我的单位</a><a href="/communication" >内部通讯</a>
 				<div class="searchItem">
-				<form action="/searchMyClient" method="post">
+				<form action="/searchMyCompany" method="post">
 				<input type="text" name="search" placeholder="输入姓名或单位名称进行搜索"><input type="submit" value="搜索" class="subBtn">
 				</form>
 				</div>