/** * Create a new Notification instance. * * @param Twig_Template $template The Twig template object to use to create this notification. * @todo Allow other content sources (string, database, etc) */ public function __construct($template) { $this->template = $template; if (!static::$app) { static::$app = UserFrosting::getInstance(); } }
public static function getWeekStats() { $dateTime = new \DateTime('First Monday of this month'); $startUts = $dateTime->format('U'); $dateTime->modify('+6 week'); $endUts = $dateTime->format('U'); $bookings = Booking::where('startUts', '>=', $startUts)->where('startUts', '<', $endUts)->where('user_id', UserFrosting::getInstance()->user->id)->get(['startUts', 'status']); $data = array(); foreach ($bookings as $booking) { $week = strftime('%G W%V', $booking->startUts); if (!isset($data[$week])) { $data[$week] = array('period' => $week, 'new' => 0, 'accepted' => 0, 'rejected' => 0); } $data[$week][$booking->status]++; } $response = new \StdClass(); $response->data = $data; $response->json = json_encode(array_values($data)); $response->title = strftime('%e %b', $startUts) . ' - ' . strftime('%e %b', $endUts - 10800); return $response; }