public static function GetMyProjects($includeValue = false, $order_column = 'project_id', $order_direction = 1) { $current_user = ProNav_Auth::getUserID(); $filter = array(); $filter['my_watch_list'] = 1; $projects = Application_Model_Projects::GetAllProjects($filter, true, $order_column, $order_direction); if ($includeValue && !empty($projects)) { $keys = implode(",", array_keys($projects)); $db = Zend_Db_Table::getDefaultAdapter(); $sql = "SELECT p.project_id, (p.acct_project_value + IFNULL(c.cor_total,0)) AS totalValue FROM projects p \n LEFT JOIN (\n SELECT project_id, SUM(IFNULL(amount,0)) AS cor_total \n FROM change_order_requests \n WHERE accounting_stage_id = 1 \n GROUP BY project_id\n ) c ON p.project_id = c.project_id\n WHERE p.project_id IN ({$keys})"; $data = $db->fetchAll($sql); if ($data) { foreach ($data as $row) { if ($projects[$row->project_id]) { $projects[$row->project_id]->totalValue = $row->totalValue; } } } } return $projects; }
public function listProjectsAction() { $filter = Zend_Json::decode($this->_getParam('data')); $this->view->filter = $filter; $this->view->projects = Application_Model_Projects::GetAllProjects($filter); if (ProNav_Auth::isEmployee()) { $this->renderScript('/project/index-display-t.phtml'); } else { $this->renderScript('/project/index-display-c.phtml'); } }