예제 #1
0
 /**
  * Get a bunch of data prepared for the view
  */
 protected function prepareForEdit()
 {
     if ($this->view->model == null) {
         throw new Exception("Task not found!");
     }
     // check the existence of the client to add this contact to
     $pid = (int) $this->_getParam('projectid') ? (int) $this->_getParam('projectid') : $this->view->model->projectid;
     $project = new Project();
     if ($pid) {
         $project = $this->projectService->getProject($pid);
     }
     $this->view->project = $project;
     $this->view->projectUsers = $this->projectService->getProjectUsers($project);
     $this->view->activeTasks = array();
     if ($project->id) {
         $this->view->projects = $this->projectService->getProjectsForClient($project->clientid);
         $this->view->activeTasks = $this->projectService->getActiveProjectTasks($project);
     } else {
         $this->view->projects = new ArrayObject();
     }
     $this->view->categories = $this->view->model->constraints['category']->getValues();
     $this->view->clients = $this->clientService->getClients();
     $this->view->model->tags = "";
     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, 'Task');
         $this->view->allUsers = $this->userService->getUserList();
         $this->view->subscribers = $this->notificationService->getSubscribers($this->view->model->id, 'Task');
         $tags = $this->tagService->getItemTags($this->view->model);
         $tagStr = "";
         $sep = "";
         foreach ($tags as $tag) {
             $tagStr .= $sep . $tag->tag;
             $sep = ',';
         }
         $this->view->model->tags = $tagStr;
         // get all the issues that triggered this task
         $this->view->issues = $this->itemLinkService->getLinkedItemsOfType($this->view->model, 'to', 'Issue');
         $this->view->features = $this->itemLinkService->getLinkedItemsOfType($this->view->model, 'to', 'Feature');
         // get selectable features based on the milestont this project is in.
         $this->view->selectableFeatures = $project->getFeatures();
         $client = $this->clientService->getClient($project->clientid);
         // get all the requests for the given client
         $this->view->selectableRequests = $client->getIssues();
     }
 }
예제 #2
0
 public function prepareForEdit($model)
 {
     // check the existence of the client to add this contact to
     $cid = $model->clientid ? $model->clientid : (int) $this->_getParam('clientid');
     $client = $this->clientService->getClient($cid);
     if ($client == null) {
         $this->flash("Client not found, please update!");
         $client = new Client();
     }
     $this->view->title = "Editing Contact";
     $this->view->client = $client;
     $this->view->clients = $this->clientService->getClients();
     $this->view->assocUser = null;
     if ($model->id) {
         $this->view->assocUser = $this->userService->getUserbyField('contactid', $model->id);
     }
 }
예제 #3
0
 /**
  * Prepare a contact for being edited. 
  */
 public function prepareForEdit($model)
 {
     if ($model == null) {
         $this->error("Specified contact not found");
         return;
     }
     // check the existence of the client to add this contact to
     $cid = $model->clientid ? $model->clientid : (int) $this->_getParam('clientid');
     $client = $this->clientService->getClient($cid);
     if ($client == null) {
         $this->error("Specified contact not found");
         return;
     }
     $this->view->title = "Editing Contact";
     $this->view->client = $client;
     $this->view->clients = $this->clientService->getClients();
     $this->view->assocUser = $this->userService->getUserbyField('contactid', $model->id);
 }
예제 #4
0
 /**
  * Present a filter form to select timesheets
  */
 public function filtersummaryAction()
 {
     /*
      * form needs to include:
      * 
      * user id
      * task category
      * client id
      * project id
      * start date
      * end date
      */
     $this->view->allUsers = $this->userService->getUserList();
     $task = new Task();
     $this->view->categories = $task->constraints['category']->getValues();
     $this->view->clients = $this->clientService->getClients();
     $this->view->projects = new ArrayObject();
     $this->renderView('timesheet/filterSummary.php');
 }
예제 #5
0
 /**
  * Give an a-z listing of clients
  */
 public function indexAction()
 {
     $this->view->clientPagerName = 'client-page';
     $this->view->relationship = $this->_getParam('relation', 'Customer');
     $this->view->clientLetters = $this->clientService->getClientTitleLetters($this->view->relationship);
     $currentLetter = ifset($this->_getAllParams(), $this->view->clientPagerName, ifset($this->view->clientLetters, 0, 'A'));
     $obj = new Client();
     $this->view->relationships = $obj->constraints['relationship']->getValues();
     if ($this->view->relationship == "ALL") {
         $this->view->clients = $this->clientService->getClients(array('title like ' => $currentLetter . '%'), 'title asc');
         // , $currentPage, za()->getConfig('project_list_size'));
     } else {
         $this->view->clients = $this->clientService->getClients(array('relationship=' => $this->view->relationship, 'title like ' => $currentLetter . '%'), 'title asc');
         // , $currentPage, za()->getConfig('project_list_size'));
     }
     if ($this->_getParam('_ajax')) {
         $this->renderRawView('client/list.php');
     } else {
         $this->renderView('client/list.php');
     }
 }
예제 #6
0
 /**
  * Override the edit action to supply some selectable relationships
  *
  * @param MappedObject $model
  */
 protected function prepareForEdit($model = null)
 {
     $clientid = $model && $model->clientid ? $model->clientid : (int) $this->_getParam('clientid');
     // check the existence of the client to add this contact to
     $client = $clientid ? $this->clientService->getClient($clientid) : null;
     // check the existence of the client to add this contact to
     $this->view->owners = $this->groupService->getGroups();
     $this->view->users = $this->userService->getUserList();
     $this->view->client = $client;
     $this->view->clients = $this->clientService->getClients();
     $this->view->projects = $clientid ? $this->projectService->getProjectsForClient($client) : array();
     parent::prepareForEdit($model);
 }
예제 #7
0
 /**
  * Edit an expense report
  */
 public function editreportAction($model = null)
 {
     $cid = $this->_getParam('clientid');
     $client = null;
     if ($cid) {
         $client = $this->byId($cid, 'Client');
     }
     $user = $this->userService->getUserByField('username', $this->_getParam('username'));
     if (!$user && !$client) {
         throw new Exception("Must specify a client or user");
     }
     $this->view->expenses = array();
     if ($client) {
         $this->view->client = $client;
         $this->view->projects = $this->projectService->getProjects(array('clientid=' => $cid));
     } else {
         $this->view->client = new Client();
         $this->view->projects = array();
     }
     if ($user) {
         $this->view->user = $user;
     } else {
         $this->view->user = new CrmUser();
     }
     if ($model == null) {
         if ((int) $this->_getParam('id')) {
             $this->view->model = $this->byId(null, 'ExpenseReport');
             //  $this->dbService->getById((int)$this->_getParam('id'), $modelType);
             if ($client) {
                 $this->view->expenses = $this->expenseService->getExpenses(array('expensereportid=' => $this->view->model->id));
             } else {
                 $this->view->expenses = $this->expenseService->getExpenses(array('userreportid=' => $this->view->model->id));
             }
         } else {
             $this->view->model = new ExpenseReport();
         }
     } else {
         $this->view->model = $model;
     }
     $this->view->clients = $this->clientService->getClients();
     $this->view->users = $this->userService->getUserList();
     $this->renderView('expense/editreport.php');
 }
예제 #8
0
 /**
  * Generates the appropriate query for returning a list of issues
  *
  * @param array $where
  * @return arrayobject
  */
 protected function getIssueList($where = array())
 {
     $sortDir = $this->_getParam('sortorder', $this->_getParam('dir', 'desc'));
     if ($sortDir == 'up' || $sortDir == 'asc') {
         $sortDir = 'asc';
         $issueParams = array('dir' => 'up');
     } else {
         $sortDir = 'desc';
         $issueParams = array('dir' => 'down');
     }
     $mineOnly = $this->_getParam('mineOnly');
     if ($mineOnly) {
         $where['issue.userid='] = za()->getUser()->getUsername();
         $issueParams['mineOnly'] = $mineOnly;
     }
     $query = $this->_getParam('query');
     if (mb_strlen($query) >= 2) {
         $where[] = new Zend_Db_Expr("issue.title like " . $this->issueService->dbService->quote('%' . $query . '%') . " OR issue.description like " . $this->issueService->dbService->quote('%' . $query . '%'));
     }
     $filter = $this->_getParam('titletext');
     if (mb_strlen($filter) >= 2) {
         // add some filtering to the query
         $where['issue.title like '] = '%' . $filter . '%';
         $issueParams['titletext'] = $filter;
     }
     $filter = $this->_getParam('severity');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.severity = '] = $filter;
         $issueParams['severity'] = $filter;
     }
     $filter = $this->_getParam('status');
     if ($filter !== null && !is_array($filter) && strlen($filter)) {
         $filter = array($filter);
         $issueParams['status'] = $filter;
     }
     if (is_array($filter)) {
         $where['status'] = $filter;
         $issueParams['status'] = $filter;
     }
     $filter = $this->_getParam('type');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.issuetype = '] = $filter;
         $issueParams['type'] = $filter;
     }
     $filter = $this->_getParam('clientid');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.clientid = '] = $filter;
         $issueParams['clientid'] = $filter;
     }
     $filter = $this->_getParam('projectid');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.projectid = '] = $filter;
         $issueParams['projectid'] = $filter;
     }
     $filter = $this->_getParam('startdate');
     if (mb_strlen($filter)) {
         $where['issue.updated >= '] = date('Y-m-d 00:00:00', strtotime($filter));
         $issueParams['startdate'] = $filter;
     }
     $filter = $this->_getParam('enddate');
     if (mb_strlen($filter)) {
         $where['issue.updated <= '] = date('Y-m-d 23:59:59', strtotime($filter));
         $issueParams['enddate'] = $filter;
     }
     // If not a User, can only see non-private issues
     if (!za()->getUser()->hasRole(User::ROLE_USER)) {
         $where['issue.isprivate='] = 0;
     }
     $sort = $this->_getParam('sortname', $this->_getParam('sort', 'updated'));
     $this->view->sort = $sort;
     $issueParams['sort'] = $sort;
     $this->view->sortDir = $sortDir;
     $tmp = new Issue();
     $this->view->severities = $tmp->constraints['severity']->getValues();
     $this->view->types = $tmp->constraints['issuetype']->getValues();
     $this->view->statuses = $tmp->constraints['status']->getValues();
     $sort .= ' ' . $sortDir;
     $totalCount = $this->issueService->getIssueCount($where);
     $this->view->pagerName = 'page';
     $currentPage = ifset($this->_getAllParams(), $this->view->pagerName, 1);
     $this->view->clients = $this->clientService->getClients();
     $this->view->totalCount = $totalCount;
     $this->view->listSize = $this->_getParam('rp', za()->getConfig('project_list_size', 10));
     if ($this->_getParam("unlimited")) {
         $currentPage = null;
     }
     $this->view->searchParams = $issueParams;
     return $this->issueService->getIssues($where, $sort, $currentPage, $this->view->listSize);
 }