Browse Source

公司统计

caipin 8 years ago
parent
commit
d77aa20515

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

@@ -377,7 +377,8 @@ $route['post']['/invoiceBindReceivables'] = array('InvoiceController', 'invoiceB
 $route['post']['/invoiceEnterReceivables'] = array('InvoiceController', 'invoiceEnterReceivables');
 
 $route['get']['/invoiceAggregate'] = array('InvoiceController', 'invoiceAggregate');
-
+$route['get']['/invoiceAggregateStaff'] = array('InvoiceController', 'invoiceAggregateStaff');
+$route['get']['/invoiceAggregateCategory/:cid'] = array('InvoiceController', 'invoiceAggregateCategory');
 
 $route['post']['/ajaxGetInvoicePostDetail'] = array('InvoiceController', 'ajaxGetInvoicePostDetail');
 $route['post']['/ajaxGetStaffByCategory'] = array('InvoiceController', 'ajaxGetStaffByCategory');

File diff suppressed because it is too large
+ 349 - 17
protected/controller/InvoiceController.php


+ 52 - 19
protected/model/L_category.php

@@ -1,38 +1,71 @@
 <?php
-
 Doo::loadCore ( 'db/DooModel' );
-
 class L_category extends DooModel {
-	
 	public $cid;
 	public $title;
 	public $defult;
 	public $districtid;
-	
 	public $_table = 'CLD_L_category';
 	public $_primarykey = 'cid';
-	public $_fields = array ('cid', 'title','defult','districtid');
-	
-	public function checkUser($uid,$passwork){
-		return $this->find ( array ('where' => "uid= '".$uid."' and passwork = '".addslashes($passwork)."'", 'asArray' => TRUE ) );
+	public $_fields = array (
+			'cid',
+			'title',
+			'defult',
+			'districtid' 
+	);
+	public function checkUser($uid, $passwork) {
+		return $this->find ( array (
+				'where' => "uid= '" . $uid . "' and passwork = '" . addslashes ( $passwork ) . "'",
+				'asArray' => TRUE 
+		) );
 	}
-	
-	public function getCategoryById($cid=0,$othercid=""){
-		if(!empty($othercid))
-			return $this->find ( array ('where' => "cid in ( ".$cid.",".$othercid.") ", 'asArray' => TRUE ) );
+	public function getCategoryById($cid = 0, $othercid = "") {
+		if (! empty ( $othercid ))
+			return $this->find ( array (
+					'where' => "cid in ( " . $cid . "," . $othercid . ") ",
+					'asArray' => TRUE 
+			) );
 		else
-			return $this->find ( array ('where' => "cid= '".$cid."' ", 'asArray' => TRUE ) );
-	
+			return $this->find ( array (
+					'where' => "cid= '" . $cid . "' ",
+					'asArray' => TRUE 
+			) );
 	}
-	
 	public function getCategory() {
-		return $this->find ( array ('asc' => 'cid', 'asArray' => TRUE ) );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		$list=$this->find ( array (
+				'asc' => 'cid',
+				'asArray' => TRUE 
+		) );
+		
+		foreach ($list as $key=>$value){
+			$list[$key]['cidKey']=$XDeode->encode ( $value ['cid'] );
+		}
+		
+		return $list;
 	}
-
-	public function getUserByIdList($puid){
-		return $this->find ( array ('where' => "uid= '".$puid."'", 'asArray' => TRUE ) );
+	public function getUserByIdList($puid) {
+		return $this->find ( array (
+				'where' => "uid= '" . $puid . "'",
+				'asArray' => TRUE 
+		) );
 	}
 	
+	
+	public function getCategoryStaff() {
+		$list = $this->find ( array (
+				'asArray' => TRUE 
+		) );
+		Doo::loadModel ( 'staff' );
+		$staff = new staff ();
+		foreach ( $list as $key => $value ) {
+			$list[$key]['staff']=$staff->getStaffByCid($value['cid']);
+		}
+		return $list;
+	}
 }
 
 ?>

+ 2 - 1
protected/model/invoiceReceivables.php

@@ -154,11 +154,12 @@ class invoiceReceivables extends DooModel {
 		}
 		return $list;
 	}
+	
 	public function getInvoiceReceivablesInIridString($iridString = "") {
 		$list = array ();
 		if (! empty ( $iridString ))
 			$list = $this->find ( array (
-					'where' => " irid in(" . $iridString . ")",
+					'where' => " irid in ( " . $iridString . " )",
 					'asArray' => TRUE 
 			) );
 		return $list;

+ 137 - 9
protected/model/invoiceStatistics.php

@@ -56,18 +56,146 @@ class invoiceStatistics extends DooModel {
 		}
 		return $lid;
 	}
-	function getClientByCid($cid) {
-		$sql = "select sum(price) from " . $this->_table . " where staff= '" . $cid . "' and  ";
-		
-		$query = Doo::db ()->query ( $sql );
+	
+	/**
+	 * 根据发票ID和绑定状态获得收款数据,绑定状态为ALL获取所有状态数据
+	 * @param string $iid 发票ID
+	 * @param string $bindStatus
+	 * @return mixed
+	 */
+	public function getInvoiceStatisticsByYear($year="", $cid = "0") {
+		$list = array ();
+		$sql = '';
+		if (empty($year))
+			$year=date("Y");
+		if ($cid != 0)
+			$sql = " and cid=" . $cid;
+	
+			$list['statisticsMonthCid'] = $this->find ( array (
+					'select'=>'cid,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+					'where' => " cid!=0 and staff!=0 and  Year(date) =" . $year . $sql,
+					'groupby'=>'cid,Month(date)',
+					'asArray' => TRUE
+			) );
+			
+			$list['statisticsYear'] = $this->find ( array (
+					'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Year(date) as Year',
+					'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+					'groupby'=>'Year(date)',
+					'asArray' => TRUE
+			) );
+			
+			$list['statisticsMonth'] = $this->find ( array (
+					'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+					'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+					'groupby'=>'Month(date)',
+					'asArray' => TRUE
+			) );
+			
+			return $list;
+	}
+	
+	/**
+	 * 获取用户的统计信息
+	 * @param string $year
+	 * @param string $cid
+	 * @return NULL[]
+	 */
+	public function getInvoiceStatisticsByStaff($year="", $cid = "0") {
+		$list = array ();
+		$sql = '';
+		if (empty($year))
+			$year=date("Y");
+			if ($cid != 0)
+				$sql = " and cid=" . $cid;
+	
+				$list['statisticsMonthCid'] = $this->find ( array (
+						'select'=>'cid,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+						'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+						'groupby'=>'cid,Month(date)',
+						'asArray' => TRUE
+				) );
+				
+				$list['statisticsMonthStaff'] = $this->find ( array (
+						'select'=>'cid,staff,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+						'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+						'groupby'=>'staff,Month(date)',
+						'asArray' => TRUE
+				) );
+				
+				$list['statisticsMonth'] = $this->find ( array (
+						'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+						'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+						'groupby'=>'Month(date)',
+						'asArray' => TRUE
+				) );
+					
+				return $list;
+	}
+	
+	
+	public function getInvoiceStatisticsByCategory($year="", $cid = "0") {
+		$list = array ();
+		$sql = '';
+		if (empty($year))
+			$year=date("Y");
+			if ($cid != 0)
+				$sql = " and cid=" . $cid;
+	
+				$list['statisticsMonthCid'] = $this->find ( array (
+						'select'=>'cid,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+						'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+						'groupby'=>'cid,Month(date)',
+						'asArray' => TRUE
+				) );
+	
+				$list['statisticsMonthStaff'] = $this->find ( array (
+						'select'=>'cid,staff,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+						'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+						'groupby'=>'staff,Month(date)',
+						'asArray' => TRUE
+				) );
+	
+				$list['statisticsMonth'] = $this->find ( array (
+						'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month',
+						'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql,
+						'groupby'=>'Month(date)',
+						'asArray' => TRUE
+				) );
+					
+				return $list;
+	}
+	
+	/**
+	 * 获取某年的汇总金额
+	 * @param string $year
+	 * @param string $cid
+	 * @return NULL[]
+	 */
+	public function getInvoiceStatisticsByTote($year="", $cid = "0") {
+		$list = array ();
+		$sql = '';
+		if (empty($year))
+			$year=date("Y");
+			if ($cid != 0)
+				$sql = " and cid=" . $cid;
+		$list['statisticsYear'] = $this->find ( array (
+				'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Year(date) as Year',
+				'where' => "  Year(date) =" . $year . $sql,
+				'groupby'=>'Year(date)',
+				'asArray' => TRUE
+		) );
 		
-		$result = $query->fetch ();
+		if (empty($list['statisticsYear'])){
+			$list['statisticsYear'][0]['invoicePrice']=0;
+			$list['statisticsYear'][0]['receivablesPrice']=0;
+			$list['statisticsYear'][0]['accountPrice']=0;
+		}
 		
-		return $result;
+		return $list;
 	}
-	/*
-	 * public function getProjectByIdList($projectid){ return $this->find ( array ('where' => "pid= '".$projectid."'", 'asArray' => TRUE ) ); }
-	 */
+	
+	
 }
 
 ?>

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


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

@@ -0,0 +1,55 @@
+<!-- include 'header' -->
+<link rel=stylesheet href="<?= WEB_SITE_GLOBAL ?>css/fixedheadertable.css">
+<script src="<?= WEB_SITE_GLOBAL ?>js/jquery.fixedheadertable.js"></script>
+<body>
+	<div class="mainLayout">
+		<div class="mainMenu">
+			<div class="menuItem">
+				<a href="#" class="mLogo">CLD</a>
+				<ul>
+					<!-- include 'menuReceipt' -->
+				</ul>
+			</div>
+			
+		</div>
+		<div class="warpContent">
+			<div class="subMenu fL">
+				<div class="menuItem">
+					<!-- include 'invoiceMenu' -->
+				</div>
+			</div>
+			<div class="adminContent autoHeight">
+				<legend>
+					{{slist.0.category}} 全年开票收款汇总
+				</legend>
+				<div class="demandCate">
+					<ul class="cateList">
+						<li><select>
+	<!-- include 'year' -->
+</select></li>
+						<li>开票总计:¥{{isList.statisticsYear.0.invoicePrice}}</li>
+						<li>收款总计:¥{{isList.statisticsYear.0.receivablesPrice}}</li>
+						<li>完成入账:¥{{isList.statisticsYear.0.accountPrice}}</li>
+					</ul>
+				</div>
+				<div class="saeaList">
+					<div class="entry autoHeightI2" style="margin-bottom:0">
+					<script type="text/javascript">$(document).ready(function() {
+						$('#invoiceTable').fixedHeaderTable({ fixedColumns:2 });
+					});</script>
+					<table class="table table-bordered table-condensed table-hover">
+						<thead>
+						<tr><th class="taC">姓名</th><th class="taC">项目</th><th class="taC">1月</th><th class="taC">2月</th><th class="taC">3月</th><th class="taC">4月</th><th class="taC">5月</th><th class="taC">6月</th><th class="taC">7月</th><th class="taC">8月</th><th class="taC">9月</th><th class="taC">10月</th><th class="taC">11月</th><th class="taC">12月</th><th class="taC">年总计</th></tr>
+						</thead>
+						<tbody>
+						{{html}}
+						
+						</tbody>
+					</table>
+				</div>
+					</div>
+			</div>
+		</div>
+	</div>
+<script type="text/javascript">autoFlashHeight();</script>	
+</body>

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