示例#1
0
 /**
  * @Route("/ajaxGetAssignTask", name="_ajaxGetAssignTask")
  */
 public function ajaxGetAssignTaskAction()
 {
     if ($this->getRequest()->getMethod() == 'POST') {
         $requestData = $this->getRequest()->request;
         $page = $requestData->get('page');
         $project_id = $requestData->get('project_id');
         $repository = $this->getDoctrine()->getRepository('TrackersBundle:Project_task');
         $tasksAll = $repository->findBy(array('projectId' => $project_id, 'status' => 'CLOSED'), array('created' => 'DESC'));
         $limit = $this->container->getParameter('limit_comment_issues');
         $offset = $page * $limit;
         $total = (int) (count($tasksAll) / $limit);
         $count = count($tasksAll);
         if ($count > $limit && $count % $limit != 0) {
             $total = $total + 1;
         }
         $pagination = new Pagination();
         $paginations = $pagination->render($page, $total, 'loadAssignTask');
         $em = $this->container->get('doctrine')->getManager();
         $query = $em->createQuery("SELECT t, u.firstname , u.lastname , u.avatar  FROM TrackersBundle:Project_task t , TrackersBundle:UserDetail u , TrackersBundle:UserTask as ut  WHERE ut.taskId = t.id AND  t.createdBy = u.user_id AND t.projectId =:projectId  AND ut.userId =:userId  ORDER BY t.created DESC ")->setMaxResults($limit)->setFirstResult($offset)->setParameter('userId', $this->getUser()->getId())->setParameter('projectId', $project_id);
         $tasks = $query->getResult();
         $arr_tasks = array();
         foreach ($tasks as $task) {
             $arr_tasks[] = array('id' => $task[0]->getId(), 'title' => $task[0]->getTitle(), 'created' => $task[0]->getCreated(), 'fullName' => $task['firstname'] . ' ' . $task['lastname']);
         }
         $template = $this->render('TrackersBundle:Task:ajaxCompleteTask.html.twig', array('tasks' => $arr_tasks, 'paginations' => $paginations, 'project_id' => $project_id));
         return new Response($template->getContent());
         die;
     }
     die;
 }
 /**
  * @Route("/ajaxGetCommentTask", name="_ajaxGetCommentTask")
  */
 public function ajaxGetCommentTaskAction()
 {
     if ($this->getRequest()->getMethod() == 'POST') {
         $requestData = $this->getRequest()->request;
         $page = $requestData->get('page');
         $task_id = $requestData->get('task_id');
         $arr_comments = array();
         $repository = $this->getDoctrine()->getRepository('TrackersBundle:Project_Task_Comments');
         $tasksAll = $repository->findBy(array('taskId' => $task_id));
         $limit = $this->container->getParameter('limit_comment_issues');
         $offset = $page * $limit;
         $total = (int) (count($tasksAll) / $limit);
         $count = count($tasksAll);
         if ($count > $limit && $count % $limit != 0) {
             $total = $total + 1;
         }
         $pagination = new Pagination();
         $paginations = $pagination->render($page, $total, 'loadcomments');
         $em = $this->container->get('doctrine')->getManager();
         $query = $em->createQuery("SELECT t, u.firstname , u.lastname , u.avatar  FROM TrackersBundle:Project_Task_Comments t , TrackersBundle:UserDetail u  WHERE  t.createdBy = u.user_id AND t.taskId =:taskId   ORDER BY t.createdAt DESC ")->setMaxResults($limit)->setFirstResult($offset)->setParameter('taskId', $task_id);
         $tasks = $query->getResult();
         foreach ($tasks as $task) {
             // is avatar
             if ($task['avatar'] != '') {
                 if (file_exists($this->get('kernel')->getRootDir() . '/../web' . $task['avatar'])) {
                     $is_avatar = true;
                 } else {
                     $is_avatar = false;
                 }
             } else {
                 $is_avatar = false;
             }
             if ($this->getUser()->getId() == $task[0]->getCreatedBy()) {
                 $is_role = true;
             } else {
                 $is_role = false;
             }
             $repository_comment = $this->getDoctrine()->getRepository('TrackersBundle:Project_Task_Attachments');
             $file_attach = $repository_comment->findBy(array('commentId' => $task[0]->getId()));
             $arr_comments[] = array('fullName' => $task['firstname'] . ' ' . $task['lastname'], 'avatar' => $task['avatar'], 'is_avatar' => $is_avatar, 'id' => $task[0]->getId(), 'comment' => $task[0]->getComment(), 'createdAt' => $task[0]->getCreatedAt(), 'is_role' => $is_role, 'attachments' => $file_attach);
         }
         $template = $this->render('TrackersBundle:Task:ajaxGetCommentTask.html.twig', array('tasks' => $arr_comments, 'task_id' => $task_id, 'page' => $page, 'paginations' => $paginations, 'user_id' => $this->getUser()->getId()));
         return new Response($template->getContent());
         die;
     }
     die('Error...');
 }
示例#3
0
 /**
  * @Route("/ajax_message", name="_ajax_message")
  */
 public function ajaxMessageAction()
 {
     $requestData = $this->getRequest()->request;
     $page = $requestData->get('page');
     $repository = $this->getDoctrine()->getRepository('TrackersBundle:Notifications');
     $limit = 50;
     $offset = $page * $limit;
     $total = (int) (count($repository->findBy(array('userId' => $this->getUser()->getId()), array('created' => 'DESC'))) / $limit);
     $count = count($repository->findBy(array('userId' => $this->getUser()->getId()), array('created' => 'DESC')));
     if ($count > $limit && $count % $limit != 0) {
         $total = $total + 1;
     }
     $pagination = new Pagination();
     $paginations = $pagination->render($page, $total, 'loadMessage');
     $notifications = $repository->findBy(array('userId' => $this->getUser()->getId()), array('created' => 'DESC', 'isRead' => 'ASC'), $limit, $offset);
     $template = $this->render('TrackersBundle:Dashboard:ajax_notifications_page.html.twig', array('notifications' => $notifications, 'paginations' => $paginations));
     return new Response($template->getContent());
     die;
 }
示例#4
0
 /**
  * @Route("/ajax_list_assigned_issues", name="_ajaxListAssignedIssues")
  */
 public function ajaxAssignedIssuesAction()
 {
     $requestData = $this->getRequest()->request;
     $page = $requestData->get('page');
     $project_id = $requestData->get('project_id');
     // get uer_id project assign
     $em = $this->container->get('doctrine')->getManager();
     $query = $em->createQuery("SELECT p FROM TrackersBundle:Project_issues p , TrackersBundle:Project_issue_assignments pm  WHERE  p.projectId =:projectId AND  p.id = pm.issueId AND pm.userId =:userId   ORDER BY p.created DESC ")->setParameter('projectId', $project_id)->setParameter('userId', $this->getUser()->getId());
     $project_issues = $query->getResult();
     $limit = $this->container->getParameter('limit_open_issues');
     $offset = $page * $limit;
     $total = (int) (count($project_issues) / $limit);
     $count = count($project_issues) / $limit;
     if ($count > $limit && $count % $limit != 0) {
         $total = $total + 1;
     }
     $pagination = new Pagination();
     $paginations = $pagination->render($page, $total, 'load_assigned');
     $query = $em->createQuery("SELECT p FROM TrackersBundle:Project_issues p , TrackersBundle:Project_issue_assignments pm  WHERE p.projectId =:projectId AND p.id = pm.issueId AND pm.userId =:userId   ORDER BY p.created DESC ")->setMaxResults($limit)->setFirstResult($offset)->setParameter('projectId', $project_id)->setParameter('userId', $this->getUser()->getId());
     $issues = $query->getResult();
     $repository_user = $this->getDoctrine()->getRepository('TrackersBundle:UserDetail');
     $arr = array();
     foreach ($issues as $issue) {
         $user = $repository_user->findBy(array('user_id' => $issue->getCreatedBy()));
         $arr[] = array('id' => $issue->getId(), 'title' => $issue->getTitle(), 'created' => $issue->getCreated(), 'users' => $user);
     }
     $template = $this->render('TrackersBundle:Issues:ajax_assigned.html.twig', array('issues' => $arr, 'paginations' => $paginations, 'project_id' => $project_id));
     return new Response($template->getContent());
     die;
 }
 /**
  * @Route("/ajaxgetcomment", name="_ajaxgetcomment")
  */
 public function ajaxGetCommentAction()
 {
     $requestData = $this->getRequest()->request;
     $issueId = $requestData->get('issueId');
     $project_id = $requestData->get('project_id');
     $page = $requestData->get('page');
     $repository_project_issues = $this->getDoctrine()->getRepository('TrackersBundle:Project_issues');
     $issue = $repository_project_issues->find($issueId);
     $arr_comments = array();
     $repository_comment = $this->getDoctrine()->getRepository('TrackersBundle:Projects_issues_comments');
     $limit = $this->container->getParameter('limit_comment_issues');
     $offset = $page * $limit;
     $total = (int) (count($repository_comment->findBy(array('issueId' => $issueId), array('createdAt' => 'DESC'))) / $limit);
     $count = count($repository_comment->findBy(array('issueId' => $issueId), array('createdAt' => 'DESC')));
     if ($count > $limit && $count % $limit != 0) {
         $total = $total + 1;
     }
     $pagination = new Pagination();
     $paginations = $pagination->render($page, $total, 'loadcomments');
     $comments = $repository_comment->findBy(array('issueId' => $issueId), array('createdAt' => 'DESC'), $limit, $offset);
     $repository_user = $this->getDoctrine()->getRepository('TrackersBundle:UserDetail');
     foreach ($comments as $comment) {
         $repository_attachments = $this->getDoctrine()->getRepository('TrackersBundle:Projects_issues_attachments');
         $attachments = $repository_attachments->findBy(array('commentId' => $comment->getId()), array('createdAt' => 'ASC'));
         $users_comment = $repository_user->findBy(array('user_id' => $comment->getCreatedBy()));
         $is_update = false;
         if ($comment->getCreatedBy() == $this->getUser()->getId()) {
             $is_update = true;
         }
         if (!empty($users_comment) && $users_comment[0]->getAvatar() != '') {
             if (file_exists($this->get('kernel')->getRootDir() . '/../web' . $users_comment[0]->getAvatar())) {
                 $is_avatar = true;
             } else {
                 $is_avatar = false;
             }
         } else {
             $is_avatar = false;
         }
         if ($issue->getStatus() == 'CLOSED') {
             $is_update = false;
         }
         $arr_comments[] = array('fullname' => $users_comment[0]->getFirstname() . " " . $users_comment[0]->getLastname(), 'created_at' => $comment->getCreatedAt(), 'comment' => $comment->getComment(), 'id' => $comment->getId(), 'attachments' => $attachments, 'id_update' => $is_update, 'is_avatar' => $is_avatar, 'avatar' => $users_comment[0]->getAvatar());
     }
     $repository_Closed_Issues = $this->getDoctrine()->getRepository('TrackersBundle:Project_Closed_Issues');
     $Closed_Issues = $repository_Closed_Issues->findBy(array('userId' => $this->getUser()->getId(), 'issueId' => $issueId));
     $array_date = array();
     $repository_user = $this->getDoctrine()->getRepository('TrackersBundle:UserDetail');
     foreach ($Closed_Issues as $closed) {
         $users = $repository_user->findBy(array('user_id' => $issue->getCreatedBy()));
         $date1 = $closed->getStartDate();
         $date2 = $closed->getEndDate();
         $diff = $date2->diff($date1);
         if ($diff->format('%i') > 0) {
             $h = $diff->format('%d') * 24 + $diff->format('%h') . " hours " . $diff->format('%i') . " minute";
         } else {
             $h = $diff->format('%d') * 24 + $diff->format('%h') . " hours ";
         }
         $array_date[] = array('full_name' => $users[0]->getFirstname() . " " . $users[0]->getLastname(), 'start_date' => $closed->getStartDate(), 'end_date' => $closed->getEndDate(), 'total_time' => $h);
     }
     $template = $this->render('TrackersBundle:Comments:ajax_getcomment.html.twig', array('comments' => $arr_comments, 'issueId' => $issueId, 'project_id' => $project_id, 'paginations' => $paginations, 'page' => $page, 'status_issue' => $issue->getStatus(), 'completes' => $array_date));
     return new Response($template->getContent());
     exit;
 }
示例#6
0
 /**
  * @Route("/ajax_project", name="_ajaxlistProjects")
  */
 public function ajaxProjectAction()
 {
     $requestData = $this->getRequest()->request;
     $page = $requestData->get('page');
     $em = $this->getDoctrine()->getEntityManager();
     $limit = $this->container->getParameter('limit_project');
     $offset = $page * $limit;
     $query = $em->createQuery("SELECT p FROM TrackersBundle:Projects p WHERE  p.owner_id = :user_id OR p.id IN ( SELECT up.projectId FROM TrackersBundle:Project_issues up WHERE up.assignedTo = :assigned_to ) ORDER BY p.created ")->setParameter('user_id', $this->getUser()->getId())->setParameter('assigned_to', $this->getUser()->getId());
     $total = (int) round(count($query->getResult()) / $limit);
     $count = count($query->getResult());
     if ($count > $limit && $count % $limit != 0) {
         $total = $total + 1;
     }
     $query = $em->createQuery("SELECT p FROM TrackersBundle:Projects p WHERE  p.owner_id = :user_id OR p.id IN ( SELECT up.projectId FROM TrackersBundle:Project_issues up WHERE up.assignedTo = :assigned_to)  ORDER BY p.created")->setParameter('user_id', $this->getUser()->getId())->setMaxResults($limit)->setFirstResult($offset)->setParameter('assigned_to', $this->getUser()->getId());
     $projects = $query->getResult();
     $pagination = new Pagination();
     $paginations = $pagination->render($page, $total, 'list_projects');
     echo $this->render('TrackersBundle:Projects:ajax_list.html.twig', array('projects' => $projects, 'paginations' => $paginations, 'user_id' => $this->getUser()->getId()));
     die;
 }