/** * Get the tags for a given item */ public function getItemTags($item) { $type = mb_strtolower(get_class($item)); $id = (int) $item->id; $tags = $this->dbService->getObjects('Tag', array('itemtype=' => $type, 'itemid=' => $id)); return $tags; }
public function indexAction() { $user = za()->getUser(); // If it's an external user, redirect to the external module if ($user->getDefaultModule() != '') { // redirect appropriately $this->redirect('index', null, null, $user->getDefaultModule()); return; } $this->view->items = $this->notificationService->getWatchedItems($user, array('Project', 'Client')); $cats = array(); $start = date('Y-m') . '-01 00:00:00'; $end = date('Y-m-t') . ' 23:59:59'; $order = 'endtime desc'; $startDay = date('Y-m-d') . ' 00:00:00'; $endDay = date('Y-m-d') . ' 23:59:59'; // $this->view->taskInfo = $this->projectService->getTimesheetReport($user, null, null, -1, $start, $end, $cats, $order); // $this->view->dayTasks = $this->projectService->getDetailedTimesheet($user, null, null, null, -1, $startDay, $endDay); $this->view->latest = $this->projectService->getProjects(array('ismilestone=' => 0), 'updated desc', 1, 10); $task = new Task(); $this->view->categories = $task->constraints['category']->getValues(); $this->view->startDate = $start; $this->view->endDate = $end; $this->view->favourites = $this->dbService->getObjects('PanelFavourite', array('creator=' => za()->getUser()->username)); $this->renderView('index/index.php'); }
/** * 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'); }
/** * Gets a collection of objects that existed at a particular point in time * * @param mixed $objects * @param datetime $from * @param datetime $to * @param string $label */ public function getObjectSnapshot($type, $date, $filter = array()) { $versionType = $type . 'Version'; $filter = array(); $filter['validfrom < '] = $date; $filter['versioncreated > '] = $date; $versions = $this->dbService->getObjects($versionType, $filter); // because we're after a snapshot, it might be the case that there // are some objects that are 'live' that haven't had a version created // in the period we're interested in. So we're looking for objects // that were created BEFORE the date we're interested in, but don't // have a date in the 'valid' range $ids = array(); foreach ($versions as $v) { $ids[] = $v->recordid; } $filter = array('versioncreated < ' => $date); if (count($ids)) { $filter['id NOT'] = $ids; } $live = $this->dbService->getObjects($type, $filter); foreach ($live as $liveObject) { $liveObject->recordid = $liveObject->id; $versions[] = $liveObject; } return $versions; }
/** * Gets all the items this passed in item is linked to * * if $side is 'from', it will return items where * this item is the 'from' side. If 'to', will return * the 'to' side, otherwise if 'both' will return * both sides. * * @param object $item * @param string $side The "side" that $item is linked on. EG left side = 'from' */ public function getLinkedItems($item, $side = 'from', $otherType = null) { $results = null; $finalResults = new ArrayObject(); if ($otherType) { return $this->getLinkedItemsOfType($item, $side, $otherType); } if ($side == 'from' || $side == 'both') { $where = array('fromid=' => $item->id, 'fromtype=' => get_class($item)); if ($otherType != null) { $where['totype='] = $otherType; } $results = $this->dbService->getObjects('ItemLink', $where); foreach ($results as $linkItem) { $object = $this->dbService->getById($linkItem->toid, $linkItem->totype); if ($object) { $finalResults[] = $object; } } } if ($side == 'to' || $side == 'both') { $where = array('toid=' => $item->id, 'totype=' => get_class($item)); if ($otherType != null) { $where['fromtype='] = $otherType; } $results = $this->dbService->getObjects('ItemLink', $where); foreach ($results as $linkItem) { $object = $this->dbService->getById($linkItem->fromid, $linkItem->fromtype); $finalResults[] = $object; } } return $finalResults; }
/** * Generates the appropriate query for returning a list of issues * * @param array $where * @return arrayobject */ protected function getList($type, $where = array()) { $query = $this->_getParam('query'); if (mb_strlen($query) >= 2) { $where[] = new Zend_Db_Expr("title like " . $this->dbService->quote('%' . $query . '%') . " OR description like " . $this->dbService->quote('%' . $query . '%')); } // Handle this up here otherwise a model object might take $sortDir = $this->_getParam('sortorder', $this->_getParam('dir', 'desc')); if ($sortDir == 'up' || $sortDir == 'asc') { $sortDir = 'asc'; } else { $sortDir = 'desc'; } // now just iterate parameters $params = $this->_getAllParams(); unset($params['title']); unset($params['sortorder']); $dummyObj = new $type(); // get all the type's parameters $fields = $dummyObj->unBind(); foreach ($fields as $name => $val) { // if we have a param with $name, add it to the filter $val = ifset($params, $name, null); if (!is_null($val)) { $where[$name . ' ='] = $val; } } // If not a User, can only see non-private issues if (za()->getUser()->getRole() == User::ROLE_EXTERNAL) { if (isset($fields['isprivate'])) { $where['isprivate='] = 0; } if (isset($fields['clientid'])) { $client = $this->clientService->getUserClient(za()->getUser()); $where['clientid='] = $client->id; } } $sort = $this->_getParam('sortname', $this->_getParam('sort', 'updated')); $sort .= ' ' . $sortDir; $this->view->totalCount = $this->dbService->getObjectCount($where, $type); $currentPage = ifset($params, 'page', 1); $this->view->listSize = $this->_getParam('rp', za()->getConfig('project_list_size', 10)); if ($this->_getParam("unlimited")) { $currentPage = null; } return $this->dbService->getObjects($type, $where, $sort, $currentPage, $this->view->listSize); }
/** * Get the list of expense report objects */ public function getExpenseReports($where = array()) { return $this->dbService->getObjects('ExpenseReport', $where, 'id desc'); }
/** * Get tracker entries * * @param unknown_type $where * @return unknown */ public function getEntries($where, $page = null, $number = null) { return $this->dbService->getObjects('TrackerEntry', $where, 'id desc', $page, $number); }
/** * Get features with a particular where clause * * @param array $where * @return ArrayObject */ public function getFeatures($where = array()) { return $this->dbService->getObjects('Feature', $where); }
/** * List all model types */ public function listAction() { $modelType = $this->modelType(); $this->view->items = $this->dbService->getObjects($modelType); $this->renderView($this->_request->getControllerName() . '/list.php'); }
/** * Get a list of timesheets. * * @param unknown_type $where * @param unknown_type $order * @param unknown_type $page * @param unknown_type $number * @return unknown */ public function getTimesheets($where = array(), $order = 'id asc', $page = null, $number = null) { return $this->dbService->getObjects('Timesheet', $where, $order, $page, $number); }
/** * Get all leave applications */ public function getLeaveApplications($where = array(), $order = 'id desc', $page = null, $number = null) { return $this->dbService->getObjects('LeaveApplication', $where, $order, $page, $number); }