public function indexAction(Request $request, SessionInterface $session)
 {
     $projectId = $request->request->get('id');
     $loggedInUserId = $session->get('user/id');
     $clientId = $session->get('client/id');
     $client = $this->getRepository(UbirimiClient::class)->getById($clientId);
     $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     if (Util::checkUserIsLoggedIn()) {
         $hasBrowsingPermission = $this->getRepository(YongoProject::class)->userHasPermission(array($projectId), Permission::PERM_BROWSE_PROJECTS, $loggedInUserId);
     } else {
         $loggedInUserId = null;
         $httpHOST = Util::getHttpHost();
         $hasBrowsingPermission = $this->getRepository(YongoProject::class)->userHasPermission(array($projectId), Permission::PERM_BROWSE_PROJECTS);
     }
     if ($hasBrowsingPermission) {
         $helpDeskFlag = 0;
         if ($session->get('selected_product_id') == SystemProduct::SYS_PRODUCT_HELP_DESK) {
             $helpDeskFlag = 1;
         }
         $endDate = Util::getServerCurrentDateTime();
         $startDate = date_sub(new \DateTime($endDate, new \DateTimeZone($clientSettings['timezone'])), date_interval_create_from_date_string('2 days'));
         $historyList = null;
         do {
             $historyList = Util::getProjectHistory(array($projectId), $helpDeskFlag, null, date_format($startDate, 'Y-m-d'), $endDate);
             if (null == $historyList && date_format($startDate, 'Y-m-d H:i:s') == $client['date_created']) {
                 break;
             }
             $startDate = date_sub($startDate, date_interval_create_from_date_string('2 days'));
             $startDate->setTime(0, 0, 0);
             if (date_format($startDate, 'Y-m-d') < $client['date_created']) {
                 $startDate = new \DateTime($client['date_created'], new \DateTimeZone($clientSettings['timezone']));
                 break;
             }
         } while ($historyList == null);
         $historyData = array();
         $userData = array();
         while ($historyList && ($history = $historyList->fetch_array(MYSQLI_ASSOC))) {
             $historyData[substr($history['date_created'], 0, 10)][$history['user_id']][$history['date_created']][] = $history;
             $userData[$history['user_id']] = array('picture' => $history['avatar_picture'], 'first_name' => $history['first_name'], 'last_name' => $history['last_name']);
         }
     }
     $index = 0;
     return $this->render(__DIR__ . '/../../Resources/views/project/ViewActivityStream.php', get_defined_vars());
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     if (Util::checkUserIsLoggedIn()) {
         $clientId = $session->get('client/id');
         $clientSettings = $session->get('client/settings');
     } else {
         $clientId = $this->getRepository(UbirimiClient::class)->getClientIdAnonymous();
         $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     }
     $client = $this->getRepository(UbirimiClient::class)->getById($clientId);
     $date = $request->request->get('date');
     $project = $request->request->get('project');
     if ($project == 'all') {
         $projectsMenu = $this->getRepository(UbirimiClient::class)->getProjectsByPermission($session->get('client/id'), $session->get('user/id'), Permission::PERM_BROWSE_PROJECTS, 'array');
         $projectIds = Util::array_column($projectsMenu, 'id');
     } else {
         $projectIds = array($project);
     }
     $historyList = null;
     $endDate = $date;
     $startDate = date_sub(new \DateTime($date, new \DateTimeZone($clientSettings['timezone'])), date_interval_create_from_date_string('2 days'));
     do {
         $historyList = Util::getProjectHistory($projectIds, 0, null, date_format($startDate, 'Y-m-d'), $endDate);
         if (null == $historyList && date_format($startDate, 'Y-m-d H:i:s') == $client['date_created']) {
             break;
         }
         $startDate = date_sub($startDate, date_interval_create_from_date_string('2 days'));
         $startDate->setTime(0, 0, 0);
         if (date_format($startDate, 'Y-m-d') < $client['date_created']) {
             $startDate = new \DateTime($client['date_created'], new \DateTimeZone($clientSettings['timezone']));
             break;
         }
     } while ($historyList == null);
     $historyData = array();
     $userData = array();
     while ($historyList && ($history = $historyList->fetch_array(MYSQLI_ASSOC))) {
         $historyData[substr($history['date_created'], 0, 10)][$history['user_id']][$history['date_created']][] = $history;
         $userData[$history['user_id']] = array('picture' => $history['avatar_picture'], 'first_name' => $history['first_name'], 'last_name' => $history['last_name']);
     }
     $index = 0;
     return $this->render(__DIR__ . '/../Resources/views/project/_activityStream.php', get_defined_vars());
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $projectId = $session->get('selected_project_id');
     $userId = $request->get('id');
     $loggedInUserId = $session->get('user/id');
     $user = $this->getRepository(UbirimiUser::class)->getById($userId);
     if ($user['client_id'] != $session->get('client/id')) {
         return new RedirectResponse('/general-settings/bad-link-access-denied');
     }
     $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($session->get('client/id'));
     $groups = $this->getRepository(UbirimiGroup::class)->getByUserIdAndProductId($userId, SystemProduct::SYS_PRODUCT_YONGO);
     $stats = $this->getRepository(IssueStatistic::class)->getUnresolvedIssuesByProjectForUser($userId);
     $hasAdministrationGlobalPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($session->get('client/id'), $userId, GlobalPermission::GLOBAL_PERMISSION_YONGO_ADMINISTRATORS);
     $hasSystemAdministrationGlobalPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($session->get('client/id'), $userId, GlobalPermission::GLOBAL_PERMISSION_YONGO_SYSTEM_ADMINISTRATORS);
     $projectsForBrowsing = $this->getRepository(UbirimiClient::class)->getProjectsByPermission($session->get('client/id'), $session->get('user/id'), Permission::PERM_BROWSE_PROJECTS, 'array');
     $projectIds = array();
     if ($projectsForBrowsing) {
         $projectIds = Util::array_column($projectsForBrowsing, 'id');
     }
     $menuSelectedCategory = 'user';
     $session->set('selected_product_id', SystemProduct::SYS_PRODUCT_YONGO);
     $hoursPerDay = $session->get('yongo/settings/time_tracking_hours_per_day');
     $daysPerWeek = $session->get('yongo/settings/time_tracking_days_per_week');
     $historyList = Util::getProjectHistory($projectIds, 0, $userId);
     $historyData = array();
     $userData = array();
     while ($historyList && ($history = $historyList->fetch_array(MYSQLI_ASSOC))) {
         $historyData[substr($history['date_created'], 0, 10)][$history['user_id']][$history['date_created']][] = $history;
         $userData[$history['user_id']] = array('picture' => $history['avatar_picture'], 'first_name' => $history['first_name'], 'last_name' => $history['last_name']);
     }
     $index = 0;
     $startDate = date_sub(new \DateTime(Util::getServerCurrentDateTime(), new \DateTimeZone($clientSettings['timezone'])), date_interval_create_from_date_string('1 months'));
     $sectionPageTitle = $session->get('client/settings/title_name') . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / User: '******'first_name'] . ' ' . $user['last_name'] . ' / Profile';
     return $this->render(__DIR__ . '/../../Resources/views/user/ViewSummary.php', get_defined_vars());
 }