Example #1
0
 /**
  * @param int $userId
  * @param bool|array $params
  * @return \DDD\Domain\Notifications\Notifications
  */
 public function getActualNotificationsCountForUser($userId, $params = false)
 {
     $today = date('Y-m-d');
     $actualDay = date('Y-m-d', strtotime("+7 day", strtotime($today)));
     $prototype = $this->getEntity();
     $this->setEntity(new \ArrayObject());
     $result = $this->fetchOne(function (Select $select) use($userId, $today, $actualDay, $params) {
         $select->columns(['count' => new Expression('COUNT(*)')]);
         if (isset($params['sender']) && $params['sender'] != NotificationsService::FROM_ALL) {
             $select->where->equalTo('sender', $params['sender']);
         } else {
             $select->where->notIn('sender', NotificationsService::getNotInboxNotifications());
         }
         $select->where->equalTo('user_id', $userId);
         if (!$params) {
             $select->where->isNull('done_date');
         } else {
             if (isset($params['active_archived']) && $params['active_archived'] == NotificationsService::STATUS_ARCHIVED) {
                 $select->where->isNotNull('done_date');
             } else {
                 $select->where->isNull('done_date');
             }
         }
         $select->where->expression('date(`show_date`) <= IF(`sender` IN (' . "'" . implode('\',\'', NotificationsService::getNotificationsList()) . "'" . '),' . "'" . $today . "'" . ',' . "'" . $actualDay . "'" . ')', []);
         $select->order(['show_date DESC, sender, message']);
     });
     $this->setEntity($prototype);
     return $result['count'];
 }
Example #2
0
 public function indexAction()
 {
     $allNotificationSenders = NotificationsService::getAllSendersForSelect();
     $searchForm = new SearchNotificationForm($allNotificationSenders);
     return new ViewModel(['search_form' => $searchForm]);
 }