statistics.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. public function getProjectByIdList($projectid){
  37. return $this->find ( array ('where' => "pid= '".$projectid."'", 'asArray' => TRUE ) );
  38. }
  39. */
  40. }
  41. ?>