receiptDetail.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. class receiptDetail extends DooModel {
  4. public $rdid;
  5. public $item;
  6. public $staff;
  7. public $itemCategory;
  8. public $price;
  9. public $date;
  10. public $pastDate;
  11. public $cid;
  12. public $rid;
  13. public $status;
  14. public $_table = 'CLD_receiptDetail';
  15. public $_primarykey = 'rdid';
  16. public $_fields = array('rdid', 'item', 'staff', 'itemCategory', 'price', 'date','pastDate', 'cid', 'rid', 'status');
  17. function getReceiptDetailByYear($cidIn,$year){
  18. if(empty($cidIn)||(!is_numeric($year))){
  19. return array();
  20. }
  21. $list=$this->find ( array (
  22. 'select' => 'item,sum(price) as price,itemCategory,item,Month(pastDate) as month,cid',
  23. 'where' => " status=1 and Year(pastDate)=" . $year ." and cid in (".$cidIn.")" ,
  24. 'groupby' => 'item,Month(pastDate),item',
  25. 'asArray' => true
  26. ) );
  27. return $list;
  28. }
  29. /**
  30. * 按人员年月合计报销单项目金额
  31. * @param string $sid
  32. * @param string $year
  33. * @param string $month
  34. * @return unknown
  35. */
  36. function getReceiptTotalItem($sid='',$year='',$month=''){
  37. if(empty($sid))
  38. return array();
  39. $list=$this->find ( array (
  40. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  41. 'where' => 'staff=' . $sid . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  42. 'groupby' => 'item,Month(pastDate),itemCategory',
  43. 'asArray' => true
  44. ) );
  45. return $list;
  46. }
  47. /**
  48. * 按人员年月合计报销单大项金额
  49. * @param string $sid
  50. * @param string $year
  51. * @param string $month
  52. * @return unknown
  53. */
  54. function getReceiptTotalItemCategory($sid='',$year='',$month=''){
  55. if(empty($sid))
  56. return array();
  57. $list=$this->find ( array (
  58. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  59. 'where' => 'staff=' . $sid . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  60. 'groupby' => 'Month(pastDate),itemCategory',
  61. 'asArray' => true
  62. ) );
  63. return $list;
  64. }
  65. /**
  66. * 根据RID 项目详情获得信息
  67. * @param string $rid
  68. * @param string $item
  69. * @param string $itemCategory
  70. * @return unknown
  71. */
  72. function getReceiptDetailByRIC($rid='',$item='',$itemCategory=''){
  73. if (!is_numeric($rid)||empty($item)||empty($itemCategory)){
  74. return array();
  75. }
  76. $rinfo = $this->getOne ( array (
  77. 'where' => 'rid=' . $rid.' and item like "'.$item.'" and itemCategory like "'.$itemCategory.'"',
  78. 'asArray' => true
  79. ) );
  80. return $rinfo;
  81. }
  82. }
  83. ?>