Example #1
0
 /**
  * Get the items that need to appear in the project listing
  */
 public function projectlistAction()
 {
     // $project = $this->projectService->getProject((int) $this->_getParam('projectid'));
     $project = $this->projectService->getProject((int) $this->_getParam('projectid'));
     $this->view->invoices = $this->dbService->getObjects('Invoice', array('projectid=' => $project->id));
     $this->view->model = $project;
     $this->renderRawView('invoice/ajax-invoice-list.php');
 }
Example #2
0
 /**
  * Notify the relevant people of a new issue
  *
  * @param unknown_type $issue
  */
 private function notifyOfNewIssue($issue)
 {
     // get the group assigned to the project that this issue is against
     $project = $this->projectService->getProject($issue->projectid);
     $group = $this->groupService->getGroup($project->ownerid);
     // Only send if the group exists
     if ($group) {
         $users = $this->groupService->getUsersInGroup($group);
         $msg = new TemplatedMessage('new-issue.php', array('model' => $issue, 'project' => $project));
         $this->notificationService->notifyUser("New request has been created", $users, $msg);
     }
     // if the new issue is a severity 1, then sms as well
     if ($issue->severity == Issue::SEVERITY_ONE) {
         $this->trackerService->track('sev1request', 'request-' . $issue->id);
         $user = $this->userService->getUserByField('username', $issue->userid);
         if ($user != null && $user->contactid) {
             $contactDetails = $this->clientService->getContact($user->contactid);
             if ($contactDetails && mb_strlen($contactDetails->mobile)) {
                 // lets send a quick SMS
                 if ($this->smsService->send("New Severity 1 request #" . $issue->id . ": " . $issue->title . ", please login and check ASAP!", $contactDetails->mobile)) {
                     $this->trackerService->track('sendsms', 'request-' . $issue->id);
                 }
             }
         }
     }
 }
Example #3
0
 protected function findPossibleParentForTaskAgainst($type, $id)
 {
     switch ($type) {
         case 'Issue':
             $context = $this->byId($id, 'Issue');
             // get its project, then a milestone in that project
             $project = $this->projectService->getProject($context->projectid);
             $possibles = $project->getMilestones();
             if (!count($possibles)) {
                 $milestone = $project->createDefaultMilestone();
                 return $milestone->id;
             } else {
                 $milestone = $possibles->getIterator()->current();
                 return $milestone->id;
             }
             break;
         case 'Feature':
             $context = $this->byId($id, 'Feature');
             // get its project, then a milestone in that project
             if ($context->milestone) {
                 return $context->milestone;
             } else {
                 $project = $context->projectid;
                 $possibles = $project->getMilestones();
                 if (!count($possibles)) {
                     $milestone = $project->createDefaultMilestone();
                     return $milestone->id;
                 } else {
                     $milestone = $possibles->getIterator()->current();
                     return $milestone->id;
                 }
             }
             break;
     }
 }
Example #4
0
 /**
  * Get the detailed timesheet for this project.
  *
  */
 public function detailedtimesheetAction()
 {
     $project = $this->projectService->getProject($this->_getParam('projectid'));
     $client = $this->clientService->getClient($this->_getParam('clientid'));
     $task = $this->projectService->getTask($this->_getParam('taskid'));
     $user = $this->userService->getUserByField('username', $this->_getParam('username'));
     if (!$project && !$client && !$task && !$user) {
         return;
     }
     if ($task) {
         $this->view->records = $this->projectService->getDetailedTimesheet(null, $task->id);
     } else {
         if ($project) {
             $start = null;
             $this->view->records = $this->projectService->getDetailedTimesheet(null, null, $project->id);
         } else {
             if ($client) {
                 $start = null;
                 $this->view->records = $this->projectService->getDetailedTimesheet(null, null, null, $client->id);
             } else {
                 if ($user) {
                     $this->view->records = $this->projectService->getDetailedTimesheet($user);
                 }
             }
         }
     }
     $this->view->task = $task;
     $this->renderRawView('timesheet/ajax-timesheet-details.php');
 }
Example #5
0
 /**
  * Get the items that need to appear in the project listing
  */
 public function projectlistAction()
 {
     $project = $this->projectService->getProject((int) $this->_getParam('projectid'));
     $where = array('projectid=' => $project->id);
     $this->bindIssueListViewData($where);
     $this->view->model = $project;
     $this->view->attachedToType = 'projectid';
     $this->view->minimal = true;
     $this->renderRawView('issue/list.php');
     //ajax-issue-list.php');
 }
Example #6
0
 /**
  * Used for ordering features within the context of their siblings
  *
  */
 public function orderfeaturesAction()
 {
     $feature = $this->byId();
     $project = null;
     if ($this->_getParam('projectid')) {
         $project = $this->projectService->getProject($this->_getParam('projectid'));
     }
     if (!$project && $feature) {
         $project = $this->projectService->getProject($feature->projectid);
     }
     if (!$project) {
         $this->flash("Cannot find valid project");
         return;
     }
     $features = $this->featureService->getOrderedFeatures($feature, $project);
     $this->view->features = $features;
     $this->renderView('feature/order.php');
 }
Example #7
0
 public function projectgroupAction()
 {
     $project = $this->projectService->getProject((int) $this->_getParam('id'));
     if ($project == null) {
         $this->flash("Project not found");
         $this->renderView('error.php');
         return;
     }
     $group = $this->groupService->getGroup($project->ownerid);
     if ($group == null) {
         throw new Exception("Invalid group #{$group->ownerid}");
     }
     $users = $this->groupService->getUsersInGroup($group, true);
     $groupUsers = new ArrayObject();
     foreach ($users as $user) {
         $groupUsers[$user->id] = $user;
     }
     $this->view->groupusers = $groupUsers;
     $this->view->users = $this->userService->getUserList();
     $this->view->group = $group;
     $this->view->model = $project;
     $this->renderRawView('project/group-list.php');
 }
Example #8
0
 /**
  * Get the task that represents the leave for a given leave application
  * and add some time to it for the given application
  */
 public function applyTimeForLeave(LeaveApplication $leaveApplication)
 {
     $project = $this->projectService->getProject(za()->getConfig('leave_project'));
     if (!$project) {
         throw new Exception("Leave project not set correctly in configuration");
     }
     $monthYear = date('F Y', strtotime($leaveApplication->to));
     $params = array('parentid=' => $project->id, 'title=' => $monthYear);
     // get the appropriate milestone
     $projs = $this->projectService->getProjects($params);
     $milestone = null;
     if (count($projs)) {
         $milestone = $projs[0];
     } else {
         // create a new milestone
         // $milestone
         $date = date('Y-m-t', strtotime($leaveApplication->to)) . ' 23:59:59';
         $milestone = $this->projectService->createMilestone($project, $monthYear, $date);
     }
     // now get the task for the given leave app
     $taskTitle = $leaveApplication->leavetype . ' Leave #' . $leaveApplication->id . ': ' . $leaveApplication->username . ' ' . date('Y-m-d', strtotime($leaveApplication->from)) . ' - ' . date('Y-m-d', strtotime($leaveApplication->to));
     $params = array('projectid=' => $milestone->id, 'title=' => $taskTitle);
     $tasks = $this->projectService->getTasks($params);
     $user = $this->getUserByField('username', $leaveApplication->username);
     $task = null;
     if (count($tasks)) {
         $task = $tasks[0];
         // delete all timesheet entries for this user on this task
         $records = $this->projectService->getDetailedTimesheet($user, $task->id);
         foreach ($records as $record) {
             $this->projectService->removeTimesheetRecord($record);
         }
     } else {
         // create the new task
         $task = new Task();
         za()->inject($task);
         $task->title = $taskTitle;
         $task->projectid = $milestone->id;
         $task->category = 'Leave';
         $task->due = $leaveApplication->to;
         $task->description = $leaveApplication->reason;
         $task->estimated = za()->getConfig('day_length') * $leaveApplication->days;
         $task->complete = 1;
         $task = $this->projectService->saveTask($task);
     }
     if ($task != null) {
         // now add all the timesheet entries for each given day
         $startTime = strtotime(date('Y-m-d', strtotime($leaveApplication->from)) . ' 09:00:00');
         // now go through and add time for the given day
         for ($i = 0; $i < $leaveApplication->days; $i++) {
             // see if today's a weekend, if so we want to skip til the next monday
             $curDay = date('D', $startTime);
             if ($curDay == 'Sat') {
                 $startTime += 2 * 86400;
             } else {
                 if ($curDay == 'Sun') {
                     $startTime += 86400;
                 }
             }
             $endTime = $startTime + za()->getConfig('day_length') * 3600;
             $this->projectService->addTimesheetRecord($task, $user, $startTime, $endTime);
             $startTime += 86400;
         }
     }
 }