admin home stats

This commit is contained in:
Etienne Roudeix
2013-10-30 16:32:24 +01:00
parent a540c50395
commit 083dde5e93
5 changed files with 209 additions and 10 deletions

View File

@@ -2,6 +2,7 @@
namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\Base\CustomerQuery as BaseCustomerQuery;
@@ -21,4 +22,20 @@ class CustomerQuery extends BaseCustomerQuery {
{
return self::create()->findOneByEmail($email);
}
public static function getNewCustomersStats($month, $year)
{
$numberOfDay = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$stats = array();
for($day=1; $day<=$numberOfDay; $day++) {
$dayCustomers = self::create()
->filterByCreatedAt(sprintf("%s-%s-%s 00:00:00", $year, $month, $day), Criteria::GREATER_EQUAL)
->filterByCreatedAt(sprintf("%s-%s-%s 23:59:59", $year, $month, $day), Criteria::LESS_EQUAL)
->count();
$stats[] = array($day-1, $dayCustomers);
}
return $stats;
}
} // CustomerQuery