Kaynağa Gözat

发票邮寄,填写相关数据

caipin 8 yıl önce
ebeveyn
işleme
7e872475df

+ 32 - 4
global/js/invoice.js

@@ -1,9 +1,37 @@
-$(function () {
-	$("a[node-approval^='approval']").click(function(){
+$(function() {
+	$("a[node-approval^='approval']").click(function() {
 		$("input[name='status']").val($(this).attr("diss-data"));
 		$("form[name='invoiceApproval']").submit();
 	});
-	
-	
+
+	$("a[node-post^='express']").click(function() {
+		var postData = $(this).attr("post-data");
+		$("input[name='iidKey']").val(postData);
+		
+		$("div[loading-msg='true']").html("<img src='/global/img/loadIco.gif' />");
+		var url = "/ajaxGetInvoicePostDetail";
+		$.ajax({
+			url : url,
+			type : "post",
+			cache : false,
+			dataType : "json",
+			data : {
+				iidKey : postData
+			},
+			global : true,
+			success : function(data) {
+				if (data.status == 1) {
+					$("td[recipients-data='true']").html(data.invoiceDetail.recipients);
+					$("td[recipientsPhone-data='true']").html(data.invoiceDetail.recipientsPhone);
+					$("td[recipientsAddress-data='true']").html(data.invoiceDetail.recipientsAddress);
+					$("td[mailItems-data='true']").html(data.invoiceDetail.mailItems);
+					$("div[loading-msg='true']").html("");
+				} else
+					$("div[loading-msg='true']").html("illegal request");
+			},
+			error : function(err) {
+			}
+		});
+	});
 
 })

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

@@ -359,6 +359,9 @@ $route['*']['/invoicePrint'] = array('InvoiceController', 'invoicePrint');
 $route['*']['/invoicePrintDetail/:iid'] = array('InvoiceController', 'invoicePrintDetail','extension'=>'.html');
 $route['*']['/invoicePrintDo'] = array('InvoiceController', 'invoicePrintDo');
 $route['*']['/invoicePost'] = array('InvoiceController', 'invoicePost');
+$route['*']['/invoiceExpressAddDo'] = array('InvoiceController', 'invoiceExpressAddDo');
+$route['post']['/ajaxGetInvoicePostDetail'] = array('InvoiceController', 'ajaxGetInvoicePostDetail');
+
 //假期管理
 $route['*']['/myList'] = array('HolidayController', 'myList');
 $route['*']['/myList/:yearnum'] = array('HolidayController', 'myList');

+ 39 - 31
protected/controller/InvoiceController.php

@@ -129,6 +129,8 @@ class InvoiceController extends DooController {
 			foreach ( $invoiceManageList as $key => $value ) {
 				if ($value ['mold'] == '发票打印')
 					$moldManage [$value ['mold']] = $value ['staffList'];
+				elseif ($value ['mold'] == '发票邮寄')
+					$moldManage [$value ['mold']] = $value ['staffList'];
 			}
 			
 			$item = array (
@@ -386,8 +388,8 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'staff' );
 		$staff = new staff ();
 		
-		$toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 2 );
-		$printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 5 );
+		$toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
+		$printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
 		
 		foreach ( $toPrint as $key => $value ) {
 			$toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
@@ -450,9 +452,9 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoiceOperationLog' );
 		$invoiceOperationLog = new invoiceOperationLog ();
 		
-		$invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 2, $iid );
-		if (empty ( $invoiceDetail ))
-			die ( 'illegal request' );
+		$invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
+		// if (empty ( $invoiceDetail ))
+		// die ( 'illegal request' );
 		
 		$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
 		
@@ -486,7 +488,7 @@ class InvoiceController extends DooController {
 				die ( 'illegal request' );
 			$item = array (
 					'iid' => $iid,
-					'status' => 5,
+					'printStatus' => 1,
 					'updateTime' => date ( "Y-m-d H:i:s" ),
 					'printTime' => date ( "Y-m-d H:i:s" ),
 					'invoiceNo' => $invoiceNo 
@@ -513,45 +515,51 @@ class InvoiceController extends DooController {
 	function invoicePost() {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
 		
 		$invoicePost = $invoice->getPostByInvoice ();
+		$invoicePosted = $invoice->getPostedByInvoice ();
 		
-		$data ['invoicePost'] = $invoicePost;
+		foreach ( $invoicePost as $key => $value ) {
+			$invoicePost [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
+		}
 		
+		$data ['invoicePost'] = $invoicePost;
+		$data ['invoicePosted'] = $invoicePosted;
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoicePost';
 		$this->render ( "/admin/invoicePost", $data );
 	}
-	private function getExeCount() {
-		Doo::loadModel ( 'receipt' );
-		$receipt = new receipt ();
-		$receiptList = $receipt->find ( array (
-				'where' => '(executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff NOT LIKE \'%' . $this->staff [0] ['sid'] . '%\' ) and (status=1 or status=6)',
-				'desc' => 'rid',
-				'asArray' => true 
-		) );
-		
-		return count ( $receiptList );
+	function invoiceExpressAddDo() {
 	}
-	private function getReceiptCount() {
-		$status = 2;
-		$year = date ( 'Y' );
-		
-		Doo::loadModel ( 'receipt' );
-		$receipt = new receipt ();
-		Doo::loadModel ( 'verify' );
+	/**
+	 * 异步获取一条发票的邮寄信息
+	 */
+	function ajaxGetInvoicePostDetail() {
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
 		
-		$dateCondition = " and Year(date) =" . $year;
+		$iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
+		$iid = $XDeode->decode ( $iid );
+		if (! is_numeric ( $iid )) {
+			echo json_encode ( array (
+					'status' => 0,
+					'msg' => 'illegal request' 
+			) );
+			die ();
+		}
 		
-		$approvalCondition = ' and nowStaff like "%' . $this->staff [0] ['sid'] . '%" ';
-		$receiptList = $receipt->find ( array (
-				'where' => ' status=' . $status . $dateCondition . $approvalCondition,
-				'desc' => 'rid',
-				'asArray' => true 
+		Doo::loadModel ( 'invoice' );
+		$invoice = new invoice ();
+		$select="recipients,recipientsPhone,recipientsAddress,mailItems";
+		$invoiceDetail=$invoice->getInvoiceByIid($iid,$select);
+		echo json_encode ( array (
+				'status' => 1,
+				'invoiceDetail' => $invoiceDetail
 		) );
 		
-		return count ( $receiptList );
 	}
 	function _GetFileEXT($filename) {
 		$pics = explode ( '.', $filename );

+ 57 - 10
protected/model/invoice.php

@@ -22,6 +22,8 @@ class invoice extends DooModel {
 	 *
 	 * @var string $invoiceManage 当前审批组人员
 	 */
+	public $printStatus;
+	public $postStatus;
 	public $invoiceManage;
 	/**
 	 *
@@ -148,6 +150,9 @@ class invoice extends DooModel {
 	 * @var string $mailItems 邮寄物品
 	 */
 	public $mailItems;
+	public $expressCompany;
+	public $expressNumber;
+	public $actualItems;
 	/**
 	 *
 	 * @var date $date 提交时间
@@ -172,6 +177,8 @@ class invoice extends DooModel {
 			'processApprovals',
 			'invoiceSerial',
 			'status',
+			'printStatus',
+			'postStatus',
 			'invoicePrice',
 			'moldManage',
 			'cid',
@@ -192,25 +199,54 @@ class invoice extends DooModel {
 			'recipientsPhone',
 			'recipientsAddress',
 			'mailItems',
+			'expressCompany',
+			'expressNumber',
+			'actualItems',
 			'sid',
 			'userName',
 			'date',
 			'updateTime',
 			'printTime' 
 	);
-	public function getInvoiceByIid($iid = 0) {
+	/**
+	 * 根据发票ID获取一条发票数据
+	 * @param number $iid 发票ID
+	 * @param number $select 需要获取的字段,为空获取全部数据
+	 * @return array|array() 返回发票数据
+	 */
+	public function getInvoiceByIid($iid = 0, $select = "") {
+		$condition = array (
+				'where' => "iid=" . $iid,
+				'asArray' => TRUE 
+		);
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
+		
+		$Detail = array ();
+		if (is_numeric ( $iid ) && ! empty ( $iid ))
+			$Detail = $this->getOne ( $condition );
+		return $Detail;
 	}
 	/**
 	 * 获取单个可以打印的发票数据
 	 * @param number $iid 发票id
+	 * @param number $select 需要获取的字段,为空获取全部数据
+	 * @return array|array() 返回发票数据
 	 */
-	public function getInvoiceByPrint($iid = 0) {
+	public function getInvoiceByPrint($iid = 0, $select = "") {
+		$condition = array (
+				'where' => "iid= '" . $iid . "' and status=2",
+				'asArray' => TRUE 
+		);
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
 		$detail = array ();
 		if (! empty ( $iid ) && is_numeric ( $iid ))
-			$detail = $this->getOne ( array (
-					'where' => "iid= '" . $iid . "' and status=2",
-					'asArray' => TRUE 
-			) );
+			$detail = $this->getOne ( $condition );
 		return $detail;
 	}
 	/**
@@ -246,7 +282,7 @@ class invoice extends DooModel {
 	/**
 	 * 根据管理组和发票当前状态获得打印发票数据;其中当iid为空时获取所有发票数据,反之获取1条数据
 	 * @param number $sid 管理组人员ID
-	 * @param number $status 状态 为2时获取可以打印数据,为5时获取已经完成打印数据
+	 * @param number $status 状态 为0时获取可以打印数据,为1时获取已经完成打印数据
 	 * @param number $iid 发票ID
 	 * @return array|array() 返回所有发票数据,当iid有值时返回一条数据
 	 */
@@ -254,13 +290,13 @@ class invoice extends DooModel {
 		$list = array ();
 		if (! empty ( $sid ) && empty ( $iid ))
 			$list = $this->find ( array (
-					'where' => "status=" . $status . " and moldManage like '%[\"" . $sid . "\",%'",
+					'where' => "status=2 and printStatus=" . $status . " and moldManage like '%[\"" . $sid . "\",%'",
 					'desc' => 'iid',
 					'asArray' => TRUE 
 			) );
 		elseif (! empty ( $sid ) && ! empty ( $iid ))
 			$list = $this->getOne ( array (
-					'where' => "status=" . $status . " and moldManage like '%[\"" . $sid . "\",%' and iid=" . $iid,
+					'where' => "status=2 and printStatus=" . $status . " and moldManage like '%[\"" . $sid . "\",%' and iid=" . $iid,
 					'asArray' => TRUE 
 			) );
 		return $list;
@@ -282,7 +318,18 @@ class invoice extends DooModel {
 	 */
 	public function getPostByInvoice() {
 		$list = $this->find ( array (
-				'where' => "status=5 and doPost=1",
+				'where' => "postStatus=0 and doPost=1 and status=2",
+				'asArray' => TRUE 
+		) );
+		return $list;
+	}
+	/**
+	 * 获取已经邮寄过的发票
+	 * @return array
+	 */
+	public function getPostedByInvoice() {
+		$list = $this->find ( array (
+				'where' => "postStatus=1 and doPost=1 and status=2",
 				'asArray' => TRUE 
 		) );
 		return $list;

+ 3 - 1
protected/plugin/TemplateTag.php

@@ -35,7 +35,9 @@ function isInvoiceMoldShow($sid = 0, $mold = '') {
 		}
 		$fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
 		$fileInvoice = json_decode ( $fileInvoice, true );
-		$delIM= explode( ',', $fileInvoice[$mold] );
+		$delIM=array();
+		if (isset($fileInvoice[$mold]))
+			$delIM= explode( ',', $fileInvoice[$mold] );
 		foreach ($delIM as $key=>$value){
 			if (!empty($value))
 					array_push($list, $value);

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

@@ -25,11 +25,12 @@
 			href="/invoicePrint">发票打印
 	</a></li>
 	<!-- endif -->
+	<!-- if isInvoiceMoldShow({{staff.0.sid}},'发票邮寄') -->
 	<li class="news"><a
 			<!-- if {{receiptMemu}}=="invoicePost" --> class="selected" <!-- endif -->
 			href="/invoicePost">发票邮寄
 	</a></li>
-
+<!-- endif -->
 	<li><a href="invoice-return.html">发票退票</a></li>
 	<li><a href="invoice-dlist-category-year.html">公司汇总</a></li>
 </ul>

+ 36 - 13
protected/view/admin/invoicePost.html

@@ -1,4 +1,5 @@
 <!-- include 'header' -->
+<script src="<?= WEB_SITE_GLOBAL ?>js/invoice.js"></script>
 <body>
 	<div class="mainLayout">
 		<div class="mainMenu">
@@ -45,17 +46,10 @@
                                     </td>
 									<td>{{invoiceList' value.categoryName}}{{invoiceList' value.userName}} {{invoiceList' value.date}}</td>
 									<td>{{invoiceList' value.userName}}&nbsp;{{invoiceList' value.printTime}}</td>
-									<td><a class="button btn-block"  href="#addshipping" data-toggle="modal">邮寄发票</a></td>
+									<td><a class="button btn-block"  node-post="express" post-data="{{invoicePost' value.iidKey}}" href="#addshipping" data-toggle="modal">邮寄发票</a></td>
 								</tr>
 								<!-- endloop -->
-								<tr>
-									<td><a href="#invdetail" data-toggle="modal">#F20160316001</a></td>
-									<td>珠海XXXX公司</td>
-									<td><b>¥3000.00</b><sup>专</sup></td>
-									<td>广东办刘飞 2016-03-03 12:20:20</td>
-									<td>赵淑燕 2016-03-03 12:20:20</td>
-									<td><a class="button btn-block"  href="#addshipping" data-toggle="modal">邮寄发票</a></td>
-								</tr>
+								
 								</tbody>
 							</table>
 							<!-- else -->
@@ -64,9 +58,32 @@
 						</div>
 						<div class="clearfix">
 							<legend><div class="fR"><a href="invoice-shipping-all.html">查看更多</a></div>最近邮寄发票</legend>
+							<!-- if !empty({{invoicePosted}}) -->
 							<table class="table table-bordered table-condensed">
 								<tbody>
 								<tr><th class="taC">开票流水号</th><th class="taC">开票单位(抬头)</th><th class="taC">开票金额</th><th class="taC">提交开票</th><th class="taC">快递信息</th><th class="taC">邮寄发票</th></tr>
+								<!-- loop invoicePosted -->
+								<tr>
+									<td><a href="#invdetail" data-toggle="modal">{{invoiceList' value.invoiceSerial}}</a></td>
+									<td>
+                                    <!-- if !empty({{invoiceList' value.invoiceType}}) -->
+                                   	{{invoiceList' value.invoiceCompany}}
+                                    <!-- else -->
+                                    {{invoiceList' value.invoiceTitle}}
+                                    <!-- endif -->
+                                    </td>
+									<td>
+                                    <!-- if !empty({{invoiceList' value.invoiceType}}) -->
+                                    <b>¥{{invoiceList' value.invoicePrice}}</b><sup>专</sup>
+                                    <!-- else -->
+                                    <b>¥{{invoiceList' value.invoicePrice}}</b>
+                                    <!-- endif -->
+                                    </td>
+									<td>{{invoiceList' value.categoryName}}{{invoiceList' value.userName}} {{invoiceList' value.date}}</td>
+									<td>{{invoiceList' value.userName}}&nbsp;{{invoiceList' value.printTime}}</td>
+									<td><a class="button btn-block"  href="#addshipping" data-toggle="modal">邮寄发票</a></td>
+								</tr>
+								<!-- endloop -->
 								<tr>
 									<td><a href="#invdetail" data-toggle="modal">#F20160316001</a></td>
 									<td>珠海XXXX公司</td>
@@ -85,7 +102,9 @@
 								</tr>
 								</tbody>
 							</table>
+							<!-- else -->
 							<blockquote><p class="colGray">暂时没有已邮寄的发票</p></blockquote>
+							<!-- endif -->
 						</div>
 					</div>
 				</div>
@@ -100,21 +119,24 @@
     <div class="modal-header">
     <h3>邮寄物品</h3>
     </div>
+    <form action="/invoiceExpressAddDo" method="post">
+    <input type="hidden" name="iidKey" value="">
     <div class="modal-body saeaList">
+    	<div style='text-align:center' loading-msg='true'></div>
 		<table class="table table-bordered table-condensed">
 			<tbody>
 			<tr>
 				<th colspan="4" class="taC">申请邮寄信息</th>
 			</tr>
 			<tr>
-				<th class="taC" width="100">收件人</th><td>陈工</td>
-				<th class="taC" width="100">收件人手机/电话</th><td>12345678901</td>
+				<th class="taC" width="100">收件人</th><td recipients-data='true' ></td>
+				<th class="taC" width="100">收件人手机/电话</th><td recipientsPhone-data='true'></td>
 			</tr>
 			<tr>
-				<th class="taC" width="100">收件地址</th><td colspan="3">广东省珠海市XXX路XXX号</td>
+				<th class="taC" width="100">收件地址</th><td colspan="3" recipientsAddress-data='true'></td>
 			</tr>
 			<tr>
-				<th class="taC" width="100">邮寄物品</th><td colspan="3">合同x1、锁套装x1</td>
+				<th class="taC" width="100">邮寄物品</th><td colspan="3" mailItems-data='true'></td>
 			</tr>
 			</tbody>
 		</table>
@@ -139,6 +161,7 @@
 	    <a href="#" class="button" data-dismiss="modal">确定邮寄</a>
 	    <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
 	</div>
+	</form>
 			</div></div>
 </div>
     <!--邮寄-->