Browse Source

Merge branch 'master' of http://smartcost.in.8866.org:26903/caipin/cld

caipin 5 years ago
parent
commit
44c94c387b

+ 16 - 15
Article.php

@@ -65,7 +65,8 @@ class Article extends DooModel {
 //		return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
 //	}
     function getArticleByTrain2($trainingType= '',$area = '', $select = false){
-    	
+
+
     	$condition='a_type=2 ';
     	$parameter=array();
     	if($trainingType != '' && is_numeric($trainingType)){
@@ -77,22 +78,22 @@ class Article extends DooModel {
     		array_push($parameter, $area);
     	}
     	$condition.=' and time+63072000 >= unix_timestamp(now())';
-    	
+
     	$qualification=array(
     			'where' => $condition,
     			'param' => $parameter,
     			'desc'=>'time',
     			'asArray' => TRUE);
-    	
+
     	if ($select) {
     		$qualification+=array('select'=> 'aid,area,trainingType,time,enroll_time,enroll_title');
-    	} 
-    	
+    	}
+
     	$result=$this->find($qualification);
     	return $result;
-    	
-    	
-    	
+
+
+
        /*  $sql = '';
         if($trainingType != '' && is_numeric($trainingType)){
             $sql .= '  and trainingType='.$trainingType;
@@ -120,7 +121,7 @@ class Article extends DooModel {
     }
 
 	function getArticleNumByTrain2($trainingType= '',$area = ''){
-		
+
 		$condition='a_type=2 ';
 		$parameter=array();
 		if($trainingType != '' && is_numeric($trainingType)){
@@ -132,17 +133,17 @@ class Article extends DooModel {
 			array_push($parameter, $area);
 		}
 		$condition.=' and time+63072000 >= unix_timestamp(now())';
-		
+
 		$qualification=array(
 				'where' => $condition,
 				'param' => $parameter,
 				'asArray' => TRUE);
-		
-		
-		
+
+
+
 		return $this->count($qualification);
-		
-		
+
+
 		/* $sql = '';
 		if($trainingType != '' && is_numeric($trainingType)){
 			$sql .= '  and trainingType='.$trainingType;

File diff suppressed because it is too large
+ 1 - 1
global/js/index.js


+ 22 - 0
global/js/receipt.js

@@ -270,6 +270,17 @@ $(function() {
 		var travelR=parseFloat($("#travelR").val());
 		var trainR=parseFloat($("#trainR").val());
 		var otherR=parseFloat($("#otherR").val());
+		
+		if(typeof(travelR)=="number"){
+			travelR=0;
+		}
+		if(typeof(trainR)=="number"){
+			trainR=0;
+		}
+		if(typeof(otherR)=="number"){
+			otherR=0;
+		}
+		
 		var RS=parseFloat($i)+parseFloat(travelR)+parseFloat(trainR)+parseFloat(otherR);
 		
 		$("#RS").html("¥"+RS.toFixed(2));
@@ -324,6 +335,17 @@ $(function() {
 		var agencyR=$("#agencyR").val();
 		var travelR=parseFloat($("#travelR").val());
 		var trainR=parseFloat($("#trainR").val());
+		
+		if(typeof(travelR)=="number"){
+			travelR=0;
+		}
+		if(typeof(trainR)=="number"){
+			trainR=0;
+		}
+		if(typeof(otherR)=="number"){
+			otherR=0;
+		}
+		
 		var RS=parseFloat($i)+parseFloat(agencyR)+parseFloat(travelR)+parseFloat(trainR);
 		
 		$("#RS").html("¥"+RS.toFixed(2));

+ 9 - 1
protected/config/acl.conf.php

@@ -170,6 +170,9 @@ $acl ['INVOICE'] ['allow'] = array (
 				'invoicePaperAdd',
 				'invoicePaperDel',
 				'ajaxGetinvoicePaperAchieve',
+				
+				'invoiceElectronic',
+				
 				'invoiceAggregate',
 				'invoiceAggregateStaff',
 				'invoiceAggregateCategory',
@@ -325,7 +328,8 @@ $acl ['DIRECTORIES'] ['allow'] = array (
 				'ajaxDeleteTagCompany',
 				'remindCL',
 				'DoEdiTag',
-				'addClientByCompany'
+				'addClientByCompany',
+				'deleteToolTip'
 		)
 );
 
@@ -463,6 +467,10 @@ $acl ['RECEIPTS'] ['allow'] = array (
 				'receiptTrainLecturerEdi',
 				'receiptTrainLecturerAddDo',
 				'receiptTrainLecturerDelDo',
+				
+				'receiptFeeDiversion',
+				'feeAgency',
+				
 				'h5Upload',
 				'receiptTrainDo',
 				'BUGFLAG',

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

@@ -12,6 +12,8 @@ $route['*']['/longle/list/update'] = array('SoftController', 'updateLockApi');
 $route['*']['/longle/list/alteration'] = array('SoftController', 'alterationLongle');
 $route['*']['/longle/syncData'] = array('SoftController', 'syncLongleData');
 
+$route['*']['/longle/list.json'] = array('SoftController', 'longleBySerialnumber');
+
 $route['get']['/longle/test'] = array('SoftController', 'longleTest');
 
 
@@ -145,7 +147,7 @@ $route['*']['/approvalExpenses'] = array('ReceiptController', 'approvalExpenses'
 $route['*']['/approvalExpenses/:status'] = array('ReceiptController', 'approvalExpenses');
 //费用报销单-分细小类
 $route['*']['/receiptFeeDiversion'] = array('ReceiptController', 'receiptFeeDiversion');
-
+$route['*']['/receipt/feeAgency'] = array('ReceiptController', 'feeAgency');
 
 //审批请求
 $route['*']['/expensesEdi/:rid'] = array('ReceiptController', 'expensesEdi');
@@ -665,6 +667,7 @@ $route['*']['/invoicePaperAdd'] = array('InvoiceController', 'invoicePaperAdd');
 $route['*']['/invoicePaperDel/:ipidKey'] = array('InvoiceController', 'invoicePaperDel');
 $route['*']['/ajaxGetinvoicePaperAchieve'] = array('InvoiceController', 'ajaxGetinvoicePaperAchieve');
 
+$route['*']['/invoiceElectronic'] = array('InvoiceController', 'invoiceElectronic');
 
 //数据导入
 $route['*']['/importInvoice'] = array('InvoiceController', 'importInvoice');

+ 5 - 2
protected/controller/AuthenticationController.php

@@ -18,7 +18,7 @@ class AuthenticationController extends DooController {
 			Doo::loadModel('client');
 			$client=new client();
 			//status=3 or status=4 or status=5
-			$longleInfo=$longle->getOne(array ('where' => "key_num= '".$key."' and (status=3 or status=4 or status=5 or status=9)",'asArray' => TRUE));
+			$longleInfo=$longle->getOne(array ('where' => "key_num= '".$key."' and (status=3 or status=4 or status=5 or status=9 or status=10)",'asArray' => TRUE));
 			if (empty($longleInfo)){
 				echo json_encode(array('list'=>array()));die;
 			}
@@ -63,7 +63,10 @@ class AuthenticationController extends DooController {
 			Doo::loadModel('client');
 			$client=new client();
 			
-			$longleInfo=$longle->getOne(array ('where' => "SerialNumber= '".$key."' and (status=3 or status=4 or status=5)",'asArray' => TRUE));
+			$longleInfo=$longle->getOne(array ('where' => "SerialNumber= '".$key."' and (status=3 or status=4 or status=5 or status=9 or status=10)",'asArray' => TRUE));
+			
+			//echo "SerialNumber= '".$key."' and (status=3 or status=4 or status=5 or status=10)";
+			
 			if (empty($longleInfo)){
 				echo json_encode(array('list'=>array()));die;
 			}

+ 4 - 0
protected/controller/InvoiceAjaxController.php

@@ -73,6 +73,10 @@ class InvoiceAjaxController extends DooController {
 		}
 	}
 	
+	function ajaxGetInvoceList(){
+		
+	}
+	
 	/**
 	 * 获得已经结算完成的培训班
 	 */

+ 143 - 44
protected/controller/InvoiceController.php

@@ -453,6 +453,8 @@ class InvoiceController extends DooController {
 		$invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
 		$invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
 		
+		$invoiceForm = $this->get_args ( 'invoiceForm' ) ? $this->get_args ( 'invoiceForm' ) : "";
+		
 		$invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
 		$invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
 		$invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
@@ -524,7 +526,7 @@ class InvoiceController extends DooController {
 		if (empty ( $this->staff [0] ))
 			die ( 'illegal request-Please login' );
 		
-		if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $settlementType )) {
+		if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $settlementType )&&!empty($invoiceForm)) {
 			Doo::loadModel ( 'invoice' );
 			$invoice = new invoice ();
 			Doo::loadModel ( 'L_category' );
@@ -576,10 +578,22 @@ class InvoiceController extends DooController {
 				die ( 'illegal request-settlementError' );
 			}
 
+			
+			if($invoiceForm=='electronic'){
+				$invoiceSerial="#FE" . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
+				$invoiceForm=1;
+			}elseif($invoiceForm=='paper'){
+				$invoiceSerial="#F" . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
+				$invoiceForm=0;
+			}else{
+				die ( 'illegal request-invoiceForm' );
+			}
+			
 			$item = array (
 					'cid' => $cid,
 					'categoryName' => $categoryDetil ['title'],
 					'invoiceElement' => $invoiceElement,
+					'invoiceForm'=>$invoiceForm,
 					
 					'invoiceQuantity' => $invoiceQuantity,
 					'invoiceUnitPrice' => $invoiceUnitPrice,
@@ -589,7 +603,7 @@ class InvoiceController extends DooController {
 					'settlementType' => $st,
 					'doPost' => $doPost,
 					'status' => 1,
-					'invoiceSerial' => "#F" . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT),
+					'invoiceSerial' => $invoiceSerial,
 					'date' => date ( "Y-m-d H:i:s" ),
 					'updateTime' => date ( "Y-m-d H:i:s" ),
 					'sid' => $this->staff [0] ['sid'],
@@ -2568,7 +2582,7 @@ class InvoiceController extends DooController {
 		if (empty ( $invoiceDetail ))
 			die ( 'illegal request' );
 		
-		$invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $invoiceDetail ['invoiceType'] );
+		$invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $invoiceDetail ['invoiceType'],$invoiceDetail['invoiceForm'] );
 		$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
 		
 		if ($invoiceDetail ['settlementType'] == 1) {
@@ -2940,7 +2954,7 @@ class InvoiceController extends DooController {
 		$limit = '0,20';
 		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 		
-		// print_r($list);
+		 //print_r($list);
 		$this->data ['MebSeaEn'] = $MebSea;
 		/*
 		 * $this->data ['get'] = $get; $this->data ['page'] = $pageinfo; $this->data ['date'] = $date;
@@ -3428,13 +3442,13 @@ class InvoiceController extends DooController {
 		}
 		
 		foreach ( $invoiceExistAccount as $key => $value ) {
-			$irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
-			if (empty ( $irList ))
-				$irList [0] ['sumPrice'] = 0;
+// 			$irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
+// 			if (empty ( $irList ))
+// 				$irList [0] ['sumPrice'] = 0;
 			
-			$balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
-			$invoiceExistAccount [$key] ['existAccount'] = $irList [0] ['sumPrice'];
-			$invoiceExistAccount [$key] ['balance'] = $balance;
+			//$balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
+			$invoiceExistAccount [$key] ['existAccount'] = $value ['invoicePrice']-$value ['invoiceBalance'];
+			//$invoiceExistAccount [$key] ['balance'] = $balance;
 		}
 		
 		$receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
@@ -3552,11 +3566,20 @@ class InvoiceController extends DooController {
 			// 收款录入 并绑定发票
 			Doo::db ()->beginTransaction ();
 			
+			//获得发票入账余额
+			//$bindInvicePrice=$invoiceReceivables->getSumOfReceivablesPrice ( $invoiceDetail['irid'] );
+			//$bindPrice=$invoiceDetail ['invoiceBalance']-$bindInvicePrice;
+			
 			$bindStatus = 0;
-			if ($receivablesPrice <= $invoiceDetail ['invoicePrice']){
+			$invoiceBalance=$invoiceDetail ['invoicePrice'];
+			if($invoiceDetail ['invoiceBalance']!=0){
+				$invoiceBalance=$invoiceDetail ['invoiceBalance'];
+			}
+			
+			if ($receivablesPrice <= $invoiceBalance){
 				$bindStatus = 1;
+				//$bindPrice=$receivablesPrice;
 			}
-				
 			
 			$titleMark = $invoiceDetail ['invoiceTitle'];
 			if (! empty ( $invoiceDetail ['invoiceCompany'] ))
@@ -3565,7 +3588,7 @@ class InvoiceController extends DooController {
 					'recepitTitleMark' => $titleMark,
 					'bindStatus' => $bindStatus,
 					'iid' => $invoiceDetail ['iid'],
-					'bindPrice' => $invoiceDetail ['invoicePrice'],
+					'bindPrice' => $receivablesPrice,
 					'bindDate' => date ( "Y-m-d H:i:s" ),
 					'receivablesPrice' => $receivablesPrice,
 					'OriginalPrice' => $receivablesPrice,
@@ -3625,13 +3648,25 @@ class InvoiceController extends DooController {
 					'updateTime' => date ( "Y-m-d H:i:s" ),
 					'iid' => $detail ['iid'] 
 			);
-			$invoiceReceivables = new invoiceReceivables ();
-			$sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
+// 			$invoiceReceivables = new invoiceReceivables ();
+// 			$sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
 			
-			if ($detail ['invoicePrice'] <= $sum)
+// 			$sumBind = $bindInvicePrice;
+// 			$sumBalance=$invoiceReceivables->balanceOfReceivablesPrice($irid);
+// 			$sum=$sumBind+$sumBalance;
+			
+// 			;
+			
+			if ($receivablesPrice>=$invoiceBalance){
 				$item += array (
+						'invoiceBalance'=>0,
 						'untreadStatus' => 3 
 				);
+			}else{
+				$item += array (
+						'invoiceBalance'=>$invoiceBalance-$receivablesPrice
+				);
+			}
 			
 			$invoice->setInvoiceByCondition ( $item );
 			
@@ -4121,6 +4156,25 @@ class InvoiceController extends DooController {
 	}
 	
 	/**
+	 * 电子发票管理
+	 */
+	function invoiceElectronic() {
+		$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
+		$invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
+	
+		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
+	
+		$this->data ['dateString'] = $date;
+		$this->data ['status'] = $status;
+		$this->data ['invoiceType'] = $invoiceType;
+	
+		$this->data ['memu'] = "invoice";
+		$this->data ['staff'] = $this->staff;
+		$this->data ['receiptMemu'] = 'invoicePaper';
+		$this->render ( "/invoice/invoiceElectronic", $this->data );
+	}
+	
+	/**
 	 * 获得纸票分页数据
 	 */
 	function ajaxGetinvoicePaperAchieve() {
@@ -4130,6 +4184,8 @@ class InvoiceController extends DooController {
 		$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
 		$invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
 		
+		$invoiceForm = $this->get_args ( 'invoiceForm' )&&is_numeric($this->get_args ( 'invoiceForm' )) ? $this->get_args ( 'invoiceForm' ) : "0";
+		
 		$invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ORDINARY";
 		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
 		
@@ -4157,6 +4213,12 @@ class InvoiceController extends DooController {
 		elseif ($invoiceType == 'SPECIAL')
 			$con .= ' and a.invoiceType=1 ';
 		
+		if($invoiceForm==0){
+			$con .= ' and a.invoiceForm=0 ';
+		}else{
+			$con .= ' and a.invoiceForm=1 ';
+		}
+			
 		$dateArr = explode ( ':', $date );
 		$D1 = $dateString = '';
 		$D2 = '';
@@ -4176,7 +4238,7 @@ class InvoiceController extends DooController {
 		if (! empty ( $MebSea ))
 			$con .= ' and ( b.invoiceTitle like "%' . $MebSea . '%" or b.invoiceCompany like "%' . $MebSea . '%" or a.invoiceNo like "%' . $MebSea . '%"  )';
 		
-		$invoiceTotal = $invoicePaper->getInvoicePaperCount ();
+		$invoiceTotal = $invoicePaper->getInvoicePaperCount ($invoiceForm);
 		
 		$sql = '  ' . $con;
 		$limit = $page . ',' . $page_size;
@@ -4245,6 +4307,8 @@ class InvoiceController extends DooController {
 		$invoiceNoStart = $this->get_args ( 'invoiceNoStart' ) && is_numeric ( $this->get_args ( 'invoiceNoStart' ) ) ? $this->get_args ( 'invoiceNoStart' ) : 0;
 		$invoiceNoTotal = $this->get_args ( 'invoiceNoTotal' ) && is_numeric ( $this->get_args ( 'invoiceNoTotal' ) ) ? $this->get_args ( 'invoiceNoTotal' ) : 0;
 		
+		$invoiceForm = $this->get_args ( 'invoiceForm' ) && is_numeric ( $this->get_args ( 'invoiceForm' ) ) ? $this->get_args ( 'invoiceForm' ) : 0;
+		
 		if ($invoiceType != '' && ! empty ( $invoiceCode ) && ! empty ( $invoiceNoStart ) && ! empty ( $invoiceNoTotal )) {
 			
 			$sum = $invoiceNoStart + $invoiceNoTotal;
@@ -4260,7 +4324,7 @@ class InvoiceController extends DooController {
 			Doo::db ()->beginTransaction ();
 			// 批量存储纸质发票
 			$date = date ( "Y-m-d H:i:s" );
-			$sql = 'INSERT INTO CLD_invoicePaper (invoiceType, invoiceCode,invoiceNo,date)
+			$sql = 'INSERT INTO CLD_invoicePaper (invoiceType, invoiceCode,invoiceNo,date,invoiceForm)
 				  VALUES ';
 			$paperList = array ();
 			for($invoiceNoStart; $invoiceNoStart <= $sum - 1; $invoiceNoStart ++) {
@@ -4269,7 +4333,7 @@ class InvoiceController extends DooController {
 				$INLENGHT = strlen ( ( int ) $invoiceNoStart ) + $sumLenght;
 				$var = sprintf ( "%0" . $INLENGHT . "d", $invoiceNoStart );
 				
-				$paperSql = '(' . $invoiceType . ',"' . $invoiceCode . '","' . $var . '","' . $date . '")';
+				$paperSql = '(' . $invoiceType . ',"' . $invoiceCode . '","' . $var . '","' . $date . '","'.$invoiceForm.'")';
 				array_push ( $paperList, $paperSql );
 			}
 			
@@ -4279,7 +4343,12 @@ class InvoiceController extends DooController {
 			
 			Doo::db ()->query ( $sql );
 			Doo::db ()->commit ();
-			return 'invoicePaper';
+			if($invoiceForm==1){
+				return 'invoiceElectronic';
+			}else{
+				return 'invoicePaper';
+			}
+			
 		}
 		die ( 'illegal request' );
 	}
@@ -4313,14 +4382,15 @@ class InvoiceController extends DooController {
 		$invoiceReceivables = new invoiceReceivables ();
 		
 		//有BUG-需修改
+		
 		$invoicePrice = $detail ['invoicePrice'] + $detailM ['bindPrice'];
 		if ($detailM ['receivablesPrice'] > $invoicePrice) {
 			$item = array (
 					'bindPrice' => $invoicePrice 
 			);
-		} elseif ($detailM ['receivablesPrice'] <= $invoicePrice) {
+		} elseif ($detailM ['receivablesPrice'] <= $invoicePrice) {//发票金额大于收款金额,绑定金额为收款金额
 			$item = array (
-					'bindPrice' => $invoicePrice,
+					'bindPrice' => $detailM ['receivablesPrice'],
 					'bindStatus' => 1,
 					'bindDate' => date ( "Y-m-d H:i:s" ) 
 			);
@@ -4364,20 +4434,36 @@ class InvoiceController extends DooController {
 		else
 			$iridString = $detail ['irid'] . ',' . $detailM ['irid'];
 		
+		
+		
+//		$invoiceReceivables = new invoiceReceivables ();
+// 		$sumBind = $invoiceReceivables->getSumOfReceivablesPrice ( $detail ['irid'] );
+// 		//这个收款余额
+// 		$sumBalance=$invoiceReceivables->balanceOfReceivablesPrice($detailM ['irid']);
+// 		$sum=$sumBind+$sumBalance;
+		
+		//这个收款余额
+		$sumBalance=$detailM ['receivablesPrice']-$detailM ['bindPrice'];
+		
+//  		echo $detailM ['irid'].'/'.$sumBalance.'/'.$detail ['invoicePrice'];
+//  		die;
+		
 		$item = array (
 				'iid' => $detail ['iid'],
-				'irid' => $iridString 
+				'irid' => $iridString
 		);
 		
-		$invoiceReceivables = new invoiceReceivables ();
-		$sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
-		
-		if ($detail ['invoicePrice'] <= $sum)
+		if ($detail ['invoicePrice'] <= $sumBalance){
 			$item += array (
+					'invoiceBalance'=>0,
 					'untreadStatus' => 3,
 					'bindTime' => date ( "Y-m-d H:i:s" ) 
 			);
-			
+		}else{
+			$item += array (
+					'invoiceBalance'=>$detail ['invoicePrice']-$sumBalance,
+			);
+		}
 			// print_r($item);
 			// echo $sum;die;
 		$invoice->setInvoiceByCondition ( $item );
@@ -6939,20 +7025,27 @@ class InvoiceController extends DooController {
 						<th class="taC" width="150">结算方式</th><td colspan="3">软件销售</td>
 					</tr>';
 				$html .= '	</tbody></table>';
-				if ($detail ['invoiceType'] == 0)
+				if ($detail ['invoiceType'] == 0){
 					$html .= '<table class="table table-bordered table-condensed"><tbody>
-							<tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
+							<tr><th colspan="4" class="taC">增值税普通发票';
+							if($detail ['invoiceForm']==1){
+								$html .= '( <span class="colRed">电子发票</span> )';
+							}
+					$html .= '</th></tr><tr>
 							<th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
 							<th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>		
 									</tr>';
-				else
+				}else{
 					$html .= '<table class="table table-bordered table-condensed"><tbody>
-							<tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
+							<tr><th colspan="4" class="taC">增值税专用发票';
+					if($detail ['invoiceForm']==1){
+						$html .= '( <span class="colRed">电子发票</span> )';
+					}
+					$html .= '</th></tr><tr>
 							<th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
 							<th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
-						
 									';
-				
+				}
 				$html .= '<tr>
 							<th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
 							<th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
@@ -7075,8 +7168,8 @@ class InvoiceController extends DooController {
 			$invoice = new invoice ();
 			Doo::loadModel ( 'invoiceOperationLog' );
 			$invoiceOperationLog = new invoiceOperationLog ();
-			Doo::loadModel ( 'invoiceReceivables' );
-			$invoiceReceivables = new invoiceReceivables ();
+// 			Doo::loadModel ( 'invoiceReceivables' );
+// 			$invoiceReceivables = new invoiceReceivables ();
 			
 			$detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
 			$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
@@ -7089,20 +7182,22 @@ class InvoiceController extends DooController {
 				$receivablesPrice = $detail ['invoicePrice'];
 				if (! empty ( $detail ['irid'] )) {
 					
-					$irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
+// 					$irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
 					
-					if (empty ( $irList ))
-						$irList [0] ['sumPrice'] = 0;
+// 					if (empty ( $irList ))
+// 						$irList [0] ['sumPrice'] = 0;
 					
-					$balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
+// 					$balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
 					
+					$enteredPrice=$detail ['invoicePrice']-$detail ['invoiceBalance'];
+
 					$receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
 						
-						<th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
-						<th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
+						<th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $enteredPrice . '</b></td>
+						<th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $detail ['invoiceBalance'] . '</b></td>
 						
 					</tr></tbody></table>';
-					$receivablesPrice = $balance;
+					$receivablesPrice = $detail ['invoiceBalance'];
 				}
 				
 				if ($loss)
@@ -7376,7 +7471,11 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
 		
-		$invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'FUZZY', " and status=2 and printStatus=1 and untreadStatus=0 and irid='' ", true );
+		
+		
+		$invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'FUZZY', " and status=2 and printStatus=1 and untreadStatus=0 and (irid='' or irid is null) ", true );
+		
+		
 		
 		$invoiceHtml = '';
 		if (! empty ( $invoiceDetail )) {

+ 3 - 1
protected/controller/MainController.php

@@ -556,7 +556,9 @@ class MainController extends DooController {
 				) );
 			}
 		} else {
-			$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
+			$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` 
+					left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid  group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
+			//echo $sql;
 			$query = Doo::db ()->query ( $sql );
 			$result = $query->fetchAll ();
 			$categorylist2 = $result;

+ 37 - 2
protected/controller/ReceiptController.php

@@ -261,13 +261,48 @@ class ReceiptController extends DooController {
 		if($feeType==2){
 			return '/receipt/feeTravel';
 		}elseif($feeType==3){
-			return '/receipt/feeAgency';
-		}else{
 			return '/receipt/feeInternalTrain';
+		}else{
+			return '/receipt/feeAgency';
 		}
 	}
 	
 	/**
+	 * 办事处相关费用
+	 */
+	function feeAgency(){
+		
+		Doo::loadModel ( 'L_category' );
+		$lCategory = new L_category ();
+		Doo::loadModel ( 'verify' );
+		$verify = new verify ();
+		Doo::loadModel ( 'accountItem' );
+		$accountItem = new accountItem ();
+		Doo::loadModel ( "role" );
+		$role = new role ();
+		
+		$acItem = $accountItem->find ( array (
+				'asArray' => true
+		) );
+		$veList = $verify->getVerifyBySubordinate('RECEIPT');
+		
+		$data ['category'] = $lCategory->find ( array (
+				'asArray' => true
+		) );
+		$data ['veList'] = $veList;
+		$data ['acItem'] = $acItem;
+		
+		$data ['memu'] = "receipt";
+		$data ['staff'] = $this->staff;
+		$data ['receiptMemu'] = 'saeaBorad';
+		$data ['verifyId'] = $this->verifyId;
+		
+		$data ['executeId'] = $this->executeId;
+		
+		$this->render ( "/receipt/feeAgency", $data );
+	}
+	
+	/**
 	 * 添加费用报销单页面
 	 */
 	function saeaCreate() {

File diff suppressed because it is too large
+ 87 - 9
protected/controller/SoftController.php


+ 36 - 8
protected/model/invoice.php

@@ -32,6 +32,8 @@ class invoice extends DooModel {
 	 */
 	public $printStatus;
 	public $postStatus;
+	
+	public $invoiceForm;
 	public $invoiceManage;
 	/**
 	 *
@@ -55,6 +57,7 @@ class invoice extends DooModel {
 	public $invoicePrice;
 	public $invoiceQuantity;
 	public $invoiceUnitPrice;
+	public $invoiceBalance;
 	
 	/**
 	 * 管理组人员:发票打印,
@@ -214,9 +217,11 @@ class invoice extends DooModel {
 			'printStatus',
 			'postStatus',
 			'untreadStatus',
+			'invoiceForm',
 			'invoiceQuantity',
 			'invoiceUnitPrice',
 			'invoicePrice',
+			'invoiceBalance',
 			'moldManage',
 			'cid',
 			'categoryName',
@@ -434,11 +439,12 @@ class invoice extends DooModel {
 					'asArray' => TRUE 
 			);
 			
-			if ($query == $this->FUZZY)
+			if ($query == $this->FUZZY){
 				$condition += array (
 						'where' => " (invoiceTitle like '%" . $title . "%' or invoiceCompany like '%" . $title . "%')  " . $cond 
 				);
-			else
+				//echo " (invoiceTitle like '%" . $title . "%' or invoiceCompany like '%" . $title . "%')  " . $cond ;
+			}else
 				$condition += array (
 						'where' => "(invoiceTitle = '" . $title . "' or invoiceCompany= '" . $title . "') " . $cond 
 				);
@@ -1016,7 +1022,13 @@ class invoice extends DooModel {
 				$list [$key] ['untreadCom'] = $express [1];
 			}
 			
-			$list [$key] ['irList'] = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
+			$paid=$value['invoicePrice']-$value['invoiceBalance'];
+			
+			$list [$key] ['irList'] = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );// array(0=>array('sumPrice'=>$paid)); // 
+			if(!empty($list [$key] ['irList'])){
+				$list [$key] ['irList'][0]['sumPrice']=$paid;
+			}
+			
 			
 			if ($olStatus == 'desc')
 				$list [$key] ['operationLog'] = $invoiceOperationLog->getInvoiceOperationLogByIid ( $value ['iid'], 'desc' );
@@ -1028,13 +1040,22 @@ class invoice extends DooModel {
 			
 			// print_r($list [$key] ['OperationLog']);
 			$list [$key] ['sumPrice'] = 0;
-			if (! empty ( $list [$key] ['irList'] ))
+			if (! empty ( $list [$key] ['irList'] )){
 				$list [$key] ['sumPrice'] = $list [$key] ['irList'] [0] ['sumPrice'];
+				if($value['invoicePrice']<=$list [$key] ['irList'] [0] ['sumPrice']){
+					$list [$key] ['sumPrice'] = $value['invoicePrice'];
+				}
+			}
 			$list [$key] ['diffPrice'] = $list [$key] ['invoicePrice'];
-			if (! empty ( $list [$key] ['irList'] [0] ['sumPrice'] ))
-				$list [$key] ['diffPrice'] = $list [$key] ['invoicePrice'] - $list [$key] ['irList'] [0] ['sumPrice'];
+			if (! empty ( $list [$key] ['irList'] [0] ['sumPrice'] )){
+				$diffPrice=$list [$key] ['invoicePrice'] - $list [$key] ['irList'] [0] ['sumPrice'];
+				if($diffPrice<=0){
+					$diffPrice=0;
+				}
+				$list [$key] ['diffPrice'] = $diffPrice;
 				// $list [$key] ['operationLog'] = $invoiceOperationLog->getInvoiceOperationLogByIid ( $value ['iid'], 'desc' );
-			$list [$key] ['lossDetail'] = array ();
+			}
+				$list [$key] ['lossDetail'] = array ();
 			if ($value ['lossIid'] != 0) {
 				$detail = $this->getOne ( array (
 						'where' => "iid=" . $value ['lossIid'],
@@ -1089,10 +1110,17 @@ class invoice extends DooModel {
 			$result ['receivablesPrice'] = 0;
 		}
 		
+		
+		$diffPrice=$invoicePrice - $result ['receivablesPrice'];
+		
+		if($diffPrice<=0){
+			$diffPrice=0;
+		}
+		
 		return array (
 				'invoicePrice' => $invoicePrice,
 				'receivablesPrice' => $result ['receivablesPrice'],
-				'diffPrice' => $invoicePrice - $result ['receivablesPrice'] 
+				'diffPrice' => $diffPrice 
 		);
 	}
 	

+ 4 - 3
protected/model/invoicePaper.php

@@ -50,8 +50,9 @@ class invoicePaper extends DooModel {
 		}
 		return $list;
 	}
-	function getInvoicePaperCount() {
+	function getInvoicePaperCount($invoiceForm=0) {
 		$listCount = $this->count ( array (
+				'where'=>'invoiceForm='.$invoiceForm,
 				'asArray' => TRUE 
 		) );
 		return $listCount;
@@ -61,10 +62,10 @@ class invoicePaper extends DooModel {
 	 * @param number $invoiceType
 	 * @return unknown
 	 */
-	function getInvoicePaperByInvoiceType( $invoiceType = 0) {
+	function getInvoicePaperByInvoiceType( $invoiceType = 0,$invoiceForm=0) {
 		
 		$list = $this->find ( array (
-				'where' => 'iid=0 and invoiceType='.$invoiceType,
+				'where' => 'iid=0 and invoiceType='.$invoiceType.' and invoiceForm='.$invoiceForm,
 				'asArray' => TRUE 
 		) );
 		Doo::loadClass ( 'XDeode' );

+ 26 - 3
protected/model/invoiceReceivables.php

@@ -81,12 +81,35 @@ class invoiceReceivables extends DooModel {
 			'relationIrid',
 			'relationLog' 
 	);
+	
+	/**
+	 * 获得单个收款的余额
+	 * @param string $iridString
+	 * @return number
+	 */
+	public function balanceOfReceivablesPrice($irid=0){
+		if (empty ( $irid ))
+			return 0;
+		
+			$list = $this->getOne ( array (
+					'select' => '  receivablesPrice , bindPrice ',
+					'where' => " irid = " . $irid ,
+					'asArray' => TRUE
+			) );
+			
+			if (empty ( $list )){
+				return 0;
+			}
+			$balance=$list ['receivablesPrice']-$list ['bindPrice'];
+			return $balance;
+	}
+	
 	public function getSumOfReceivablesPrice($iridString = "") {
 		if (empty ( $iridString ))
 			return 0;
 		
 		$list = $this->getOne ( array (
-				'select' => ' sum(receivablesPrice) as receivablesPrice ',
+				'select' => ' sum(receivablesPrice) as receivablesPrice ,sum(bindPrice) as bindPrice ',
 				'where' => " irid IN ( " . $iridString . " )",
 				'groupby' => 'iid',
 				'asArray' => TRUE 
@@ -532,7 +555,7 @@ class invoiceReceivables extends DooModel {
 // 				   find_in_set(b.iid,a.iidExtend) or a.iid=b.iid 
 // 				where ' . $con . ' group by a.irid ORDER BY  ' . $descField . ' ' . $desc . ' limit ' . $limit . '
 // 				';
-		
+// 		echo $sql;
 		
 		
 		$sql='select * from '.$this->_table.' as a where '.$con.' ORDER BY '.$descField.' '.$desc.' limit '.$limit;
@@ -552,7 +575,7 @@ class invoiceReceivables extends DooModel {
 			$query = Doo::db ()->query ( $sql );
 			$invoiceList = $query->fetchAll ();
 		}
-		
+// 		echo $sql;
 		Doo::loadClass ( 'XDeode' );
 		$XDeode = new XDeode ( 5 );
 		Doo::loadModel ( 'invoiceROLog' );

+ 8 - 0
protected/model/longle.php

@@ -87,6 +87,10 @@ class longle extends DooModel {
 		return $this->find ( array ('where' => " key_num like '%".$keynum."%'",'limit'=>'10', 'asArray' => TRUE ) );
 	}
 	
+	public function getLongleByKeyNumDetail($keynum,$SerialNumber=''){
+		return $this->getOne ( array ('where' => " key_num = '".$keynum."' and SerialNumber like '".$SerialNumber."'", 'asArray' => TRUE ) );
+	}
+	
 	public function getLongleByLid($lid){
 		return $this->find ( array ('where' => " lid =".$lid, 'asArray' => TRUE ) );
 	}
@@ -99,6 +103,10 @@ class longle extends DooModel {
 		return $this->getOne ( array ('where' => " SerialNumber like '".$SerialNumber."'", 'asArray' => TRUE ) );
 	}
 	
+	public function getLongleBySerialNumberList($SerialNumber){
+		return $this->find ( array ('where' => " SerialNumber like '".$SerialNumber."'", 'asArray' => TRUE ) );
+	}
+	
 	public function getLongleByClientid($client){
 		return $this->find ( array ('where' => " clientid = '".$client."'", 'asArray' => TRUE ) );
 	}

+ 7 - 0
protected/view/admin/invoiceAdd.html

@@ -313,6 +313,13 @@ $("input[autoIFBTIN]").autocomplete({
 								</tr>
 								
 								<tr>
+									<th class="taC"><span class="colRed">*</span>发票形式</th><td colspan="3">
+									<label class="radio inline"><input type="radio" checked name="invoiceForm" value="paper">纸质发票</label>
+									<label class="radio inline"><input type="radio" name="invoiceForm" value="electronic">电子发票</label>
+									</td>
+								</tr>
+								
+								<tr>
 									<th class="taC"><span class="colRed">*</span>发票类型</th><td colspan="3">
 									<label class="radio inline"><input checked name="invoiceType" id="invoicePlain" onclick="invoiceShow()"  value="0" type="radio"  >增值税普通发票</label>
 									<label class="radio inline colRed"><input name="invoiceType" id="invoiceSpecial" onclick="invoiceShow()"  value="1" type="radio">增值税专用发票</label>

+ 7 - 0
protected/view/admin/invoiceAddFill.html

@@ -259,6 +259,13 @@ $("input[autoIFBTIN]").autocomplete({
 								</tr>
 								
 								<tr>
+									<th class="taC"><span class="colRed">*</span>发票形式</th><td colspan="3">
+									<label class="radio inline"><input type="radio" <!-- if {{invoiceDetail.invoiceForm}}==0 --> checked <!-- endif --> name="invoiceForm" value="paper">纸质发票</label>
+									<label class="radio inline"><input type="radio" <!-- if {{invoiceDetail.invoiceForm}}==1 --> checked <!-- endif --> name="invoiceForm" value="electronic">电子发票</label>
+									</td>
+								</tr>
+								
+								<tr>
 									<th class="taC"><span class="colRed">*</span>发票类型</th><td colspan="3">
 									<label class="radio inline"><input <!-- if {{invoiceDetail.invoiceType}}==0 --> checked <!-- endif --> name="invoiceType" id="invoicePlain" onclick="invoiceShow()"  value="0" type="radio"  >增值税普通发票</label>
 									<label class="radio inline colRed"><input <!-- if {{invoiceDetail.invoiceType}}==1 --> checked <!-- endif --> name="invoiceType" id="invoiceSpecial" onclick="invoiceShow()"  value="1" type="radio">增值税专用发票</label>

+ 2 - 2
protected/view/admin/invoiceApprovalDetail.html

@@ -67,7 +67,7 @@
 						<table class="table table-bordered table-condensed">
 							<tbody>
 							<tr>
-								<th colspan="4" class="taC">增值税普通发票</th>
+								<th colspan="4" class="taC">增值税普通发票<!-- if {{invoiceDetail.invoiceForm}}==1 --> ( <span class="colRed">电子发票</span> ) <!-- endif --></th>
 							</tr>
 							<tr>
 								<th class="taC" width="150">发票抬头</th>
@@ -91,7 +91,7 @@
 						<table class="table table-bordered table-condensed">
 							<tbody>
 							<tr>
-								<th colspan="4" class="taC">增值税专用发票</th>
+								<th colspan="4" class="taC">增值税专用发票 <!-- if {{invoiceDetail.invoiceForm}}==1 --> ( <span class="colRed">电子发票</span> ) <!-- endif --></th>
 							</tr>
 							<tr>
 								<th class="taC" width="150">单位名称</th><td>{{invoiceDetail.invoiceCompany}}</td>

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

@@ -13,7 +13,7 @@
 
 
 <!-- if isInvoiceMoldShow({{staff.0.sid}},'纸票管理') -->
-<li class="topLine"><a <!-- if {{receiptMemu}}=="invoicePaper" --> class="selected" <!-- endif --> href="/invoicePaper">票管理</a></li>
+<li class="topLine"><a <!-- if {{receiptMemu}}=="invoicePaper" --> class="selected" <!-- endif --> href="/invoicePaper">票管理</a></li>
 <!-- endif -->
 <!-- if isInvoiceMoldShow({{staff.0.sid}},'收款管理') -->
 	<li ><a <!-- if {{receiptMemu}}=="invoiceReceivables" --> class="selected" <!-- endif --> href="/invoiceReceivables">收款录入</a></li>

+ 3 - 1
protected/view/admin/invoicePaper.html

@@ -28,7 +28,8 @@
 			</div>
 			<div class="adminContent autoHeight">
 				<legend>
-				纸质发票</legend>
+				纸质发票
+				<a href="/invoiceElectronic">电子发票</a></legend>
 				<div class="demandCate">
 				
 				<form action="/invoicePaper" id="iaa" method="get" >
@@ -196,6 +197,7 @@ $(document).ready( function () {
                    "status": '{{status}}',
                    'invoiceType':'{{invoiceType}}',
                    'date':'{{dateString}}',
+                   'invoiceForm':'0',
                  } );
                }
         }

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

@@ -242,7 +242,7 @@
 									<td>{{invoiceUnAccount' value.categoryName}}{{invoiceUnAccount' value.userName}} {{invoiceUnAccount' value.date}}</td>
 									
 									<td>{{invoiceUnAccount' value.existAccount}}</td>
-									<td>{{invoiceUnAccount' value.balance}}</td>
+									<td>{{invoiceUnAccount' value.invoiceBalance}}</td>
 									
 									<td>
 									<a href="#invdetail" node-invoice='INFO' data-isKey="{{invoiceUnAccount' value.iidKeyUrl}}" data-toggle="modal">{{invoiceUnAccount' value.invoiceSerial}}</a>

+ 5 - 5
protected/view/menu.html

@@ -18,9 +18,11 @@
 <!-- endif -->
 
 <!-- if isShowMenu('BUILD') -->
-<li data-placement="right" data-toggle="ctooltip" data-original-title="建筑计价">
-    <a href="/building" class="icon- <!-- if {{memu}}=="building" --> selected <!-- endif -->">e</a>
+
+<li data-placement="right" data-toggle="ctooltip"  data-original-title="云版管理">
+<a href="/cloud/curing/edition" class="icon- <!-- if {{memu}}=="buildActivation" --> selected <!-- endif -->">e</a>
 </li>
+
 <!-- endif -->
 
 <!-- if isShowMenu('RECEIPTS') -->
@@ -35,9 +37,7 @@
 </li>
 <!-- endif -->
 
-<li data-placement="right" data-toggle="ctooltip"  data-original-title="云版管理">
-<a href="/cloud/curing/edition" class="icon- <!-- if {{memu}}=="buildActivation" --> selected <!-- endif -->">D</a>
-</li>
+
 
 <!-- if isShowMenu('HR') -->
 <li data-placement="right" data-toggle="ctooltip" <!-- if isHRNew() --> class="news" <!-- endif --> data-original-title="人资管理">

+ 2 - 1
protected/view/receipt/receiptFee.html

@@ -335,7 +335,8 @@
 					
                 </div>
                 <div class="modal-footer">
-                	<a href="saea-receipt-add1.html" class="button" target="_blank">确认</a>
+                	<input type="submit" value="确认" class="button">
+                	
                     <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
                 </div>