12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?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,$cidString=''){
- //staff= '".$sid."' and
- $cidSql='';
- if(!empty($cidString))
- $cidSql=' and cid in ('.$cidString.')';
- $sql = "select sum(rePrice) as rePrice,sum(agPrice) as agPrice from " . $this->_table . " where Year(date) =".$year.$cidSql." 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;
- }
- }
- ?>
|