$value ) { $this->$key = $value; } $lid = $this->insert (); } return $lid; } /** * 根据参数字段更新相应字段(主键ID必须传) * @param array $item 相关需要更新的字段信息 * @return number 返回发票ID */ public function updateInvoiceStatisticsByIrid($item = array(), $irid = 0) { if (is_numeric ( $irid ) && is_array ( $item ) && ! empty ( $item )) { foreach ( $item as $key => $value ) { $this->$key = $value; } $lid = $this->update ( array ( 'where' => 'irid=' . $irid ) ); } return $lid; } /** * 根据发票ID和绑定状态获得收款数据,绑定状态为ALL获取所有状态数据 * @param string $iid 发票ID * @param string $bindStatus * @return mixed */ public function getInvoiceStatisticsByYear($year="", $cid = "0") { $list = array (); $sql = ''; if (empty($year)) $year=date("Y"); if ($cid != 0) $sql = " and cid=" . $cid; $list['statisticsMonthCid'] = $this->find ( array ( 'select'=>'cid,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'cid,Month(date)', 'asArray' => TRUE ) ); $list['statisticsYear'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Year(date) as Year', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'Year(date)', 'asArray' => TRUE ) ); if (empty($list['statisticsYear'])){ $list['statisticsYear'][0]['invoicePrice']=0; $list['statisticsYear'][0]['receivablesPrice']=0; $list['statisticsYear'][0]['accountPrice']=0; } $list['statisticsMonth'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'Month(date)', 'asArray' => TRUE ) ); return $list; } /** * 获取用户的统计信息 * @param string $year * @param string $cid * @return NULL[] */ public function getInvoiceStatisticsByStaff($year="", $cid = "0") { $list = array (); $sql = ''; if (empty($year)) $year=date("Y"); if ($cid != 0) $sql = " and cid=" . $cid; $list['statisticsMonthCid'] = $this->find ( array ( 'select'=>'cid,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'cid,Month(date)', 'asArray' => TRUE ) ); $list['statisticsMonthStaff'] = $this->find ( array ( 'select'=>'cid,staff,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'staff,Month(date)', 'asArray' => TRUE ) ); $list['statisticsMonth'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'Month(date)', 'asArray' => TRUE ) ); return $list; } public function getInvoiceStatisticsByCategory($year="", $cid = "0") { $list = array (); $sql = ''; if (empty($year)) $year=date("Y"); if ($cid != 0) $sql = " and cid=" . $cid; $list['statisticsMonthCid'] = $this->find ( array ( 'select'=>'cid,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'cid,Month(date)', 'asArray' => TRUE ) ); $list['statisticsMonthStaff'] = $this->find ( array ( 'select'=>'cid,staff,sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'staff,Month(date)', 'asArray' => TRUE ) ); $list['statisticsMonth'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . $sql, 'groupby'=>'Month(date)', 'asArray' => TRUE ) ); return $list; } /** * 获取某年的汇总金额 * @param string $year * @param string $cid * @return NULL[] */ public function getInvoiceStatisticsByTote($year="", $cid = "0") { $list = array (); $sql = ''; if (empty($year)) $year=date("Y"); if ($cid != 0) $sql = " and cid=" . $cid; $list['statisticsYear'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Year(date) as Year', 'where' => " Year(date) =" . $year . $sql, 'groupby'=>'Year(date)', 'asArray' => TRUE ) ); if (empty($list['statisticsYear'])){ $list['statisticsYear'][0]['invoicePrice']=0; $list['statisticsYear'][0]['receivablesPrice']=0; $list['statisticsYear'][0]['accountPrice']=0; } return $list; } public function getStatisticsByMonth(){ $month=date("m"); $year=date("Y"); $list['statisticsMonth'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . " and Month(date)=".$month, 'groupby'=>'Month(date)', 'asArray' => TRUE ) ); if (empty($list['statisticsMonth'])){ $list['statisticsMonth'][0]['invoicePrice']=0; $list['statisticsMonth'][0]['receivablesPrice']=0; $list['statisticsMonth'][0]['accountPrice']=0; $list['statisticsMonth'][0]['month']=$month; } $list['statisticsYear'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Year(date) as Year', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year , 'groupby'=>'Year(date)', 'asArray' => TRUE ) ); if (empty($list['statisticsYear'])){ $list['statisticsYear'][0]['invoicePrice']=0; $list['statisticsYear'][0]['receivablesPrice']=0; $list['statisticsYear'][0]['accountPrice']=0; $list['statisticsYear'][0]['month']=$month; } return $list; } public function getBrieflyStatistics(){ $year=date("Y"); $month=date("m"); $tmp_date=date("Ym"); $tmp_year=substr($tmp_date,0,4); $tmp_mon =substr($tmp_date,4,2); $tmp_forwardmonth=mktime(0,0,0,$tmp_mon-1,1,$tmp_year); $fm_forward_month=date("m",$tmp_forwardmonth); $list['statisticsMonth'] = $this->find ( array ( 'select'=>'sum(invoicePrice) as invoicePrice,sum(receivablesPrice) as receivablesPrice,sum(accountPrice) as accountPrice,Month(date) as month', 'where' => " cid!=0 and staff!=0 and Year(date) =" . $year . " and Month(date)=".$fm_forward_month, 'groupby'=>'Month(date)', 'asArray' => TRUE ) ); if (empty($list['statisticsMonth'])){ $list['statisticsMonth'][0]['invoicePrice']=0; $list['statisticsMonth'][0]['receivablesPrice']=0; $list['statisticsMonth'][0]['accountPrice']=0; $list['statisticsMonth'][0]['month']=$fm_forward_month; } return $list; } } ?>