statistics.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. class statistics extends DooModel {
  4. public $sid;
  5. public $date;
  6. public $cid;
  7. public $staff;
  8. public $rePrice;
  9. public $agPrice;
  10. public $_table = 'CLD_statistics';
  11. public $_primarykey = 'sid';
  12. public $_fields = array('sid', 'staff', 'rePrice', 'date', 'cid','agPrice');
  13. function statisticsByYear($year,$sid){
  14. //
  15. $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where staff= '".$sid."' and Year(date) =".$year." group by Year(date)" ;
  16. //echo '<div style="display:none">'.$sql.'</div>';
  17. $query = Doo::db ()->query ( $sql );
  18. $result = $query->fetch ();
  19. return $result;
  20. }
  21. function statisticsByComPanyYear($year,$sid){
  22. //staff= '".$sid."' and
  23. $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where Year(date) =".$year." group by Year(date)" ;
  24. $query = Doo::db ()->query ( $sql );
  25. $result = $query->fetch ();
  26. return $result;
  27. }
  28. function statisticsByCid($year,$cid){
  29. //
  30. $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where cid= '".$cid."' and Year(date) =".$year." group by Year(date)" ;
  31. $query = Doo::db ()->query ( $sql );
  32. $result = $query->fetch ();
  33. return $result;
  34. }
  35. /**
  36. * 按员工年月获得报销单汇总信息
  37. * @param string $sid
  38. * @param string $year
  39. * @param string $month
  40. */
  41. function getStatisticsBySid($sid='',$year='',$month=''){
  42. if(empty($sid))
  43. return array();
  44. $stList = $this->getOne ( array (
  45. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  46. 'where' => 'staff='.$sid.' and Month(date)=' . $month . " and Year(date)=" . $year,
  47. 'groupby' => 'Month(date)',
  48. 'asArray' => true
  49. ) );
  50. return $stList;
  51. }
  52. }
  53. ?>