|
@@ -56,18 +56,146 @@ class invoiceStatistics extends DooModel {
|
|
}
|
|
}
|
|
return $lid;
|
|
return $lid;
|
|
}
|
|
}
|
|
- function getClientByCid($cid) {
|
|
|
|
- $sql = "select sum(price) from " . $this->_table . " where staff= '" . $cid . "' and ";
|
|
|
|
-
|
|
|
|
- $query = Doo::db ()->query ( $sql );
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据发票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
|
|
|
|
+ ) );
|
|
|
|
+
|
|
|
|
+ $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
|
|
|
|
+ ) );
|
|
|
|
|
|
- $result = $query->fetch ();
|
|
|
|
|
|
+ if (empty($list['statisticsYear'])){
|
|
|
|
+ $list['statisticsYear'][0]['invoicePrice']=0;
|
|
|
|
+ $list['statisticsYear'][0]['receivablesPrice']=0;
|
|
|
|
+ $list['statisticsYear'][0]['accountPrice']=0;
|
|
|
|
+ }
|
|
|
|
|
|
- return $result;
|
|
|
|
|
|
+ return $list;
|
|
}
|
|
}
|
|
- /*
|
|
|
|
- * public function getProjectByIdList($projectid){ return $this->find ( array ('where' => "pid= '".$projectid."'", 'asArray' => TRUE ) ); }
|
|
|
|
- */
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
?>
|