/** * Prepare a feature to be edited * * @param Feature $model * @return */ public function prepareForEdit($model) { $project = $this->projectService->getProject((int) $this->_getParam('projectid', $model->projectid)); $parentFeature = $this->projectService->getFeature((int) $this->_getParam('parent')); if ($project == null) { $this->flash("Specified project not found"); $this->renderView('error.php'); return; } $this->view->project = $project; if ($parentFeature) { $this->view->parentfeature = $parentFeature->id; } if ($model->id) { $this->view->linkedToFeatures = $this->itemLinkService->getLinkedItems($model, 'from', 'Feature'); $this->view->linkedFromFeatures = $this->itemLinkService->getLinkedItems($model, 'to', 'Feature'); } else { $model->milestone = $this->_getParam('milestone'); } $this->view->projects = $this->projectService->getProjectsForClient($project->clientid); $this->view->projectFeatures = $this->featureService->getFeatures(array('projectid=' => $project->id)); $this->view->projectTasks = $this->projectService->getTasks(array('projectid=' => $project->id), 'title asc'); $this->view->priorities = array('Must Have', 'Should Have', 'Would Like', 'Nice To Have'); $this->view->statuses = $model->constraints['status']->getValues(); $this->view->linkedTasks = array(); if ($model->id) { $this->view->linkedTasks = $this->itemLinkService->getLinkedItemsOfType($model, 'from', 'Task'); } parent::prepareForEdit($model); }
public function editAction($model = null) { if ($this->_getParam('clientid')) { $this->view->client = $this->clientService->getClient($this->_getParam('clientid')); } else { $ownerId = za()->getConfig('owning_company'); $this->view->client = $this->clientService->getClient($ownerId); } $this->view->locations = $this->expenseService->getExpenseLocations(); $this->view->users = $this->userService->getUserList(); $this->view->defaultProjectid = za()->getConfig('default_expense_project'); $this->view->clients = $this->clientService->getClients(); $this->view->projects = new ArrayObject(); // Figure out the stuff for displaying the files if ($model == null) { if ((int) $this->_getParam('id')) { $this->view->model = $this->byId(); // $this->dbService->getById((int)$this->_getParam('id'), $modelType); $this->view->client = $this->clientService->getClient($this->view->model->clientid); } else { $this->view->model = new Expense(); } $this->view->files = array(); } else { $this->view->model = $model; $this->view->client = $this->clientService->getClient($this->view->model->clientid); } if ($this->view->client) { $this->view->projects = $this->projectService->getProjectsForClient($this->view->client); // get the support project at the very least if (!$this->view->defaultProjectid) { $project = $this->clientService->getClientSupportProject($this->view->client); $this->view->defaultProjectid = $project->id; } } $this->view->categories = $this->view->model->constraints['atocategory']->getValues(); $this->view->expenseTypes = $this->view->model->constraints['expensetype']->getValues(); $this->view->expenseCategories = $this->view->model->constraints['expensecategory']->getValues(); if ($this->view->model->id) { $this->view->files = $this->expenseService->getExpenseFiles($this->view->model); $path = 'Expenses/' . $this->view->model->id; $this->view->filePath = $path; } $this->renderView('expense/edit.php'); }
/** * Loads up a project select HTML control that can be ajaxed in * to replace any existing one. */ public function projectselectorAction() { $clientid = (int) $this->_getParam('clientid'); $this->view->fieldName = $this->_getParam('fieldName'); $this->view->selectorType = $this->_getParam('selectorType', 'any'); $this->view->empty = $this->_getParam('empty', 0); $this->view->projects = $this->projectService->getProjectsForClient($clientid); $this->renderRawView('project/project-selector.php'); $this->view->showMilestones = $this->_getParam('showMilestones'); }
/** * Need an ajax action for the new task form because we can't have it * nested inside a dialog that gets hidden before it becomes a form * in its own right... * */ public function linkedtaskformAction() { $this->view->model = $this->byId($this->_getParam('id'), $this->_getParam('type')); if (isset($this->view->model->projectid)) { $project = $this->projectService->getProject($this->view->model->projectid); $this->view->projects = $this->projectService->getProjectsForClient($project->clientid); } if (isset($this->view->model->milestone)) { $this->view->defaultmilestone = $this->view->model->milestone; } else { $this->view->defaultmilestone = $this->findPossibleParentForTaskAgainst(get_class($this->view->model), $this->view->model->id); } $this->renderRawView('task/linkedtaskform.php'); }
/** * Override the edit action to supply some selectable relationships * * @param MappedObject $model */ public function prepareForEdit($model = null) { if ($this->view->model == null) { $this->flash("Invalid request specified"); $this->redirect('error'); return; } $this->view->issueHistory = $this->issueService->getIssueHistory($this->view->model); $pid = (int) $this->_getParam('projectid'); $cid = (int) $this->_getParam('clientid'); if ($this->view->model->projectid) { $pid = $this->view->model->projectid; } if ($this->view->model->clientid) { $cid = $this->view->model->clientid; } // Which one? if ($pid) { $this->view->project = $this->projectService->getProject($pid); $this->view->client = $this->clientService->getClient($this->view->project->clientid); // figure out the releases available for this project $this->view->releases = $this->issueService->getProjectReleases($this->view->project); } else { if ($cid) { $this->view->client = $this->clientService->getClient($cid); $this->view->releases = array(); } } if ($this->view->client != null) { $this->view->categories = $this->issueService->getIssueCategoriesForCompany($this->view->client); } else { $this->view->categories = array(); } // if it's a new issue, and it's a normal user set it to be private by default // User can always specify a different one though if (!$this->view->model->id && za()->getUser()->hasRole(User::ROLE_USER)) { $this->view->model->isprivate = true; } $this->view->users = $this->userService->getUserList(); $this->view->severities = $this->view->model->constraints['severity']->getValues(); $this->view->types = $this->view->model->constraints['issuetype']->getValues(); $this->view->statuses = $this->view->model->constraints['status']->getValues(); if ($this->view->model->id) { $this->view->notes = $this->notificationService->getNotesFor($this->view->model); $this->view->existingWatch = $this->notificationService->getWatch(za()->getUser(), $this->view->model->id, 'Issue'); $this->view->userStatuses = $this->view->model->getUserStatuses(); $clientUsers = $this->userService->getUsersForClient($this->view->model->clientid); foreach ($this->view->users as $user) { $clientUsers->append($user); } $this->view->allUsers = $clientUsers; $this->view->subscribers = $this->notificationService->getSubscribers($this->view->model->id, 'Issue'); $this->view->project = $this->projectService->getProject($this->view->model->projectid); $this->view->client = $this->clientService->getClient($this->view->model->clientid); $this->view->files = $this->issueService->getIssueFiles($this->view->model); $path = 'Clients/' . $this->view->client->title . '/Issues/' . $this->view->model->id; $this->view->filePath = $path; // Get all the features for this project $this->view->projectFeatures = $this->featureService->getFeatures(array('projectid=' => $this->view->model->projectid)); $this->view->projectTasks = $this->projectService->getTasks(array('projectid=' => $this->view->project->id), 'title asc'); $this->view->linkedTasks = $this->itemLinkService->getLinkedItems($this->view->model, 'from', 'Task'); $this->view->linkedToFeatures = $this->itemLinkService->getLinkedItems($this->view->model, 'from', 'Feature'); $this->view->linkedFromFeatures = $this->itemLinkService->getLinkedItems($this->view->model, 'to', 'Feature'); } $this->view->clients = $this->clientService->getClients(); if ($this->view->client) { $this->view->projects = $this->projectService->getProjectsForClient($this->view->client->id); } }