예제 #1
0
 /**
  * Get the total number of clients for a given where clause
  *
  * @param array $where
  * @return int
  */
 public function getIssueCount($where)
 {
     // if the current user is an external, filter by their clientid
     if (za()->getUser()->getRole() == User::ROLE_EXTERNAL) {
         // get their client
         $client = $this->clientService->getUserClient(za()->getUser());
         $where['clientid='] = $client->id;
     }
     return $this->dbService->getObjectCount($where, 'Issue');
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
 /**
  * Get the total number of expenses for a given where clause
  *
  * @param array $where
  * @return int
  */
 public function getExpensesCount($where)
 {
     return $this->dbService->getObjectCount($where, 'Expense');
 }
예제 #4
0
 /**
  * Get the number of contacts in the system from the given where clause
  */
 public function getContactCount($where)
 {
     return $this->dbService->getObjectCount($where, 'contact');
 }
예제 #5
0
 /**
  * Get the total number of tasks.
  *
  * @param unknown_type $where
  * @return unknown
  */
 public function getTaskCount($where = array())
 {
     return $this->dbService->getObjectCount($where, 'Task');
 }
예제 #6
0
 public function getLeaveApplicationsCount($where = array())
 {
     return $this->dbService->getObjectCount($where, 'LeaveApplication');
 }