accountItem.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class accountItem extends DooModel {
  4. public $aid;
  5. public $category;
  6. public $name;
  7. public $_table = 'CLD_accountItem';
  8. public $_primarykey = 'aid';
  9. public $_fields = array (
  10. 'aid',
  11. 'category',
  12. 'name'
  13. );
  14. /**
  15. *
  16. */
  17. function getAccountItem(){
  18. $sql = 'select category
  19. from ' . $this->_table . '
  20. GROUP BY category ORDER BY aid ASC ';
  21. $query = Doo::db ()->query ( $sql );
  22. $itemCategory = $query->fetchAll ();
  23. $list = $this->find ( array (
  24. 'asArray' => TRUE
  25. ) );
  26. $acctionItem=array();
  27. foreach ($itemCategory as $key=>$value){
  28. $acctionItem[$value['category']]=array();
  29. foreach ($list as $k=>$v){
  30. if ($value['category']==$v['category']){
  31. array_push($acctionItem[$value['category']], $v);
  32. }
  33. }
  34. }
  35. return $acctionItem;
  36. }
  37. /**
  38. * 根据项目获得ITEM
  39. */
  40. function getAccountBookByCategory($category=''){
  41. $list = $this->find ( array (
  42. 'where' => ' category like "%' . $category.'%"',
  43. 'asArray' => TRUE
  44. ) );
  45. return $list;
  46. }
  47. /**
  48. * 获得培训班金额详情
  49. * @param array $RItemList 支出项目
  50. * @param array $RILecturerList 讲师项目
  51. * @return number[]
  52. */
  53. function getTrainingDetail($RItemList=array(),$RILecturerList=array(),$invoiceArriveAmount=0){
  54. $aiList = $this->find ( array (
  55. 'where' => ' category like "%培训班费用%"',
  56. 'asArray' => TRUE
  57. ) );
  58. $total=0;$categoryActualExpenditure='';
  59. foreach ($aiList as $k=>$v){
  60. $aiList[$k]['price']=$aiList[$k]['companyPrice']=$aiList[$k]['categoryPrice']=0;
  61. $aiList[$k]['insidePrice']=$aiList[$k]['outsideNoTaxPrice']=$aiList[$k]['outsideTaxPrice']=0;
  62. foreach ($RItemList as $key=>$value){
  63. if($v['name']=='讲课费'){
  64. }elseif($v['name']=='办公费'&&$value['item']=='办公费'){
  65. if($value['payType']==0){
  66. $aiList[$k]['categoryPrice']+=$value['price'];
  67. $total+=$value['price'];
  68. }elseif($value['payType']==1){
  69. $aiList[$k]['companyPrice']+=$value['price'];
  70. $categoryActualExpenditure+=$value['price'];
  71. $total+=$value['price'];
  72. }
  73. $aiList[$k]['price']+=$value['price'];
  74. unset($RItemList[$key]);
  75. }elseif($v['name']=='邮寄费'&&$value['item']=='邮寄费'){
  76. if($value['payType']==0){
  77. $aiList[$k]['categoryPrice']+=$value['price'];
  78. $total+=$value['price'];
  79. }elseif($value['payType']==1){
  80. $aiList[$k]['companyPrice']+=$value['price'];
  81. $categoryActualExpenditure+=$value['price'];
  82. $total+=$value['price'];
  83. }
  84. $aiList[$k]['price']+=$value['price'];
  85. unset($RItemList[$key]);
  86. }else{
  87. if ($v['name']==$value['item']){
  88. $aiList[$k]['price']+=$value['price'];
  89. $total+=$value['price'];
  90. unset($RItemList[$key]);
  91. }
  92. }
  93. if($value['item']=='研究中心经费'&&$v['name']=='研究中心经费'){
  94. $categoryActualExpenditure+=$value['price'];
  95. }
  96. if($value['item']=='税款'&&$v['name']=='税款'){
  97. $categoryActualExpenditure+=$value['price'];
  98. }
  99. }
  100. //讲师项
  101. foreach ($RILecturerList as $lecKey=>$lecValue){
  102. if($v['name']=='讲课费'){
  103. if($lecValue['ltype']=='INSIDE'){
  104. $bValue=$lecValue['price']*$lecValue['schoolDay'];
  105. $aiList[$k]['insidePrice']+=$bValue;
  106. $total+=$bValue;
  107. $categoryActualExpenditure+=$bValue;
  108. $aiList[$k]['price']+=$bValue;
  109. unset($RILecturerList[$lecKey]);
  110. }elseif($lecValue['ltype']=='OUTSIDE'){
  111. if($lecValue['taxation']==0){
  112. $bValue=$lecValue['price']*$lecValue['schoolDay'];
  113. $aiList[$k]['outsideNoTaxPrice']+=$bValue;
  114. $total+=$bValue;
  115. $aiList[$k]['price']+=$bValue;
  116. unset($RILecturerList[$lecKey]);
  117. }elseif($lecValue['taxation']==1){
  118. $bValue=$lecValue['price']*$lecValue['schoolDay'];
  119. $aiList[$k]['outsideTaxPrice']+=$bValue;
  120. $total+=$bValue;
  121. $aiList[$k]['price']+=$bValue;
  122. unset($RILecturerList[$lecKey]);
  123. }
  124. }
  125. }
  126. }
  127. $aiList[$k]['categoryProportion']=$aiList[$k]['companyProportion']=$aiList[$k]['proportion']=0;
  128. $aiList[$k]['insideProportion']=$aiList[$k]['outsideNoTaxProportion']=$aiList[$k]['outsideTaxProportion']=0;
  129. if ($invoiceArriveAmount!=0){
  130. if($v['name']=='办公费'||$v['name']=='邮寄费'){
  131. $proportion=$aiList[$k]['categoryPrice']/$invoiceArriveAmount;
  132. $aiList[$k]['categoryProportion']=number_format ( $proportion, 2, '.', '' )*100;
  133. $proportion=$aiList[$k]['companyPrice']/$invoiceArriveAmount;
  134. $aiList[$k]['companyProportion']=number_format ( $proportion, 2, '.', '' )*100;
  135. }elseif($v['name']=='讲课费'){
  136. $proportion=$aiList[$k]['insidePrice']/$invoiceArriveAmount;
  137. $aiList[$k]['insideProportion']=number_format ( $proportion, 2, '.', '' )*100;
  138. $proportion=$aiList[$k]['outsideTaxPrice']/$invoiceArriveAmount;
  139. $aiList[$k]['outsideTaxProportion']=number_format ( $proportion, 2, '.', '' )*100;
  140. $proportion=$aiList[$k]['outsideNoTaxPrice']/$invoiceArriveAmount;
  141. $aiList[$k]['outsideNoTaxProportion']=number_format ( $proportion, 2, '.', '' )*100;
  142. }else{
  143. $proportion=$aiList[$k]['price']/$invoiceArriveAmount;
  144. $aiList[$k]['proportion']=number_format ( $proportion, 2, '.', '' )*100;
  145. }
  146. }
  147. }
  148. return array('dataList'=>$aiList,'total'=>$total,'categoryActualExpenditure'=>$categoryActualExpenditure);
  149. }
  150. }
  151. ?>