admin home stats and information
This commit is contained in:
@@ -23,7 +23,7 @@ class CustomerQuery extends BaseCustomerQuery {
|
||||
return self::create()->findOneByEmail($email);
|
||||
}
|
||||
|
||||
public static function getNewCustomersStats($month, $year)
|
||||
public static function getMonthlyNewCustomersStats($month, $year)
|
||||
{
|
||||
$numberOfDay = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
||||
|
||||
|
||||
@@ -50,11 +50,12 @@ class Order extends BaseOrder
|
||||
/**
|
||||
* calculate the total amount
|
||||
*
|
||||
* @param int $tax
|
||||
* @param int $tax
|
||||
* @param bool $includePostage
|
||||
*
|
||||
* @return int|string|Base\double
|
||||
* @return float|int|string
|
||||
*/
|
||||
public function getTotalAmount(&$tax = 0)
|
||||
public function getTotalAmount(&$tax = 0, $includePostage = true)
|
||||
{
|
||||
$amount = 0;
|
||||
$tax = 0;
|
||||
@@ -76,7 +77,13 @@ class Order extends BaseOrder
|
||||
$tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity();
|
||||
}
|
||||
|
||||
return $amount + $tax + $this->getPostage(); // @todo : manage discount
|
||||
$total = $amount + $tax;
|
||||
|
||||
if(false !== $includePostage) {
|
||||
$total += $this->getPostage();
|
||||
}
|
||||
|
||||
return $total; // @todo : manage discount
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,7 +55,7 @@ class OrderQuery extends BaseOrderQuery
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function getSaleStats($month, $year)
|
||||
public static function getMonthlySaleStats($month, $year)
|
||||
{
|
||||
$numberOfDay = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
||||
|
||||
@@ -75,7 +75,7 @@ class OrderQuery extends BaseOrderQuery
|
||||
return $stats;
|
||||
}
|
||||
|
||||
public static function getOrdersStats($month, $year, $status = null)
|
||||
public static function getMonthlyOrdersStats($month, $year, $status = null)
|
||||
{
|
||||
$numberOfDay = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
||||
|
||||
@@ -121,5 +121,42 @@ class OrderQuery extends BaseOrderQuery
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $startDate
|
||||
* @param \DateTime $endDate
|
||||
* @param $includeShipping
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getSaleStats(\DateTime $startDate, \DateTime $endDate, $includeShipping)
|
||||
{
|
||||
$amount = 0;
|
||||
foreach(self::create()
|
||||
->filterByStatusId(array(2,3,4), Criteria::IN)
|
||||
->filterByCreatedAt(sprintf("%s 00:00:00", $startDate->format('Y-m-d')), Criteria::GREATER_EQUAL)
|
||||
->filterByCreatedAt(sprintf("%s 23:59:59", $endDate->format('Y-m-d')), Criteria::LESS_EQUAL)
|
||||
->find() as $order) {
|
||||
$tax = 0;
|
||||
$amount += $order->getTotalAmount($tax, $includeShipping);
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $startDate
|
||||
* @param \DateTime $endDate
|
||||
* @param $status
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrderStats(\DateTime $startDate, \DateTime $endDate, $status = array(1,2,3,4))
|
||||
{
|
||||
return self::create()
|
||||
->filterByStatusId($status, Criteria::IN)
|
||||
->filterByCreatedAt(sprintf("%s 00:00:00", $startDate->format('Y-m-d')), Criteria::GREATER_EQUAL)
|
||||
->filterByCreatedAt(sprintf("%s 23:59:59", $endDate->format('Y-m-d')), Criteria::LESS_EQUAL)
|
||||
->count();
|
||||
}
|
||||
|
||||
} // OrderQuery
|
||||
|
||||
Reference in New Issue
Block a user