瀏覽代碼

退款相关功能

caipin 7 年之前
父節點
當前提交
d1f1848da0

+ 1 - 0
global/css/global.css

@@ -109,6 +109,7 @@ a.disenable{color:#ccc}
   transition: color 0.2s linear 0s, background-color 0.2s linear 0s, border-color 0.2s linear 0s;
   -o-transition: color 0.2s linear 0s, background-color 0.2s linear 0s, border-color 0.2s linear 0s;
 }
+
 .colRed {color:#f70000}
 .colOrange {color:#ed8b00}
 .colYel {color:#d9a601}

+ 112 - 0
global/js/invoice.js

@@ -73,6 +73,71 @@ function submitForm(){
     form.submit();
 }
 
+function getRefundByDetail(irid){
+	var url = "/getRefundByDetail";
+	$.ajax({
+		url : url,
+		type : "post",
+		cache : false,
+		dataType : "json",
+		data : {
+			iridKey : irid
+		},
+		global : true,
+		success : function(data) {
+			if (data.status == 1) {
+				$("td[data-refundCompany]").html(data.irDetail.refundCompany);
+				$("td[data-refundNumber]").html(data.irDetail.refundNumber);
+				$("td[data-refundPrice]").html(data.irDetail.refundPrice);
+			} else{
+				$("td[data-refundCompany]").html('');
+				$("td[data-refundNumber]").html('');
+				$("td[data-refundPrice]").html('');
+			}
+		},
+		error : function(err) {
+		}
+	});
+}
+
+function invoiceReceivblesDivShow(postData,type){
+	
+		var po='INVOICE';
+		if(type=='receivables')
+			po='RECEIVABLES';
+		
+		$("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
+		var url = "/ajaxGetInvoiceInfoByType";
+		$.ajax({
+			url : url,
+			type : "post",
+			cache : false,
+			dataType : "json",
+			data : {
+				serial : postData,
+				type:po
+			},
+			global : true,
+			success : function(data) {
+				if (data.status == 1) {
+					$("div[loading-msg='true']").html("");
+					if(type=='receivables')
+						$("#nr").html(data.html);
+					else
+						$("#nc").html(data.html);
+				} else
+					$("div[loading-msg='true']").html("illegal request");
+			},
+			error : function(err) {
+				$("div[loading-msg='true']").html("");
+				$("#nr").html('');
+			}
+		});
+
+}
+
+
+
 $(function() {
 	
 	$('#invoiceNoStart').keyup(function() {
@@ -268,7 +333,45 @@ $(function() {
 		
 	});
 		
+	
+	$("a[node-newReceivables]").click(function() {
+		var postData = $(this).attr("dataKey");
+		$("input[id='iridKey']").val(postData);
+		
+	});	
+	
+	
+	$("button[search-invoiceReceivables]").click(function() {
+		
+		var searchData=$("input[name='searchData']").val();
+		if(searchData==''){
+			alert('请填写完整的流水号');
+			return ;
+		}
+		var url = "/ajaxGetInvoiceReceivablesBySerial";
+		$.ajax({
+			url : url,
+			type : "post",
+			cache : false,
+			dataType : "json",
+			data : {
+				receivablesSerial : searchData
+			},
+			global : true,
+			success : function(data) {
+				if (data.status == 1) {
+					$("tr[htmlReceivables]").html(data.html);
+					
+				} else
+					$("tr[htmlReceivables]").html();
+			},
+			error : function(err) {
+			}
+		});
 		
+	
+	});	
+	
 	$("a[node-post='express']").click(function() {
 		var postData = $(this).attr("post-data");
 		$("input[name='iidKey']").val(postData);
@@ -615,6 +718,8 @@ $(function() {
 			},
 			error : function(err) {
 				$("div[loading-msg='true']").html("");
+				$("#nr").html('');
+				$("#nc").html('');
 			}
 		});
 	});
@@ -648,6 +753,13 @@ $(function() {
 		});
 	});
 	
+	$("a[node-refund]").click(function() {
+		var postData = $(this).attr("dataKey");
+		$("input[name='iridKey']").val(postData);
+	});
+	
+	
+	
 	
 	
 	$("a[node-alter]").click(function() {

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

@@ -93,7 +93,12 @@ $acl ['收款管理'] ['allow'] = array (
 				//开发中
 				'invoiceReceivablesImport',
 				'setInvoiceReceivablesClaim',
-				'invoiceReceivablesBankUpload'
+				'invoiceReceivablesBankUpload',
+				'getRefundByDetail',
+				'ajaxGetInvoiceReceivablesBySerial',
+				'relationNewInvoiceReceivables',
+				'delInvoiceReceivables',
+				'setInvoiceReceivablesRefund'
 				
 		) 
 );

+ 1 - 1
protected/config/execute/invoice.ini

@@ -1 +1 @@
-,41,58,50,41,58
+,41,58,50,41,58,58

+ 1 - 1
protected/config/invoice/invoice.ini

@@ -1 +1 @@
-{"\u53d1\u7968\u5ba1\u6279":"41,58,50"}
+

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

@@ -7,6 +7,8 @@ $route['*']['/statistics'] = array('MainController', 'keyStatistics');
 $route['*']['/category/list.json'] = array('SoftController', 'categoryApi');
 $route['*']['/product/list.json'] = array('SoftController', 'productApi');
 $route['post']['/longle/list/add'] = array('SoftController', 'addLockApi');
+
+
 $route['get']['/longle/test'] = array('SoftController', 'longleTest');
 
 $route['*']['/adlogin'] = array('AdminController', 'adlogin', 'authFailURL' => './error/loginFail');
@@ -45,6 +47,14 @@ $route['*']['/adminExecute'] = array('AdminController', 'adminExecute');
 $route['*']['/addExecute'] = array('AdminController', 'addExecute');
 $route['*']['/delExecute/:uid/:eid'] = array('AdminController', 'delExecute');
 
+$route['*']['/adminReceiptAuthority'] = array('AdminController', 'adminReceiptAuthority');
+$route['*']['/addReceiptAuthorityManage'] = array('AdminController', 'addReceiptAuthorityManage');
+$route['get']['/delReceiptAuthorityManage/:sidKey/:icidKey'] = array('AdminController', 'delReceiptAuthorityManage');
+
+$route['*']['/addUserDistrictAuthor'] = array('AdminController', 'addUserDistrictAuthor');
+$route['*']['/delUserDistrictAuthor/:didKey/:sidKey'] = array('AdminController', 'delUserDistrictAuthor');
+
+
 $route['*']['/adminlock'] = array('MainController', 'adminLock');
 
 //官网查询真伪
@@ -550,6 +560,12 @@ $route['post']['/invoiceUnBundLing'] = array('InvoiceController', 'invoiceUnBund
 $route['*']['/invoiceReceivablesBankUpload'] = array('InvoiceController', 'invoiceReceivablesBankUpload');
 $route['*']['/invoiceReceivablesImport'] = array('InvoiceController', 'invoiceReceivablesImport');
 
+$route['post']['/setInvoiceReceivablesRefund'] = array('InvoiceController', 'setInvoiceReceivablesRefund');
+
+$route['post']['/getRefundByDetail'] = array('InvoiceController', 'getRefundByDetail');
+$route['post']['/ajaxGetInvoiceReceivablesBySerial'] = array('InvoiceController', 'ajaxGetInvoiceReceivablesBySerial');
+$route['post']['/relationNewInvoiceReceivables'] = array('InvoiceController', 'relationNewInvoiceReceivables');
+$route['get']['/delInvoiceReceivables/:iridKey'] = array('InvoiceController', 'delInvoiceReceivables');
 
 
 // $route['get']['/invoiceReceivablesAS/:page/:status/:year'] = array('InvoiceController', 'invoiceReceivablesAS');

+ 270 - 4
protected/controller/AdminController.php

@@ -203,15 +203,93 @@ class AdminController extends DooController {
 		
 		Doo::loadModel ( 'L_category' );
 		Doo::loadModel ( 'staff' );
-		
 		$staff = new staff ();
 		$L_category = new L_category ();
+		Doo::loadModel('district');
+		$district=new district();
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		$stafflist=$staff->getStaff ();
+		foreach ($stafflist as $key=>$value){
+			$info=$staff->getUserById ( $value['sid'] );
+			$didList=explode(',', $info[0]['did']);
+			$didList=array_filter($didList);
+			$list=array();
+			
+			if (!empty($didList)){
+				foreach ($didList as $k=>$v){
+					array_push($list, $XDeode->decode ( $v )) ;
+				}
+				$stafflist[$key]['idDistrictList']=$district->getDistrictInId(implode(',', $list));
+			}else{
+				$stafflist[$key]['idDistrictList']=array();
+			}
+		}
 		
+		$data['districtList']=$district->get_lv(1);
 		$data ['category'] = $L_category->getCategory ();
-		$data ['stafflist'] = $staff->getStaff ();
+		$data ['stafflist'] = $stafflist;
 		$data ['staff'] = $this->staff;
 		$this->render ( "/admin/admin_user", $data );
 	}
+	
+	/**
+	 * 添加浏览省份的权限
+	 */
+	function addUserDistrictAuthor(){
+		$didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array();
+		$sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : array();
+		
+		if (! empty ( $didKey )&&! empty ( $sidKey ) ) {
+			Doo::loadModel ( 'staff' );
+			$staff = new staff ();
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$sid=$XDeode->decode($sidKey);
+			$sDetail=$staff->getStaffBySid($sid);
+			
+			$sDidList=explode(',', $sDetail['did']);
+			
+			$commonList=array_unique(array_merge($sDidList, $didKey));
+			
+			$staff->did=implode(',', $commonList);
+			$staff->sid = $sid;
+			$staff->update ();
+			return '/edi/user/'.$sid;
+		}
+		die ( 'illegal request' );
+	}
+	
+	/**
+	 * 删除省份权限
+	 */
+	function delUserDistrictAuthor(){
+		$didKey = isset ( $this->params ['didKey'] ) ? $this->params ['didKey'] : "";
+		$sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : "";
+		if (! empty ( $sidKey ) && ! empty ( $didKey ) ) {
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			Doo::loadModel ( 'staff' );
+			$staff = new staff ();
+			$sid=$XDeode->decode($sidKey);
+			$sDetail=$staff->getStaffBySid($sid);
+			$sDidList=explode(',', $sDetail['did']);
+			
+			foreach ($sDidList as $key=>$value){
+				if ($value==$didKey)
+					unset($sDidList[$key]);
+			}
+			
+			$staff->did=implode(',', $sDidList);
+			$staff->sid = $sid;
+			$staff->update ();
+			return '/edi/user/'.$sid;
+		}
+		die ( 'illegal request' );
+	}
+	
 	function adduser() {
 		$username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
 		$password = $this->get_args ( 'password' ) ? $this->get_args ( 'password' ) : "";
@@ -219,6 +297,8 @@ class AdminController extends DooController {
 		$hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
 		$nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 1;
 		
+		$didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array();
+		
 		if (! empty ( $username ) && ! empty ( $password ) && ! empty ( $cid ) && ! empty ( $hiredate ) && ! empty ( $nature )) {
 			
 			Doo::loadModel ( 'L_category' );
@@ -243,6 +323,9 @@ class AdminController extends DooController {
 			$staff->category = $cagegory [0] ['title'];
 			$staff->hiredate = $hiredate;
 			$staff->nature = $nature;
+			
+			$staff->did=implode(',', $didKey);
+			
 			$id = $staff->insert ();
 			
 			$holidaystaff = new HStaff ();
@@ -270,14 +353,33 @@ class AdminController extends DooController {
 		
 		if (! empty ( $sid )) {
 			
+			Doo::loadModel('district');
+			$district=new district();
+			
 			$data ['msg'] = urldecode ( $msg );
 			Doo::loadModel ( 'L_category' );
+			$L_category = new L_category ();
 			Doo::loadModel ( 'staff' );
 			$staff = new staff ();
-			$L_category = new L_category ();
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
 			
+			$info=$staff->getUserById ( $sid );
+			$didList=explode(',', $info[0]['did']);
+			$didList=array_filter($didList);
+			$list=array();
+			if (!empty($didList)){
+				foreach ($didList as $key=>$value){
+					array_push($list, $XDeode->decode ( $value )) ;
+				}
+				$idDistrictList=$district->getDistrictInId(implode(',', $list));
+			}else{
+				$idDistrictList=array();
+			}
+			$data['idDistrictList']=$idDistrictList;
+			$data['districtList']=$district->get_lv(1);
 			$data ['newPw'] = '';
-			$data ['staffInfo'] = $staff->getUserById ( $sid );
+			$data ['staffInfo'] = $info;
 			$data ['category'] = $L_category->getCategory ();
 			$data ['staff'] = $this->staff;
 			$data ['memu'] = "adminuser";
@@ -978,6 +1080,170 @@ class AdminController extends DooController {
 	}
 	
 	/**
+	 * 报销单汇总权限配置 
+	 */
+	function adminReceiptAuthority(){
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		Doo::loadModel ( 'staff' );
+		$staff = new staff ();
+		Doo::loadModel ( "receiptAuthorityManage" );
+		$receiptAuthorityManage = new receiptAuthorityManage ();
+		Doo::loadModel ( 'L_category' );
+		$category = new L_category ();
+		
+		$categoryList = $category->getCategory ();
+		$managelist = $receiptAuthorityManage->find ( array (
+				'asArray' => true
+		) );
+		$staffList = $staff->getStaff ();
+		
+		$invoiceStaff = array ();
+		foreach ( $categoryList as $key => $value ) {
+			$invoiceStaff [$value ['cidKey']] = array ();
+			$categoryList [$key] ['html'] = '';
+			foreach ( $staffList as $k => $v ) {
+				$ul = array ();
+				if ($value ['cid'] == $v ['cid']) {
+					array_push ( $ul, $v ['sidKey'] );
+					array_push ( $ul, $v ['username'] );
+					array_push ( $invoiceStaff [$value ['cidKey']], $ul );
+				}
+			}
+				
+			foreach ( $managelist as $e => $a ) {
+				if ($value ['cid'] == $a ['cid']) {
+					$name = json_decode ( $a ['staff'] );
+					$staffString = "";
+					foreach ( $name as $y => $l ) {
+						$sidKey = $XDeode->encode ( $l [0] );
+						$icidKey = $XDeode->encode ( $a ['icid'] );
+						$staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delReceiptAuthorityManage/' . $sidKey . '/' . $icidKey . '\'"  role="button" title="删除" class="icon-">k</a>&nbsp;';
+					}
+					$categoryList [$key] ['html'] = $staffString;
+					break;
+				}
+			}
+		}
+		
+		$data ['categoryList'] = $categoryList;
+		$data ['invoiceStaff'] = json_encode ( $invoiceStaff );
+		
+		$data ['memu'] = "verify";
+		$data ['staff'] = $this->staff;
+		$this->render ( "/admin/adminReceiptAuthority", $data );
+	}
+	
+	/**
+	 * 添加报销单汇总查看权限
+	 */
+	function addReceiptAuthorityManage() {
+		$cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
+		$sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
+	
+		if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
+			Doo::loadModel ( "receiptAuthorityManage" );
+			$receiptAuthorityManage = new receiptAuthorityManage ();
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			Doo::loadModel ( 'staff' );
+			$staff = new staff ();
+	
+			$cid = $XDeode->decode ( $cidKey );
+			$sid = $XDeode->decode ( $sidKey );
+			if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
+				die ( 'illegal request' );
+					
+				$icm = $receiptAuthorityManage->getOne ( array (
+						'where' => 'cid =' . $cid,
+						'asArray' => true
+				) );
+				$staffDetail = $staff->getStaffBySid ( $sid );
+					
+				if (empty ( $icm )) {
+					$receiptAuthorityManage = new receiptAuthorityManage ();
+					$list = array ();
+	
+					$info = array (
+							$staffDetail ['sid'],
+							$staffDetail ['username']
+					);
+					array_push ( $list, $info );
+	
+					$receiptAuthorityManage->cid = $cid;
+					$receiptAuthorityManage->staff = json_encode ( $list );
+	
+					$receiptAuthorityManage->insert ();
+				} else {
+					$invoiceCompanyManage = new receiptAuthorityManage ();
+					$list = json_decode ( $icm ['staff'], true );
+	
+					$flag = true;
+					foreach ( $list as $key => $value ) {
+						if ($value [0] == $sid) {
+							$flag = false;
+							break;
+						}
+					}
+					if ($flag) {
+						$info = array (
+								$staffDetail ['sid'],
+								$staffDetail ['username']
+						);
+						array_push ( $list, $info );
+					}
+					$invoiceCompanyManage->staff = json_encode ( $list );
+					$invoiceCompanyManage->update ( array (
+							'where' => 'icid = ' . $icm ['icid']
+					) );
+				}
+				return '/adminReceiptAuthority';
+		}
+		die ( 'illegal request' );
+	}
+	
+	/**
+	 * 去除查看办事处汇总人员
+	 */
+	function delReceiptAuthorityManage() {
+		$sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
+		$icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
+	
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+	
+		$icid = $XDeode->decode ( $icidKey );
+		$sid = $XDeode->decode ( $sidKey );
+		if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
+			die ( 'illegal request' );
+	
+			Doo::loadModel ( "receiptAuthorityManage" );
+			$receiptAuthorityManage = new receiptAuthorityManage ();
+	
+			$icmDetail = $receiptAuthorityManage->getInvoiceCMByIcid ( $icid );
+			if (empty ( $icmDetail ))
+				die ( 'illegal request' );
+	
+				$list = json_decode ( $icmDetail ['staff'], true );
+	
+				foreach ( $list as $k => $v ) {
+					if ($v [0] == $sid) {
+						unset ( $list [$k] );
+						break;
+					}
+				}
+				$invoiceCompanyManage = new receiptAuthorityManage ();
+				$invoiceCompanyManage->staff = json_encode ( $list );
+				$invoiceCompanyManage->update ( array (
+						'where' => 'icid = ' . $icmDetail ['icid']
+				) );
+	
+				return '/adminReceiptAuthority';
+	}
+	
+	
+	
+	/**
 	 * 开票应收款权限设置
 	 */
 	function adminInvoiceCompany() {

+ 363 - 48
protected/controller/InvoiceController.php

@@ -74,17 +74,16 @@ class InvoiceController extends DooController {
 			if (empty ( $icm ))
 				die ( 'illegal request' );
 		}
-		//单独判断应收款访问权限 
-		if ($action == 'invoiceAggregateCompanyDetail' ) {
+		// 单独判断应收款访问权限
+		if ($action == 'invoiceAggregateCompanyDetail') {
 			Doo::loadModel ( "invoiceCompanyManage" );
 			$invoiceCompanyManage = new invoiceCompanyManage ();
-				
+			
 			$icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
 			if (empty ( $icm ))
 				die ( 'illegal request' );
 		}
 		
-		
 		if (! $flag)
 			die ( 'illegal request' );
 	}
@@ -2135,7 +2134,7 @@ class InvoiceController extends DooController {
 			if (empty ( $divApproval ))
 				return '/invoiceApproval';
 			else
-				return '/invoiceApprovalAchieve';
+				return '/invoiceApprovalAchieve/PEND';
 		}
 		die ( 'illegal request' );
 	}
@@ -2299,7 +2298,7 @@ class InvoiceController extends DooController {
 			$con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
 		
 		if (! empty ( $MebSea )) {
-			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
+			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
 		}
 		$pageinfo ['page'] = array (
 				'previous' => '' 
@@ -2867,12 +2866,12 @@ class InvoiceController extends DooController {
 			
 			Doo::db ()->beginTransaction ();
 			// 批量存储收款--由于必须获得收款ID,
-			$sql = 'INSERT INTO CLD_invoiceReceivables (receivablesPrice, receivablesMessage,receivablesSerial,receivablesBank,receivablesDate,inputStaff,date,receivablesCategory,receivablesStaff,bankBatchNumber,recepitTitleMark)
+			$sql = 'INSERT INTO CLD_invoiceReceivables (OriginalPrice,receivablesPrice, receivablesMessage,receivablesSerial,receivablesBank,receivablesDate,inputStaff,date,receivablesCategory,receivablesStaff,bankBatchNumber,recepitTitleMark)
 				  VALUES ';
 			$date = date ( "Y-m-d" );
 			$receivablesList = array ();
 			foreach ( $exlArray as $key => $value ) {
-				$receivablesSql = '(' . $value ["receivablesPrice"] . ',"' . $value ["receivablesMessage"] . '",' . '"#SK' . date ( "Ymd" ) . mt_rand ( 1000, 9999 ) . '","' . $value ["receivablesBank"] . '","' . $value ["receivablesDate"] . '","' . $this->staff [0] ['username'] . '","' . $date . '","PUBLIC","PUBLIC","' . $bankBatchNumber . '","' . $value ["receivablesMessage"] . '")';
+				$receivablesSql = '(' . $value ["receivablesPrice"] . ',' . $value ["receivablesPrice"] . ',"' . $value ["receivablesMessage"] . '",' . '"#SK' . date ( "Ymd" ) . mt_rand ( 1000, 9999 ) . '","' . $value ["receivablesBank"] . '","' . $value ["receivablesDate"] . '","' . $this->staff [0] ['username'] . '","' . $date . '","PUBLIC","PUBLIC","' . $bankBatchNumber . '","' . $value ["receivablesMessage"] . '")';
 				array_push ( $receivablesList, $receivablesSql );
 			}
 			$sql = $sql . implode ( ',', $receivablesList );
@@ -3090,6 +3089,7 @@ class InvoiceController extends DooController {
 					'bindPrice' => $invoiceDetail ['invoicePrice'],
 					'bindDate' => date ( "Y-m-d H:i:s" ),
 					'receivablesPrice' => $receivablesPrice,
+					'OriginalPrice' => $receivablesPrice,
 					'receivablesMessage' => $receivablesMessage,
 					'receivablesSerial' => $receivablesSerial,
 					'receivablesBank' => $receivablesBank,
@@ -3219,6 +3219,7 @@ class InvoiceController extends DooController {
 			
 			$item = array (
 					'receivablesPrice' => $receivablesPrice,
+					'OriginalPrice' => $receivablesPrice,
 					'receivablesMessage' => $receivablesMessage,
 					'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
 					'receivablesBank' => $receivablesBank,
@@ -3426,7 +3427,10 @@ class InvoiceController extends DooController {
 	}
 	function invoiceReceivablesDelete() {
 		$claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
+		$skll = $this->get_args ( 'skll' ) ? $this->get_args ( 'skll' ) : "";
 		
+		if ($skll!='删除到款')
+			die ( 'illegal request' );
 		if (empty ( $claimKey ))
 			die ( 'illegal request' );
 		
@@ -3439,6 +3443,30 @@ class InvoiceController extends DooController {
 			die ( 'illegal request' );
 		
 		$invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
+		
+		//扣除收款汇总信息 汇总
+		Doo::loadModel ( 'invoiceStatistics' );
+		$invoiceStatistics = new invoiceStatistics ();
+		$item = array (
+				'date' => $detail['receivablesDate'],
+				'priceClass' => 2,
+				'irid' => $detail['irid'],
+				'receivablesPrice' => -$detail['receivablesPrice']
+		);
+		if ($detail['receivablesCategory'] != 'PUBLIC') {
+			$receivablesCategory = explode ( ":", $detail['receivablesCategory'] );
+			$item += array (
+					'cid' => $receivablesCategory [0]
+			);
+		}
+		if ($detail['receivablesStaff'] != 'PUBLIC') {
+			$receivablesStaff = explode ( "-", $detail['receivablesStaff'] );
+			$item += array (
+					'staff' => $receivablesStaff [0]
+			);
+		}
+		$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
+		
 		return '/invoiceReceivablesAS';
 	}
 	
@@ -4854,7 +4882,7 @@ class InvoiceController extends DooController {
 		$get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
 		
 		if (! empty ( $MebSea )) {
-			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%"  or invoiceCompany like "%' . $MebSea . '%" )';
+			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%"  or invoiceCompany like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
 		}
 		$pageinfo ['page'] = array (
 				'previous' => '' 
@@ -4926,6 +4954,8 @@ class InvoiceController extends DooController {
 			$con .= ' and a.bindStatus=0 and a.receivablesStaff="PUBLIC"';
 		elseif ($status == 'BBN')
 			$con .= ' and a.bankBatchNumber!=""';
+		elseif ($status == 'REFUND')
+			$con .= ' and ( (a.bindStatus=0 and a.refundLog!="" ) or a.bindStatus=2)';
 		
 		$get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
 		
@@ -4968,6 +4998,246 @@ class InvoiceController extends DooController {
 		$this->render ( "/admin/invoiceReceivablesAS", $this->data );
 	}
 	
+	/**
+	 * 删除一条收款
+	 */
+	function delInvoiceReceivables() {
+		$iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
+		
+		if (empty ( $iridKey ))
+			die ( 'illegal request' );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		$irid = $XDeode->decode ( $iridKey );
+			
+		Doo::loadModel ( 'invoiceReceivables' );
+		$invoiceReceivables = new invoiceReceivables ();
+		
+		
+		$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
+		if (empty ( $detail ))
+			die ( 'illegal request' );
+		
+		$invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
+		
+		//扣除收款汇总信息 汇总
+		Doo::loadModel ( 'invoiceStatistics' );
+		$invoiceStatistics = new invoiceStatistics ();
+		$item = array (
+					'date' => $detail['receivablesDate'],
+					'priceClass' => 2,
+					'irid' => $detail['irid'],
+					'receivablesPrice' => -$detail['receivablesPrice'] 
+		);
+		if ($detail['receivablesCategory'] != 'PUBLIC') {
+			$receivablesCategory = explode ( ":", $detail['receivablesCategory'] );
+			$item += array (
+					'cid' => $receivablesCategory [0] 
+			);
+		}
+		if ($detail['receivablesStaff'] != 'PUBLIC') {
+			$receivablesStaff = explode ( "-", $detail['receivablesStaff'] );
+			$item += array (
+					'staff' => $receivablesStaff [0] 
+			);
+		}
+		$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
+		
+		return '/invoiceReceivablesAS';
+	}
+	
+	/**
+	 * 添加退款信息
+	 */
+	function setInvoiceReceivablesRefund() {
+		$iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
+		
+		$refundType = $this->get_args ( 'refundType' ) && is_numeric ( $this->get_args ( 'refundType' ) ) ? $this->get_args ( 'refundType' ) : '0';
+		$refundCompany = $this->get_args ( 'refundCompany' ) ? $this->get_args ( 'refundCompany' ) : "";
+		$refundNumber = $this->get_args ( 'refundNumber' ) ? $this->get_args ( 'refundNumber' ) : "";
+		$refundPrice = $this->get_args ( 'refundPrice' ) ? $this->get_args ( 'refundPrice' ) : "";
+		
+		if($refundPrice<0)
+			die ( 'illegal request' );
+		if (! empty ( $iridKey ) && ! empty ( $refundCompany ) && ! empty ( $refundNumber ) && ! empty ( $refundPrice )) {
+			
+			Doo::loadModel ( 'invoiceReceivables' );
+			$invoiceReceivables = new invoiceReceivables ();
+			Doo::loadModel ( 'invoiceRefund' );
+			$invoiceRefund = new invoiceRefund ();
+			
+			$irid = $invoiceReceivables->authcode ( $iridKey );
+			$irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
+			
+			$invoiceReceivables = new invoiceReceivables ();
+			$refundLog = $this->staff [0] ['username'] . ' 退款  <b class="colRed">¥' . $refundPrice . '</b>
+					<br/><a href="#refunded" onclick="getRefundByDetail(\'' . $iridKey . '\')" data-toggle="modal">退款信息</a> <br/>' . date ( "Y-m-d H:i:s" ) . '
+							';
+			$item = array (
+					'irid' => $irid,
+					'refundCompany' => $refundCompany,
+					'refundNumber' => $refundNumber,
+					'refundPrice' => $refundPrice,
+					'refundLog' => $refundLog 
+			);
+			if ($refundType == 1) {
+				$item += array (
+						'refundType' => $refundType,
+						'receivablesPrice' => $refundPrice,
+						'bindStatus' => 2 
+				);
+			} elseif ($refundType == 0 && $irDetail ['receivablesPrice'] <= $refundPrice) {
+				$item += array (
+						'refundType' => 1,
+						'receivablesPrice' => $irDetail ['receivablesPrice'] -$refundPrice,
+						'bindStatus' => 2 
+				);
+			} else {
+				$item += array (
+						'refundType' => $refundType,
+						'receivablesPrice' => $irDetail ['receivablesPrice'] - $refundPrice 
+				);
+			}
+			$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
+			
+			// 添加退款记录
+			$item = array (
+					'irid' => $irid,
+					'refundType' => $refundType,
+					'refundCompany' => $refundCompany,
+					'refundNumber' => $refundNumber,
+					'refundPrice' => $refundPrice,
+					'refundLog' => $refundLog,
+					'date' => date ( "Y-m-d H:i:s" ) 
+			);
+			$invoiceRefund->addInvoiceRefund ( $item );
+			
+			
+			//扣除收款汇总信息 汇总
+			Doo::loadModel ( 'invoiceStatistics' );
+			$invoiceStatistics = new invoiceStatistics ();
+			$item = array (
+					'date' => $irDetail['receivablesDate'],
+					'priceClass' => 2,
+					'irid' => $irDetail['irid'],
+					'receivablesPrice' => -$refundPrice
+			);
+			if ($irDetail['receivablesCategory'] != 'PUBLIC') {
+				$receivablesCategory = explode ( ":", $irDetail['receivablesCategory'] );
+				$item += array (
+						'cid' => $receivablesCategory [0]
+				);
+			}
+			if ($irDetail['receivablesStaff'] != 'PUBLIC') {
+				$receivablesStaff = explode ( "-", $irDetail['receivablesStaff'] );
+				$item += array (
+						'staff' => $receivablesStaff [0]
+				);
+			}
+			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
+			
+			
+			
+			return '/invoiceReceivablesAS';
+		}
+		die ( 'illegal request' );
+	}
+	
+	/**
+	 * 获得收款退款信息
+	 */
+	function getRefundByDetail() {
+		$iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
+		
+		Doo::loadModel ( 'invoiceReceivables' );
+		$invoiceReceivables = new invoiceReceivables ();
+		if (! empty ( $iridKey )) {
+			$irid = $invoiceReceivables->authcode ( $iridKey );
+			$irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
+			
+			echo json_encode ( array (
+					'status' => 1,
+					'irDetail' => $irDetail 
+			) );
+			die ();
+		}
+		echo json_encode ( array (
+				'status' => 2 
+		) );
+	}
+	
+	/**
+	 * 根据收款序列号获得收款退款信息
+	 */
+	function ajaxGetInvoiceReceivablesBySerial() {
+		$receivablesSerial = $this->get_args ( 'receivablesSerial' ) ? $this->get_args ( 'receivablesSerial' ) : '';
+		
+		if (! empty ( $receivablesSerial )) {
+			Doo::loadModel ( 'invoiceReceivables' );
+			$invoiceReceivables = new invoiceReceivables ();
+			
+			$irDetail = $invoiceReceivables->getInvoiceReceivablesBySerial ( $receivablesSerial, ' and refundLog=""' );
+			$html = '';
+			if (! empty ( $irDetail ))
+				$html = '<td><b>¥' . $irDetail ['receivablesPrice'] . '</b></td>
+					<td>' . $irDetail ['receivablesMessage'] . '</td>
+					<td>' . $irDetail ['receivablesBank'] . '<br>' . $irDetail ['receivablesDate'] . '</td>
+					<td>' . $irDetail ['title'] . '-' . $irDetail ['username'] . '<br>' . $irDetail ['confirmTime'] . '</td>
+					<td>' . $irDetail ['recepitTitleMark'] . '
+							<input type="hidden" name="iridKey" id="iridKey" value="' . $irDetail ['iridKey'] . '">
+							</td>';
+			
+			echo json_encode ( array (
+					'status' => 1,
+					'html' => $html,
+					'irDetail' => $irDetail 
+			) );
+			die ();
+		}
+		echo json_encode ( array (
+				'status' => 2 
+		) );
+	}
+	
+	/**
+	 * 绑定新收款
+	 */
+	function relationNewInvoiceReceivables() {
+		$iridKeyOld = $this->get_args ( 'iridKeyOld' ) ? $this->get_args ( 'iridKeyOld' ) : '';
+		$iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
+		
+		if (! empty ( $iridKeyOld ) && ! empty ( $iridKey )) {
+			Doo::loadModel ( 'invoiceReceivables' );
+			$invoiceReceivables = new invoiceReceivables ();
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$irid = $XDeode->decode ( $iridKey );
+			$iridOld = $invoiceReceivables->authcode ( $iridKeyOld );
+			echo $irid . 'bbb' . $iridOld;
+			$oldIrDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridOld );
+			$IrDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
+			
+			if (empty ( $oldIrDetail ) || empty ( $IrDetail ))
+				die ( 'illegal request' );
+			
+			$relationLog = $this->staff [0] ['username'] . ' 关联新款  <a href="#billing" onclick="invoiceReceivblesDivShow(\'' . $iridKey . '\',\'receivables\')" data-toggle="modal">' . $IrDetail ['receivablesSerial'] . '</a>
+				<br/>' . date ( "Y-m-d H:i:s" ) . '
+			';
+			$invoiceReceivables = new invoiceReceivables ();
+			$item = array (
+					'irid' => $iridOld,
+					'relationIrid' => $irid,
+					'relationLog' => $relationLog 
+			);
+			$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
+			
+			return '/invoiceReceivablesAS';
+		}
+		die ( 'illegal request' );
+	}
+	
 	// function invoiceApprovalAchieve() {
 	// Doo::loadModel ( 'invoice' );
 	// $invoice = new invoice ();
@@ -5451,10 +5721,9 @@ class InvoiceController extends DooController {
 	 * 公司应收款
 	 */
 	function invoiceAggregateCompanyDetail() {
-		
 		$sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
 		$cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : '';
-		$year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date("Y");
+		$year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : 'ALL';
 		$month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
 		$invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
 		
@@ -5469,38 +5738,43 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'L_category' );
 		$category = new L_category ();
 		
-		$sid='';
-		if (!empty($sidKey))
+		$sid = '';
+		if (! empty ( $sidKey ))
 			$sid = $XDeode->decode ( $sidKey );
 		$staffDetail = $staff->getStaffBySid ( $sid );
 		
-		$cid='';
-		if (!empty($cidKey))
+		$cid = '';
+		if (! empty ( $cidKey ))
 			$cid = $XDeode->decode ( $cidKey );
 		
 		$imcStaff = $invoiceCompanyManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
 		$cidList = array ();
 		foreach ( $imcStaff as $key => $value ) {
 			array_push ( $cidList, $value ['cid'] );
-			
 		}
 		$categoryList = $category->getCategoryInCid ( implode ( ',', $cidList ) );
 		
 		$cidString = implode ( ',', $cidList );
-		$staffList = $staff->getStaffInCid ( $cidString );
+		
+		if (empty ( $cid ))
+			$staffList = $staff->getStaffInCid ( $cidString );
+		else
+			$staffList = $staff->getStaffByCid ( $cid ); //
 		
 		$MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
 		
-		$page_size = 2;
+		$page_size = 25;
 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 		$status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
 		
-		$con = ' status=2  ';
- 		if (! empty ( $year ))
- 			$con .= ' and Year(printTime)=' . $year . '';
-		if ( ! empty ( $month )&&is_numeric($month))
- 			$con .= ' and Month(printTime)="' . $month . '" ';
- 		
+		$con = ' status=2 and untreadStatus!=2  ';
+		
+		$statisticsCon = '';
+		if (! empty ( $year ) && is_numeric ( $year ))
+			$con .= ' and Year(printTime)=' . $year . '';
+		if (! empty ( $month ) && is_numeric ( $month ))
+			$con .= ' and Month(printTime)="' . $month . '" ';
+		
 		if ($status == 'UNRECORD')
 			$con .= ' and printStatus=1 and untreadStatus=0';
 		elseif ($status == 'RECORD')
@@ -5510,20 +5784,22 @@ class InvoiceController extends DooController {
 		elseif ($status == 'PARTRECORD')
 			$con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
 		elseif ($status == 'All') {
-			$con .= ' and printStatus=1 and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
+			$con .= ' and printStatus=1 and (  untreadStatus=0 or untreadStatus=3 )';
 		}
 		
-		if(!empty($sid)&&is_numeric($sid))
+		if (! empty ( $sid ) && is_numeric ( $sid ))
 			$con .= ' and sid=' . $sid;
 		
-		if(!empty($cid)&&is_numeric($cid))
+		if (! empty ( $cid ) && is_numeric ( $cid ))
 			$con .= ' and cid=' . $cid;
-		//开票内容筛选 
-		if(!empty($invoiceElement)&&$invoiceElement!='ALL'){
-			$con .= ' and invoiceElement="' . $invoiceElement.'"';
+		else
+			$con .= ' and cid in (' . $cidString . ')';
+			// 开票内容筛选
+		if (! empty ( $invoiceElement ) && $invoiceElement != 'ALL') {
+			$con .= ' and invoiceElement="' . $invoiceElement . '"';
 		}
-			
-		$get = "/" . $status . "?cidKey=".$cidKey."&sidKey=".$sidKey."&year=".$year."&month=".$month."&invoiceElement=".$invoiceElement  ;
+		
+		$get = "/" . $status . "?cidKey=" . $cidKey . "&sidKey=" . $sidKey . "&year=" . $year . "&month=" . $month . "&invoiceElement=" . $invoiceElement;
 		
 		if (! empty ( $MebSea )) {
 			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%"  or invoiceCompany like "%' . $MebSea . '%" )';
@@ -5535,35 +5811,39 @@ class InvoiceController extends DooController {
 		$pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAggregateCompanyDetail", $get, "" );
 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 		
-		//应收款合计
-		$ics=$invoice->getInvoiceCompanyStatistics($con);
+		// 应收款合计
+		$ics = $invoice->getInvoiceCompanyStatistics ( $con );
 		
 		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
 		$monthHtml = "";
-		for($i = 1; $i <= 12; $i ++) {
-			if ($i == $month)
-				$monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
-			else
-				$monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
+		if ($year != "ALL") {
+			for($i = 1; $i <= 12; $i ++) {
+				if ($i == $month)
+					$monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
+				else
+					$monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
+			}
 		}
 		$this->data ['monthHtml'] = $monthHtml;
 		$this->data ['year'] = $year;
 		$this->data ['month'] = $month;
 		
-		$this->data['ics']=$ics;
-		$this->data ['cidKey']=$cidKey;
-		$this->data ['sid'] =$sid;
+		$this->data ['ics'] = $ics;
+		$this->data ['cidKey'] = $cidKey;
+		$this->data ['sid'] = $sid;
 		$this->data ['staffDetail'] = $staffDetail;
 		$this->data ['staffList'] = $staffList;
 		$this->data ['MebSeaEn'] = $MebSea;
 		$this->data ['MebSea'] = urlencode ( $MebSea );
-
-		$this->data ['invoiceDetail'] = array('invoiceElement'=>$invoiceElement);
+		
+		$this->data ['invoiceDetail'] = array (
+				'invoiceElement' => $invoiceElement 
+		);
 		$this->data ['page'] = $pageinfo;
 		$this->data ['get'] = $get;
 		$this->data ['list'] = $list;
 		$this->data ['status'] = $status;
-		$this->data ['categoryList'] =$categoryList;
+		$this->data ['categoryList'] = $categoryList;
 		
 		$this->data ['memu'] = "invoice";
 		$this->data ['staff'] = $this->staff;
@@ -5987,12 +6267,18 @@ class InvoiceController extends DooController {
 		} elseif ($type == 'RECEIVABLES') {
 			Doo::loadModel ( 'invoiceReceivables' );
 			$invoiceReceivables = new invoiceReceivables ();
-			//
+			Doo::loadModel ( 'invoiceRefund' );
+			$invoiceRefund = new invoiceRefund ();
+			
 			$detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial );
+			$ireList = $invoiceRefund->getInvoiceRefundIrid ( $detail ['irid'] );
+			
 			if (empty ( $detail ))
 				$html = '';
 			else {
-				$html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList"><table class="table table-bordered table-condensed">
+				$html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList">
+						
+						<table class="table table-bordered table-condensed">
 						<tbody><tr>
 							<th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
 							<th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
@@ -6007,7 +6293,36 @@ class InvoiceController extends DooController {
 						<tr>
 							<th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['confirmTime'] . '</td>
 						</tr>
-						</tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
+						</tbody></table>';
+				if (! empty ( $ireList )) {
+					$html .= '					
+						<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" colspan="2">退款记录</th></tr>';
+					
+					foreach ( $ireList as $key => $value ) {
+						
+						
+						
+						$refundLogList=explode("<br/>",$value['refundLog']);
+						
+						
+						
+						$html .= '					
+								<tr>
+									<th class="taC">退款单位名称</th><td>' . $value ['refundCompany'] . '</td>
+								</tr> 
+								<tr>
+									<th class="taC">退款的账号</th><td>' . $value ['refundNumber'] . '</td>
+								</tr>
+								<tr>
+									<th class="taC">退款金额</th><td class="colRed">¥' . $value ['refundPrice'] . '</td>
+								</tr>
+								<tr>
+									<th class="taC">退款</th><td>' . $refundLogList [0].$refundLogList [2] . '</td>
+								</tr>	
+							';
+					}
+				}
+				$html .= '</tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
 			}
 			echo json_encode ( array (
 					'status' => 1,

+ 111 - 47
protected/controller/MainController.php

@@ -1805,21 +1805,59 @@ class MainController extends DooController {
 		
 		$data ['district2'] = $district->get_lv ( 1 );
 		$category = $lcategory->getCategoryById ( $this->staff [0] ['cid'], $this->staff [0] ['othercid'] );
-		$cateStr = "";
+		$cateStr = " cid =0 ";
 		
-		$list = array ();
 		
-		foreach ( $category as $key => $value ) {
-			array_push ( $list, " district like '" . $value ['districtid'] . ",%' " );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		$didList=explode(',',  $this->staff [0]['did']);
+		$didList=array_filter($didList);
+		$didListContont=array();
+		if (!empty($didList)){
+			foreach ($didList as $key=>$value){
+				array_push($didListContont, $XDeode->decode ( $value )) ;
+			}
+		
+			$data ['district'] = $district->getDistrictInId(implode(',', $didListContont));//$district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
+		}else{
+			$data ['district'] =array();
+		}
+		
+		
+		$sqstr='';
+		if (!empty($didListContont)){
+			
+			foreach ( $didListContont as $key => $value ) {
+				if ($key != 0) {
+					$sqstr .= " or district like '" . $value  . ",%'";
+				}
+			}
+			$cateStr = " ( district like '" . $didListContont [0]  . ",%'" . $sqstr.')';
 		}
-		if ($this->staff [0] ['isadmin'] != 1)
-			$cateStr = implode ( " or ", $list );
-		else
-			$cateStr = " 1";
-		$size = 300;
 		
-		if (! empty ( $nature ))
-			$cateStr = " 1";
+		
+		
+		
+// 		$list = array ();
+// 		foreach ( $category as $key => $value ) {
+// 			array_push ( $list, " district like '" . $value ['districtid'] . ",%' " );
+// 		}
+// 		if ($this->staff [0] ['isadmin'] != 1)
+// 			$cateStr = implode ( " or ", $list );
+// 		else
+// 			$cateStr = " 1";
+// 		
+		
+// 		if (! empty ( $nature ))
+// 			$cateStr = " 1";
+		
+$size = 300;
+	
+			
+			
+			
 		
 		$data ['htmllv2'] = array ();
 		$data ['htmllv3'] = array ();
@@ -1827,6 +1865,7 @@ class MainController extends DooController {
 		
 		if ($districtLv == 1) {
 			$condition = "";
+			
 			if (! empty ( $lv1 )) {
 				$condition = " district like '" . $lv1 . ",%'";
 				$data ['htmllv2'] = $district->get_lvByid ( 2, $lv1 );
@@ -1894,11 +1933,18 @@ class MainController extends DooController {
 		
 		$data ['company'] = $company->getCompanyByDistrict ( $this->staff [0] ['sid'], $cateStr, $this->staff [0] ['isadmin'], $page, $size, $tagSQL );
 		
-		if ($this->staff [0] ['isadmin'] != 1) {
-			$data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
-		} else {
-			$data ['district'] = $data ['district2'];
-		}
+		
+		
+		
+		
+		
+		
+		
+// 		if ($this->staff [0] ['isadmin'] != 1) {
+// 			$data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
+// 		} else {
+// 			$data ['district'] = $data ['district2'];
+// 		}
 		
 		// 获得标签
 		$ClientTagList = $tagCompanyNexus->getTagClientBySid ( $this->staff [0] ['sid'] );
@@ -2031,6 +2077,7 @@ class MainController extends DooController {
 		$this->render ( "/contacts_company", $data );
 	}
 	function contacts() {
+		
 		$data ['memu'] = "contacts";
 		
 		$data ['staff'] = $this->staff;
@@ -2093,44 +2140,57 @@ class MainController extends DooController {
 		$linfo = $category->getCategoryById ( $this->staff [0] ['cid'], $this->staff ['0'] ['othercid'] );
 		$staffid = $condition = $a = "";
 		
-		if ($this->staff [0] ['isadmin'] != 1) {
+		//if ($this->staff [0] ['isadmin'] != 1) {
 			// 加入办事处地区
-			$data ['district'] = $district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		$didList=explode(',',  $this->staff [0]['did']);
+		$didList=array_filter($didList);
+		$didListContont=array();
+		if (!empty($didList)){
+			foreach ($didList as $key=>$value){
+				array_push($didListContont, $XDeode->decode ( $value )) ;
+			}
 			
+			$data ['district'] = $district->getDistrictInId(implode(',', $didListContont));//$district->get_lvByStaffid ( 1, $this->staff [0] ['sid'] );
+		}else{
+			$data ['district'] =array();
+		}
+		
 			if (! empty ( $search ))
 				$sch = "  and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
 			else {
-				// or b.district like '".$linfo[0]['districtid']."%'
-				$a = " and b.district like '" . $linfo [0] ['districtid'] . "%'";
-				
-				if (! empty ( $tooltip ))
-					$sch = "";
-				$search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
-				
-				if (! empty ( $search ))
-					$sch = "  and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
-				else {
-					$staffid = $data ['staff'] [0] ['sid'];
-					$sqstr = "";
-					foreach ( $linfo as $key => $value ) {
+				$a ='';
+				$sqstr='';
+				if (!empty($didListContont)){
+					$a ='';
+					foreach ( $didListContont as $key => $value ) {
 						if ($key != 0) {
-							$sqstr .= " or b.district like '" . $value ['districtid'] . ",%'";
+							$sqstr .= " or b.district like '" . $value  . ",%'";
 						}
 					}
-					$a = "and b.district like '" . $linfo [0] ['districtid'] . ",%'" . $sqstr;
+					$a = "and ( b.district like '" . $didListContont [0]  . ",%'" . $sqstr.')';
 				}
+				
+				if (! empty ( $tooltip ))
+					$sch = "";
+				$staffid = $data ['staff'] [0] ['sid'];
+				
 			}
-		} else {
-			$data ['district'] = $data ['district2'];
-			if (! empty ( $search ))
-				$sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
-			else {
-				$sch = " ";
-				$search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
-				if (! empty ( $search ))
-					$sch = "  and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
-			}
-		}
+			
+// 		} else {
+// 			$data ['district'] = $data ['district2'];
+// 			if (! empty ( $search ))
+// 				$sch = " and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
+// 			else {
+// 				$sch = " ";
+// 				$search = urldecode ( isset ( $this->params ['search'] ) ? $this->params ['search'] : "" );
+// 				if (! empty ( $search ))
+// 					$sch = "  and ( address like '%" . $search . "%' or clientname like '%" . $search . "%' or companyname like '%" . $search . "%' or qq like '%" . $search . "%' or telephone like '%" . $search . "%' or phone like '%" . $search . "%')";
+// 			}
+// 		}
 		$data ['htmllv2'] = $data ['htmllv3'] = array ();
 		
 		if ($districtLv == 1) {
@@ -2182,8 +2242,9 @@ class MainController extends DooController {
 			$condition .= $sch;
 			// if(!empty($tooltip))
 			// $condition.=" and tooltip like '%".$tooltip."%'";
-		
-		$pageinfo = $this->get_page ( "CLD_client_staff", $condition, $page, $page_size, "", "", "", $staffid, $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
+			$pageinfo =array('lower'=>0,'total_page'=>0,'total_data'=>0);
+		if (!empty($didListContont)||! empty ( $search ))
+			$pageinfo = $this->get_page ( "CLD_client_staff", $condition, $page, $page_size, "", "", "", $staffid, $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
 		
 		if ($sortV == "h") { // order by a.cid desc
 			$limit = " order by cid desc limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
@@ -2198,7 +2259,10 @@ class MainController extends DooController {
 			$limit = "  limit " . $pageinfo ['lower'] . " , " . $page_size . " ";
 		}
 		// 检索是全局
-		$data ['clientInfo'] = $client_staff->getClientByStaff ( $condition, $limit, $staffid, $this->staff [0] ['sid'], $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
+		//echo $condition;
+		$data ['clientInfo'] =array();
+		if (!empty($didListContont)||! empty ( $search ))
+			$data ['clientInfo'] = $client_staff->getClientByStaff ( $condition, $limit, $staffid, $this->staff [0] ['sid'], $search, $tooltip, $this->staff [0] ['cid'], $tagSQL );
 		
 		// 获取其他办事处的客户
 		// if(!empty($districtstr)){

+ 92 - 8
protected/controller/ReceiptController.php

@@ -55,6 +55,23 @@ class ReceiptController extends DooController {
 		$collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
 		return $collectHtml;
 	}
+	
+	public function beforeRun($resource, $action) {
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
+		//单独判断公司汇总的访问权限
+		if ($action == 'companyCategoryCollect' ) {
+			Doo::loadModel ( "receiptAuthorityManage" );
+			$invoiceCompanyManage = new receiptAuthorityManage ();
+		
+			$icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
+			if (empty ( $icm ))
+				die ( 'illegal request' );
+		}
+		
+	}
+	
 	function __construct() {
 		if (isset ( $_COOKIE ["staff"] )) {
 			
@@ -2737,7 +2754,7 @@ class ReceiptController extends DooController {
 				'previous' => '' 
 		);
 		
-		if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
+		if ($status == 'done' || $status == 'termination' || $status == 'finish' ) { // $dateCondition .
 			$pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
 			
 			$receiptList = $receipt->find ( array ( // $dateCondition.
@@ -2748,7 +2765,7 @@ class ReceiptController extends DooController {
 			) );
 		} else {
 			$receiptList = $receipt->find ( array ( // $dateCondition
-					'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
+					'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition.$dateCondition . ' and verify in (' . $vid . ')',
 					'desc' => 'rid',
 					'asArray' => true 
 			) );
@@ -3350,6 +3367,8 @@ class ReceiptController extends DooController {
 		
 		$data ['receiptList'] = $receiptList;
 		
+		//print_r($receiptList);
+		
 		$data ['memu'] = "receipt";
 		$data ['staff'] = $this->staff;
 		
@@ -9100,7 +9119,20 @@ class ReceiptController extends DooController {
 		$Lcategory = new L_category ();
 		$itemStatistics = new itemStatistics ();
 		
+		Doo::loadModel ( "receiptAuthorityManage" );
+		$receiptAuthorityManage = new receiptAuthorityManage ();
+		
+		$imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
+		$cidList = array ();
+		foreach ( $imcStaff as $key => $value ) {
+			array_push ( $cidList, $value ['cid'] );
+		}
+		$cidString=implode ( ',', $cidList );
+		
+		
+		
 		$LcategoryList = $Lcategory->find ( array (
+				'where'=>' cid in ('.$cidString.')',
 				'asArray' => true 
 		) ); // 'staff='.$this->staff[0]['sid']." and
 		$itemStatisticsList = $itemStatistics->find ( array (
@@ -9156,7 +9188,10 @@ class ReceiptController extends DooController {
 		$data ['total'] = $total;
 		
 		// statistics html
-		$stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
+		
+	//echo $cidString;
+		
+		$stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'],$cidString );
 		if (empty ( $stList ))
 			$stList = array (
 					'rePrice' => 0,
@@ -9209,7 +9244,19 @@ class ReceiptController extends DooController {
 		Doo::loadModel ( 'accountItem' );
 		$accountItem = new accountItem ();
 		
+		Doo::loadModel ( "receiptAuthorityManage" );
+		$receiptAuthorityManage = new receiptAuthorityManage ();
+		
+		$imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
+		$cidList = array ();
+		foreach ( $imcStaff as $key => $value ) {
+			array_push ( $cidList, $value ['cid'] );
+		}
+		$cidString=implode ( ',', $cidList );
+		
+		
 		$LcategoryList = $Lcategory->find ( array (
+				'where'=>'cid in ('.$cidString.')',
 				'asArray' => true 
 		) );
 		
@@ -9362,8 +9409,18 @@ class ReceiptController extends DooController {
 		Doo::loadModel ( 'itemStatistics' );
 		$itemStatistics = new itemStatistics ();
 		
+		Doo::loadModel ( "receiptAuthorityManage" );
+		$receiptAuthorityManage = new receiptAuthorityManage ();
+		
+		$imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
+		$cidList = array ();
+		foreach ( $imcStaff as $key => $value ) {
+			array_push ( $cidList, $value ['cid'] );
+		}
+		$cidString=implode ( ',', $cidList );
+		
 		// statistics html
-		$stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
+		$stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'],$cidString );
 		if (empty ( $stList ))
 			$stList = array (
 					'rePrice' => 0,
@@ -9385,13 +9442,17 @@ class ReceiptController extends DooController {
 		) ); // 'staff='.$this->staff[0]['sid']." and
 		$itemStatisticsList = $itemStatistics->find ( array (
 				'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
-				'where' => " Year(date)=" . $year,
+				'where' => " Year(date)=" . $year.' and cid in ('.$cidString.')',
 				'groupby' => 'staff,Month(date)',
 				'asArray' => true 
 		) );
+		
+		
+		
+		
 		$categoryList = $staff->find ( array (
 				'select' => 'COUNT(*) as count,cid,category',
-				'where' => 'username !="admin"',
+				'where' => 'username !="admin" and cid in ('.$cidString.')',
 				'groupby' => 'cid',
 				'asArray' => true 
 		) );
@@ -9872,13 +9933,23 @@ class ReceiptController extends DooController {
 		Doo::loadModel ( 'L_category' );
 		$lCategory = new L_category ();
 		
+		Doo::loadModel ( "receiptAuthorityManage" );
+		$receiptAuthorityManage = new receiptAuthorityManage ();
+		
+		$imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
+		$cidList = array ();
+		foreach ( $imcStaff as $key => $value ) {
+			array_push ( $cidList, $value ['cid'] );
+		}
+		$cidString=implode ( ',', $cidList );
+		
 		$staffList = $staff->find ( array (
-				'where' => 'username!="admin"',
+				'where' => 'username!="admin" and cid in ('.$cidString.')',
 				'asArray' => true 
 		) );
 		$categoryList = $staff->find ( array (
 				'select' => 'COUNT(*) as count,cid,category',
-				'where' => 'username !="admin"',
+				'where' => 'username !="admin" and cid in ('.$cidString.')',
 				'groupby' => 'cid',
 				'asArray' => true 
 		) );
@@ -11127,7 +11198,20 @@ class ReceiptController extends DooController {
 		Doo::loadModel ( 'L_category' );
 		$lCategory = new L_category ();
 		
+		
+		Doo::loadModel ( "receiptAuthorityManage" );
+		$receiptAuthorityManage = new receiptAuthorityManage ();
+		
+		$imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
+		$cidList = array ();
+		foreach ( $imcStaff as $key => $value ) {
+			array_push ( $cidList, $value ['cid'] );
+		}
+		$cidString=implode ( ',', $cidList );
+		
+		
 		$staffList = $staff->find ( array (
+				'where'=>' cid in ('.$cidString.')',
 				'asArray' => true 
 		) );
 		

+ 55 - 10
protected/controller/SoftController.php

@@ -35,6 +35,7 @@ class SoftController extends DooController {
 	function addLockApi(){
 
 		$longleList=isset($_POST['longle'])?$_POST['longle']:"";
+		
 		header ( 'Content-Type:text/html;charset=utf-8' );
 		if($longleList!=""){
 			Doo::loadModel ( 'longle' );
@@ -48,17 +49,34 @@ class SoftController extends DooController {
 				echo json_encode(array('status'=>2,'msg'=>'锁数据不正确'),JSON_UNESCAPED_UNICODE);die;
 			}
 			 
-			$findStr='';$longle = new longle ();
-			foreach ($longleList as $key=>$value){
-				$li=$longle->getOne(array('where'=>'key_num like "'.$value['key_num'].'"','asArray' => TRUE));
+// 			$findStr='';$longle = new longle ();
+// 			foreach ($longleList as $key=>$value){
+// 				$li=$longle->getOne(array('where'=>'key_num like "'.$value['key_num'].'"','asArray' => TRUE));
 				
-				if (!empty($li))
-					$findStr.=$li['key_num']." ; ";
-			}
-			if (!empty($findStr))
-				$this->postEmail($findStr);
+// 				if (!empty($li))
+// 					$findStr.=$li['key_num']." ; ";
+// 			}
+// 			if (!empty($findStr))
+// 				$this->postEmail($findStr);
 			
 			
+// $longleList=array(1=>array('key_num'=>'SC-Z26150','product'=>'1','make_day'=>'2','alloted_time'=>'2','status'=>'1','statusT'=>'生成','cid'=>'2'
+// 		,'category'=>'广东','SerialNumber'=>'SZ26150','version'=>'1.1')
+// 		,2=>array('key_num'=>'SC-Z26150','product'=>'1','make_day'=>'2','alloted_time'=>'2','status'=>'1','statusT'=>'生成','cid'=>'2'
+// 		,'category'=>'广东','SerialNumber'=>'SZ26150','version'=>'1.1')
+// 		,3=>array('key_num'=>'SC-Z2615022','product'=>'1','make_day'=>'2','alloted_time'=>'2','status'=>'1','statusT'=>'生成','cid'=>'2'
+// 				,'category'=>'广东','SerialNumber'=>'SZ26150','version'=>'1.1')
+// 		,4=>array('key_num'=>'SC-Z261504','product'=>'1','make_day'=>'2','alloted_time'=>'2','status'=>'1','statusT'=>'生成','cid'=>'2'
+// 				,'category'=>'广东','SerialNumber'=>'SZ26150','version'=>'1.1')
+// 		,5=>array('key_num'=>'SC-Z261503','product'=>'1','make_day'=>'2','alloted_time'=>'2','status'=>'1','statusT'=>'生成','cid'=>'2'
+// 				,'category'=>'广东','SerialNumber'=>'SZ26150','version'=>'1.1')
+// 		,6=>array('key_num'=>'SC-Z2615022','product'=>'1','make_day'=>'2','alloted_time'=>'2','status'=>'1','statusT'=>'生成','cid'=>'2'
+// 				,'category'=>'广东','SerialNumber'=>'SZ26150','version'=>'1.1')
+		
+// );
+
+			$longleList=$this->array_unique_fb($longleList);
+
 			//$category=$L_category->getCategoryById($cid);
 			try {
 			Doo::db()->beginTransaction();
@@ -125,8 +143,8 @@ class SoftController extends DooController {
 			   
 			     $param = array('api_user' => 'cldmail',
 			            'api_key' => 'cDO1GjtY1seH',
-			    		'to'=>'1971614655@qq.com',
-			            'from' =>'1971614655@qq.com',
+			    		'to'=>'cpthought@vip.qq.com',
+			            'from' =>'cpthought@vip.qq.com',
 			            'fromname' => '软件导入CLD锁接口',
 			            'subject' => '软件导入CLD锁接口通知',
 			            'html' => $elid);
@@ -147,6 +165,33 @@ class SoftController extends DooController {
 	}
 	
 	
+	function array_unique_fb($array2D){
+		 foreach ($array2D as $k=>$v){
+  $v=join(',',$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
+  $temp[$k]=$v;
+ }
+ $temp=array_unique($temp); //去掉重复的字符串,也就是重复的一维数组 
+ foreach ($temp as $k => $v){
+  $array=explode(',',$v); //再将拆开的数组重新组装
+  //下面的索引根据自己的情况进行修改即可
+  $temp2[$k]['key_num'] =$array[0];
+  $temp2[$k]['serialnumber'] =$array[1];
+  $temp2[$k]['product'] =$array[2];
+  $temp2[$k]['make_day'] =$array[3];
+  
+  $temp2[$k]['alloted_time'] =$array[4];
+  $temp2[$k]['version'] =$array[5];
+  $temp2[$k]['cid'] =$array[6];
+  $temp2[$k]['title'] =$array[7];
+  
+ }
+ 
+
+ 
+ return $temp2;
+	}
+	
+	
 	
 	/**
 	 * 格式化excel文件为数组

+ 1 - 1
protected/model/client_staff.php

@@ -46,7 +46,7 @@ class client_staff extends DooModel {
 			else
 			$sql = "select b.address,b.district, b.office,b.fax,b.email,b.qq,b.phone,b.mark,b.nicename, b.cid,b.gender,b.clientname,b.keynum,b.companyid,b.companyname,b.updatetime,b.servicetime,b.department,b.position,b.priority,b.telephone from CLD_C_tooltip as a  left join CLD_client as b on (a.cid=b.cid )  where  a.name like '%".$tooltip."%' and a.cateid = ".$cateid." ".$condition."  ".$limit ;
 		}
-			//echo "<div style='display:none'>".$sql."</div>";//die;
+		//	echo $sql;//die;
     	$query = Doo::db ()->query ( $sql );
 		
 		$result = $query->fetchAll ();

+ 18 - 0
protected/model/district.php

@@ -16,6 +16,16 @@ class district extends DooModel {
     public $_primarykey = 'id';
     public $_fields = array('id', 'name', 'level', 'usetype', 'upid', 'displayorder', 'area');
 
+    public function getDistrictInId($idString=''){
+    	if (empty($idString)) return array();
+    	$list=$this->find(array('where' => 'id in (' . $idString.')', 'asArray' => true));
+    	Doo::loadClass ( 'XDeode' );
+    	$XDeode = new XDeode ( 5 );
+    	foreach ( $list as $key => $value ) {
+    		$list [$key] ['idKey'] = $XDeode->encode ( $value ['id'] );
+    	}
+    	return $list;
+    }
 
 	public function get_all() {
         $archive_list = $this->find(array( 'asc' => 'id',  'asArray' => true));
@@ -56,6 +66,14 @@ class district extends DooModel {
     
 	public function get_lv($lv) {
         $archive_list = $this->find(array( 'asc' => 'id','where'=>'level='.$lv,  'asArray' => true));
+        
+        Doo::loadClass ( 'XDeode' );
+        $XDeode = new XDeode ( 5 );
+        
+        foreach ($archive_list as $key=>$value){
+        	$archive_list[$key] ['didKey'] = $XDeode->encode ( $value ['id'] );
+        }
+        
         return $archive_list;
     }
     

+ 4 - 1
protected/model/invoice.php

@@ -843,6 +843,8 @@ class invoice extends DooModel {
 				from ' . $this->_table . '
 						where '.$con.'
 						 ';
+		
+		
 		$query = Doo::db ()->query ( $sql );
 		$result = $query->fetchAll ();
 		$iidlist=array();
@@ -853,10 +855,11 @@ class invoice extends DooModel {
 		}
 		$iidString=implode(',', $iidlist);
 		
+		//获得已收款发票
 		if (!empty($iidString)){
 		$sql = 'select sum(receivablesPrice) as receivablesPrice 
 				from CLD_invoiceReceivables 
-				where iid in (' . $iidString . ')  
+				where iid in (' . $iidString . ')  and bindStatus=1
 				GROUP BY bindStatus';
 		$query = Doo::db ()->query ( $sql );
 		$result = $query->fetch ();

+ 62 - 3
protected/model/invoiceReceivables.php

@@ -17,6 +17,7 @@ class invoiceReceivables extends DooModel {
 	public $iidExtend;
 	public $bindPrice;
 	public $receivablesPrice;
+	public $OriginalPrice;
 	public $receivablesSerial;
 	public $receivablesMessage;
 	public $receivablesBank;
@@ -34,6 +35,13 @@ class invoiceReceivables extends DooModel {
 	public $accountClerk;
 	public $sourcePrice;
 	public $bankBatchNumber;
+	public $refundType;
+	public $refundCompany;
+	public $refundNumber;
+	public $refundPrice;
+	public $refundLog;
+	public $relationIrid;
+	public $relationLog;
 	public $_table = 'CLD_invoiceReceivables';
 	public $_primarykey = 'irid';
 	public $_fields = array (
@@ -45,6 +53,7 @@ class invoiceReceivables extends DooModel {
 			'iidExtend',
 			'bindPrice',
 			'receivablesPrice',
+			'OriginalPrice',
 			'receivablesSerial',
 			'receivablesMessage',
 			'receivablesBank',
@@ -61,7 +70,14 @@ class invoiceReceivables extends DooModel {
 			'unbundlingTime',
 			'accountClerk',
 			'sourcePrice',
-			'bankBatchNumber' 
+			'bankBatchNumber',
+			'refundType',
+			'refundCompany',
+			'refundNumber',
+			'refundPrice',
+			'refundLog',
+			'relationIrid',
+			'relationLog'
 	);
 	public function getSumOfReceivablesPrice($iridString = "") {
 		if (empty ( $iridString ))
@@ -342,6 +358,48 @@ class invoiceReceivables extends DooModel {
 		$detail ['iridEn'] = $this->authcode ( $detail ['irid'], '' );
 		return $detail;
 	}
+	
+	/**
+	 * 根据收款序列号获取一条相关数据
+	 * @param string $irid
+	 * @param string $con 附加获取收款条件 可以为空
+	 * @return unknown[]|mixed[]|string[]
+	 */
+	public function getInvoiceReceivablesBySerial($receivablesSerial = "", $con = "") {
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		if (!empty($receivablesSerial))
+			
+			
+				$detail = $this->getOne ( array (
+						'where' => " receivablesSerial like '%" . $receivablesSerial."%'" . $con,
+						'limit'=>1,
+						'asArray' => TRUE
+				) );
+	
+				if (empty ( $detail ))
+					return $detail;
+					$detail ['cid'] = '';
+					$detail ['title'] = '';
+					if ($detail ['receivablesCategory'] != "PUBLIC") {
+						$category = explode ( ":", $detail ['receivablesCategory'] );
+						$detail ['cid'] = $category [0];
+						$detail ['title'] = $category [1];
+					}
+	
+					$detail ['sid'] = '';
+					$detail ['username'] = '';
+					if ($detail ['receivablesStaff'] != "PUBLIC") {
+						$staff = explode ( "-", $detail ['receivablesStaff'] );
+						$detail ['sid'] = $staff [0];
+						$detail ['username'] = $staff [1];
+					}
+	
+					$detail ['iridKey'] = $XDeode->encode ( $detail ['irid'] );
+					$detail ['iridEn'] = $this->authcode ( $detail ['irid'], '' );
+					return $detail;
+	}
+	
 	public function getInvoiceReceivablesByIrsid($irid = "", $sid = "") {
 		Doo::loadClass ( 'XDeode' );
 		$XDeode = new XDeode ( 5 );
@@ -361,10 +419,11 @@ class invoiceReceivables extends DooModel {
 				) );
 			
 			$detail ['sid'] = '';
-			$detail ['username'] = '';
-			if (! empty ( $detail ['receivablesStaff'] )) {
+			$detail ['username'] = '';//
+			if (! empty ( $detail ['receivablesStaff'] )&&$detail ['receivablesStaff'] !='PUBLIC') {
 				$staff = explode ( "-", $detail ['receivablesStaff'] );
 				$detail ['sid'] = $staff [0];
+				
 				$detail ['username'] = $staff [1];
 			}
 			$detail ['iridKey'] = $XDeode->encode ( $detail ['irid'] );

+ 25 - 5
protected/model/staff.php

@@ -26,6 +26,9 @@ class staff extends DooModel {
 	public $bankNumber;
 	public $coupletNumber;
 	public $remittanceBankType;
+	public $did;
+	public $didName;
+	
 	public $_table = 'CLD_staff';
 	public $_primarykey = 'sid';
 	public $_fields = array (
@@ -53,7 +56,9 @@ class staff extends DooModel {
 			'bankName',
 			'bankNumber',
 			'remittanceBankType',
-			'coupletNumber' 
+			'coupletNumber',
+			'did',
+			'didName'
 	);
 	public function checkUser($uid, $passwork) {
 		return $this->find ( array (
@@ -115,21 +120,36 @@ class staff extends DooModel {
 		return $list;
 	}
 	public function getUserById($sid = 0) {
-		return $this->find ( array (
+		
+		$list =$this->find ( array (
 				'asc' => 'sid',
 				'where' => "sid= '" . $sid . "'",
-				'asArray' => TRUE 
+				'asArray' => TRUE
 		) );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
+		}
+		
+		return $list;
 	}
 	public function getUserByIdList($puid) {
 		Doo::loadClass ( 'XDeode' );
 		$XDeode = new XDeode ( 5 );
 		
 		$puid = $XDeode->decode ( $puid );
-		return $this->find ( array (
+		$list=$this->find ( array (
 				'where' => "sid= '" . $puid . "'",
-				'asArray' => TRUE 
+				'asArray' => TRUE
 		) );
+		
+		foreach ($list as $key=>$value){
+			$list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
+		}
+		
+		return $list;
 	}
 	/**
 	 * 根据用户ID获取相关信息

+ 6 - 2
protected/model/statistics.php

@@ -26,9 +26,13 @@ class statistics extends DooModel {
 		return $result;
     }
     
-	function statisticsByComPanyYear($year,$sid){
+	function statisticsByComPanyYear($year,$sid,$cidString=''){
     	//staff= '".$sid."' and
-    	$sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where  Year(date) =".$year." group by Year(date)" ;
+    	$cidSql='';
+		if(!empty($cidString))
+			$cidSql=' and cid in ('.$cidString.')';
+    	$sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where  Year(date) =".$year.$cidSql."  group by Year(date)" ;
+    	
     	$query = Doo::db ()->query ( $sql );
 		$result = $query->fetch ();
 		

+ 34 - 0
protected/plugin/TemplateTag.php

@@ -20,6 +20,8 @@ Doo::conf ()->TEMPLATE_GLOBAL_TAGS = array (
 		'getGlobals',
 		'countArray',
 		'isInvoiceMoldShow',
+		'isReceiptAuthorityShow',
+		'isInvoiceAggregateCompanyShow',
 		'isInvoiceCategoryShow'
 );
 
@@ -173,6 +175,38 @@ function isInvoiceCategoryShow($sid){
 		return false;
 }
 
+/**
+ * 是否有查看应收款的权限
+ * @param unknown $sid
+ */
+function isInvoiceAggregateCompanyShow($sid){
+	Doo::loadModel ( "invoiceCompanyManage" );
+	$receiptAuthorityManage = new invoiceCompanyManage ();
+
+	$icm=$receiptAuthorityManage->getInvoiceCMByStaff($sid);
+	if (!empty($icm))
+		return true;
+		else
+			return false;
+}
+
+/**
+ * 是否有查看报销单汇总的权限
+ * @param unknown $sid
+ */
+function isReceiptAuthorityShow($sid){
+	Doo::loadModel ( "receiptAuthorityManage" );
+	$receiptAuthorityManage = new receiptAuthorityManage ();
+
+	
+	$icm=$receiptAuthorityManage->getInvoiceCMByStaff($sid);
+	
+	if (!empty($icm))
+		return true;
+		else
+			return false;
+}
+
 function isInvoiceCompanyShow($sid){
 	
 }

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

@@ -24,6 +24,7 @@
 						<li ><a href="/adminverify">审批组</a></li>
 						<li><a href="/adminRole">审批角色</a></li>
 						<li class="active" ><a href="/adminExecute">费用执行人</a></li>
+						<li ><a href="/adminReceiptAuthority">汇总权限</a></li>
 					</ul>
 				</div>
 					<legend>编辑执行人</legend><form method="post" action="/addCategory" name="group">

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

@@ -24,6 +24,7 @@
 						<li ><a href="/adminverify">审批组</a></li>
 						<li class="active"><a href="/adminRole">审批角色</a></li>
 						<li><a href="/adminExecute">费用执行人</a></li>
+						<li ><a href="/adminReceiptAuthority">汇总权限</a></li>
 					</ul>
 				</div>
 			

+ 55 - 0
protected/view/admin/admin_EdiUser.html

@@ -99,6 +99,28 @@
 		            </div>
 		            
 			    </form>
+			    
+			    
+			    
+			   
+			    <legend>添加省份权限</legend>
+			    <p class="cGroup">
+				    已加入:
+				    <!-- loop idDistrictList -->
+				    <span class="tagGroup">{{idDistrictList' value.name}}<a href="/delUserDistrictAuthor/{{idDistrictList' value.idKey}}/{{staffInfo.0.sidKey}}" title="删除" class="icon-">k</a></span>
+					<!-- endloop -->
+				   
+			    </p>
+			    <div class="control-group">
+		              <!-- <label for="inputEmail" class="control-label">省份</label> -->
+		              <div class="controls">
+		                <a href="#pikProvince" id="" data="省份权限" data-toggle="modal">添加省份权限</a>
+		              </div>
+		            </div>
+			    
+			    
+			    
+			    
 			    <form name="myinfo" action="/adminDoAddCategory" method="post">
 			    <legend>添加办事处信息</legend>
 			    已加入:{{staffInfo.0.category}},{{staffInfo.0.othercategory}}
@@ -124,5 +146,38 @@
 			</div>
 		</div>
 	</div>
+	
+	<!--选择省份-->
+<div class="modal hide fade" id="pikProvince">
+<form name="userDistrict" action="/addUserDistrictAuthor" method="post">
+<input type="hidden" name="sidKey" value="{{staffInfo.0.sidKey}}">
+
+	<div class="modal-dialog">
+		<div class="modal-content">
+	<div class="modal-header">
+    	<h3>选择省份</h3>
+    </div>
+    <div class="modal-body">
+			<style>.controls > .checkbox{margin-left: 10px}</style>
+    	<div class="controls">
+    	<!-- loop districtList -->
+	    	<label class="checkbox inline">
+			  <input type="checkbox" name="didKey[]" value="{{districtList' value.didKey}}"> {{districtList' value.name}}
+			</label>
+		<!-- endloop -->
+			
+		</div>
+    </div>
+	<div class="modal-footer">
+	    <div class="fR"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">取消</a>
+	    <button type="submit" class="button">确认添加</button>
+	   </div>
+	</div>
+	</div>
+</div>
+</form>
+</div>
+<!--选择省份-->	
+	
 <script type="text/javascript">autoFlashHeight();</script>	
 </body>

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

@@ -25,6 +25,7 @@
 						<li class="active"><a href="/adminverify">审批组</a></li>
 						<li><a href="/adminRole">审批角色</a></li>
 						<li><a href="/adminExecute">费用执行人</a></li>
+						<li ><a href="/adminReceiptAuthority">汇总权限</a></li>
 					</ul>
 				</div>
 					

+ 37 - 4
protected/view/admin/admin_user.html

@@ -42,6 +42,22 @@
 		                </select>
 		              </div>
 		            </div>
+		            
+		            <div class="control-group">
+		              <label class="control-label">省份权限</label>
+		              <div class="controls">
+		                <p class="cGroup">
+							<!-- loop districtList -->
+					    	<label class="checkbox inline">
+							  <input type="checkbox" name="didKey[]" value="{{districtList' value.didKey}}"> {{districtList' value.name}}
+							</label>
+							<!-- endloop -->
+				  
+								    </p>
+								    
+		              </div>
+		            </div>
+		            
 					<div class="control-group">
 						<label class="control-label">入职时间</label>
 						<div class="controls">
@@ -63,12 +79,15 @@
               <thead>
                 <tr>
                   <th>#</th>
-                  <th>员工名称</th>
+                  <th width="60">员工名称</th>
                   <th>所在办事处</th>
+                  <th>省份权限</th>
+                  
+                  
                   <th>手机</th>
-                  <th>APP登录</th>
-				  <th>入职时间</th>
-                  <th>操作</th>
+                  <th width="120">APP登录</th>
+				  <th width="90">入职时间</th>
+                  <th width="80">操作</th>
                 </tr>
               </thead>
               <tbody>
@@ -77,6 +96,15 @@
                   <td>{{staff' value.sid}}</td>
                   <td>{{staff' value.username}}<!-- if {{staff' value.nature}} == 2 -->(实习)<!-- endif --></td>
                   <td>{{staff' value.category}},{{staff' value.othercategory}}</td>
+                  
+                  <td>
+                  <!-- loop stafflist' value.idDistrictList -->
+                  	{{stafflist' value' value.name}}&nbsp;
+                  
+                  
+                  <!-- endloop -->
+                  </td>
+                  
                   <td>{{staff' value.telephone}}</td>
                   <td>{{staff' value.appDate}}</td>
                   <td>{{staff' value.hiredate}}</td>
@@ -88,6 +116,11 @@
 			</div>
 		</div>
 	</div>
+	
+	
+	
+	
+	
 	<script language="javascript">
     <!--
     function linkok(url){

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

@@ -58,7 +58,7 @@
 	  					
 	  					<!-- endif -->
 	  					
-	  					<!-- if {{status}}=='done' || {{status}}=='termination'|| {{status}}=='finish' --> 
+	  					<!-- if {{status}}=='done' || {{status}}=='termination'|| {{status}}=='finish'|| {{status}}=='ongoing' --> 
 	  					<li style="display:none" >
 	  					<input type="month" name="date" id="date" style="width:120px" onChange="receiptDate();" value="">
 	  					</li>

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

@@ -23,7 +23,7 @@
 				<div class="demandCate">
 				
 				
-					<ul class="cateList">
+					<ul class="cateList" style="display:none">
 						<li><a href="/approvalExpenses/finish">返回</a></li>
 						
 	  			</ul>

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

@@ -71,7 +71,7 @@
 								<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"><input name="invoiceType" id="invoiceSpecial" onclick="invoiceShow()"  value="1" type="radio">增值税专用发票</label>
+									<label class="radio inline colRed"><input name="invoiceType" id="invoiceSpecial" onclick="invoiceShow()"  value="1" type="radio">增值税专用发票</label>
 									</td>
 								</tr>
 								</tbody>
@@ -109,7 +109,7 @@
 						<table id="specialInvoice_box" class="table table-bordered table-condensed" style="display:none">
 								<tbody>
 								<tr>
-									<th colspan="4" class="taC">增值税专用发票</th>
+									<th colspan="4" class="taC colRed">增值税专用发票</th>
 								</tr>
 								<tr>
 									<th class="taC" width="150"><span class="colRed">*</span>单位名称</th>

+ 3 - 9
protected/view/admin/invoiceAggregateCompanyDetail.html

@@ -53,9 +53,11 @@
 						
 						<li>
 						<select name="year" node-invoicetype >
+						<option value="ALL">所有</option>
 						<!-- include 'year' -->
 						</select>&nbsp;
 						<select name="month" node-invoicetype >
+						
 						<option value="ALL">全年</option>
 						{{monthHtml}}
 						</select>
@@ -77,7 +79,7 @@
 				</form>
 				</div>
 				<div class="saeaList">
-					<div class="entry autoHeightI2" style="margin-bottom:0;">
+					<div class="entry" style="margin-bottom:0;">
 					<script type="text/javascript">$(document).ready(function() {
 						// $('#invoiceTable').fixedHeaderTable({ fixedColumns:1 });
 					});</script>
@@ -169,14 +171,6 @@
 			  		</ul>
 			  	</div>	
 					
-					
-					
-					
-					
-					
-					
-					
-					
 			</div>
 		</div>
 	</div>

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

@@ -48,9 +48,9 @@
 	<li><a <!-- if {{receiptMemu}}=="invoiceAggregate" --> class="selected" <!-- endif --> href="/invoiceAggregate">公司汇总</a></li>
 	<!-- endif -->
 	
-	
+	<!-- if isInvoiceAggregateCompanyShow({{staff.0.sid}}) -->
 	<li><a <!-- if {{receiptMemu}}=="invoiceAggregateCompanyDetail" --> class="selected" <!-- endif --> href="/invoiceAggregateCompanyDetail">公司应收款</a></li>
-	
+	<!-- endif -->
 	<li class="topLine"><a href="#invhelp" data-toggle="modal">使用帮助</a></li>
 	
 </ul>

+ 177 - 14
protected/view/admin/invoiceReceivablesAS.html

@@ -38,9 +38,10 @@
 	  					<a <!-- if {{status}}=='Unclaimed' --> class="now" <!-- endif --> title="未入账" href="/invoiceReceivablesAS/1/Unclaimed" >未入账</a>
 	  					<a <!-- if {{status}}=='Credited' --> class="now" <!-- endif --> title="已入账" href="/invoiceReceivablesAS/1/Credited" >已入账</a>
 	  					<a <!-- if {{status}}=='BBN' --> class="now" <!-- endif --> title="已入账" href="/invoiceReceivablesAS/1/BBN" >批量导入</a>
+	  					
+	  					<a <!-- if {{status}}=='REFUND' --> class="now" <!-- endif --> title="已入账" href="/invoiceReceivablesAS/1/REFUND" >退款</a>
 	  				</li>
 					
-					
 	  					<li>
 	  					<div class="search">
 	  					<input type="radio" <!-- if {{timeType}}=='BIND' --> checked <!-- endif --> refreshData=time name="timeType" value="BIND">按到账时间
@@ -65,25 +66,41 @@
 				<div class="saeaList">
 		  		<table class="table table-hover">
 					<tr class="thead">
+					<th>收款流水号</th>
+						
+						<th>收款金额</th>
+						<th>实际收款金额</th>
+						
+						
 						<th>银行到账时间</th>
 						<th>收款信息</th>
 						<th>办事处</th>
 						<th>收款银行</th>
-						<th>收款金额</th>
+						
 						<th>录入收款</th>
 						<th>收款认领</th>
 						<th>发票入账</th>
+						
+						<th>退款</th>
+						<th>关联新款</th>
+						
 						<th>开票流水号</th>
 						<th>操作</th>
 					</tr>
 					
 					<!-- loop list -->
 						<tr>
+						<td><a href="#billing" node-invoice='INFO' data-type="receivables" data-isKey="{{list' value.iridKeyK}}" data-toggle="modal">{{list' value.receivablesSerial}}</a></td>
+						
+						<td><b>¥{{list' value.OriginalPrice}}</b></td>
+						<td><b class="colGreen">¥{{list' value.receivablesPrice}}</b></td>
+						
+						
 						<td>{{list' value.receivablesDate}}</td>
 						<td>{{list' value.receivablesMessage}}</td>
 						<td>{{list' value.category}}</td>
 						<td>{{list' value.receivablesBank}}</td>
-						<td><b>¥{{list' value.receivablesPrice}}</b></td>
+						
 						<td>{{list' value.inputStaff}} <br>{{list' value.date}}</td>
 						<td>
 						<!-- if {{list' value.receivablesCategory}}!='PUBLIC' -->
@@ -97,14 +114,42 @@
 						{{list' value.untreadStaff}}&nbsp;退票<br/>{{list' value.unbundlingTime}}
 						<!-- endif -->
 						</td>
+						
+						
+						<td>
+						<!-- if {{list' value.bindStatus}}==0||{{list' value.bindStatus}}==2 -->
+						{{list' value.refundLog}}
+						<!-- endif -->
+						</td>
+						<td>
+						
+						<!-- if {{list' value.relationIrid}}!=0||{{list' value.bindStatus}}==2 -->
+						{{list' value.relationLog}}
+						<!-- endif -->
+						
+						</td>
+						
 						<td>
 						<!-- loop list' value.invoiceList -->
 							<a href="#invdetail" node-invoice='INFO' data-isKey="{{halfList' value' key}}" data-toggle="modal">{{halfList' value' value}}</a>&nbsp;
 						<!-- endloop -->
-						
-						
 						</td>
+						
 						<td>
+						
+						<!-- if {{list' value.bindStatus}}==2&&{{list' value.relationIrid}}==0 -->
+						<a href="#receipt" dataKey="{{list' value.iridKey}}" node-newReceivables data-toggle="modal">关联新收款</a><br/>
+						<!-- endif -->
+						
+						<!-- if {{list' value.bindStatus}}==0 -->
+						<a href="#refund" dataKey="{{list' value.iridKey}}" node-refund data-toggle="modal">退款</a><br/>
+						<!-- endif -->
+						
+						<!-- if {{list' value.bindStatus}}==0&&empty({{list' value.refundLog}}) -->
+						<a  href="#billdel" data-isKey="{{list' value.iridKey}}" node-irDelete data-toggle="modal">删除</a>
+						<br/>
+						<!-- endif -->
+						
 						<!-- 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' -->	
@@ -178,12 +223,8 @@
 		<div id="nc"></div>
 	</div>
 
-
-
-
 <div class="modal hide fade" id="Unbundling" >
 
-
 <form action="/invoiceUnBundLing" method="post" class="form-horizontal">
 <input type="hidden" name="unBundKey" id="unBundKey" value >
 	<div class="modal-dialog">
@@ -209,9 +250,6 @@
 </form>
 </div>
 
-
-
-
 	<!--弹出变更-->
 <div class="modal hide fade" id="receive">
 <form action="/invoiceReceivablesUpdateClaim" method="post" class="form-horizontal">
@@ -318,7 +356,8 @@
     <h3>删除收款</h3>
     </div>
     <div class="modal-body">
-    	数据诚可贵,删除需谨慎!
+    	<p class="alert alert-block">需要删除该到款,请在以下输入框输入"   删除到款   ",再点击“确认删除”按钮。</p>
+			<input style="width:100%;" type="text" name="skll" id="" placeholder="" aria-required="true" aria-invalid="true">
     </div>
 	<div class="modal-footer">
 	<input type="submit" class="button" value="删除">
@@ -416,6 +455,130 @@
 </div>
 	
 	
-	<!--弹出内容-->
+	 <!--弹出退款-->
+<div class="modal hide fade" id="refund">
+<form action="/setInvoiceReceivablesRefund" id="SIRC" method="post">	
+	<input type="hidden" name="iridKey" id="iridKey" value="">
+	<div class="modal-dialog">
+		<div class="modal-content">
+    <div class="modal-header">
+    <h3>填写退款信息</h3>
+    </div>
+    <div class="modal-body saeaList">
+    	<table class="table table-bordered table-condensed">
+				<tbody>
+				<tr>
+					<th colspan="2" class="taC">
+					<label class="radio inline"><input name="refundType" checked value='1' type="radio">全部退款</label>
+					<label class="radio inline"><input name="refundType" value='0' type="radio">部分退款</label>
+					</th>
+				</tr>
+				<tr>
+					<th colspan="2" class="taC">退款信息</th>
+				</tr>
+				<tr>
+					<th class="taC">退款单位名称</th>
+					<td><input type="text" name="refundCompany" id="" placeholder="请输入单位名称" aria-required="true" aria-invalid="true"></td>
+				</tr>
+				<tr>
+					<th class="taC">退款的账号</th>
+					<td><input type="text" name="refundNumber" id="" placeholder="请输入账号" aria-required="true" aria-invalid="true"></td>
+				</tr>
+				<tr>
+					<th class="taC">退款金额</th>
+					<td><input type="text" name="refundPrice" id="" placeholder="请输入退款金额" aria-required="true" aria-invalid="true"></td>
+				</tr>
+				</tbody>
+			</table>
+    </div>
+	<div class="modal-footer">
+	    <input type="submit" class="button" value="确定">
+	    <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
+	</div>
+			</div>
+		</div>
+		
+	</form>
+</div>
+    <!--弹出退款-->
+    
+    <!--弹出退款-->
+<div class="modal hide fade" id="refunded">
+	<div class="modal-dialog">
+		<div class="modal-content">
+    <div class="modal-header">
+    <h3>填写退款信息</h3>
+    </div>
+    <div class="modal-body saeaList">
+    	<table class="table table-bordered table-condensed">
+				<tbody >
+				<th colspan="2" class="taC">退款信息</th>
+				<tr>
+					<th class="taC">退款单位名称</th>
+					<td data-refundCompany ></td>
+				</tr>
+				<tr>
+					<th class="taC">退款的账号</th>
+					<td data-refundNumber ></td>
+				</tr>
+				<tr>
+					<th class="taC">退款金额</th>
+					<td data-refundPrice ></td>
+				</tr>
+				</tbody>
+			</table>
+    </div>
+	<div class="modal-footer">
+	    
+	    <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
+	</div>
+			</div>
+		</div>
+</div>
+    <!--弹出退款-->
+    
+    
+    <!--弹出绑定新收款-->
+<div class="modal hide fade" id="receipt">
+<form action="/relationNewInvoiceReceivables" id="SIRC" method="post">	
+<input type="hidden" name="iridKeyOld" id="iridKey" value="">
+	<div class="modal-dialog">
+		<div class="modal-content">
+    <div class="modal-header">
+    <h3>关联新联</h3>
+    </div>
+    <div class="modal-body">
+    	<blockquote>
+				<p></p><div class="input-append">
+						<input class=" span4" placeholder="你可以按收款流水搜索" name='searchData' value='' type="text">
+						<button class="btn btn-small" search-invoiceReceivables type="button">查询</button>
+				</div><p></p>
+			</blockquote>
+			<table class="table table-bordered table-condensed">
+				<tbody>
+				<tr><th class="taC" width="70">收款金额</th><th class="taC">银行到帐信息</th><th class="taC">银行/到帐时间</th><th class="taC">收款认领</th><th class="taC">开票单位</th></tr>
+				<tr htmlReceivables >
+				
+				</tr>
+				</tbody>
+			</table>
+    </div>
+	<div class="modal-footer">
+	<input type="submit" class="button" value="关联新款">
+	   
+	    <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
+	</div>
+			</div>
+		</div>
+		</form>
+</div>
+    <!--弹出退款-->
+	
+	<div loading-msg='true' style="position:absolute;  left:50%;  top:50%;  "></div>
+	
+	<div class="modal  fade" id="billing">
+		<div id="nr"></div>
+	</div>
+	
 <script type="text/javascript">autoFlashHeight();</script>	
 </body>

+ 4 - 3
protected/view/admin/receipt_menu.html

@@ -14,12 +14,13 @@
 				
 	<li><a <!-- if {{receiptMemu}}=="remittanceHky" --> class="selected" <!-- endif --> href="/remittanceHky">费用汇款</a></li>			
 						
-	<!-- if {{staff.0.cid}}==12 -->
-	<li><a href="/companyCategoryCollect" <!-- if {{receiptMemu}}=="companyCategoryCollect" --> class="selected" <!-- endif --> >公司汇总</a></li>			
-	<!-- endif -->
+	
 			
 						
 	<!-- endif -->
+	<!-- if isReceiptAuthorityShow({{staff.0.sid}}) -->
+	<li><a href="/companyCategoryCollect" <!-- if {{receiptMemu}}=="companyCategoryCollect" --> class="selected" <!-- endif --> >公司汇总</a></li>			
+	<!-- endif -->
 	<li class="topLine"><a href="#welcome" data-toggle="modal">使用帮助</a></li>
 
 	</ul>