소스 검색

发票分页功能

caipin 8 년 전
부모
커밋
c13673c597

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

@@ -367,6 +367,8 @@ $route['post']['/invoiceBindReceivables'] = array('InvoiceController', 'invoiceB
 $route['post']['/invoiceUntreadDo'] = array('InvoiceController', 'invoiceUntreadDo');
 
 $route['get']['/invoiceAchieve'] = array('InvoiceController', 'invoiceAchieve');
+$route['get']['/invoiceAchieve/:page'] = array('InvoiceController', 'invoiceAchieve');
+$route['get']['/invoiceAchieve/:page/:date'] = array('InvoiceController', 'invoiceAchieve');
 
 $route['post']['/ajaxGetInvoiceInfoByType'] = array('InvoiceController', 'ajaxGetInvoiceInfoByType');
 $route['post']['/ajaxGetInvoiceReceivables'] = array('InvoiceController', 'ajaxGetInvoiceReceivables');

+ 94 - 6
protected/controller/InvoiceController.php

@@ -91,8 +91,10 @@ class InvoiceController extends DooController {
 		$invoice = new invoice ();
 		Doo::loadModel ( 'express' );
 		$express = new express ();
+		
 		Doo::loadModel ( 'invoiceReceivables' );
 		$invoiceReceivables = new invoiceReceivables ();
+		
 		Doo::loadModel ( 'invoiceStatistics' );
 		$invoiceStatistics = new invoiceStatistics ();
 		
@@ -110,9 +112,11 @@ class InvoiceController extends DooController {
 		$expressList = $express->getExpressByAll ();
 		$invoiceList = $invoice->getMyInvoice ( $_COOKIE ["staff"] );
 		
-		$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
+		//$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 		
-		// print_r($invoiceList);
+		$list=$invoice->getInvoiceByUntreadStatusPage(4,$_COOKIE ["staff"]);
+		
+		// print_r($list);
 		
 		$this->data ['isMonth'] = $isMonth;
 		$this->data ['htm'] = $htm;
@@ -1626,14 +1630,30 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
 		
-		$page_size=12;
+		$page_size=1;
 		$page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
+		$date = isset($this->params ['date']) ? $this->params ['date'] : 'MONTHO';
+		
+		$con='';
+		if ($date=='MONTHO')
+			$con=' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
+		elseif ($date=='MONTHT')
+			$con=' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
+		elseif ($date=='MONTHY')
+			$con=' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 		
 		$pageinfo['page']=array('previous'=>'');
-		//$pageinfo=$this->get_page("CLD_receipt", $dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.') and status!=5', $page, $page_size, "approvalExpenses","","");
+		$sql='status=2 and untreadStatus=3 and sid='.$_COOKIE ["staff"].$con;
+		$pageinfo=$this->get_page("CLD_invoice", $sql, $page, $page_size, "invoiceAchieve","","");
 		
-		$invoice->getInvoiceByUntreadStatusPage();
+		$limit=$pageinfo ['lower'].','.$page_size;
 		
+		$list=$invoice->getInvoiceByUntreadStatusPage($limit,$_COOKIE ["staff"],$con);
+		//print_r($pageinfo);
+		
+		$this->data['page']=$pageinfo;
+		$this->data ['list'] = $list;
+		$this->data ['date']=$date;
 		$this->data ['memu'] = "invoice";
 		$this->data ['staff'] = $this->staff;
 		$this->data ['receiptMemu'] = 'invoice';
@@ -2044,7 +2064,7 @@ class InvoiceController extends DooController {
 			$receivablesPrice += $detailM ['receivablesPrice'];
 		}
 		
-		if ($receivablesPrice >= $detail ['invoicePrice']) {
+		if ($receivablesPrice > $detail ['invoicePrice']) {
 			$price = $receivablesPrice - $detail ['invoicePrice'];
 			echo json_encode ( array (
 					'status' => 1,
@@ -2342,6 +2362,74 @@ class InvoiceController extends DooController {
 		} else
 			return false;
 	}
+	
+	/**
+	 * 获得分页数据
+	 * @param unknown_type $table
+	 * @param unknown_type $condition
+	 * @param unknown_type $on_page
+	 * @param unknown_type $page_size
+	 */
+	function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
+		$page_c = "";
+		$page ['previous'] = $this->get_previous ( $on_page );
+		$page ['on_page'] = $on_page;
+		$total_count = $this->get_table_count ( $table, $condition );
+		$total = intval ( $total_count / $page_size );
+	
+		$page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
+		$page ['total_data'] = $total_count;
+		$page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
+	
+		$i = 1;
+		$page_max = 1;
+		$page_width=3;
+	
+	
+		if ($on_page >= $page_width) {
+			$page_max = intval ( $on_page / $page_width ) + 1;
+			$i = intval ( $on_page / $page_width ) * $page_width - 1;
+		}
+	
+		for(; $i <= $page ['total_page']; $i ++) {
+			if ($i == $on_page)
+				$page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
+				else
+					$page_c .= '<li><a href="/' . $action .'/'. $i . $get . '">' . $i . '</a></li>';
+						
+	
+	
+					if ($i == ($page_width * $page_max))
+						break;
+		}
+	
+		$page ['page'] = $page_c;
+		$page ['lower'] = (-- $on_page) * $page_size;
+		return $page;
+	}
+	/**
+	 * 获取上一页
+	 * @param unknown_type $on_page
+	 */
+	function get_previous($on_page = 1) {
+		return $on_page != 0 ? $on_page - 1 : $on_page;
+	}
+	/**
+	 * 获取总页数
+	 * @param unknown_type $table
+	 * @param unknown_type $condition
+	 */
+	public function get_table_count($table = "", $condition = "") {
+		//$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
+	
+		$sql = "select count(*) as count from " . $table . " where  " . $condition;
+	
+		//echo $sql;die;
+		$query = Doo::db ()->query ( $sql );
+		$result = $query->fetch ();
+		return $result ['count'];
+	}
+	
 	function isInvoiceNew($type = "GLOBAL") {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();

+ 24 - 2
protected/model/invoice.php

@@ -513,9 +513,31 @@ class invoice extends DooModel {
 		}
 		return $list;
 	}
-	
-	function getInvoiceByUntreadStatusPage(){
+	function getInvoiceByUntreadStatusPage($limit = 0, $sid = 0, $con = "", $desc = 'desc') {
+		if (empty ( $limit ) || empty ( $sid ))
+			return array ();
 		
+		$list = $this->find ( array (
+				'where' => " status=2 and untreadStatus=3 and sid=" . $sid.$con,
+				'limit' => $limit,
+				$desc => 'iid',
+				'asArray' => TRUE 
+		) );
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		Doo::loadModel ( 'invoiceReceivables' );
+		$invoiceReceivables = new invoiceReceivables ();
+		
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['iidKeyK'] = $XDeode->encode ( $value ['iid'] );
+			$list [$key] ['irList'] = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
+			$list [$key] ['sumPrice'] = 0;
+			if (! empty ( $list [$key] ['irList'] ))
+				$list [$key] ['sumPrice'] = $list [$key] ['irList'] [0] ['sumPrice'];
+			// $list [$key] ['operationLog'] = $invoiceOperationLog->getInvoiceOperationLogByIid ( $value ['iid'], 'desc' );
+		}
+		
+		return $list;
 	}
 	
 	/**

+ 47 - 20
protected/model/invoiceReceivables.php

@@ -49,15 +49,15 @@ class invoiceReceivables extends DooModel {
 	 * @return unknown
 	 */
 	public function getInvoiceReceivablesByNew($limit = 4) {
-		$list  = $this->find ( array (
+		$list = $this->find ( array (
 				'desc' => 'irid',
-				'limit'=>$limit,
-				'asArray' => TRUE
+				'limit' => $limit,
+				'asArray' => TRUE 
 		) );
 		Doo::loadModel ( 'invoiceROLog' );
 		$invoiceROLog = new invoiceROLog ();
-		foreach ($list as $key=>$value){
-			$list[$key]['invoiceROLog']=$invoiceROLog->getInvoiceROLogByIrid($value['irid'],'desc');
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['invoiceROLog'] = $invoiceROLog->getInvoiceROLogByIrid ( $value ['irid'], 'desc' );
 		}
 		return $list;
 	}
@@ -83,7 +83,7 @@ class invoiceReceivables extends DooModel {
 			}
 			
 			$list ['arClaim'] = $this->find ( array (
-					'where' => "receivablesCategory!='public' and receivablesStaff!='public' and receivablesCategory like '" . $cid . ":%' and receivablesStaff  like '".$sid."-%' and bindStatus=0",
+					'where' => "receivablesCategory!='public' and receivablesStaff!='public' and receivablesCategory like '" . $cid . ":%' and receivablesStaff  like '" . $sid . "-%' and bindStatus=0",
 					'desc' => 'irid',
 					'asArray' => TRUE 
 			) );
@@ -108,7 +108,7 @@ class invoiceReceivables extends DooModel {
 			}
 			
 			$list ['bindClaim'] = $this->find ( array (
-					'where' => " bindStatus=1 and receivablesStaff  like '".$sid."-%' ",
+					'where' => " bindStatus=1 and receivablesStaff  like '" . $sid . "-%' ",
 					'desc' => 'irid',
 					'limit' => 3,
 					'asArray' => TRUE 
@@ -118,8 +118,8 @@ class invoiceReceivables extends DooModel {
 			Doo::loadClass ( 'XDeode' );
 			$XDeode = new XDeode ( 5 );
 			foreach ( $list ['bindClaim'] as $key => $value ) {
-				$id=$invoice->getInvoiceByIid ( $value ['iid'] );
-				$id['iidKeyUrl']= $XDeode->encode ( $id ['iid'] );
+				$id = $invoice->getInvoiceByIid ( $value ['iid'] );
+				$id ['iidKeyUrl'] = $XDeode->encode ( $id ['iid'] );
 				$list ['bindClaim'] [$key] ['invoice'] = $id;
 				$list ['bindClaim'] [$key] ['iridKeyUrl'] = $XDeode->encode ( $value ['irid'] );
 			}
@@ -159,7 +159,6 @@ class invoiceReceivables extends DooModel {
 		}
 		return $list;
 	}
-	
 	public function getInvoiceReceivablesInIridString($iridString = "") {
 		$list = array ();
 		if (! empty ( $iridString ))
@@ -167,6 +166,16 @@ class invoiceReceivables extends DooModel {
 					'where' => " irid in ( " . $iridString . " )",
 					'asArray' => TRUE 
 			) );
+		$price=0;
+		$serial=0;
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ($list as $key=>$value){
+			$price+=$value['receivablesPrice'];
+			$list [$key] ['iridKeyK'] = $XDeode->encode ( $value ['irid'] );
+		}
+		if (!empty($list))
+			$list[0]['sumPrice']=$price;
 		return $list;
 	}
 	public function getInvoiceReceivablesByIrid($irid = "") {
@@ -184,24 +193,23 @@ class invoiceReceivables extends DooModel {
 		$detail ['iridEn'] = $this->authcode ( $detail ['irid'], '' );
 		return $detail;
 	}
-	
-	public function getInvoiceReceivablesByIrsid($irid = "",$sid="") {
+	public function getInvoiceReceivablesByIrsid($irid = "", $sid = "") {
 		Doo::loadClass ( 'XDeode' );
 		$XDeode = new XDeode ( 5 );
-		$irid = $XDeode->decode( $irid );
+		$irid = $XDeode->decode ( $irid );
 		$detail = array ();
-		if (! empty ( $irid ) && is_numeric ( $irid )){
+		if (! empty ( $irid ) && is_numeric ( $irid )) {
 			$detail = $this->getOne ( array (
-					'where' => " irid=" . $irid." and receivablesStaff like '".$sid."_%'",
-					'asArray' => TRUE
+					'where' => " irid=" . $irid . " and receivablesStaff like '" . $sid . "_%'",
+					'asArray' => TRUE 
 			) );
 			
 			$detail ['sid'] = '';
 			$detail ['username'] = '';
-			if (!empty($detail ['receivablesStaff'])){
-			$staff = explode ( "-", $detail ['receivablesStaff'] );
-			$detail ['sid'] = $staff [0];
-			$detail ['username'] = $staff [1];
+			if (! empty ( $detail ['receivablesStaff'] )) {
+				$staff = explode ( "-", $detail ['receivablesStaff'] );
+				$detail ['sid'] = $staff [0];
+				$detail ['username'] = $staff [1];
 			}
 			$detail ['iridKey'] = $XDeode->encode ( $detail ['irid'] );
 			$detail ['iridEn'] = $this->authcode ( $detail ['irid'], '' );
@@ -242,6 +250,25 @@ class invoiceReceivables extends DooModel {
 	}
 	
 	/**
+	 * 根据irid 获取一组收款数据
+	 * @param string $irid
+	 * @return unknown
+	 */
+	public function getInvoiceReceivablesInIrid($irid = '') {
+		if (empty($irid))
+			return array();
+		
+		$list = $this->find ( array (
+				'where' => " irid in(" . $irid . ")",
+				'asArray' => TRUE 
+		) );
+		foreach ($list as $key=>$value){
+			
+		}
+		return $list;
+	}
+	
+	/**
 	 * 加密或解密指定字符串
 	 *
 	 * @param string $string 要加密或解密的字符串

+ 15 - 11
protected/view/admin/invoice.html

@@ -153,30 +153,34 @@
 							<div class="clearfix">
 							
 							
-							<!-- if !empty({{receivablesList.bindClaim}}) -->
+							<!-- if !empty({{receivablesList}}) -->
 							<legend><div class="fR"><a href="/invoiceAchieve">查看更多</a></div>最近入账</legend>
 							<table class="table table-bordered table-condensed">
 								<tbody>
 								<tr><th class="taC">开票单位(抬头)</th><th class="taC" width="90">开票金额</th><th class="taC">开票流水号</th><th class="taC" width="90">收款金额</th><th class="taC">收款流水号</th><th class="taC">处理时间</th></tr>
-								<!-- loop receivablesList.bindClaim -->
+								<!-- loop receivablesList -->
 								<tr>
 										<td>
-										<!-- if !empty({{receivablesList' value.invoice.invoiceType}}) -->
-	                                   	{{receivablesList' value.invoice.invoiceCompany}}
+										<!-- if !empty({{receivablesList' value.invoiceType}}) -->
+	                                   	{{receivablesList' value.invoiceCompany}}
 	                                    <!-- else -->
-	                                    {{receivablesList' value.invoice.invoiceTitle}}
+	                                    {{receivablesList' value.invoiceTitle}}
 	                                    <!-- endif --></td>
 										<td>
 										<!-- if !empty({{pendingInvoice' value.invoiceType}}) -->
-	                                    <b>¥{{receivablesList' value.invoice.invoicePrice}}</b><sup>专</sup>
+	                                    <b>¥{{receivablesList' value.invoicePrice}}</b><sup>专</sup>
 	                                    <!-- else -->
-	                                    <b>¥{{receivablesList' value.invoice.invoicePrice}}</b>
+	                                    <b>¥{{receivablesList' value.invoicePrice}}</b>
 	                                    <!-- endif -->
 										</td>
-										<td><a href="#invdetail" node-invoice='INFO' data-isKey="{{receivablesList' value.invoice.iidKeyUrl}}"  data-toggle="modal">{{receivablesList' value.invoice.invoiceSerial}}</a></td>
-										<td><b>¥{{receivablesList' value.receivablesPrice}}</b></td>
-										<td><a href="#billing" node-invoice='INFO' data-type="receivables" data-isKey="{{receivablesList' value.iridKeyUrl}}" data-toggle="modal">{{receivablesList' value.receivablesSerial}}</a></td>
-										<td>{{receivablesList' value.invoice.userName}} {{receivablesList' value.invoice.updateTime}}</td>
+										<td><a href="#invdetail" node-invoice='INFO' data-isKey="{{receivablesList' value.iidKeyK}}"  data-toggle="modal">{{receivablesList' value.invoiceSerial}}</a></td>
+										<td><b>¥{{receivablesList' value.sumPrice}}</b></td>
+										<td>
+										<!-- loop list' value.irList -->
+										<a href="#billing" node-invoice='INFO' data-type="receivables" data-isKey="{{list' value' value.iridKeyK}}" data-toggle="modal">{{list' value' value.receivablesSerial}}</a>&nbsp;
+										<!-- endloop -->
+										</td>
+										<td>{{receivablesList' value.userName}} {{receivablesList' value.updateTime}}</td>
 									</tr>
 								<!-- endloop -->
 								

+ 70 - 34
protected/view/admin/invoiceAchieve.html

@@ -1,4 +1,5 @@
 <!-- include 'header' -->
+<script src="<?= WEB_SITE_GLOBAL ?>js/invoice.js"></script>
 <body>
 	<div class="mainLayout">
 		<div class="mainMenu">
@@ -21,7 +22,10 @@
 				入账完成发票</legend>
 				<div class="demandCate">
 					<ul class="cateList">
-	  					<li><a class="now" href="#">最近一个月</a><a href="#">最近三个月</a><a href="#" >今年</a><a href="#" >更旧</a></li>
+	  					<li><a <!-- if {{date}}=='MONTHO' --> class="now" <!-- endif --> href="/invoiceAchieve/1/MONTHO">最近一个月</a>
+	  					<a <!-- if {{date}}=='MONTHT' --> class="now" <!-- endif --> href="/invoiceAchieve/1/MONTHT">最近三个月</a>
+	  					<a <!-- if {{date}}=='MONTHY' --> class="now" <!-- endif --> href="/invoiceAchieve/1/MONTHY" >今年</a>
+	  					<a <!-- if {{date}}=='MONTHA' --> class="now" <!-- endif --> href="/invoiceAchieve/1/MONTHA" >更旧</a></li>
 						<li>
 							<div class="search">
 							<div class="input-append">
@@ -35,50 +39,82 @@
 					<table class="table table-hover">
 						<tbody>
 						<tr class="thead"><th>开票流水号</th><th>开票金额</th><th>开票单位(抬头)</th><th>开票内容</th><th>收款流水号</th><th>收款金额</th><th>入账时间</th></tr>
+						<!-- loop list -->
 						<tr>
-							<td><a href="#invdetail" data-toggle="modal">#F20160316001</a></td>
-							<td><b>¥3000.00</b></td>
-							<td>珠海XXXX公司</td>
-							<td>纵横公路工程造价管理系统V9.0</td>
-							<td><a href="#" data-toggle="modal">#SK20160316001</a>,<a href="#" data-toggle="modal">#SK20160316001</a>,<a href="#" data-toggle="modal">#SK20160316001</a></td>
-							<td><b>¥3000.00</b></td>
-							<td>2016-03-03<br>11:30:03</td>
-						</tr>
-						<tr>
-							<td><a href="#invdetail" data-toggle="modal">#F20160316001</a></td>
-							<td><b>¥3000.00</b><sup>专</sup></td>
-							<td>珠海XXXX公司</td>
-							<td>纵横公路工程造价管理系统V9.0</td>
-							<td><a href="#" data-toggle="modal">#SK20160316001</a></td>
-							<td><b>¥3000.00</b></td>
-							<td>2016-03-03<br>11:30:03</td>
-						</tr>
-						<tr>
-							<td><a href="#invdetail" data-toggle="modal">#F20160316001</a></td>
-							<td><b>¥3000.00</b></td>
-							<td>珠海XXXX公司</td>
-							<td>纵横公路工程造价管理系统V9.0</td>
-							<td><a href="#" data-toggle="modal">#SK20160316001</a></td>
-							<td><b>¥3000.00</b></td>
-							<td>2016-03-03<br>11:30:03</td>
+							<td><a href="#invdetail" node-invoice='INFO' data-isKey="{{pendingInvoice' value.iidKeyK}}" data-toggle="modal">{{list' value.invoiceSerial}}</a></td>
+							<td>
+							<!-- if !empty({{list' value.invoiceType}}) -->
+	                        <b>¥{{list' value.invoicePrice}}</b><sup>专</sup>
+	                          <!-- else -->
+	                          <b>¥{{list' value.invoicePrice}}</b>
+	                          <!-- endif -->
+							</td>
+							<td><!-- if !empty({{list' value.invoiceType}}) -->
+	                                   	{{list' value.invoiceCompany}}
+	                                    <!-- else -->
+	                                    {{list' value.invoiceTitle}}
+	                                    <!-- endif --></td>
+							<td>{{list' value.invoiceElement}}</td>
+							<td>
+							<!-- loop list' value.irList -->
+							<a href="#billing" node-invoice='INFO' data-type="receivables" data-isKey="{{list' value' value.iridKeyK}}" data-toggle="modal">{{list' value' value.receivablesSerial}}</a>&nbsp;
+							<!-- endloop -->
+							</td>
+							<td><b>¥{{list' value.sumPrice}}</b></td>
+							<td>{{list' value.updateTime}}</td>
 						</tr>
+						<!-- endloop -->
+						
 						</tbody>
 					</table>
 				</div>
 				<!--翻页-->
 				<div class="demandPage">
 					<ul class="pagination fL">
-						<li><a href="#">&lt;</a></li>
-						<li><a href="#">1</a></li>
-						<li class="active"><a href="#">2</a></li>
-						<li><a href="#">3</a></li>
-						<li><a href="#">4</a></li>
-						<li><a href="#">5</a></li>
-						<li><a href="#">&gt;</a></li>
-					</ul>
+	  							<!-- if {{page.previous}}==0 -->
+								<li><a href="javascript:void(0)" title="上一页">&lt;</a></li>
+								<!-- else -->
+								<li><a href="/invoiceAchieve/{{page.previous}}" title="上一页">&lt;</a></li>
+								<!-- endif -->	
+								
+	  							<!-- if {{page.on_page}}>=3 -->
+	  							<li><a href="/invoiceAchieve/1" title="上一页">1</a></li>
+	  							<li class="point"><span>...</span></li>
+	  							<!-- endif -->
+	  							
+	  							{{page.page}}
+	  							
+	  							<!-- if {{page.on_page}}<3 && {{page.total_page}}>5 -->
+	  							<li><a href="/invoiceAchieve/4" >4</a></li>
+	  							<li><a href="/invoiceAchieve/5" >5</a></li>
+	  							<!-- endif -->
+	  							
+	  							<!-- if {{page.total_page}}>3 -->
+	  							<li class="point"><span>...</span></li>
+			  					<!-- endif -->
+			  					
+			  					<!-- if {{page.next}}=={{page.on_page}} -->
+								<li><a href="javascript:void(0)" title="下一页">&gt;</a></li>
+								<!-- else -->
+								<li><a href="/invoiceAchieve/{{page.next}}" title="下一页">&gt;</a></li>
+								<!-- endif -->
+			  					
+			  		</ul>
+					
+					
 			  	</div>
 			</div>
 		</div>
 	</div>
+	<div loading-msg='true' style="position:absolute;  left:50%;  top:50%;  "></div>
+	
+	<div class="modal  fade" id="invdetail">
+		
+		<div id="nc"></div>
+	</div>
+	
+	<div class="modal  fade" id="billing">
+		<div id="nr"></div>
+	</div>
 <script type="text/javascript">autoFlashHeight();</script>	
 </body>