123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?php
- Doo::loadCore ( 'db/DooModel' );
- class accountItem extends DooModel {
- public $aid;
- public $category;
- public $name;
- public $_table = 'CLD_accountItem';
- public $_primarykey = 'aid';
- public $_fields = array (
- 'aid',
- 'category',
- 'name'
- );
-
- /**
- *
- */
- function getAccountItem(){
- $sql = 'select category
- from ' . $this->_table . '
- GROUP BY category ORDER BY aid ASC ';
- $query = Doo::db ()->query ( $sql );
- $itemCategory = $query->fetchAll ();
-
- $list = $this->find ( array (
- 'asArray' => TRUE
- ) );
-
- $acctionItem=array();
- foreach ($itemCategory as $key=>$value){
- $acctionItem[$value['category']]=array();
- foreach ($list as $k=>$v){
- if ($value['category']==$v['category']){
- array_push($acctionItem[$value['category']], $v);
- }
- }
- }
-
- return $acctionItem;
- }
-
- /**
- * 根据项目获得ITEM
- */
- function getAccountBookByCategory($category=''){
- $list = $this->find ( array (
- 'where' => ' category like "%' . $category.'%"',
- 'asArray' => TRUE
- ) );
- return $list;
- }
-
- /**
- * 获得培训班金额详情
- * @param array $RItemList 支出项目
- * @param array $RILecturerList 讲师项目
- * @return number[]
- */
- function getTrainingDetail($RItemList=array(),$RILecturerList=array(),$invoiceArriveAmount=0){
- $aiList = $this->find ( array (
- 'where' => ' category like "%培训班费用%"',
- 'asArray' => TRUE
- ) );
-
- $total=0;$categoryActualExpenditure='';
- foreach ($aiList as $k=>$v){
- $aiList[$k]['price']=$aiList[$k]['companyPrice']=$aiList[$k]['categoryPrice']=0;
- $aiList[$k]['insidePrice']=$aiList[$k]['outsideNoTaxPrice']=$aiList[$k]['outsideTaxPrice']=0;
- foreach ($RItemList as $key=>$value){
- if($v['name']=='讲课费'){
- }elseif($v['name']=='办公费'&&$value['item']=='办公费'){
- if($value['payType']==0){
- $aiList[$k]['categoryPrice']+=$value['price'];
- $total+=$value['price'];
- }elseif($value['payType']==1){
- $aiList[$k]['companyPrice']+=$value['price'];
- $categoryActualExpenditure+=$value['price'];
- $total+=$value['price'];
- }
- $aiList[$k]['price']+=$value['price'];
- unset($RItemList[$key]);
- }elseif($v['name']=='邮寄费'&&$value['item']=='邮寄费'){
- if($value['payType']==0){
- $aiList[$k]['categoryPrice']+=$value['price'];
- $total+=$value['price'];
- }elseif($value['payType']==1){
- $aiList[$k]['companyPrice']+=$value['price'];
- $categoryActualExpenditure+=$value['price'];
- $total+=$value['price'];
- }
- $aiList[$k]['price']+=$value['price'];
- unset($RItemList[$key]);
- }else{
- if ($v['name']==$value['item']){
- $aiList[$k]['price']+=$value['price'];
- $total+=$value['price'];
- unset($RItemList[$key]);
- }
- }
- if($value['item']=='研究中心经费'&&$v['name']=='研究中心经费'){
- $categoryActualExpenditure+=$value['price'];
- }
- if($value['item']=='税款'&&$v['name']=='税款'){
- $categoryActualExpenditure+=$value['price'];
- }
- }
- //讲师项
- foreach ($RILecturerList as $lecKey=>$lecValue){
- if($v['name']=='讲课费'){
- if($lecValue['ltype']=='INSIDE'){
- $bValue=$lecValue['price']*$lecValue['schoolDay'];
- $aiList[$k]['insidePrice']+=$bValue;
- $total+=$bValue;
- $categoryActualExpenditure+=$bValue;
- $aiList[$k]['price']+=$bValue;
- unset($RILecturerList[$lecKey]);
- }elseif($lecValue['ltype']=='OUTSIDE'){
- if($lecValue['taxation']==0){
- $bValue=$lecValue['price']*$lecValue['schoolDay'];
- $aiList[$k]['outsideNoTaxPrice']+=$bValue;
- $total+=$bValue;
- $aiList[$k]['price']+=$bValue;
- unset($RILecturerList[$lecKey]);
- }elseif($lecValue['taxation']==1){
- $bValue=$lecValue['price']*$lecValue['schoolDay'];
- $aiList[$k]['outsideTaxPrice']+=$bValue;
- $total+=$bValue;
- $aiList[$k]['price']+=$bValue;
- unset($RILecturerList[$lecKey]);
- }
- }
- }
- }
-
- $aiList[$k]['categoryProportion']=$aiList[$k]['companyProportion']=$aiList[$k]['proportion']=0;
- $aiList[$k]['insideProportion']=$aiList[$k]['outsideNoTaxProportion']=$aiList[$k]['outsideTaxProportion']=0;
-
- if ($invoiceArriveAmount!=0){
- if($v['name']=='办公费'||$v['name']=='邮寄费'){
- $proportion=$aiList[$k]['categoryPrice']/$invoiceArriveAmount;
- $aiList[$k]['categoryProportion']=number_format ( $proportion, 2, '.', '' )*100;
- $proportion=$aiList[$k]['companyPrice']/$invoiceArriveAmount;
- $aiList[$k]['companyProportion']=number_format ( $proportion, 2, '.', '' )*100;
- }elseif($v['name']=='讲课费'){
- $proportion=$aiList[$k]['insidePrice']/$invoiceArriveAmount;
- $aiList[$k]['insideProportion']=number_format ( $proportion, 2, '.', '' )*100;
-
- $proportion=$aiList[$k]['outsideTaxPrice']/$invoiceArriveAmount;
- $aiList[$k]['outsideTaxProportion']=number_format ( $proportion, 2, '.', '' )*100;
-
- $proportion=$aiList[$k]['outsideNoTaxPrice']/$invoiceArriveAmount;
- $aiList[$k]['outsideNoTaxProportion']=number_format ( $proportion, 2, '.', '' )*100;
- }else{
- $proportion=$aiList[$k]['price']/$invoiceArriveAmount;
- $aiList[$k]['proportion']=number_format ( $proportion, 2, '.', '' )*100;
- }
- }
-
-
- }
-
- return array('dataList'=>$aiList,'total'=>$total,'categoryActualExpenditure'=>$categoryActualExpenditure);
- }
-
- }
- ?>
|