123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- Doo::loadCore('db/DooModel');
- class statistics extends DooModel {
- public $sid;
- public $date;
- public $cid;
- public $staff;
- public $rePrice;
- public $agPrice;
-
- public $_table = 'CLD_statistics';
- public $_primarykey = 'sid';
-
- public $_fields = array('sid', 'staff', 'rePrice', 'date', 'cid','agPrice');
- function statisticsByYear($year,$sid){
- //
- $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where staff= '".$sid."' and Year(date) =".$year." group by Year(date)" ;
- //echo '<div style="display:none">'.$sql.'</div>';
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
-
- return $result;
- }
-
- function statisticsByComPanyYear($year,$sid){
- //staff= '".$sid."' and
- $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where Year(date) =".$year." group by Year(date)" ;
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
-
- return $result;
- }
-
- function statisticsByCid($year,$cid){
- //
- $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where cid= '".$cid."' and Year(date) =".$year." group by Year(date)" ;
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
-
- return $result;
- }
-
- /**
- * 按员工年月获得报销单汇总信息
- * @param string $sid
- * @param string $year
- * @param string $month
- */
- function getStatisticsBySid($sid='',$year='',$month=''){
- if(empty($sid))
- return array();
- $stList = $this->getOne ( array (
- 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
- 'where' => 'staff='.$sid.' and Month(date)=' . $month . " and Year(date)=" . $year,
- 'groupby' => 'Month(date)',
- 'asArray' => true
- ) );
- return $stList;
- }
- }
- ?>
|