public function getReport($user, EventRepository $eventRepo)
 {
     $date = new \DateTime('7 days ago');
     $results = $this->getEntityManager()->createQuery("SELECT h\n        FROM AppBundle:History h\n        WHERE h.date >= '" . $date->format("Y-m-d H:i:s") . "'\n        AND h.user = '******'\n        ORDER BY h.date DESC")->getResult();
     $events = array();
     foreach ($results as $result) {
         $events = $eventRepo->fineNear($result->getLat(), $result->getLon(), false) + $events;
     }
     return $events;
 }
Example #2
0
 /**
  * Methode zum anzeigen des Contents.
  *
  * @return String Content der Applikation.
  */
 public function display()
 {
     $event = EventRepository::find($this->request['id']);
     if ($event !== null) {
         $events = array();
         for ($i = 0; $i < 3; $i++) {
             array_push($events, $event->toArray());
         }
         //$res = $events;
         $res['events'] = array_values($events);
         $res['status'] = 'success';
     } else {
         $res = array('status' => 'error');
     }
     $this->view->setTemplate($this->template);
     $this->view->assign('outlet', json_encode($res));
     return $this->view->loadTemplate();
 }
Example #3
0
 /**
  * Methode zum anzeigen des Contents.
  *
  * @return string string to display
  */
 public function display()
 {
     //Decide what to do / CREATE / UPDATE / DELETE / GET
     // GET
     if ($this->request['type'] === 'GET') {
         if (empty($this->request['query'])) {
             $res = EventRepository::findAll();
         } elseif (!empty($this->request['query']['id'])) {
             $res = EventRepository::find($this->request['query']['id']);
         } else {
             $events = EventRepository::query($request['query']);
         }
         if ($res !== null) {
             if (!is_array($res)) {
                 $res = array(0 => $res);
             }
             for ($i = 0, $length = count($res); $i < $length; $i++) {
                 $events[$i] = $res[$i]->toArray();
             }
             $return['events'] = array_values($events);
             $return['status'] = 'success';
             $return = json_encode($return);
         } else {
             $return = array('status' => 'error');
         }
         // POST
     } elseif ($this->request['type'] === 'POST') {
         $data = $this->request['data'];
         $res = EventRepository::create($data);
         if ($res !== 200) {
             $return = array('status' => 'error');
         } else {
             $return = array('status' => 'success');
         }
         $return = json_encode($return);
         echo $return;
     }
     $this->view->setTemplate($this->template);
     $this->view->assign('outlet', $return);
     return $this->view->loadTemplate();
 }
 /**
  * Push events to a receiver
  *
  * @param mixed $receiver
  */
 public function replayTo($receiver)
 {
     $events = $this->eventRepository->events();
     $this->replayRequestHandler->replay($events, $receiver);
 }