caipin пре 5 година
родитељ
комит
d00daad982

+ 59 - 0
protected/model/RAssist.php

@@ -0,0 +1,59 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class RAssist extends DooModel {
+	public $aid;
+	public $rid;
+	public $sid;
+	public $inputer;
+	public $date;
+	
+	public $_table = 'CLD_RAssist';
+	public $_primarykey = 'aid';
+	public $_fields = array (
+			'aid',
+			'rid',
+			'sid',
+			'inputer',
+			'date',
+			
+	);
+	
+	/**
+	 * 更加费用ID获得可操作人员
+	 * @param number $rid
+	 */
+	function getRAssistByRid($rid=0){
+		$sql = 'select * from ' . $this->_table . ' a left JOIN CLD_staff as b on (a.sid=b.sid)  where a.rid='.$rid;
+		
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ($list as $key=>$value){
+			$list[$key]['aidKey']=$XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	
+	function getRAssistBySid($sid=0){
+		$sql = 'select * from ' . $this->_table . ' a left JOIN CLD_receipt as b on (a.rid=b.rid)  where a.sid='.$sid;
+		
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		$XDeode7 = new XDeode ( 7 );
+		
+		foreach ($list as $key=>$value){
+			$list[$key]['aidKey']=$XDeode->encode ( $value ['aid'] );
+			$list[$key]['ridKey7']=$XDeode7->encode ( $value ['rid'] );
+			$list[$key]['ridKey']=$XDeode->encode ( $value ['rid'] );
+		}
+		
+		return $list;
+	}
+	
+}
+
+?>

+ 82 - 0
protected/model/RIExtend.php

@@ -0,0 +1,82 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class RIExtend extends DooModel {
+	public $riid;
+	public $rid;
+	public $iid;
+	public $RIstatus;
+	
+	public $_table = 'CLD_RIExtend';
+	public $_primarykey = 'riid';
+	public $_fields = array (
+			'riid',
+			'rid',
+			'iid',
+			'RIstatus',
+			
+	);
+	
+	/**
+	 * 
+	 */
+	function getRIExtendByRid($rid=0){
+		$sql = 'select a.iid,b.irid
+				from ' . $this->_table . ' as a left join  CLD_invoice  as b on (a.iid=b.iid)
+				where b.status=2 and b.printStatus=1 and  b.untreadStatus=3 and b.irid!="" and a.RIstatus=1 and a.rid= '.$rid;
+		
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		return $list;
+	}
+	
+	/**
+	 */
+	function getAccountBookByLimit($limit = 3) {
+		$sql = 'select *
+				from ' . $this->_table . '
+						 ORDER BY  aid desc limit ' . $limit;
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	/**
+	 *
+	 * @param number $limit
+	 * @param string $con
+	 * @param string $desc
+	 * @return boolean
+	 */
+	function getAccountBookBySql($limit = 0, $con = "", $desc = 'desc') {
+		
+		// $listCount = $this->count ( array (
+		// 'where' => $con,
+		// 'asArray' => TRUE
+		// ) );
+		$list = $this->find ( array (
+				'where' => '1 ' . $con,
+				'limit' => $limit,
+				$desc => 'aid',
+				'asArray' => TRUE 
+		) ); // echo $con;
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ( $list as $key => $value ) {
+			// $list [$key] ['count'] = $listCount;
+			$list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	
+}
+
+?>

+ 81 - 0
protected/model/RILecturer.php

@@ -0,0 +1,81 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class RILecturer extends DooModel {
+	public $rlid;
+	public $rid;
+	public $ltype;
+	public $lecturerName;
+	public $schoolDay;
+	public $taxation;
+	public $price;
+	public $fees;
+	
+	public $_table = 'CLD_RILecturer';
+	public $_primarykey = 'rlid';
+	public $_fields = array (
+			'rlid',
+			'rid',
+			'ltype',
+			'lecturerName',
+			'schoolDay',
+			'taxation',
+			'price',
+			'fees',
+			
+	);
+	
+	function getRILecturerByRlid($rlid){
+		$detail=$this->getOne(array (
+				'where' => "rlid=".$rlid,
+				'asArray' => TRUE
+		));
+		
+		return $detail;
+	}
+	
+	/**
+	 * 根据rid获得教师详情
+	 * @param number $rid
+	 */
+	function getRILecturerByRid($rid=0){
+		$sql = 'select (@rowNO := @rowNo+1) AS  i, a.* from ' . $this->_table . ' a, (select @rowNO :=0) b where rid='.$rid;
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ($list as $key=>$value){
+			$list[$key]['rlidKey']=$XDeode->encode ( $value ['rlid'] );
+			$list[$key]['sum']=$value['schoolDay']*$value['price'];
+		}
+		return $list;
+	}
+
+    /**
+     * 获得教师支出的金额
+     * @param string $rids
+     * @return int
+     */
+	function getRILecturerPriceByRids($rids=''){
+        if (empty($rids)){
+            return 0;
+        }
+        $list = $this->find ( array (
+            'where' => " rid in (" .$rids.")",
+            'asArray' => TRUE
+        ) );
+        $bValue=0;
+        foreach ($list as $key=>$value){
+            if($value['fees']=='0.00'){
+                $bValue+=($value['price']*$value['schoolDay']);
+            }else{
+                $bValue+=$value['fees'];
+            }
+        }
+        return $bValue;
+    }
+	
+}
+
+?>

+ 166 - 0
protected/model/RItem.php

@@ -0,0 +1,166 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class RItem extends DooModel {
+	public $riid;
+	public $rid;
+	public $identifying;
+	public $item;
+	public $price;
+	
+	public $date;
+	public $inputer;
+	public $describe;
+	public $payType;
+	
+	public $creater;
+	public $createrId;
+	public $creatDate;
+	
+	public $_table = 'CLD_RItem';
+	public $_primarykey = 'riid';
+	public $_fields = array (
+			'riid',
+			'rid',
+			'identifying',
+			'item',
+			'price',
+			
+			'date',
+			'inputer',
+			'describe',
+			'payType',
+			'creater',
+			'createrId',
+			'creatDate',
+			
+	);
+
+    /**
+     * 一组培训班结算支出项金额总和
+     * @param string $rids
+     */
+	function getRItemPriceByRids($rids=''){
+        if (empty($rids)){
+            return 0;
+        }
+        $sum = $this->getOne ( array (
+            'select' => 'sum(price) as price',
+            'where' => " rid in (" .$rids.")",
+            //'groupby' => 'cid,Month(date)',
+            'asArray' => TRUE
+        ) );
+        return $sum['price'];
+    }
+
+	function getRItemByRiid($riid){
+		$detail=$this->getOne(array (
+				'where' => "riid=".$riid,
+				'asArray' => TRUE
+		));
+	
+		return $detail;
+	}
+	
+	function addRItem($itemData,$receipt,$receiptDetail,$rid,$item,$price,$payType){
+		
+		if (is_array ( $itemData ) && ! empty ( $itemData )) {
+			foreach ( $itemData as $key => $value ) {
+				$this->$key = $value;
+			}
+			$lid = $this->insert ();
+		}
+		
+		
+		
+		// 添加公司汇总
+		// 报销详情
+		$rInfo = $receipt->getReceiptByRid ( $rid );
+		$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' );
+		if (empty ( $rdInfo )) {
+			$receiptDetail = new receiptDetail ();
+			$receiptDetail->staff = $rInfo ['staff'];
+			$receiptDetail->item = $item;
+			$receiptDetail->itemCategory = '培训班费用';
+			$receiptDetail->price =  $price;
+			$receiptDetail->date = date ( "Y-m-d" );
+			$receiptDetail->cid = $rInfo ['cid'];
+			$receiptDetail->rid = $rid;
+			$receiptDetail->status = 4;
+			$receiptDetail->insert ();
+		} else {
+			$receiptDetail = new receiptDetail ();
+			$rdInfo ['price'] +=  $price;
+			$receiptDetail->price = $rdInfo ['price'];
+			$receiptDetail->update ( array (
+					'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"'
+			) );
+		}
+		//更新费用合计金额
+		$receipt = new receipt ();
+		$receipt->sum=$rInfo['sum']+ $price;
+		$receipt->update ( array (
+				'where' => 'rid=' . $rid
+		) );
+			
+			
+		//汇总金额--提交审批之后有 支出项时 需要更新汇总
+		if($payType=='company'){
+			Doo::loadModel ( "statistics" );
+			$statistics = new statistics ();
+		
+		
+			$dateArray = explode ( "-", $rInfo ['date'] );
+			$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
+		
+			$stat = $statistics->getOne ( array (
+					'where' => 'staff=' . $rInfo ['staff'] . $dateCondition,
+					'asArray' => true
+			) );
+			if (!empty($stat)){
+				//$statistics->agPrice = $stat ['agPrice'] + $price;
+				$statistics->rePrice = $stat ['rePrice'] + $price;
+					
+				$statistics->update ( array (
+						'where' => 'sid=' . $stat ['sid']
+				) );
+			}
+		}
+		
+		
+		
+	}
+	
+	/**
+	 * 根据rid获得支出项详情
+	 * @param number $rid
+	 */
+	function getRItemByRid($rid=0,$name=''){
+		
+		$con='';
+		if(!empty($name)){
+			$con=' ORDER BY case WHEN item like "%'.$name.'%" then 1 end desc';
+		}else{
+			$con=' ORDER BY creatDate  desc';
+		}
+		
+		$sql = 'select (@rowNO := @rowNo+1) AS  i, a.* from ' . $this->_table . '  a  , (select @rowNO :=0) b where rid='.$rid.$con;
+		
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ($list as $key=>$value){
+			
+			$list[$key]['riidKey']=$XDeode->encode($value['riid']);
+			
+// 			if($value['item']=='税款'){
+// 				$list[$key]['price']=$value['price']*0.07;
+// 			}
+		}
+		
+		return $list;
+	}
+	
+}
+
+?>

+ 172 - 0
protected/model/accountBook.php

@@ -0,0 +1,172 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class accountBook extends DooModel {
+	public $aid;
+	public $expensesType;
+	public $accountType;
+	public $accountMsg;
+	public $receivedPrice;
+	public $receivedMsg;
+	public $receivedBank;
+	public $receivedDate;
+	public $expenditureType;
+	public $expenditureMsg;
+	public $expenditurePrice;
+	public $expenditureBank;
+	public $bookSerial;
+	public $inputDate;
+	public $remarks;
+	public $expenditureDate;
+	
+	public $inputStaff;
+	
+	public $_table = 'CLD_accountBook';
+	public $_primarykey = 'aid';
+	public $_fields = array (
+			'aid',
+			'expensesType',
+			'accountType',
+			'accountMsg',
+			'receivedPrice',
+			'receivedMsg',
+			'receivedBank',
+			'receivedDate',
+			'expenditureType',
+			'expenditureMsg',
+			'expenditurePrice',
+			'expenditureBank',
+			
+			'expenditureDate',
+			
+			'bookSerial',
+			'remarks',
+			'inputDate' ,
+			'inputStaff'
+	);
+	
+	/**
+	 */
+	function getAccountBookByLimit($limit = 3) {
+		$sql = 'select *
+				from ' . $this->_table . '
+						 ORDER BY  aid desc limit ' . $limit;
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	/**
+	 *
+	 * @param number $limit
+	 * @param string $con
+	 * @param string $desc
+	 * @return boolean
+	 */
+	function getAccountBookBySql($limit = 0, $con = "", $desc = 'desc') {
+		
+		// $listCount = $this->count ( array (
+		// 'where' => $con,
+		// 'asArray' => TRUE
+		// ) );
+		$list = $this->find ( array (
+				'where' => '1 ' . $con,
+				'limit' => $limit,
+				$desc => 'aid',
+				'asArray' => TRUE 
+		) ); // echo $con;
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ( $list as $key => $value ) {
+			// $list [$key] ['count'] = $listCount;
+			$list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	function getAccountBookByAid($aid = 0, $select = "") {
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		Doo::loadModel ( 'staff' );
+		$staff = new staff ();
+		
+		if (! is_numeric ( $aid ))
+			$aid=$XDeode->decode( $aid );
+			
+		
+		$condition = array (
+				'where' => "aid=" . $aid,
+				'asArray' => TRUE 
+		);
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
+		
+		$Detail = array ();
+		if (is_numeric ( $aid ) && ! empty ( $aid ))
+			$Detail = $this->getOne ( $condition );
+		
+		if (empty ( $Detail ))
+			return $Detail;
+		
+		$Detail ['aidKey'] = $XDeode->encode ( $Detail ['aid'] );
+		
+		$Detail['expenditureTypeMsg']='';
+		if($Detail ['expenditureType']==1){
+			$Detail['expenditureTypeMsg']='银行手续费';
+		}elseif($Detail ['expenditureType']==2){
+			$Detail['expenditureTypeMsg']='总部电话费';
+		}elseif($Detail ['expenditureType']==3){
+			$Detail['expenditureTypeMsg']='缴税';
+		}elseif($Detail ['expenditureType']==4){
+			$Detail['expenditureTypeMsg']='广发理财';
+		}elseif($Detail ['expenditureType']==5){
+			$Detail['expenditureTypeMsg']='保证金';
+		}elseif($Detail ['expenditureType']==6){
+			$Detail['expenditureTypeMsg']='工行理财';
+		}elseif($Detail ['expenditureType']==7){
+			$Detail['expenditureTypeMsg']='理财支出';
+		}
+		
+		$Detail['incomeTypeMsg']='';
+		if($Detail ['accountType']==1){
+			$Detail['incomeTypeMsg']='利息收入';
+		}elseif($Detail ['accountType']==2){
+			$Detail['incomeTypeMsg']='补贴收入';
+		}elseif($Detail ['accountType']==3){
+			$Detail['incomeTypeMsg']='纵横知道';
+		}elseif($Detail ['accountType']==4){
+			$Detail['incomeTypeMsg']='借款收回';
+		}elseif($Detail ['accountType']==5){
+			$Detail['incomeTypeMsg']='退汇';
+		}elseif($Detail ['accountType']==6){
+			$Detail['incomeTypeMsg']='其他';
+		}elseif($Detail ['accountType']==7){
+			$Detail['incomeTypeMsg']='广发理财';
+		}elseif($Detail ['accountType']==8){
+			$Detail['incomeTypeMsg']='保证金';
+		}elseif($Detail ['accountType']==9){
+			$Detail['incomeTypeMsg']='工行理财';
+		}elseif($Detail ['accountType']==10){
+			$Detail['incomeTypeMsg']='理财收入';
+		}
+		
+		$Detail['staffDetail']=$staff->getStaffBySid($Detail['inputStaff']);
+		
+		return $Detail;
+	}
+	
+	
+	
+}
+
+?>

+ 213 - 0
protected/model/accountBookStatistics.php

@@ -0,0 +1,213 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class accountBookStatistics extends DooModel {
+	
+	public $reusltPrice=0;
+	
+	public $aid;
+	public $asid;
+	public $inComePrice;
+	public $payPrice;
+	public $expensesType;
+	public $financingPrice;
+	public $date;
+	
+	public $accountType;
+	public $expenditureType;
+	
+	public $_table = 'CLD_accountBookStatistics';
+	public $_primarykey = 'asid';
+	public $_fields = array (
+			'aid',
+			'expensesType',
+			'asid',
+			'inComePrice',
+			'payPrice',
+			'financingPrice',
+			'date',
+			'accountType',
+			'expenditureType',
+			'accountMsg',
+			'expenditureMsg',
+			
+			
+	);
+	
+	/**
+	 * 添加相关开票操作日志
+	 *
+	 * @param array $item 要记录的相关发票操作数据
+	 * @return integer|0 返回操作ID
+	 */
+	public function setAccountBookStatistics($item = array()) {
+		$lid = 0;
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			$lid = $this->insert ();
+		}
+		return $lid;
+	}
+	
+	public function updateAccountBookStatistics($item = array(),$aid=0){
+		$lid = 0;
+		if (is_array ( $item ) && ! empty ( $item )&& ! empty ( $aid )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			$lid = $this->update (array (
+				'where' => "aid=" . $aid.' and ',
+				'asArray' => TRUE 
+		));
+		}
+		return $lid;
+	}
+	
+	/**
+	 * 
+	 * @param unknown $year
+	 * @param number $expensesType 汇总类型
+	 */
+	public function getStatisticsByCollect($year= '',$expensesType=1) {
+		
+		if (empty($year))
+			$year=date ( "Y" );
+		
+		$list=array();
+		if ($expensesType==1){
+			$list  = $this->find ( array (
+					'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,accountType,accountMsg,Year(date)',
+					'where' => "  Year(date) =" . $year . " and expensesType=" . $expensesType,
+					'groupby' => 'Month(date),accountType,accountMsg',
+					'asArray' => TRUE
+			) );
+		}elseif($expensesType==2){
+			$list  = $this->find ( array (
+					'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,expenditureType,expenditureMsg,Year(date)',
+					'where' => "  Year(date) =" . $year . " and expensesType=" . $expensesType,
+					'groupby' => 'Month(date),expenditureType,expenditureMsg',
+					'asArray' => TRUE
+			) );
+		}
+		return $list;
+	}
+	
+	/**
+	 *
+	 * @param unknown $year
+	 * @param number $expensesType 汇总类型
+	 */
+	public function getStatisticsByCollectDay($year= '',$expensesType=1,$month=1) {
+	
+		if (empty($year))
+			$year=date ( "Y" );
+	
+			$list=array();
+			if ($expensesType==1){
+				$list  = $this->find ( array (
+						'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,accountType,accountMsg,Year(date),Day(date) as day',
+						'where' => "  Year(date) =" . $year . " and expensesType=" . $expensesType.' and Month(date)='.$month,
+						'groupby' => 'Day(date),accountType,accountMsg',
+						'asArray' => TRUE
+				) );
+			}elseif($expensesType==2){
+				$list  = $this->find ( array (
+						'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,expenditureType,expenditureMsg,Year(date),Day(date) as day',
+						'where' => "  Year(date) =" . $year . " and expensesType=" . $expensesType.' and Month(date)='.$month,
+						'groupby' => 'Day(date),expenditureType,expenditureMsg',
+						'asArray' => TRUE
+				) );
+			}
+			return $list;
+	}
+	
+	
+	public function getStatisticsByMonth() {
+		$day = date ( "d" );
+		$month = date ( "m" );
+		$year = date ( "Y" );
+		
+		$list ['statisticsMonth'] = $this->find ( array (
+				'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month',
+				'where' => "  Year(date) =" . $year . " and Month(date)=" . $month.' and  (accountType!=8 and expenditureType!=5)',
+				'groupby' => 'Month(date)',
+				'asArray' => TRUE
+		) );
+		
+		if (empty ( $list ['statisticsMonth'] )) {
+			$list ['statisticsMonth'] [0] ['inComePrice'] = 0;
+			$list ['statisticsMonth'] [0] ['payPrice'] = 0;
+			$list ['statisticsMonth'] [0] ['month'] = $month;
+		}
+		
+		$list ['statisticsDay'] = $this->find ( array (
+				'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Year(date) as Year',
+				'where' => "  Year(date) =" . $year. " and Month(date)=" . $month.' and Day(date)='.$day.' and  (accountType!=8 and expenditureType!=5)',
+				'groupby' => 'Day(date)',
+				'asArray' => TRUE
+		) );
+		if (empty ( $list ['statisticsDay'] )) {
+			$list ['statisticsDay'] [0] ['inComePrice'] = 0;
+			$list ['statisticsDay'] [0] ['payPrice'] = 0;
+			$list ['statisticsDay'] [0] ['month'] = $month;
+		}
+		
+		//理财
+		$list ['financingPrice'] = $this->find ( array (
+				'select' => 'sum(financingPrice) as financingPrice',
+				'where' => " expensesType=3",
+				'groupby' => 'expensesType',
+				'asArray' => TRUE
+		) );
+		
+		//保证金
+		$list ['statisticsBond'] = $this->find ( array (
+				'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice',
+				'where' => " accountType=8 or expenditureType=5",
+				'groupby' => 'expenditureType,accountType',
+				'asArray' => TRUE
+		) );
+		
+		$bondPriceA=0;
+		if (isset($list ['statisticsBond'][0])){
+			$bondPriceA=$list ['statisticsBond'][0]['inComePrice'];
+		}	
+		$bondPriceB=0;
+		if (isset($list ['statisticsBond'][1])){
+			$bondPriceB=$list ['statisticsBond'][1]['payPrice'];
+		}	
+		$list ['statisticsBond']=$bondPriceA+$bondPriceB;
+			
+		
+		if (empty ( $list ['financingPrice'] )) {
+			$list ['financingPrice'] [0] ['financingPrice'] = $this->reusltPrice;
+		}else{
+			$list ['financingPrice'][0]['financingPrice']=$this->reusltPrice+$list ['financingPrice'][0]['financingPrice'];
+		}
+		
+		return $list;
+	}
+	
+	public function getStatisticsByBalance($year= '',$expensesType=1,$month=0) {
+		
+		$con='';$groupby='Month(date)';
+		if ($month!=0){
+			$con=' and Month(date)='.$month;
+			$groupby='Day(date)';
+		}
+		
+		$list  = $this->find ( array (
+				'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,expensesType,Year(date),Day(date) as day',
+				'where' => "  Year(date) =" . $year . " and expensesType=" . $expensesType.$con,
+				'groupby' => $groupby,
+				'asArray' => TRUE
+		) );
+		
+		return $list;
+		
+	}
+	
+}
+
+?>

+ 102 - 0
protected/model/invoiceInfoBase.php

@@ -0,0 +1,102 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class invoiceInfoBase extends DooModel {
+	public $iibID;
+	public $invoiceTitle;
+	public $TIN;
+	public $address;
+	public $phone;
+	public $bank;
+	public $bankAccount;
+	public $updateDate;
+	
+	public $_table = 'CLD_invoiceInfoBase';
+	public $_primarykey = 'iibID';
+	public $_fields = array (
+			'iibID',
+			'invoiceTitle',
+			'TIN',
+			'address',
+			'phone',
+			'bank',
+			'bankAccount',
+			'updateDate'
+	);
+	
+	/**
+	 * 
+	 */
+	function getIFBByTitle($fill=''){
+		if(empty($fill)){
+			return array();
+		}
+		return $this->find ( array ('where' => "invoiceTitle like '%".$fill."%'", 'asArray' => TRUE ) );
+	}
+	
+	function getIFBByTIN($fill=''){
+		if(empty($fill)){
+			return array();
+		}
+		return $this->find ( array ('where' => "TIN like '%".$fill."%'", 'asArray' => TRUE ) );
+	}
+	
+	/**
+	 * 根据纳税人识别码和抬头获得发票
+	 * @param string $TIN
+	 * @return unknown
+	 */
+	function getInvoiceInfoByTT($TIN='',$invoiceTitle=''){
+		if(empty($TIN)){
+			return array();
+		}
+		
+		$list = $this->find ( array ( 
+				'where' => "(TIN=  '" . $TIN."' and invoiceTitle='".$invoiceTitle."' ) or TIN=  '" . $TIN."' or invoiceTitle='".$invoiceTitle."'",
+				'asArray' => TRUE 
+		) );
+		
+		return $list;
+	}
+	
+	/**
+	 * 添加一个发票并进入审批状态
+	 * @param array $item 发票相关数据
+	 * @return number 返回发票ID
+	 */
+	public function addInvoiceInfoBase($item = array()) {
+		$lid = 0;
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			$lid = $this->insert ();
+		}
+		return $lid;
+	}
+	/**
+	 * 根据参数字段更新相应字段(主键ID必须传)
+	 * @param array $item 相关需要更新的字段信息
+	 * @return number 返回发票ID
+	 */
+	public function setInvoiceInfoBaseByCondition($item = array()) {
+		$lid = 0;
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			$lid = $this->update ();
+		}
+		return $lid;
+	}
+	
+	public function delInvoiceInfoBaseByIibStr($iibIDStr=''){
+		if (empty($iibIDStr)){
+			return '';
+		}
+		$sql='delete from '.$this->_table.' where iibID in('.$iibIDStr.')';
+		$query = Doo::db ()->query ( $sql );
+	}
+	
+}
+
+?>

+ 65 - 0
protected/model/invoiceTrainManage.php

@@ -0,0 +1,65 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+/**
+ * 发票相关管理相关信息及其操作业务逻辑
+ * @author CP.
+ * @version 1.0
+ * @namespace invoice
+ * @package invoiceModel
+ */
+class invoiceTrainManage extends DooModel {
+	/**
+	 *
+	 * @var integer $iid 管理组ID
+	 */
+	public $icid;
+	/**
+	 *
+	 * @var string $staff 管理组人员
+	 */
+	public $staff;
+	public $category;
+	public $cid;
+	
+	public $_table = 'CLD_invoiceTrainManage';
+	public $_primarykey = 'icid';
+	public $_fields = array (
+			'icid',
+			'staff',
+			'category',
+			'cid'
+	);
+	
+	/**
+	 * 获得查看人员
+	 * @param number $icid
+	 */
+	public function getInvoiceCMByIcid($icid=0){
+		$lsit=array();
+		if (! empty ( $icid ))
+			$lsit = $this->getOne ( array (
+					'where' => 'icid='.$icid,
+					'asArray' => TRUE
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 是否有该用户在权限列表中
+	 * @param number $sid
+	 */
+	public function getInvoiceCMByStaff($sid = 0) {
+		$lsit=array();
+		if (! empty ( $sid ))
+			$lsit = $this->find ( array (
+					'select'=>'cid',
+					'where' => 'staff like "%[\"' . $sid . '\",%"',
+					'asArray' => TRUE
+			) );
+	
+			return $lsit;
+	}
+}
+
+// ?>

+ 56 - 0
protected/model/lecturer.php

@@ -0,0 +1,56 @@
+<?php
+
+Doo::loadCore('db/DooModel');
+
+class lecturer extends DooModel {
+
+    public $lid;
+    public $sid;
+    public $staff;
+    public $mold;
+    public $cid;
+    public $category;
+    public $ltype;
+    
+    public $_table = 'CLD_lecturer';
+    public $_primarykey = 'lid';
+    
+    public $_fields = array('lid', 'sid', 'staff','mold','cid','category','ltype');
+
+    
+    /**
+     * 是否有查看日常收支的权限
+     */
+    function getLecturerAll(){
+    	Doo::loadClass ( 'XDeode' );
+    	$XDeode = new XDeode ( 5 );
+    	$list = $this->find ( array (
+    			'asArray' => true
+    	) );
+    	foreach ($list as $key=>$value){
+    		$list[$key]['lidKey']=$XDeode->encode ( $value ['lid'] );
+    	}
+    	
+    	
+    	return $list;
+    }
+    /**
+	 * 根据ID删除数据
+	 * @param number $itid
+	 */
+	function delLecturerByLid($lid = 0) {
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		if (!is_numeric($lid))
+			$lid = $XDeode->decode ( $lid );
+		
+		if (! empty ( $lid )&&is_numeric($lid))
+			$this->delete ( array (
+					'where' => 'lid=' . $lid ,
+					'limit'=>1
+			) );
+	}
+}
+
+?>

+ 20 - 0
protected/model/payments.php

@@ -0,0 +1,20 @@
+<?php
+
+Doo::loadCore('db/DooModel');
+
+class payments extends DooModel {
+
+    public $pid;
+    public $description;
+    public $staff;
+    public $mold;
+    
+    public $_table = 'CLD_payments';
+    public $_primarykey = 'eid';
+    
+    public $_fields = array('eid', 'description', 'staff','mold');
+
+    
+}
+
+?>

+ 77 - 0
protected/model/position.php

@@ -0,0 +1,77 @@
+<?php
+
+Doo::loadCore('db/DooModel');
+
+class position extends DooModel {
+
+    public $pid;
+    
+    public $positionName;
+    public $positionDescribe;
+    public $baseWage;
+    public $postWage;
+    public $achievementBonus;
+    
+    public $_table = 'CLD_position';
+    public $_primarykey = 'pid';
+    
+    public $_fields = array('pid', 'positionName', 'positionDescribe', 'baseWage', 'postWage', 'achievementBonus');
+
+    /**
+     * 获得所有岗位
+     */
+    function getPositionByAll(){
+    	Doo::loadClass ( 'XDeode' );
+    	$XDeode = new XDeode ( 5 );
+    	Doo::loadModel ( 'staff' );
+    	$staff = new staff ();
+    	
+    	$list=$this->find ( array (
+    			'asArray' => TRUE
+    	) );
+    	
+    	foreach ($list as $key=>$value){
+    		$list [$key] ['pidKey'] = $XDeode->encode ( $value ['pid'] );
+    		$list [$key] ['staffCount']=$staff->count(array ('where' => 'positionId = "' . $value ['pid'] . '"'));
+    		
+    	}
+    	
+    	return $list;
+    }
+    
+    /**
+     * 根据ID获取相关信息
+     * @param number $sid 用户ID
+     */
+    public function getPositionByPid($pid = 0) {
+    	Doo::loadClass ( 'XDeode' );
+    	$XDeode = new XDeode ( 5 );
+    	if (!is_numeric($pid)){
+    		$pid = $XDeode->decode ( $pid );
+    	}
+    	
+    	$detail = array ();
+    	if (! empty ( $pid )){
+    		
+    		Doo::loadModel ( 'staff' );
+    		$staff = new staff ();
+    		
+    		$detail = $this->getOne ( array (
+    				'where' => "pid= '" . $pid . "'",
+    				'asArray' => TRUE
+    		) );
+    		if (!empty($detail)){
+    			$detail ['pidKey'] = $XDeode->encode ( $detail ['pid'] );
+    			$detail ['staffCount']=$staff->count(array ('where' => 'positionId = "' . $detail ['pid'] . '"'));
+    		}
+    			
+    	}
+    	
+    	return $detail;
+    }
+    
+    //public function getPositionByPid
+    
+}
+
+?>

+ 92 - 0
protected/model/promoteManage.php

@@ -0,0 +1,92 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+/**
+ *
+ * @author CP.
+ * @version 1.0
+ * @namespace invoice
+ * @package invoiceModel
+ */
+class promoteManage extends DooModel {
+	/**
+	 *
+	 * @var integer $iid 管理组ID
+	 */
+	public $icid;
+	/**
+	 *
+	 * @var string $staff 管理组人员
+	 */
+	public $staff;
+	public $category;
+	public $cid;
+	public $CC;
+	public $_table = 'CLD_promoteManage';
+	public $_primarykey = 'icid';
+	public $_fields = array (
+			'icid',
+			'staff',
+			'category',
+			'CC',
+			'cid' 
+	);
+	
+	/**
+	 * 获得查看人员
+	 * @param number $icid
+	 */
+	public function getInvoiceCMByIcid($icid = 0) {
+		$lsit = array ();
+		if (! empty ( $icid ))
+			$lsit = $this->getOne ( array (
+					'where' => 'icid=' . $icid,
+					'asArray' => TRUE 
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 是否有该用户在权限列表中
+	 * @param number $sid
+	 */
+	public function getInvoiceCMByStaff($sid = 0) {
+		$lsit = array ();
+		
+		if (!is_numeric($sid)){
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$sid = $XDeode->decode ( $sid );
+		}
+		
+		if (! empty ( $sid ))
+			$lsit = $this->find ( array (
+					'select' => 'cid',
+					'where' => 'staff like "%[\"' . $sid . '\",%"',
+					'asArray' => TRUE 
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 根据cid获得审批组
+	 * @param string $cidMode
+	 */
+	public function getStaffManageByCid($cidMode = '') {
+		$detail = array ();
+		if (! empty ( $cidMode ))
+			$detail = $this->getOne ( array (
+					'where' => 'cid ="' . $cidMode . '" ',
+					'asArray' => true 
+			) );
+		if (empty ( $detail ['staff'] ))
+			$detail ['staffList'] = array ();
+		else
+			$detail ['staffList'] = json_decode ( $detail ['staff'], true );
+		return $detail;
+	}
+}
+
+// ?>

+ 59 - 0
protected/model/receiptTrainManage.php

@@ -0,0 +1,59 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+
+class receiptTrainManage extends DooModel {
+	/**
+	 *
+	 * @var integer $iid 管理组ID
+	 */
+	public $icid;
+	/**
+	 *
+	 * @var string $staff 管理组人员
+	 */
+	public $staff;
+	public $category;
+	public $cid;
+	
+	public $_table = 'CLD_receiptTrainManage';
+	public $_primarykey = 'icid';
+	public $_fields = array (
+			'icid',
+			'staff',
+			'category',
+			'cid'
+	);
+	
+	/**
+	 * 获得查看人员
+	 * @param number $icid
+	 */
+	public function getInvoiceCMByIcid($icid=0){
+		$lsit=array();
+		if (! empty ( $icid ))
+			$lsit = $this->getOne ( array (
+					'where' => 'icid='.$icid,
+					'asArray' => TRUE
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 是否有该用户在权限列表中
+	 * @param number $sid
+	 */
+	public function getInvoiceCMByStaff($sid = 0) {
+		$lsit=array();
+		if (! empty ( $sid ))
+			$lsit = $this->find ( array (
+					'select'=>'cid',
+					'where' => 'staff like "%[\"' . $sid . '\",%"',
+					'asArray' => TRUE
+			) );
+	
+			return $lsit;
+	}
+}
+
+// ?>

+ 319 - 0
protected/model/receiptTraining.php

@@ -0,0 +1,319 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+/**
+ * 费用培训班相关信息及其操作业务逻辑
+ * @author CP.
+ * @version 1.0
+ * @namespace invoice
+ * @package invoiceModel
+ */
+class receiptTraining extends DooModel {
+	public $rtid;
+	
+	public $trainName;
+	public $cid;
+	public $categoryName;
+	public $trainStartDate;
+	public $trainEndDate;
+	public $participants;
+	public $trainAddress;
+	public $trainRemarks;
+	public $creator;
+	public $creatorDate;
+	public $identifyingTotal;
+
+	public $_table = 'CLD_receiptTraining';
+	public $_primarykey = 'rtid';
+	public $_fields = array (
+			'rtid',
+			
+			'trainName',
+			'cid',
+			'categoryName',
+			'trainStartDate',
+			'trainEndDate',
+			'participants',
+			'trainAddress',
+			'trainRemarks',
+			'creator',
+			'creatorDate' ,
+            'identifyingTotal'
+	);
+	
+	/**
+	 * 添加一个培训班
+	 * @param array $item 培训班相关数据
+	 * @return number 返回培训班ID
+	 */
+	public function addReceiptTraining($item = array()) {
+		$itid = 0;
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			$itid = $this->insert ();
+		}
+		return $itid;
+	}
+	function getInvoiceTrainStatistics($itid = 0) {
+		$itidCondition = ' and trainId=NULL ';
+		if (! empty ( $itid ))
+			$itidCondition = ' and trainId in (' . $itid . ') ';
+		
+		$sql = 'select sum(invoicePrice) as invoicePrice ,trainId
+				from CLD_invoice
+				where status=2 and printStatus=1 and (untreadStatus =0 or untreadStatus=3) ' . $itidCondition . '
+				GROUP BY status';
+		$query = Doo::db ()->query ( $sql );
+		$result = $query->fetchAll ();
+		
+		if (! empty ( $result ))
+			$detail = array (
+					'invoicePrice' => $result [0] ['invoicePrice'] 
+			);
+		else
+			$detail = array (
+					'invoicePrice' => 0 
+			);
+			// print_r($result);
+		$itidCondition = ' and a.trainId=NULL ';
+		if (! empty ( $itid ))
+			$itidCondition = ' and a.trainId in (' . $itid . ') ';
+		$sql = 'select sum(b.receivablesPrice) as receivablesPrice ,a.trainId,count(*) as count
+				from CLD_invoice as a left join CLD_invoiceReceivables as b on find_in_set(b.irid,a.irid)
+				where  a.status=2 and a.printStatus=1 and (a.untreadStatus =0 or a.untreadStatus=3) and a.irid!="" ' . $itidCondition . '
+				GROUP BY a.status';
+		$query = Doo::db ()->query ( $sql );
+		$result = $query->fetchAll ();
+		
+		if (! empty ( $result )) {
+			$detail += array (
+					'receivablesPrice' => $result [0] ['receivablesPrice'] 
+			);
+			$detail += array (
+					'rPrice' => $detail ['invoicePrice'] - $result [0] ['receivablesPrice'] 
+			);
+		} else {
+			$detail += array (
+					'receivablesPrice' => 0 
+			);
+			$detail += array (
+					'rPrice' => $detail ['invoicePrice'] 
+			);
+		}
+		return $detail;
+	}
+	function getInvoiceTrainingByTodo($select = "", $cid = 0, $sid = 0) {
+		Doo::loadModel ( 'staff' );
+		$staff = new staff ();
+		Doo::loadModel ( 'L_category' );
+		$lCategory = new L_category ();
+		
+		$condition = array (
+				'where' => "(status= 0 or status=1) and ( cid=" . $cid . " or creator=" . $sid . " )",
+				//'limit' => 8,
+				'asArray' => TRUE 
+		);
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
+		
+		$list = $this->find ( $condition );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		$itid = array ();
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['trainingKey'] = $XDeode->encode ( $value ['itid'] );
+			$detail = $staff->getStaffBySid ( $value ['creator'] );
+			$list [$key] ['staff'] = $detail;
+			$detail = $lCategory->getCategoryById ( $value ['cid'] );
+			$list [$key] ['category'] = $detail;
+			array_push ( $itid, $value ['itid'] );
+		}
+		
+		// 获得开票金额合计 入账金额合计 入账完成度
+		Doo::loadModel ( 'invoice' );
+		$invoice = new invoice ();
+		
+		$invoiceList = $invoiceRecelvablesList = array ();
+		if (! empty ( $itid )) {
+			$itidSql = implode ( ',', $itid );
+			$invoiceList = $invoice->sumOfinvoiceTrain ( $itidSql );
+			$invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidSql );
+		}
+		// print_r($invoiceRecelvablesList);
+		
+		foreach ( $list as $key => $value ) {
+			
+			$countInvoice=$invoice->getInvoiceByTrainingCount($value['itid']);
+			$value ['invoiceTotal']=$countInvoice;
+			$list [$key] ['invoiceTotal'] =$countInvoice;
+			
+			foreach ( $invoiceList as $k => $v ) {
+				if ($value ['itid'] == $v ['trainId']) {
+					$list [$key] ['invoiceTotalAmount'] = $v ['invoicePrice'];
+					break;
+				}
+			}
+			foreach ( $invoiceRecelvablesList as $i => $o ) {
+				if ($value ['itid'] == $o ['trainId']) {
+					$list [$key] ['invoiceArriveAmount'] = $o ['receivablesPrice'];
+					$list [$key] ['arriveSchedule'] = "0";
+					if ($value ['invoiceTotal'] != 0)
+						$list [$key] ['arriveSchedule'] = round ( $o ['count'] / $value ['invoiceTotal'] * 100, 2 );
+					
+					break;
+				}
+			}
+		}
+		
+		return $list;
+	}
+	
+	/**
+	 * 根据参数字段更新相应字段(主键ID必须传)
+	 * @param array $item 相关需要更新的字段信息
+	 * @return number 返回发票ID
+	 */
+	public function setReceiptTrainByCondition($item = array(), $rtid = "") {
+		$lid = 0;
+		
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			
+			if (! empty ( $isid )) {
+				$condition = array (
+						'where' => "rtid in (" . $rtid . ")",
+						'asArray' => TRUE 
+				);
+				$this->update ( $condition );
+			} else
+				$lid = $this->update ();
+		}
+		return $lid;
+	}
+	
+	/**
+	 * 根据状态获取培训班
+	 * @param number $status
+	 */
+	function getInvoiceTrainingByStatus($status = 0, $select = "", $cid = 0, $sid = 0) {
+		Doo::loadModel ( 'staff' );
+		$staff = new staff ();
+		Doo::loadModel ( 'L_category' );
+		$lCategory = new L_category ();
+		
+		$condition = array (
+				'where' => "status= '" . $status . "' and  (cid=" . $cid . " or creator=" . $sid . " )",
+				'limit' => 8,
+				'asArray' => TRUE 
+		);
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
+		
+		$list = $this->find ( $condition );
+		
+		foreach ( $list as $key => $value ) {
+			$detail = $staff->getStaffBySid ( $value ['creator'] );
+			$list [$key] ['staff'] = $detail;
+			$detail = $lCategory->getCategoryById ( $value ['cid'] );
+			$list [$key] ['category'] = $detail;
+		}
+		
+		return $list;
+	}
+	
+	/**
+	 * 根据ID获得培训班
+	 * @param number $itid
+	 */
+	function getReceiptTrainingByRtid($rtid = 0) {
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		if (!is_numeric($rtid))
+			$rtid = $XDeode->decode ( $rtid );
+		
+		$detail = array ();
+		if (! empty ( $rtid ) && is_numeric ( $rtid )) {
+			$detail = $this->getOne ( array (
+					'where' => " rtid=" . $rtid,
+					'asArray' => TRUE 
+			) );
+		}
+		$detail ['rtidKey'] = '';
+		if (! empty ( $detail ))
+			$detail ['rtidKey'] = $XDeode->encode ( $detail ['rtid'] );
+		
+		return $detail;
+	}
+	
+	/**
+	 * 根据ID删除数据
+	 * @param number $itid
+	 */
+	function delInvoiceTrainingByItid($itid = 0) {
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		$itid = $XDeode->decode ( $itid );
+		if (! empty ( $itid ) && is_numeric ( $itid ))
+			$this->delete ( array (
+					'where' => 'itid=' . $itid 
+			) );
+			// 删除培训班下的发票
+		Doo::loadModel ( 'invoiceStore' );
+		$invoiceStore = new invoiceStore ();
+		
+		$invoiceStore->delete ( array (
+				'where' => 'trainId=' . $itid 
+		) );
+	}
+	
+	/**
+	 * 获得某办事处未完成的培训班
+	 * @return string
+	 */
+	function getInvoiceTrainingByUnfinished($cid=0){
+		$condition = array (
+				'where' => "(status= 0 or status=1) and cid=".$cid,
+				'asArray' => true 
+		);
+		
+		$list = $this->find ( $condition );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ( $list as $key => $value ) {
+			$list[$key] ['itidKey'] = $XDeode->encode ( $value ['itid'] );
+		}
+		
+		return $list;
+	}
+	
+	/**
+	 * 获得所有培训班
+	 */
+	function getInvoiceTrainingBySubmitStatus() {
+		$condition = array (
+				'where' => "submitStatus=1",
+				'asArray' => TRUE 
+		);
+		
+		$list = $this->find ( $condition );
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		foreach ( $list as $key => $value ) {
+			$list[$key] ['itidKey'] = $XDeode->encode ( $value ['itid'] );
+		}
+		
+		return $list;
+	}
+}
+
+?>

+ 98 - 0
protected/model/reentryManage.php

@@ -0,0 +1,98 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+/**
+ *
+ * @author CP.
+ * @version 1.0
+ * @namespace invoice
+ * @package invoiceModel
+ */
+class reentryManage extends DooModel {
+	/**
+	 *
+	 * @var integer $iid 管理组ID
+	 */
+	public $icid;
+	/**
+	 *
+	 * @var string $staff 管理组人员
+	 */
+	public $staff;
+	public $category;
+	public $cid;
+	public $CC;
+	public $_table = 'CLD_reentryManage';
+	public $_primarykey = 'icid';
+	public $_fields = array (
+			'icid',
+			'staff',
+			'category',
+			'CC',
+			'cid' 
+	);
+	
+	/**
+	 * 获得查看人员
+	 * @param number $icid
+	 */
+	public function getInvoiceCMByIcid($icid = 0) {
+		$lsit = array ();
+		if (! empty ( $icid ))
+			$lsit = $this->getOne ( array (
+					'where' => 'icid=' . $icid,
+					'asArray' => TRUE 
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 是否有该用户在权限列表中
+	 * @param number $sid
+	 */
+	public function getInvoiceCMByStaff($sid = 0) {
+		$lsit = array ();
+		
+		if (! is_numeric ( $sid )) {
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$sid = $XDeode->decode ( $sid );
+		}
+		
+		if (! empty ( $sid ))
+			$lsit = $this->find ( array (
+					'select' => 'cid',
+					'where' => 'staff like "%[\"' . $sid . '\",%"',
+					'asArray' => TRUE 
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 根据cid获得审批组
+	 * @param string $cidMode
+	 */
+	public function getStaffManageByCid($cidMode = '') {
+		$detail = array ();
+		if (! empty ( $cidMode ))
+			$detail = $this->getOne ( array (
+					'where' => 'cid ="' . $cidMode . '" ',
+					'asArray' => true 
+			) );
+		if (empty ( $detail ['staff'] ))
+			$detail ['staffList'] = array ();
+		else
+			$detail ['staffList'] = json_decode ( $detail ['staff'], true );
+		
+		if (empty ( $detail ['CC'] ))
+			$detail ['staffList'] = array ();
+		else
+			$detail ['staffList'] = json_decode ( $detail ['staff'], true );
+		
+		return $detail;
+	}
+}
+
+// ?>

+ 92 - 0
protected/model/staffRegularManage.php

@@ -0,0 +1,92 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+/**
+ *
+ * @author CP.
+ * @version 1.0
+ * @namespace invoice
+ * @package invoiceModel
+ */
+class staffRegularManage extends DooModel {
+	/**
+	 *
+	 * @var integer $iid 管理组ID
+	 */
+	public $icid;
+	/**
+	 *
+	 * @var string $staff 管理组人员
+	 */
+	public $staff;
+	public $category;
+	public $cid;
+	public $CC;
+	public $_table = 'CLD_staffRegularManage';
+	public $_primarykey = 'icid';
+	public $_fields = array (
+			'icid',
+			'staff',
+			'category',
+			'CC',
+			'cid' 
+	);
+	
+	/**
+	 * 获得查看人员
+	 * @param number $icid
+	 */
+	public function getInvoiceCMByIcid($icid = 0) {
+		$lsit = array ();
+		if (! empty ( $icid ))
+			$lsit = $this->getOne ( array (
+					'where' => 'icid=' . $icid,
+					'asArray' => TRUE 
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 是否有该用户在权限列表中
+	 * @param number $sid
+	 */
+	public function getInvoiceCMByStaff($sid = 0) {
+		$lsit = array ();
+		
+		if (!is_numeric($sid)){
+			Doo::loadClass ( 'XDeode' );
+			$XDeode = new XDeode ( 5 );
+			
+			$sid = $XDeode->decode ( $sid );
+		}
+		
+		if (! empty ( $sid ))
+			$lsit = $this->find ( array (
+					'select' => 'cid',
+					'where' => 'staff like "%[\"' . $sid . '\",%"',
+					'asArray' => TRUE 
+			) );
+		
+		return $lsit;
+	}
+	
+	/**
+	 * 根据cid获得审批组
+	 * @param string $cidMode
+	 */
+	public function getStaffManageByCid($cidMode = '') {
+		$detail = array ();
+		if (! empty ( $cidMode ))
+			$detail = $this->getOne ( array (
+					'where' => 'cid ="' . $cidMode . '" ',
+					'asArray' => true 
+			) );
+		if (empty ( $detail ['staff'] ))
+			$detail ['staffList'] = array ();
+		else
+			$detail ['staffList'] = json_decode ( $detail ['staff'], true );
+		return $detail;
+	}
+}
+
+// ?>

+ 348 - 0
protected/model/wasteBook.php

@@ -0,0 +1,348 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class wasteBook extends DooModel {
+	public $wid;
+	public $expensesType;
+	public $accountType;
+	public $accountMsg;
+	public $accountPrice;
+	public $accountBank;
+	public $category;
+	public $cid;
+	public $name;
+	public $sid;
+	public $dailyIncomeType;
+	public $dailyExpenditureType;
+	public $inputDate;
+	public $dataID;
+	
+	public $accountPriceShow;
+	
+	
+	public $_table = 'CLD_wasteBook';
+	public $_primarykey = 'wid';
+	public $_fields = array (
+			'wid',
+			'expensesType',
+			'accountType',
+			'accountMsg',
+			
+			'accountPrice',
+			'accountBank',
+			'category',
+			'name',
+			'cid',
+			'sid',
+			'dailyIncomeType',
+			'dailyExpenditureType',
+			'inputDate' ,
+			'dataID',
+			
+			'accountPriceShow',
+	);
+	
+	//
+	function getWasteBookByStatisticsYear($year=''){
+		if (empty($year))
+			$year=date ( "Y" );
+		
+			$list  = $this->find ( array (
+					'select' => 'sum(accountPrice) as accountPrice ',
+					'where' => "  Year(inputDate) <" . $year ,
+					//'groupby' => 'Month(inputDate)',
+					'asArray' => TRUE
+			) );
+		
+			return $list;
+	}
+	function getWasteBookByStatisticsDay($year='',$month=''){
+		$day=cal_days_in_month(CAL_GREGORIAN, date('m'), date('Y'));
+		if (empty($year)){
+			$year=date ( "Y" );
+			$month=date("m");
+		}
+	
+			$list  = $this->find ( array (
+					'select' => 'sum(accountPrice) as accountPrice ',
+					'where' => "  inputDate <'" . $year."-".$month."-1'" ,
+					//'groupby' => 'Month(inputDate)',
+					'asArray' => TRUE
+			) );
+	
+			return $list;
+	}
+	
+	function getWasteBookByStatistics($expensesType=1,$year=''){
+	
+		if (empty($year))
+			$year=date ( "Y" );
+		
+		$list  = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow ,Month(inputDate) as month,expensesType,Year(inputDate)',
+				'where' => "  Year(inputDate) =" . $year . " and expensesType=" . $expensesType,
+				'groupby' => 'Month(inputDate),expensesType',
+				'asArray' => TRUE
+		) );
+		
+		//print_r($list);
+		return $list;
+	}
+	
+	public function getStatisticsByDay($expensesType=1,$year= '',$month='') {
+	
+		
+	
+		$list  = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") ,Month(inputDate) as month,expensesType,Year(inputDate),Day(inputDate) as day',
+				'where' => " date_format(inputDate,'%Y-%m')=date_format('".$year."-".$month."-1','%Y-%m')  and expensesType=" . $expensesType,
+				'groupby' => 'Day(inputDate),expensesType',
+				'asArray' => TRUE
+		) );
+		
+// 		$list  = $this->find ( array (
+// 				'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,expensesType,Year(date),Day(date) as day',
+// 				'where' => "  Year(date) =" . $year . " and expensesType=" . $expensesType.$con,
+// 				'groupby' => $groupby,
+// 				'asArray' => TRUE
+// 		) );
+	
+		return $list;
+	
+	}
+	
+	function getAccountBookByExpensesType($limit=4,$expensesType=1,$con=''){
+		
+		$where= array (
+				'where' => "expensesType=".$expensesType.$con,
+				'desc' => 'wid',
+				'asArray' => TRUE
+		);
+		if($limit!=0){
+			$where += array (
+					'limit' => $limit
+			);
+		}
+		
+		$list = $this->find ( $where );
+		
+		Doo::loadModel ( "accountBook" );
+		$accountBook = new accountBook ();
+		Doo::loadModel ( 'receipt' );
+		$receipt = new receipt ();
+		Doo::loadModel ( 'invoiceReceivables' );
+		$invoiceReceivables = new invoiceReceivables ();
+		Doo::loadModel ( 'invoice' );
+		$invoice = new invoice ();
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ($list as $key=>$value){
+			$list[$key]['widKey']=$XDeode->encode ( $value ['wid'] );
+			$list[$key]['accountTypeKey']=$XDeode->encode ( $value ['accountType'] );
+			
+			$list[$key]['accountBankMsg']='';
+			if($value['accountBank']=='CGBDeposit'){
+				$list[$key]['accountBankMsg']='纵横广发';
+			}elseif($value['accountBank']=='ICBCDeposit'){
+				$list[$key]['accountBankMsg']='纵横工行';
+			}elseif($value['accountBank']=='HUADeposit'){
+				$list[$key]['accountBankMsg']='华润银行';
+			}elseif($value['accountBank']=='PersonalDeposit'){
+				$list[$key]['accountBankMsg']='个人广发';
+			}
+			
+			
+			$list[$key]['data']=array();
+			if ($value['accountType']==5||$value['accountType']==6||$value['accountType']==9||$value['accountType']==10){
+				
+				$list[$key]['data']=$accountBook->getAccountBookByAid($value['dataID']);
+			}elseif($value['accountType']==7||$value['accountType']==11){
+				$list[$key]['data']=$invoiceReceivables->getInvoiceReceivablesByIrid($value['dataID']);
+			}elseif($value['accountType']==8){
+				$list[$key]['data']= $invoice->getInvoiceByIid ( $value['dataID'] );
+ 			
+			}elseif($value['accountType']==1||$value['accountType']==2||$value['accountType']==3||$value['accountType']==4||$value['accountType']==12){
+				$list[$key]['data']=$receipt->getReceiptByRid($value['dataID']);
+			}
+			
+		}
+		//print_r($list);
+		return $list;
+	}
+	
+	/**
+	 */
+	function getAccountBookByLimit($limit = 3) {
+		$sql = 'select *
+				from ' . $this->_table . '
+						 ORDER BY  aid desc limit ' . $limit;
+		$query = Doo::db ()->query ( $sql );
+		$list = $query->fetchAll ();
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ( $list as $key => $value ) {
+			$list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	/**
+	 *
+	 * @param number $limit
+	 * @param string $con
+	 * @param string $desc
+	 * @return boolean
+	 */
+	function getAccountBookBySql($limit = 0, $con = "", $desc = 'desc') {
+		
+		// $listCount = $this->count ( array (
+		// 'where' => $con,
+		// 'asArray' => TRUE
+		// ) );
+		$list = $this->find ( array (
+				'where' => '1 ' . $con,
+				'limit' => $limit,
+				$desc => 'aid',
+				'asArray' => TRUE 
+		) ); // echo $con;
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		foreach ( $list as $key => $value ) {
+			// $list [$key] ['count'] = $listCount;
+			$list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
+		}
+		
+		return $list;
+	}
+	
+	/**
+	 * 
+	 * @param number $expensesType
+	 * @param number $accountType
+	 * @param number $dataID
+	 * @param string $select
+	 * @return unknown|string[]
+	 */
+	function getAccountBookByAid($expensesType=1,$accountType=1,$dataID = 0, $select = "") {
+		
+		Doo::loadClass ( 'XDeode' );
+		$XDeode = new XDeode ( 5 );
+		
+		if (! is_numeric ( $dataID ))
+			$rid=$XDeode->decode( $dataID );
+			
+		
+		$condition = array (
+				'where' => "dataID=" . $dataID.' and expensesType='.$expensesType.' and accountType='.$accountType,
+				'asArray' => TRUE 
+		);
+		if (! empty ( $select ))
+			$condition += array (
+					'select' => $select 
+			);
+		
+		$Detail = array ();
+		if (is_numeric ( $dataID ) && ! empty ( $dataID ))
+			$Detail = $this->getOne ( $condition );
+		
+		if (empty ( $Detail ))
+			return $Detail;
+		
+		$Detail ['widKey'] = $XDeode->encode ( $Detail ['wid'] );
+		
+		
+		return $Detail;
+	}
+	
+	/**
+	 * 
+	 */
+	function getAccountBookByWid(){
+		
+	}
+	
+	/**
+	 * 统计存款部分
+	 */
+	function getWasteBookStatisticsByIncome(){
+		//and dailyIncomeType!=7
+		$list['incomeStatistics'] = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyIncomeType',
+				'where' => " expensesType=1  and (accountType =6 or accountType =7 or accountType=8  or accountType =1 or accountType =2 or accountType=3 or accountType=4 or accountType=12 ) ",
+				'groupby' => 'accountBank',
+				'asArray' => TRUE
+		) );
+		
+		$list['expenditureStatistics'] = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType',
+				'where' => " expensesType=2   and (accountType =1 or accountType =2 or accountType=3 or accountType=4 or accountType=5 or accountType=11  or accountType=12) ",
+				'groupby' => 'accountBank',
+				'asArray' => TRUE
+		) );
+		//活期
+		$list['currentStatistics'] = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType',
+				'where' => " accountType =10 ",
+				'groupby' => 'accountBank',
+				'asArray' => TRUE
+		) );
+		//固期
+		$list['fixedStatistics'] = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType',
+				'where' => " accountType =9 ",
+				'groupby' => 'accountBank',
+				'asArray' => TRUE
+		) );
+		//月份总计
+		$list['incomeReport'] = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") as inputDate,expensesType',
+				'where' => " YEAR(inputDate)= YEAR( NOW( ) ) and expensesType=1",
+				'groupby' => 'date_format(inputDate,"%Y-%m"),expensesType',
+				'asArray' => TRUE
+		) );
+		$list['expenditureReport'] = $this->find ( array (
+				'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") as inputDate,expensesType',
+				'where' => " YEAR(inputDate)= YEAR( NOW( ) ) and expensesType=2",
+				'groupby' => 'date_format(inputDate,"%Y-%m"),expensesType',
+				'asArray' => TRUE
+		) );
+// 		//合计
+// 		$list['total'] = $this->find ( array (
+// 				'select' => 'sum(accountPrice) as accountPrice',
+// 				//'where' => " accountType =9 ",
+// 				//'groupby' => 'accountBank',
+// 				'asArray' => TRUE
+// 		) );
+ 		return $list;
+	}
+	
+	/**
+	 * 插入数据
+	 * @param array $item
+	 * @return number
+	 */
+	function setAccountBookStatistics($item=array()){
+		$lid = 0;
+		if (is_array ( $item ) && ! empty ( $item )) {
+			foreach ( $item as $key => $value ) {
+				$this->$key = $value;
+			}
+			$lid = $this->insert ();
+		}
+		return $lid;
+	}
+	
+	function getWateBookByAD($accountType='',$dataID=''){
+		$detail=$this->getOne(array (
+				'where' => "accountType=".$accountType.' and dataID='.$dataID,
+				'asArray' => TRUE
+		));
+		
+		return $detail;
+	}
+}
+
+?>