Browse Source

更新开票功能

caipin 7 years ago
parent
commit
7d6b965b81

+ 3 - 3
global/js/index.js

@@ -1579,8 +1579,6 @@ $(function() {
 	
 	a();
 	
-	
-	
 	$("input[id^='longleStatus_']").click(function() {
 		
 		var lid=$(this).val();
@@ -1734,7 +1732,9 @@ $(function() {
 			});
 		
 	});
-
+	
+//	name=CASYN[]
+//	  $('input[name=CASYN]:checked').length;
 })
 
 

+ 56 - 0
global/js/invoice.js

@@ -1,3 +1,59 @@
+
+var notify = null;
+var isNotifyShowing = false;
+var isError = false;
+$(function() {
+    Notification.requestPermission(function(status) {});
+
+	// 轮询查找是否有未处理的审批
+    var permission = Notification.permission;
+    if (permission === 'granted') {
+        var interval = setInterval(checkNotify, 90000);//
+        if (isError) {
+            clearInterval(interval);
+        }
+
+    }
+});
+/**
+ * 获取未审批数量
+ */
+function checkNotify() {
+	$.ajax({
+		url: '/ajaxInvoicePushNotice',
+		type: 'get',
+		data: '',
+		dataType: 'json',
+		error: function() {
+            console.log('数据错误');
+            isError = true;
+		},
+		success: function(response) {
+		    var isNotice = response.isNotice;
+            
+            if (isNotice && !isNotifyShowing) {
+                notify = new Notification("你有发票需要审批", {
+                   // icon: '/global/img/wen.png111',
+                    body: '点击本消息可跳转至审批页',
+                    silent: true
+                });
+                notify.onclick = function() {
+                    notify.close();
+                    window.location.href = '/invoiceApproval';
+                };
+                notify.onshow = function () {
+                    isNotifyShowing = true;
+                };
+                notify.onclose = function () {
+                    isNotifyShowing = false;
+                };
+            }
+		}
+	});
+}
+
+
+//
 function receiptYear(){
 	 var form = $('#up'); 
 	 $('#year').val($('#Y').val());

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

@@ -59,7 +59,9 @@ $acl ['发票审批'] ['allow'] = array (
 				'invoiceApproval',
 				'invoiceDetail',
 				'invoiceApprovalDo',
-				'invoiceApprovalAchieve'
+				'invoiceApprovalAchieve',
+				
+				'ajaxInvoicePushNotice'
 		) 
 );
 $acl ['发票打印'] ['allow'] = array (

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

@@ -1 +1 @@
-,43,58,50,50,9,2
+,43,58,50,50,9,2,43,44

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

@@ -0,0 +1 @@
+{"\u53d1\u7968\u5ba1\u6279":"43,44"}

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

@@ -420,6 +420,10 @@ $route['get']['/invoiceApprovalAchieve/:page'] = array('InvoiceController', 'inv
 $route['get']['/invoiceApprovalAchieve/:page/:date'] = array('InvoiceController', 'invoiceApprovalAchieve');
 $route['get']['/invoiceApprovalAchieve/:page/:date/:MebSea'] = array('InvoiceController', 'invoiceApprovalAchieve');
 
+//新加信息推送
+$route['get']['/ajaxInvoicePushNotice'] = array('InvoiceController', 'ajaxInvoicePushNotice');
+
+
 //发票打印
 $route['*']['/invoicePrint'] = array('InvoiceController', 'invoicePrint');
 $route['*']['/invoicePrintDetail/:iid'] = array('InvoiceController', 'invoicePrintDetail','extension'=>'.html');

+ 121 - 34
protected/controller/InvoiceController.php

@@ -37,7 +37,7 @@ class InvoiceController extends DooController {
 			foreach ( $moldList as $value ) {
 				// echo $value['mold'];
 				// echo $action;
-				
+				//删除审批人后的权限加入问题
 				if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) {
 					$flag = true;
 					break;
@@ -79,6 +79,7 @@ class InvoiceController extends DooController {
 	function invoice() {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
+		
 // 		Doo::loadModel ( 'express' );
 // 		$express = new express ();
 // 		$expressList = $express->getExpressByAll ();
@@ -222,6 +223,8 @@ class InvoiceController extends DooController {
 			
 			$invoiceManageList = $invoiceManage->getInvoiceByAll ();
 			$invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
+// 			print_r(current($invoiceManageDetail ['staffList']));
+// 			die;
 			
 			$moldManage = array ();
 			foreach ( $invoiceManageList as $key => $value ) {
@@ -247,7 +250,7 @@ class InvoiceController extends DooController {
 					'sid' => $this->staff [0] ['sid'],
 					'userName' => $this->staff [0] ['username'],
 					'invoiceManage' => $invoiceManageDetail ['staff'],
-					'pendingApprovals' => $invoiceManageDetail ['staffList'] [0] [0],
+					'pendingApprovals' => current($invoiceManageDetail ['staffList']) [0],
 					'moldManage' => json_encode ( $moldManage ),
 					'remark' => $remark 
 			);
@@ -991,6 +994,8 @@ class InvoiceController extends DooController {
 			Doo::loadModel ( 'invoiceOperationLog' );
 			$invoiceOperationLog = new invoiceOperationLog ();
 			
+			
+			
 			$invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
 			if (empty ( $invoicePrintDetail ))
 				die ( 'illegal request' );
@@ -1014,6 +1019,13 @@ class InvoiceController extends DooController {
 					'iid' => $iid 
 			);
 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
+			
+			
+			
+			
+			
+			
+			
 			return "/invoicePrint";
 		}
 	}
@@ -1066,7 +1078,7 @@ class InvoiceController extends DooController {
 		);
 		$invoice->setInvoiceByCondition ( $item );
 		
-		// $this->setWXMsg ( $iid, 41 );
+		 $this->setWXMsg ( $iid );
 		
 		return '/invoicePost';
 	}
@@ -1389,6 +1401,27 @@ class InvoiceController extends DooController {
 					'iid' => $detail ['iid'] 
 			);
 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
+			
+			
+			Doo::loadModel ( 'invoiceStatistics' );
+			$invoiceStatistics = new invoiceStatistics ();
+			
+			$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
+			$accountPrice = 0;
+			foreach ( $list as $key => $value ) {
+				$accountPrice += $value ['receivablesPrice'];
+			}
+			$item = array (
+					'date' => date ( "Y-m-d H:i:s" ),
+					'priceClass' => 3,
+			
+					'cid' => $this->staff [0] ['cid'],
+					'staff' => $this->staff [0] ['sid'],
+					'accountPrice' => $accountPrice
+			);
+			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
+			
+			
 			Doo::db ()->commit ();
 			
 		}
@@ -1762,12 +1795,31 @@ class InvoiceController extends DooController {
 		);
 		$invoiceOperationLog->setInvoiceOperationLog ( $item );
 		
+		Doo::loadModel ( 'invoiceStatistics' );
+		$invoiceStatistics = new invoiceStatistics ();
+			
+		$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
+		$accountPrice = 0;
+		foreach ( $list as $key => $value ) {
+			$accountPrice += $value ['receivablesPrice'];
+		}
+		$item = array (
+				'date' => date ( "Y-m-d H:i:s" ),
+				'priceClass' => 3,
+					
+				'cid' => $this->staff [0] ['cid'],
+				'staff' => $this->staff [0] ['sid'],
+				'accountPrice' => $accountPrice
+		);
+		$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
+		
+		
 		return "/invoiceReceivables";
 	}
 	
 	
 	/**
-	 * @deprecated
+	 * 核销 动作,确认入账统计
 	 * 发票收款完成--需求更变 废弃
 	function invoiceEnterReceivables() {
 		$invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
@@ -3150,6 +3202,8 @@ class InvoiceController extends DooController {
 								$html .= '<span class="colOrange">退回</span>';
 							} elseif ($value ['status'] == 5) {
 								$html .= '<span class="colGreen">打印</span>';
+							}elseif($value ['status'] == 4){
+								$html .= '<span class="colRed">终止</span>';
 							}
 							$html .= $value ['operation'] . '</p></blockquote>';
 						}
@@ -3352,7 +3406,7 @@ class InvoiceController extends DooController {
 		$invoice = new invoice ();
 		
 		$detail=$invoiceReceivables->getInvoiceReceivablesByIrid($irid);
-		$invoiceDetail=$invoice->getInvoiceByTitle($detail['recepitTitleMark'],'EXACTLY'," and status=2 and printStatus=1 and irid='' ");//
+		$invoiceDetail=$invoice->getInvoiceByTitle($detail['recepitTitleMark'],'EXACTLY'," and status=2 and printStatus=1 and doPost=1 and postStatus=1 and irid='' ");//
 		
 		$receivablesHtml='<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>
@@ -3484,6 +3538,29 @@ class InvoiceController extends DooController {
 		) );
 	}
 	
+	function ajaxInvoicePushNotice(){
+		
+		Doo::loadModel ( 'invoice' );
+		$invoice = new invoice ();
+		
+		$approval = $invoice->getOne ( array (
+				'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
+				'desc' => 'iid',
+				'asArray' => true
+		) );
+		
+		$isNotice=false;
+		if (!empty($approval))
+			$isNotice=true;
+		$response = array(
+				'error' => 0,
+				'isNotice' => $isNotice
+		);
+		
+		echo json_encode($response);
+		exit();
+	}
+	
 	function _GetFileEXT($filename) {
 		$pics = explode ( '.', $filename );
 		$num = count ( $pics );
@@ -3761,52 +3838,62 @@ class InvoiceController extends DooController {
 			$new ['untread'] = TRUE;
 		return $new;
 	}
-	function setWXMsg($rid, $uid) {
+	function setWXMsg($rid) {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
-		$receiptDetail = $invoice->getOne ( array (
+		$invoiceDetail = $invoice->getOne ( array (
 				'where' => 'iid=' . $rid,
 				'asArray' => true 
 		) );
 		
-		if (! empty ( $receiptDetail )) {
+		
+		
+		if (! empty ( $invoiceDetail )) {
 			Doo::loadModel ( 'staff' );
 			$staff = new staff ();
 			$staffmsg = $staff->getOne ( array (
-					'where' => "sid='" . $uid . "'",
+					'where' => "sid='" . $invoiceDetail['sid'] . "'",
 					'asArray' => TRUE 
 			) );
 			if (! empty ( $staffmsg ['wxid'] )) {
 				require_once (SITE_PATH . '/protected/class/client.php');
 				$client = new client ( 'http://m.cld.smartcost.com.cn/' );
 				$user = $staffmsg ['wxid'];
-				$receiptName = '费用';
-				$msg = '';
-				// switch ($receiptDetail ['Rtype']) {
-				// case 0 :
-				// $receiptName = '报销';
-				// break;
-				// case 1 :
-				// $receiptName = '借款';
-				// break;
-				// case 2 :
-				// $receiptName = '对公汇款';
-				// break;
-				// }
 				
-				// 单位名称 金额 开票内容 已邮寄,顺丰 123123213
+				$expCom=explode(":",$invoiceDetail ['expressCompany']);
+				if (empty($expCom))
+					$expCom[0]='';
+					
+				$msg = '太好了,您的发票' . $invoiceDetail['invoiceSerial'] . ' 已邮寄  ' . $expCom [0] . ' ,快递号: ' . $invoiceDetail ['expressNumber'];
 				
-				switch (2) {
-					case 1 :
-						$msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已同意支付。';
-						break;
-					case 2 :
-						$msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已被撤回,请及时处理。';
-						break;
-					case 3 :
-						$msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
-						break;
-				}
+				
+// 				$receiptName = '费用';
+// 				$msg = '';
+// 				// switch ($receiptDetail ['Rtype']) {
+// 				// case 0 :
+// 				// $receiptName = '报销';
+// 				// break;
+// 				// case 1 :
+// 				// $receiptName = '借款';
+// 				// break;
+// 				// case 2 :
+// 				// $receiptName = '对公汇款';
+// 				// break;
+// 				// }
+				
+// 				// 单位名称 金额 开票内容 已邮寄,顺丰 123123213
+				
+// 				switch (2) {
+// 					case 1 :
+// 						$msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已同意支付。';
+// 						break;
+// 					case 2 :
+// 						$msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已被撤回,请及时处理。';
+// 						break;
+// 					case 3 :
+// 						$msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
+// 						break;
+// 				}
 				
 				$result = $client->SendMsg ( $user, $msg, 'text' );
 			}

+ 45 - 2
protected/controller/MainController.php

@@ -3459,6 +3459,12 @@ class MainController extends DooController {
 		  					<tr><td colspan="4">
 		  					' . $taghtml . '
 		  					</td></tr>
+		  					<tr><td colspan="4">
+		  						<a class="button" node-synadd="true" href="javascript:void(0)">确定同步</a><span class="bsAlert bsSuccess fL hide">同步成功</span>
+		  							已选择 <span id="tl">0</span>/<span id="bl">'.sizeof($clientlist).'</span>
+		  						</td>
+		  					</tr>		
+		  							
 		  				</tbody></table></div>
 		  				<h2 class="cate">';
 				$html .= '<a  href="javascript:void(0)" onclick="departmentC()" class="now">不限</a>';
@@ -3478,8 +3484,18 @@ class MainController extends DooController {
 					$scinfo = $client_staff->getClientByCid ( $value ['cid'] );
 					
 					$staffinfo = $staff->getUserById ( $scinfo ['sid'] );
+					//客户信息
 					$html .= '<div class="contactPanel" id="PART_' . $value ['department'] . '">
-						<h1><p class="fR">' . $staffinfo [0] ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffinfo [0] ['username'] . '\')" >' . $staffinfo [0] ['username'] . '</a></p><a href="javascript:void(0)" onclick="getClientInfo(\'' . $value ['cid'] . '\')" class="clientName">' . $value ['clientname'] . '</a><i class="icon- sport">' . $value ['priority'] . '</i><a class="icon- edit" title="编辑客户" href="javascript:clientEdit(' . $value ['cid'] . ')">I</a></h1><table>
+						<h1><p class="fR">' . $staffinfo [0] ['category'] . '-<a href="javascript:void(0)" onclick="getStaffInfo(\'' . $staffinfo [0] ['username'] . '\')" >
+							' . $staffinfo [0] ['username'] . '</a></p>
+									
+			<input type="checkbox" name="CASYN[]" CAS-NUM="TR" value="'.$value ['cid'].'">
+			<a href="javascript:void(0)" onclick="getClientInfo(\'' . $value ['cid'] . '\')" class="clientName">' . $value ['clientname'] . '   </a>
+			
+					
+			<i class="icon- sport">' . $value ['priority'] . '</i><a class="icon- edit" title="编辑客户" href="javascript:clientEdit(' . $value ['cid'] . ')">I</a></h1><table>
+											
+											
 							<tbody><tr><th>性别</th><td>' . $value ['gender'] . '</td><th>昵称</th><td>' . $value ['nicename'] . '</td></tr>
 							<tr><th>部门</th><td>' . $value ['department'] . '</td><th>办公室</th><td>' . $value ['office'] . '</td></tr>
 							<tr><th>手机</th><td>' . $value ['telephone'] . '</td><th>电话</th><td>' . $value ['phone'] . '</td></tr>
@@ -3503,7 +3519,34 @@ class MainController extends DooController {
 					
 					$html .= '</tbody></table></div>';
 				}
-				$html .= "</div><script type='text/javascript'>autoFlashHeight();</script>";
+				$html .= "</div><script type='text/javascript'>
+						
+						
+		$(\"input[CAS-NUM='TR']\").click(function() {
+						
+			$('#tl').html($('input[CAS-NUM=TR]:checked').length);
+		
+		
+		});
+		$(\"a[node-synadd='true']\").click(function() {
+						
+			var id_array=new Array();  
+			$('input[CAS-NUM=TR]:checked').each(function(){  
+    			id_array.push($(this).val());
+			});  
+			if(id_array.length==0){
+				alert('未选中客户');
+			}else{
+				var idstr=id_array.join(',');
+				console.log(idstr);
+			}
+			
+		});				
+						
+						
+						
+						autoFlashHeight();
+						</script>";
 				echo json_encode ( array (
 						"success" => true,
 						'html' => $html 

+ 6 - 4
protected/model/invoice.php

@@ -423,8 +423,10 @@ class invoice extends DooModel {
 		} elseif (! empty ( $sid ) && empty ( $iid )) {
 			$list ['pendingInvoice'] = array ();
 			$list ['handleInvoice'] = array ();
-			$list ['pendingInvoice'] = $this->find ( array (
-					'where' => "((status=1) or (status=2 and printStatus=0) or ( status=2 and printStatus=1 and untreadStatus=1) )  and sid=" . $sid,
+			$list ['pendingInvoice'] = $this->find ( array (//加入邮件中也为 处理中 已退票
+					'where' => "((status=1) or (status=2 and printStatus=0) or ( status=2 and printStatus=1 and untreadStatus=1) 
+					
+					or (postStatus=0 and doPost=1 and status=2) )  and sid=" . $sid,
 					'desc' => 'iid',
 					'asArray' => TRUE 
 			) );
@@ -435,7 +437,7 @@ class invoice extends DooModel {
 			
 			$list ['handleInvoice'] = $this->find ( array (
 					// 需求变更 -去除出票状态的数据 or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 )
-					'where' => "(status=3 or status=4   )  and isDelete=0 and sid=" . $sid,
+					'where' => "(status=3 or status=4 or (status=2 and printStatus=1 and untreadStatus=2 )  )  and isDelete=0 and sid=" . $sid,
 					'desc' => 'iid',
 					'asArray' => TRUE 
 			) );
@@ -462,7 +464,7 @@ class invoice extends DooModel {
 			$title=' and (invoiceTitle like "%'.$invoiceTC.'%" or invoiceCompany like "%'.$invoiceTC.'%" )';
 		
 		$list = $this->find ( array (//
-				'where' => "status=2 and printStatus=1 and untreadStatus=0 and irid=''  and isDelete=0 ".$title,
+				'where' => "status=2 and printStatus=1 and untreadStatus=0 and irid='' and doPost=1 and postStatus=1  and isDelete=0 ".$title,
 				'desc' => 'iid',
 				'asArray' => TRUE 
 		));

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

@@ -4,6 +4,9 @@
 <script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/zh-CN.js"></script>
 <script src="<?= WEB_SITE_GLOBAL ?>js/invoice.validator.js"></script>
 <script src="<?= WEB_SITE_GLOBAL ?>js/invoice.js"></script>
+
+<script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/notifications/notifications.js"></script>
+
 <body>
 	<div class="mainLayout">
 		<div class="mainMenu">
@@ -122,7 +125,7 @@
 									<!-- loop invoiceList.pendingInvoice -->
 									<tr>
 										<td>
-										<!-- if {{pendingInvoice' value.status}}==2 and {{pendingInvoice' value.printStatus}}==0 -->
+										<!-- if ({{pendingInvoice' value.status}}==2 and {{pendingInvoice' value.printStatus}}==0) or ({{pendingInvoice' value.status}}==2 and {{pendingInvoice' value.postStatus}}==0 and {{pendingInvoice' value.doPost}}==1 ) -->
 										<span class="colBlue">出票中</span>
 										 <!-- elseif {{pendingInvoice' value.status}}==1 -->
 										 <span class="">审核中</span>

File diff suppressed because it is too large
+ 2 - 2
protected/view/admin/invoiceAggregate.html


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

@@ -31,7 +31,7 @@
 </select></li>
 						<li>开票总计:¥{{isList.statisticsYear.0.invoicePrice}}</li>
 						<li>收款总计:¥{{isList.statisticsYear.0.receivablesPrice}}</li>
-						<li>完成核销:¥{{isList.statisticsYear.0.accountPrice}}</li>
+						<li>完成入账:¥{{isList.statisticsYear.0.accountPrice}}</li>
 					</ul>
 					</form>
 				</div>

File diff suppressed because it is too large
+ 2 - 2
protected/view/admin/invoiceAggregateStaff.html


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

@@ -256,7 +256,7 @@
 								<!-- endloop -->
 							</select>
 
-							<select name="receivablesStaff">
+							<select name="receivablesStaff" style="display:none">
 							<option value="PUBLIC">办事处待认领款项</option>
 								<!-- loop staffList -->
 								<option value="{{staffList' value.sid}}-{{staffList' value.username}}">{{staffList' value.category}}-{{staffList' value.username}}</option>