| 
					
				 | 
			
			
				@@ -127,6 +127,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// 判断执行人的审批权限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$executeList = $execute->find ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						'where'=>'mold !="日常收支"', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						'select' => 'staff', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						'asArray' => true  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				) ); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -218,7 +219,11 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$receiptDetail [$key] ['category'] = $category ['title']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// print_r($receiptLogList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Doo::loadModel ( 'RAssist' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$RAssist = new RAssist (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['receiptExtendList'] = $receiptExtendList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data ['receiptLogList'] = $receiptLogList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data ['receiptDetail'] = $receiptDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2122,7 +2127,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * 添加培训班结算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	function receiptTrainAddDo() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 培训班信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : ""; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2225,24 +2230,26 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$receiptTraining = new receiptTraining (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$receiptDetail = $receipt->getReceiptByRid ( $rid ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			die (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			die ('illegal request--status'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 汇总表合计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 收入合计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 收入合计--加入开票合计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Doo::loadModel ( 'invoiceTraining' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceTraining = new invoiceTraining (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceTrainingDetail = array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				'invoiceArriveAmount' => 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				'RIAmount' => 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				'invoiceTotalAmount' => 0 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				'invoiceTotalAmount' => 0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				'invoiceCompanyAmount'=>0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if ($receiptDetail ['invoiceTrainId'] != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// print_r($invoiceTrainingDetail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$invoiceArriveAmount = $RIAmount = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (! empty ( $invoiceTrainingDetail )) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2267,41 +2274,82 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// print_r($aiData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$data ['profit'] = $invoiceArriveAmount - $aiData ['total']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$data ['companyProfit'] = $data ['profit'] * 0.6; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$data ['categoryProfit'] = $data ['profit'] * 0.4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// 利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$profit=$invoiceArriveAmount - $aiData ['total']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$companyProfit=$profit * 0.6; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$categoryProfit=$profit * 0.4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['profit'] = number_format ( $profit, 2 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['companyProfit'] = number_format ($companyProfit, 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['categoryProfit'] = number_format ( $categoryProfit, 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//发票利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['invoiceCompanyProfit'] = $data ['invoiceProfit'] * 0.6;//发票公司利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['invoiceCategoryProfit'] = $data ['invoiceProfit'] * 0.4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// print_r($aiData['dataList']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$data ['categoryActualExpenditure'] = $aiData ['total'] - $aiData ['categoryActualExpenditure']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['categoryActualExpenditure'] = number_format ( $categoryActualExpenditure, 2 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 备用金 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$sum = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data ['receiptLoanDetail'] = array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				'sum' => 0  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				'sum' => '0.00'  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (! empty ( $receiptDetail ['trainLoanRid'] )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$sum = $data ['receiptLoanDetail'] ['sum']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$data ['payment'] = $sum + $RIAmount - $data ['categoryActualExpenditure']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$data ['total'] = $aiData ['total']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$payment=$sum + $RIAmount - $categoryActualExpenditure; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['payment'] = number_format ( $payment, 2 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data ['total'] = number_format ( $aiData ['total'], 2 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data ['aiCount'] = count ( $aiData ['dataList'] ) + 5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$data ['aiList'] = $aiData ['dataList']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 占比计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if ($invoiceArriveAmount != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['totalProportion'] = number_format ( $aiData ['total'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['profitProportion'] = number_format ( $data ['profit'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['sumProportion'] = number_format ( $sum / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['invoiceTotalAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['RIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['companyProfitProportion'] = number_format ( $data ['companyProfit'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['categoryProportion'] = number_format ( $data ['categoryProfit'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['categoryActualExpenditureProportion'] = number_format ( $data ['categoryActualExpenditure'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$data ['paymentProportion'] = number_format ( $data ['payment'] / $invoiceArriveAmount, 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['totalProportion'] = number_format ( $aiData ['total'] / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['profitProportion'] = number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['sumProportion'] = number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoiceTotalAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['RIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['companyProfitProportion'] = number_format ( $companyProfit / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['categoryProportion'] = number_format ( $categoryProfit / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['categoryActualExpenditureProportion'] = number_format ( $categoryActualExpenditure / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['paymentProportion'] = number_format ( $payment / $invoiceArriveAmount, 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//发票金额占比计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//支出 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoicetotalProportion'] = number_format ( $aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoiceprofitProportion'] = number_format ( $data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//公司利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoicecompanyProfitProportion'] = number_format ( $data ['invoiceCompanyProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//办事处利润 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoicecategoryProportion'] = number_format ( $data ['invoiceCategoryProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//公司收款 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoiceTotalAmountProportionB'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//备用金 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoicesumProportion'] = number_format ( $sum / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//办事处收款 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoiceRIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//办事处实际支出 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['ICAEP'] = number_format ( $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//付总部款 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoicepaymentProportion'] = number_format ( $payment / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//讲师人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Doo::loadModel ( 'RILecturer' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$RILecturer = new RILecturer (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$RILecturerList = $RILecturer->getRILecturerByRid ( $rid ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$data['lectureCount']=count($RILecturerList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 审批组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Doo::loadModel ( 'verify' ); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2800,14 +2848,14 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 支出项信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		$price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (! empty ( $ridKey ) && ! empty ( $item ) && ! empty ( $price ) && ! empty ( $date ) && ! empty ( $inputer )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (! empty ( $ridKey ) && ! empty ( $item ) &&  is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Doo::loadClass ( 'XDeode' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$XDeode = new XDeode ( 5 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Doo::loadModel ( 'RItem' ); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2826,8 +2874,19 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$RItem->price = $price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$RItem->date = $date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$RItem->inputer = $inputer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$order = array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					"\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					"\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					"\r" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$replace = '<br/>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$describe = str_replace ( $order, $replace, $describe ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$RItem->describe = $describe; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$RItem->creater=$this->staff['0']['username']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$RItem->creatDate=date ( "Y-m-d H:i:s" ) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$RItem->insert (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// 添加公司汇总 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2841,10 +2900,10 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (empty ( $rdInfo )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail = new receiptDetail (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$receiptDetail->staff = $this->staff [0] ['sid']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$receiptDetail->staff = $rInfo ['staff']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->item = $item; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->itemCategory = '培训班费用'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$receiptDetail->price = number_format ( $price, 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$receiptDetail->price =  $price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->date = date ( "Y-m-d" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->cid = $rInfo ['cid']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->rid = $rid; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2852,7 +2911,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->insert (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail = new receiptDetail (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$rdInfo ['price'] += number_format ( $price, 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$rdInfo ['price'] +=  $price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->price = $rdInfo ['price']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->update ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"'  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2860,11 +2919,50 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			//更新费用合计金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$receipt = new receipt (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			$receipt->sum=$rInfo['sum']+number_format ( $price, 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt->sum=$rInfo['sum']+ $price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$receipt->update ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					'where' => 'rid=' . $rid  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//汇总金额--提交审批之后有 支出项时 需要更新汇总 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			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'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 					) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$XDeode = new XDeode ( 7 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if($payType=='company'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2872,7 +2970,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			die ( 'illegal request' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			die ( 'illegal request-dataError' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2933,6 +3031,8 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$this->render ( "/receipt/receiptTrainLecturerEdi", $data ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * 添加讲师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2987,7 +3087,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (empty ( $rdInfo )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail = new receiptDetail (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$receiptDetail->staff = $this->staff [0] ['sid']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$receiptDetail->staff = $rInfo ['staff']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->item = '讲课费'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->itemCategory = '培训班费用'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->price = number_format ( $price, 2, '.', '' ); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2998,12 +3098,17 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->insert (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail = new receiptDetail (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				$rdInfo ['price'] += number_format ( $price, 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$rdInfo ['price'] +=  $price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->price = $rdInfo ['price']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				$receiptDetail->update ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt = new receipt (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt->sum=$rInfo['sum']+$price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt->update ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					'where' => 'rid=' . $rid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$XDeode = new XDeode ( 7 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3030,12 +3135,36 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (is_numeric ( $rid ) && is_numeric ( $rlid )) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$receiptDetail = $receipt->getReceiptByRid ( $rid ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				die ( 'illegal request-status' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$detail=$RILecturer->getRILecturerByRlid($rlid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (empty($detail)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				die ( 'illegal request-data' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$RILecturer->delete ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					'where' => 'rid=' . $rid . ' and rlid=' . $rlid  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//更新费用合计金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$rInfo = $receipt->getReceiptByRid ( $rid ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt = new receipt (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt->sum= $receiptDetail['sum']-$detail['price']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receipt->update ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					'where' => 'rid=' . $rid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Doo::loadModel ( 'receiptDetail' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receiptDetail = new receiptDetail (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receiptDetail = new receiptDetail (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receiptDetail->price = $rdInfo ['price']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$receiptDetail->update ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$XDeode = new XDeode ( 7 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} else 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3889,7 +4018,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 = 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$page_size = 8; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		$vidList = array (); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -9490,7 +9619,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (empty ( $receiptDetail ) || $nsflag) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				return "/approvalExpenses/pendApproval"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$verifyDetail = $verify->getOne ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					'where' => ' vid =' . $receiptDetail ['verify'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					'asArray' => true  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -10036,7 +10165,7 @@ class ReceiptController extends DooController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$receipt = new receipt (); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			$rd = $receipt->getOne ( array ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					'asc' => 'rid', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					'asArray' => true  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			) ); 
			 |