Procházet zdrojové kódy

修改发票打印排序,发票打印人的显示不正确

caipin před 7 roky
rodič
revize
705fb63b36

+ 23 - 0
global/js/invoice.js

@@ -657,6 +657,29 @@ $(function() {
 		
 		var postData = $(this).attr("data-isKey");
 		$("input[id='unBundKey']").val(postData);
+		$("tbody[node-unBundInvoice]").html("loading");
+		var url = "/ajaxGetInvoiceReceivablesByInvoice";
+		$.ajax({
+			url : url,
+			type : "post",
+			cache : false,
+			dataType : "json",
+			data : {
+				postData : postData
+			},
+			global : true,
+			success : function(data) {
+				if (data.status == 1) {
+					$("tbody[node-unBundInvoice]").html(data.html);
+				} else
+					$("tbody[node-unBundInvoice]").html("illegal request");
+			},
+			error : function(err) {
+				$("tbody[node-unBundInvoice]").html("illegal request");
+			}
+		});
+		
+		
 	});
 	
 	$("a[node-irUpdate]").click(function() {

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

@@ -77,6 +77,7 @@ $acl ['收款管理'] ['allow'] = array (
 				'invoiceAS',
 				'invoiceUnBundLing',
 				'ajaxCheckInvoicePrice',
+				'ajaxGetInvoiceReceivablesByInvoice',
 				'invoiceCompareClaimPrice'
 				
 		) 

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

@@ -1,6 +1,7 @@
 <?php
 
 
+
 $route['*']['/emailtext'] = array('ErrorController', 'emailtext');
 
 $route['*']['/statistics'] = array('MainController', 'keyStatistics');
@@ -107,6 +108,7 @@ $route['*']['/mycompany'] = array('MainController', 'mycompany');
 $route['*']['/searchMyCompany'] = array('MainController', 'mycompany');
 $route['*']['/ajaxSetCompanyAddress'] = array('MainController', 'ajaxSetCompanyAddress');
 
+$route['*']['/backUpActionLog'] = array('MainController', 'backUpActionLog');
 
 
 
@@ -520,6 +522,7 @@ $route['post']['/invoiceUnBundLing'] = array('InvoiceController', 'invoiceUnBund
 
 
 
+
 // $route['get']['/invoiceReceivablesAS/:page/:status/:year'] = array('InvoiceController', 'invoiceReceivablesAS');
 // $route['get']['/invoiceReceivablesAS/:page/:status/:year/:month'] = array('InvoiceController', 'invoiceReceivablesAS');
 // $route['get']['/invoiceReceivablesAS/:page/:status/:year/:month/:MebSea'] = array('InvoiceController', 'invoiceReceivablesAS');
@@ -529,6 +532,7 @@ $route['post']['/invoiceCompareClaimPrice'] = array('InvoiceController', 'invoic
 $route['post']['/ajaxGetInvoiceReceivablesByIrid'] = array('InvoiceController', 'ajaxGetInvoiceReceivablesByIrid');
 $route['post']['/ajaxGetInvoiceReceivablesByTitle'] = array('InvoiceController', 'ajaxGetInvoiceReceivablesByTitle');
 $route['post']['/ajaxCheckInvoicePrice'] = array('InvoiceController', 'ajaxCheckInvoicePrice');
+$route['post']['/ajaxGetInvoiceReceivablesByInvoice'] = array('InvoiceController', 'ajaxGetInvoiceReceivablesByInvoice');
 
 
 //公司汇总查阅

+ 147 - 105
protected/controller/InvoiceController.php

@@ -681,7 +681,7 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoiceTraining' );
 		$invoiceTraining = new invoiceTraining ();
 		
-		$itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $this->staff [0] ['cid'], $this->staff [0] ['sid']);
+		$itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 		$itedList = $invoiceTraining->getInvoiceTrainingByStatus ( 2, '', $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 		$category = $lCategory->getCategory ();
 		
@@ -784,7 +784,7 @@ class InvoiceController extends DooController {
 		foreach ( $isList as $key => $value ) {
 			$irDetail = array ();
 			if ($value ['apStatus'] == 1) {
-				//array_push ( $irDetail, '' );
+				// array_push ( $irDetail, '' );
 				array_push ( $irDetail, '<input class="hide" disabled type="checkbox"  >' );
 			} else {
 				
@@ -800,9 +800,9 @@ class InvoiceController extends DooController {
 				array_push ( $irDetail, $value ['invoiceTitle'] );
 			array_push ( $irDetail, $value ['TIN'] );
 			
-			if (empty ( $value ['mailItems'])&&$value ['apStatus'] != 1){
+			if (empty ( $value ['mailItems'] ) && $value ['apStatus'] != 1) {
 				array_push ( $irDetail, '<a href="#confirm-erro" onclick="invoiceStoreMail(\'' . $value ['storeKey'] . '\')" data-toggle="modal">设置邮寄物品</a>' );
-			}else
+			} else
 				array_push ( $irDetail, $value ['mailItems'] );
 			array_push ( $irDetail, $value ['recipientsAddress'] . $value ['recipients'] . $value ['recipientsPhone'] );
 			
@@ -818,7 +818,6 @@ class InvoiceController extends DooController {
 				array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
 			array_push ( $irDetail, $value ['remark'] );
 			
-			
 			if ($value ['status'] == 1)
 				array_push ( $irDetail, '审批中' );
 			elseif ($value ['status'] == 2 && $value ['printStatus'] == 1)
@@ -931,7 +930,7 @@ class InvoiceController extends DooController {
 			
 			$exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoiceTraining/" . $path, 'invoiceTrain' );
 			
-			$userName=$this->staff [0] ['username'];
+			$userName = $this->staff [0] ['username'];
 			$sDetail = $staff->getStaffByName ( $userName );
 			
 			// 可以优化
@@ -942,7 +941,7 @@ class InvoiceController extends DooController {
 				$invoice->trainId = $itid;
 				
 				$invoice->invoiceType = 0;
-				if ($value ['invoiceType'] == '专'||$value ['invoiceType'] == '专票')
+				if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
 					$invoice->invoiceType = 1;
 				
 				$invoice->invoiceQuantity = $value ['invoiceQuantity'];
@@ -951,10 +950,10 @@ class InvoiceController extends DooController {
 				$invoice->invoicePrice = $value ['invoiceQuantity'] * $value ['invoiceUnitPrice'];
 				
 				$invoice->invoiceTitle = $value ['invoiceTitle'];
-				if ($value ['invoiceType'] == '专'||$value ['invoiceType'] == '专票')
+				if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
 					$invoice->invoiceCompany = $value ['invoiceTitle'];
 				
-				$invoice->userName =$userName;
+				$invoice->userName = $userName;
 				
 				$invoice->sid = $sDetail ['sid'];
 				$invoice->cid = $sDetail ['cid'];
@@ -2071,7 +2070,7 @@ class InvoiceController extends DooController {
 				if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
 					$invoice->status = $status;
 					$invoice->pendingApprovals = 0;
-					$invoice->approvalTime=date ( "Y-m-d H:i:s" );
+					$invoice->approvalTime = date ( "Y-m-d H:i:s" );
 				} elseif ($status == 4) {
 					$invoice->status = $status;
 					$item = array (
@@ -2245,7 +2244,7 @@ class InvoiceController extends DooController {
 		
 		$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
 		$limit = $pageinfo ['lower'] . ',' . $page_size;
-		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql,'desc',5 );
+		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 5 );
 		
 		$this->data ['MebSeaEn'] = $MebSea;
 		$this->data ['MebSea'] = urlencode ( $MebSea );
@@ -2314,7 +2313,7 @@ class InvoiceController extends DooController {
 			$invoice->setInvoiceByCondition ( $item );
 			$item = array (
 					'date' => date ( "Y-m-d H:i:s" ),
-					'operation' => $invoiceNo,
+					'operation' => '打印发票号:'.$invoiceNo,
 					'status' => 5,
 					'img' => $this->staff [0] ['avatar'],
 					'username' => $this->staff [0] ['username'],
@@ -2765,11 +2764,11 @@ class InvoiceController extends DooController {
 		
 		$receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
 		
-		$halfList=$invoiceReceivables->getInvoiceReceivablesByHalf();
+		$halfList = $invoiceReceivables->getInvoiceReceivablesByHalf ();
 		$this->data ['halfList'] = $halfList;
 		$this->data ['halfCount'] = count ( $halfList );
 		
-		//print_r($receivablesList);
+		// print_r($receivablesList);
 		$this->data ['receivablesDate'] = date ( "Y-m-d" );
 		$this->data ['ieaCount'] = count ( $invoiceExistAccount );
 		$this->data ['invoiceExistAccount'] = $invoiceExistAccount;
@@ -2822,9 +2821,15 @@ class InvoiceController extends DooController {
 			
 			// 收款录入 并绑定发票
 			Doo::db ()->beginTransaction ();
+			
+			$bindStatus=0;
+			if ($receivablesPrice<=$invoiceDetail['invoicePrice'])
+				$bindStatus=1;
+			
 			$item = array (
-					'bindStatus' => 1,
+					'bindStatus' => $bindStatus,
 					'iid' => $invoiceDetail ['iid'],
+					'bindPrice'=>$invoiceDetail['invoicePrice'],
 					'bindDate' => date ( "Y-m-d H:i:s" ),
 					'receivablesPrice' => $receivablesPrice,
 					'receivablesMessage' => $receivablesMessage,
@@ -3226,13 +3231,10 @@ class InvoiceController extends DooController {
 		
 		$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 		
-		
-		
 		$this->data ['isMonth'] = $isMonth;
 		$this->data ['htm'] = $htm;
 		$this->data ['list'] = $list;
 		
-		
 		$this->data ['memu'] = "invoice";
 		$this->data ['staff'] = $this->staff;
 		$this->data ['receiptMemu'] = 'invoiceMyReceivables';
@@ -3264,39 +3266,39 @@ class InvoiceController extends DooController {
 		if ($detail ['untreadStatus'] == 3)
 			die ( 'illegal request' );
 			
-		//修改 绑定状态改为 金额	
+			// 修改 绑定状态改为 金额
 		$invoiceReceivables = new invoiceReceivables ();
 		
-		$invoicePrice=$detail['invoicePrice']+$detailM['bindPrice'];
-		if ($detailM['receivablesPrice']>$invoicePrice){
-			$item=array(
-					'bindPrice'=>$invoicePrice
+		$invoicePrice = $detail ['invoicePrice'] + $detailM ['bindPrice'];
+		if ($detailM ['receivablesPrice'] > $invoicePrice) {
+			$item = array (
+					'bindPrice' => $invoicePrice 
 			);
-		}elseif ($detailM['receivablesPrice']<=$invoicePrice){
-			$item=array(
-					'bindPrice'=>$invoicePrice,
-					'bindStatus'=>1,
-					'bindDate' => date ( "Y-m-d H:i:s" )
+		} elseif ($detailM ['receivablesPrice'] <= $invoicePrice) {
+			$item = array (
+					'bindPrice' => $invoicePrice,
+					'bindStatus' => 1,
+					'bindDate' => date ( "Y-m-d H:i:s" ) 
 			);
-		}else{
+		} else {
 			die ( 'illegal request' );
 		}
 		
-		if($detailM['iid']==0){
-			$item+=array(
-					'iid'=>$detail ['iid']
+		if ($detailM ['iid'] == 0) {
+			$item += array (
+					'iid' => $detail ['iid'] 
 			);
-		}else{
-			$iidExtend=explode(',', $detailM ['iidExtend']);
-			array_push($iidExtend, $detail ['iid']);
-			$item+=array(
-					'iidExtend'=>implode(',', $iidExtend)
+		} else {
+			$iidExtend = explode ( ',', $detailM ['iidExtend'] );
+			array_push ( $iidExtend, $detail ['iid'] );
+			$item += array (
+					'iidExtend' => implode ( ',', $iidExtend ) 
 			);
 		}
-			
+		
 		$item += array (
 				'irid' => $detailM ['irid'],
-				'accountClerk' => $this->staff [0] ['username']
+				'accountClerk' => $this->staff [0] ['username'] 
 		);
 		$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 		
@@ -3845,6 +3847,7 @@ class InvoiceController extends DooController {
 	 */
 	function invoiceUnBundLing() {
 		$unBundKey = $this->get_args ( 'unBundKey' ) ? $this->get_args ( 'unBundKey' ) : '';
+		$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
 		
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
@@ -3855,22 +3858,46 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoiceROLog' );
 		$invoiceROLog = new invoiceROLog ();
 		Doo::loadModel ( 'invoiceStatistics' );
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
 		
+		if (empty ( $iidKey ) )
+			die ( 'illegal request' );
+		
+		$iid = $XDeode->decode ( $iidKey );
 		$irid = $invoice->authcode ( $unBundKey );
-		if (! empty ( $irid ) && ! is_numeric ( $irid ))
+		if ((! empty ( $irid ) && ! is_numeric ( $irid ))|| (! empty ( $iid ) && ! is_numeric ( $iid )))
 			die ( 'illegal request' );
 		
 		$irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-		$invoiceDetails = $invoice->getInvoiceByIid ( $irDetails ['iid'] );
+		$invoiceDetails = $invoice->getInvoiceByIid ( $iid );
 		
-		if (empty ( $irDetails ) || $irDetails ['bindStatus'] == 0 || $invoiceDetails ['untreadStatus'] == 2)
+		if (empty ( $irDetails ) || empty ( $invoiceDetails ) || (empty ( $irDetails['iid'] )&& empty ( $irDetails['iidExtend'] )) || $invoiceDetails ['untreadStatus'] == 2)
 			die ( 'illegal request' );
-			// 收款
+		
+			
+		//收款
 		$item = array (
 				'irid' => $irDetails ['irid'],
-				'bindStatus' => 0,
-				'iid' => 0 
+				'bindPrice'=>$irDetails['bindPrice']-$invoiceDetails['invoicePrice'],
+				'bindStatus' => 0
 		);
+		if ($irDetails['iid']==$iid)
+			$item += array (
+					'iid' => 0
+			);
+		else{
+			$iidExtend=explode(',', $irDetails['iidExtend']);
+			foreach ($iidExtend as $key=>$value){
+				if ($value==$iid)
+					unset($iidExtend[$key]);
+			}
+			$iidExtend=implode(',', $iidExtend);
+			$item += array (
+					'iidExtend' => $iidExtend
+			);
+		}
+		
 		$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 		
 		// 收款操作日志
@@ -3948,6 +3975,45 @@ class InvoiceController extends DooController {
 	}
 	
 	/**
+	 * 或者该收款下的所以发票
+	 */
+	function ajaxGetInvoiceReceivablesByInvoice() {
+		$irid = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : '';
+		
+		Doo::loadModel ( 'invoice' );
+		$invoice = new invoice ();
+		Doo::loadModel ( 'invoiceReceivables' );
+		$invoiceReceivables = new invoiceReceivables ();
+		
+		$irid = $invoice->authcode ( $irid );
+		if (! empty ( $irid ) && ! is_numeric ( $irid ))
+			die ( 'illegal request' );
+		
+		$irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
+		$iidString = $irDetails ['iid'];
+		
+		$iidExtend=array_filter(explode(',', $irDetails ['iidExtend']));
+		if (! empty ( $irDetails ['iidExtend'] ))
+			$iidString .= ',' . implode(',', $iidExtend) ;
+		
+		$invoiceList = $invoice->getInvoiceInIid ( $iidString, 'iid,invoiceSerial,invoicePrice,invoiceTitle,invoiceCompany,invoiceElement' );
+		
+		
+		$html = "";
+		foreach ( $invoiceList as $key => $value ) {
+			$title=$value['invoiceTitle'];
+			if (!empty($value['invoiceCompany']))
+				$title=$value['invoiceCompany'];
+			$html .= '<tr><td>'.$value['invoiceSerial'].'</td><td>¥'.$value['invoicePrice'].'</td><td>'.$title.'</td><td>'.$value['invoiceElement'].'</td><td><input type="radio" name="iidKey" value="'.$value['iidKey'].'"></td></tr>';
+		}
+		echo json_encode ( array (
+				'status' => 1,
+				'html' => $html
+		) );
+		
+	}
+	
+	/**
 	 * 发票管理
 	 */
 	function invoiceAS() {
@@ -4074,25 +4140,19 @@ class InvoiceController extends DooController {
 				'previous' => '' 
 		);
 		
-		
 		$sql = 'select count(*) as count
 				from CLD_invoiceReceivables as a left join CLD_invoice as b on
 				find_in_set(b.iid,a.iidExtend) or a.iid=b.iid
 				where ' . $con . ' group by a.irid
 				';
 		
-		$pageinfo =$this->getPageBySql($sql, $page, $page_size, "invoiceReceivablesAS", $get, "");
+		$pageinfo = $this->getPageBySql ( $sql, $page, $page_size, "invoiceReceivablesAS", $get, "" );
 		
-		//print_r($pageinfo);
+		// print_r($pageinfo);
 		
-		//$pageinfo = $this->get_page ( "CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
+		// $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 		
-		
-		
-		
-		
-		
 		$list = $invoiceReceivables->getInvoiceReceivablesByConditionPage ( $limit, $con, 'desc', $descField );
 		// print_r($list);
 		
@@ -4123,11 +4183,11 @@ class InvoiceController extends DooController {
 		
 		$con = '';
 		if ($date == 'MONTHO')
-			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
+			$con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
 		elseif ($date == 'MONTHT')
-			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
+			$con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
 		elseif ($date == 'MONTHY')
-			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
+			$con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 		
 		if (! empty ( $MebSea )) {
 			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
@@ -4203,7 +4263,7 @@ class InvoiceController extends DooController {
 		
 		$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
 		$limit = $pageinfo ['lower'] . ',' . $page_size;
-		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
+		
 		
 		$this->data ['MebSeaEn'] = $MebSea;
 		$this->data ['MebSea'] = urlencode ( $MebSea );
@@ -4216,27 +4276,13 @@ class InvoiceController extends DooController {
 		$this->data ['staff'] = $this->staff;
 		
 		if ($this->ACTION == 'invoicePrintAchieve') {
-			foreach ( $list as $key => $value ) {
-				$list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-				
-				$lastApprover = json_decode ( $value ['processApprovals'], true );
-				if (! empty ( $lastApprover )) {
-					$lastApproverKey = array_keys ( $lastApprover );
-					$lastApprover = end ( $lastApprover );
-					
-					$staffDetail = $staff->getOne ( array (
-							'where' => 'sid=' . end ( $lastApproverKey ),
-							'asArray' => true 
-					) );
-					$lastApprover ['username'] = $staffDetail ['username'];
-				}
-				$list [$key] ['lastApprover'] = $lastApprover;
-			}
+			$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql,'desc',5 );
+			
 			$this->data ['receiptMemu'] = 'invoicePrint';
 			$this->data ['list'] = $list;
 			$this->render ( "/admin/invoicePrintAchieve", $this->data );
 		} elseif ($this->ACTION == 'invoicePostAchieve') {
-			
+			$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 			Doo::loadModel ( 'express' );
 			$express = new express ();
 			$expressList = $express->getExpressByAll ();
@@ -4246,7 +4292,7 @@ class InvoiceController extends DooController {
 			$this->data ['list'] = $list;
 			$this->render ( "/admin/invoicePostAchieve", $this->data );
 		} elseif ($this->ACTION == 'invoiceUntreadAchieve') {
-			
+			$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 			$this->data ['receiptMemu'] = 'invoiceUntread';
 			$this->data ['list'] = $list;
 			$this->render ( "/admin/invoiceUntreadAchieve", $this->data );
@@ -4421,7 +4467,7 @@ class InvoiceController extends DooController {
 			$html = '
 					
 					<form action="/invoicePrintDo" method="post" name="invoicePrint" class="nice-validator n-yellow" onSubmit="return checkPrintForm()" novalidate="novalidate">
-						<input type="hidden" name="invoiceKey" value="'.$detail ['iidKeyXD'].'">
+						<input type="hidden" name="invoiceKey" value="' . $detail ['iidKeyXD'] . '">
 					
 						<div class="modal-dialog modal-lg">
 								
@@ -4511,14 +4557,13 @@ class InvoiceController extends DooController {
 						
 						
 						</tr></tbody></table>';
-				
 			}
 			$html .= '</div><div class="modal-footer"><button type="submit" class="button btn-green"  data-toggle="modal">完成打印</button><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div>
 					</div></div></form>
-					<link rel=stylesheet href="'.WEB_SITE_GLOBAL.'css/jquery.validator.css"> 
-					<script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/jquery.validator.min.js"></script>
-					<script type="text/javascript" src="'.WEB_SITE_GLOBAL.'js/zh-CN.js"></script>
-					<script src="'.WEB_SITE_GLOBAL.'js/invoice.validator.js"></script>
+					<link rel=stylesheet href="' . WEB_SITE_GLOBAL . 'css/jquery.validator.css"> 
+					<script type="text/javascript" src="' . WEB_SITE_GLOBAL . 'js/jquery.validator.min.js"></script>
+					<script type="text/javascript" src="' . WEB_SITE_GLOBAL . 'js/zh-CN.js"></script>
+					<script src="' . WEB_SITE_GLOBAL . 'js/invoice.validator.js"></script>
 					
 					
 					';
@@ -4609,7 +4654,7 @@ class InvoiceController extends DooController {
 							<th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
 						</tr></tbody></table>';
 				
-				if ($detail ['doPost'] == 1){
+				if ($detail ['doPost'] == 1) {
 					$html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
 							<th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
 							<th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
@@ -4619,13 +4664,12 @@ class InvoiceController extends DooController {
 							<th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
 						</tr>
 									';
-								
-					if ($detail ['expressCom']=='SF')
+					
+					if ($detail ['expressCom'] == 'SF')
 						$html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="http://www.sf-express.com/cn/sc/dynamic_function/waybill/#search/bill-number/">' . $detail ['expressNumber'] . '</a> </td></tr>';
-					else 
-						$html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="/invoiceExpress/'.$detail ['expressCom'].'/' . $detail ['expressNumber'] . '.html">' . $detail ['expressNumber'] . '</a> </td></tr>';
+					else
+						$html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="/invoiceExpress/' . $detail ['expressCom'] . '/' . $detail ['expressNumber'] . '.html">' . $detail ['expressNumber'] . '</a> </td></tr>';
 					$html .= '</tbody></table>';
-				
 				}
 				if (! empty ( $invoiceOperationLogList )) {
 					$html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
@@ -4991,7 +5035,7 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
 		
-		$invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 " );
+		$invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'FUZZY', " and status=2 and printStatus=1 and untreadStatus=0 and irid='' " );
 		
 		$invoiceHtml = '';
 		if (! empty ( $invoiceDetail )) {
@@ -5446,7 +5490,7 @@ class InvoiceController extends DooController {
 						$excel_column ['recipients'] = $val;
 					} elseif ($currentColumn == 'N') {
 						$excel_column ['recipientsPhone'] = $val;
-					} 
+					}
 				} else {
 					if ($currentColumn == 'A')
 						$excel_column ['invoiceNo'] = $val;
@@ -5698,7 +5742,6 @@ class InvoiceController extends DooController {
 		return $result ['count'];
 	}
 	
-	
 	/**
 	 * 获得分页数据
 	 * @param unknown_type $table
@@ -5706,36 +5749,36 @@ class InvoiceController extends DooController {
 	 * @param unknown_type $on_page
 	 * @param unknown_type $page_size
 	 */
-	function getPageBySql($sql= "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
+	function getPageBySql($sql = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
 		$page_c = "";
 		$page ['previous'] = $this->get_previous ( $on_page );
 		$page ['on_page'] = $on_page;
 		$total_count = $this->getTableCountBySql ( $sql );
 		$total = intval ( $total_count / $page_size );
-	
+		
 		$page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
 		$page ['total_data'] = $total_count;
 		$page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
-	
+		
 		$i = 1;
 		$page_max = 1;
 		$page_width = 3;
-	
+		
 		if ($on_page >= $page_width) {
 			$page_max = intval ( $on_page / $page_width ) + 1;
 			$i = intval ( $on_page / $page_width ) * $page_width - 1;
 		}
-	
+		
 		for(; $i <= $page ['total_page']; $i ++) {
 			if ($i == $on_page)
 				$page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
-				else
-					$page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
-						
-					if ($i == ($page_width * $page_max))
-						break;
+			else
+				$page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
+			
+			if ($i == ($page_width * $page_max))
+				break;
 		}
-	
+		
 		$page ['page'] = $page_c;
 		$page ['lower'] = (-- $on_page) * $page_size;
 		return $page;
@@ -5746,12 +5789,11 @@ class InvoiceController extends DooController {
 	 * @param string $type
 	 * @return boolean[]
 	 */
-	public function getTableCountBySql($sql=""){
+	public function getTableCountBySql($sql = "") {
 		$query = Doo::db ()->query ( $sql );
 		$result = $query->fetch ();
 		return $result ['count'];
-	}	
-	
+	}
 	function isInvoiceNew($type = "GLOBAL") {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();

+ 16 - 0
protected/controller/MainController.php

@@ -140,6 +140,22 @@ class MainController extends DooController {
 		}
 		return false;
 	}
+	
+	/**
+	 * 优化actionLog表
+	 */
+	function backUpActionLog(){
+		Doo::loadModel ( 'action_log' );
+		$action_log = new action_log ();
+		
+		$date=date("Y");
+		$tableName='CLD_action_log'.$date;
+		$action_log->copyActionLogToBakTable($tableName);
+		$action_log = new action_log ();
+		$aid=0;
+		$action_log->delActionLogByAid($aid);
+	}
+	
 	function login() {
 		$passwork = $this->get_args ( 'passwork' ) ? $this->get_args ( 'passwork' ) : 0;
 		$uid = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : 0;

+ 25 - 1
protected/model/action_log.php

@@ -33,7 +33,31 @@ class action_log extends DooModel {
 	public $iconLock="iconLock";
 	public $iconContacts="iconContacts";
 
-    
+    /**
+     * 拷贝日志表到存储
+     */
+	function copyActionLogToBakTable($tableNmae=''){
+		
+		if (empty($tableNmae))
+			return '';
+		
+		$sql = "SELECT table_name FROM information_schema.TABLES WHERE table_name ='".$tableNmae."'" ;
+		$query = Doo::db ()->query ( $sql );
+		$result = $query->fetch ();
+		if (!empty($result))
+			return '';
+		
+		$sql = "create table ".$tableNmae." as (select * from ".$this->_table.")" ;
+		$query = Doo::db ()->query ( $sql );
+	}
+	
+	function delActionLogByAid($aid=''){
+		if (empty($aid))
+			return '';
+		$sql ="DELETE FROM " . $this->_table . " WHERE `aid`>".$aid;
+		$query = Doo::db ()->query ( $sql );
+	}
+	
     function getClientByCid($cid){
     	$sql = "select * from " . $this->_table . " as a left join CLD_staff as b on (a.sid=b.sid)  where a.cid= '".$cid."' " ;
 		

+ 34 - 13
protected/model/invoice.php

@@ -298,6 +298,31 @@ class invoice extends DooModel {
 		$Detail ['category'] = $lCategory->getCategory ();
 		return $Detail;
 	}
+	/**
+	 * 根据多个iid获得多个发票
+	 * @param number $iid
+	 */
+	function getInvoiceInIid($iid = 0, $select = '') {
+		if (empty ( $iid ))
+			die ( 'illegal request' );
+		
+		$condition = array (
+				'where' => "iid in ( " . $iid . ")",
+				'asArray' => TRUE 
+		);
+		
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
+		$list = $this->find ( $condition );
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ($list as $key=>$value){
+			$list [$key]['iidKey'] = $XDeode->encode ( $value ['iid'] );
+		}
+		return $list;
+	}
 	function setInvoiceLoss($iid = "") {
 		if (empty ( $iid ))
 			return 0;
@@ -333,7 +358,7 @@ class invoice extends DooModel {
 			
 			if ($query == $this->FUZZY)
 				$condition += array (
-						'where' => " (invoiceTitle like '%" . $title . "%' or invoiceCompany '%" . $title . "%')  " . $cond 
+						'where' => " (invoiceTitle like '%" . $title . "%' or invoiceCompany like '%" . $title . "%')  " . $cond 
 				);
 			else
 				$condition += array (
@@ -393,26 +418,22 @@ 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)
+						where trainId in (' . $itidSql . ') and status=2 and printStatus=1 and (untreadStatus =0 or untreadStatus=3)
 						 GROUP BY trainId';
 		$query = Doo::db ()->query ( $sql );
 		return $result = $query->fetchAll ();
 	}
-	
-	function sumOfInvoiceRecelvablesTrain($itidSql){
+	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!="" 
+				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 ();
 	}
 	
-	
 	/**
 	 * 根据仓库ID获得发票
 	 * @param string $Istoreid
@@ -734,7 +755,7 @@ class invoice extends DooModel {
 		}
 		return $list;
 	}
-	function getInvoiceByUntreadStatusPage($limit = 0, $con = "", $desc = 'desc',$olStatus="desc") {
+	function getInvoiceByUntreadStatusPage($limit = 0, $con = "", $desc = 'desc', $olStatus = "desc") {
 		if (empty ( $limit ) || empty ( $con ))
 			return array ();
 		
@@ -766,15 +787,15 @@ class invoice extends DooModel {
 			
 			$list [$key] ['irList'] = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
 			
-			if ($olStatus=='desc')
+			if ($olStatus == 'desc')
 				$list [$key] ['operationLog'] = $invoiceOperationLog->getInvoiceOperationLogByIid ( $value ['iid'], 'desc' );
-			else 
+			else
 				$list [$key] ['operationLog'] = $invoiceOperationLog->getInvoiceOperationByStatus ( $value ['iid'], $olStatus );
 			
 			$list [$key] ['OperationLog'] = $invoiceOperationLog->getInvoiceOperationByStatus ( $value ['iid'], 6 );
-			$list [$key] ['OL'] = $invoiceOperationLog->getInvoiceOperationInStatus($value ['iid'], '2,3,4');
+			$list [$key] ['OL'] = $invoiceOperationLog->getInvoiceOperationInStatus ( $value ['iid'], '2,3,4' );
 			
-			//print_r($list [$key] ['OperationLog']);
+			// print_r($list [$key] ['OperationLog']);
 			$list [$key] ['sumPrice'] = 0;
 			if (! empty ( $list [$key] ['irList'] ))
 				$list [$key] ['sumPrice'] = $list [$key] ['irList'] [0] ['sumPrice'];

+ 1 - 1
protected/model/invoiceReceivables.php

@@ -132,7 +132,7 @@ class invoiceReceivables extends DooModel {
 		$sql = 'select group_concat(b.invoiceSerial) as invoiceSerial ,group_concat(b.iid) as invoiceId ,a.*
 				from ' . $this->_table . ' as a left join CLD_invoice as b on
 				find_in_set(b.iid,a.iidExtend) or a.iid=b.iid 
-				where a.bindStatus=0 and a.iid!=0 
+				where a.bindStatus=0 and a.iid!=0 GROUP BY a.irid
 				';
 		$query = Doo::db ()->query ( $sql );
 		$list = $query->fetchAll ();

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

@@ -106,7 +106,7 @@
 										<!-- elseif {{pendingInvoice' value.status}}==2  and {{pendingInvoice' value.untreadStatus}}==2  -->
 										<a class="button btn-gray btn-block" href="/invoiceDelDo/{{pendingInvoice' value.iidKeyUrl}}.do">从待处理移除</a>
 										
-										<!-- elseif {{handleInvoice' value.status}}==2  and {{handleInvoice' value.untreadStatus}}==1 and {{handleInvoice' value.untreadPost}}==1 -->
+										<!-- elseif {{handleInvoice' value.status}}==2  and {{handleInvoice' value.untreadStatus}}==1 and {{handleInvoice' value.untreadPost}}==1 and empty({{handleInvoice' value.untreadNumber}}) -->
 										<a class="button btn-block" diss-data="{{handleInvoice' value.iidKey}}" node-invoice="untreadInvoice" data-toggle="modal" href="#return">填写快递</a>
 										<!-- endif -->
 										</td>

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

@@ -70,7 +70,7 @@
 							<td>
 							  {{invoiceList' value.invoiceNo}}
 							</td>
-							<td>{{invoiceList' value.lastApprover.username}}&nbsp;{{invoiceList' value.printTime}}</td>
+							<td>{{invoiceList' value.operationLog.username}}&nbsp;{{invoiceList' value.printTime}}</td>
 						</tr>
 						<!-- endloop -->
 						

+ 11 - 7
protected/view/admin/invoiceReceivablesAS.html

@@ -102,15 +102,19 @@
 						<td>
 						<!-- if {{list' value.receivablesStaff}}=='PUBLIC'&&{{list' value.iid}}==0 -->
 							<a href="#receive" data-isKey="{{list' value.iridKey}}" node-alter data-toggle="modal">变更</a>
-						<!-- elseif {{list' value.bindStatus}}==0&&{{list' value.receivablesStaff}}!='PUBLIC'&&{{list' value.iid}}==0 -->	
+						<!-- elseif {{list' value.bindStatus}}==0&&{{list' value.receivablesStaff}}!='PUBLIC' -->	
 						<a  href="#search-invoice" bind-invoice='receivables' node-key="{{list' value.iridKey}}" data-toggle="modal">查询发票</a>
-						<!-- if {{list' value.untreadStatus}}==0 -->
-						</br><a href="#receive" data-isKey="{{list' value.iridKey}}" node-alter data-toggle="modal">变更</a>
-						<!-- endif -->
-						
+							<!-- if {{list' value.untreadStatus}}==0 -->
+							</br><a href="#receive" data-isKey="{{list' value.iridKey}}" node-alter data-toggle="modal">变更</a>
+							<!-- endif -->
+							<!-- if !empty({{list' value.iid}})||!empty({{list' value.iidExtend}}) -->
+							</br><a href="#Unbundling" data-isKey="{{list' value.iridKey}}" node-unBundLing data-toggle="modal">解绑</a>
+							<!-- endif -->
+							
 						<!-- elseif {{list' value.bindStatus}}==1 -->
 						<a href="#Unbundling" data-isKey="{{list' value.iridKey}}" node-unBundLing data-toggle="modal">解绑</a>
-						
+						<!-- elseif {{list' value.bindStatus}}==0 &&(!empty({{list' value.iid}})||!empty({{list' value.iidExtend}})) -->
+						<a href="#Unbundling" data-isKey="{{list' value.iridKey}}" node-unBundLing data-toggle="modal">解绑</a>
 						<!-- endif -->
 						</td>
 						</tr>
@@ -179,7 +183,7 @@
     <div class="modal-body">
 		<p>解绑后,发票与收款 可重新进行新的入账。</p>
 			<table class="table table-bordered">
-			<tbody>
+			<tbody node-unBundInvoice>
 				<tr><td>#F20160316001</td><td>¥1000.00</td><td>珠海纵横公司</td><td>纵横公路工程造价管理系统V9.0</td><td><input type="radio"></td></tr>
 				<tr><td>#F20160316003</td><td>¥1000.00</td><td>珠海纵横公司</td><td>纵横公路工程造价管理系统V9.0</td><td><input type="radio"></td></tr>
 			</tbody>