|
@@ -63,42 +63,42 @@ class invoiceStatistics extends DooModel {
|
|
|
* @param string $bindStatus
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function getInvoiceStatisticsByYear($year="", $cid = "0") {
|
|
|
+ public function getInvoiceStatisticsByYear($year = "", $cid = "0") {
|
|
|
$list = array ();
|
|
|
$sql = '';
|
|
|
- if (empty($year))
|
|
|
- $year=date("Y");
|
|
|
+ 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;
|
|
|
+
|
|
|
+ $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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -107,69 +107,67 @@ class invoiceStatistics extends DooModel {
|
|
|
* @param string $cid
|
|
|
* @return NULL[]
|
|
|
*/
|
|
|
- public function getInvoiceStatisticsByStaff($year="", $cid = "0") {
|
|
|
+ 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;
|
|
|
+ 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") {
|
|
|
+ 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;
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -178,86 +176,92 @@ class invoiceStatistics extends DooModel {
|
|
|
* @param string $cid
|
|
|
* @return NULL[]
|
|
|
*/
|
|
|
- public function getInvoiceStatisticsByTote($year="", $cid = "0") {
|
|
|
+ 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',
|
|
|
+ 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
|
|
|
+ 'groupby' => 'Year(date)',
|
|
|
+ 'asArray' => TRUE
|
|
|
) );
|
|
|
|
|
|
- if (empty($list['statisticsYear'])){
|
|
|
- $list['statisticsYear'][0]['invoicePrice']=0;
|
|
|
- $list['statisticsYear'][0]['receivablesPrice']=0;
|
|
|
- $list['statisticsYear'][0]['accountPrice']=0;
|
|
|
+ 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
|
|
|
+ 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;
|
|
|
+ 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
|
|
|
+ $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;
|
|
|
+ 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");
|
|
|
+ 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);
|
|
|
+ $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
|
|
|
+ $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;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ public function getInvoiceStatisticsByCondition($condition = '') {
|
|
|
+ if (empty ( $condition ))
|
|
|
+ return array ();
|
|
|
|
|
|
+ $list = $this->find ( array (
|
|
|
+ 'where' => $condition,
|
|
|
+ 'asArray' => TRUE
|
|
|
+ ) );
|
|
|
return $list;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
?>
|