public function render($tpl = null) { $app = JFactory::getApplication(); $deal_id = $app->input->get('deal_id'); $event_id = $app->input->get('event_id'); $companyId = $app->input->get('company_id'); $model = new PeopleModel(); $model->set('deal_id', $deal_id); $model->set('event_id', $event_id); $model->set('company_id', $companyId); $contacts = $model->getContacts(); $this->contacts = $contacts; if ($deal_id) { $primary_contact_id = DealHelper::getPrimaryContact($deal_id); $this->primary_contact_id = $primary_contact_id; } //display view echo parent::render(); }
public function getDealDetails(&$deal) { $closed_stages = DealHelper::getClosedStages(); $deal->closed = in_array($deal->stage_id, $closed_stages) ? TRUE : FALSE; $deal_id = $deal->id; /** ------------------------------------------ * Join contacts */ $peopleModel = new People(); $peopleModel->set('deal_id', $deal_id); $people = $peopleModel->getContacts(); //assign results to company $deal->people = $people; /** ------------------------------------------ * Join conversations */ $convoModel = new Conversation(); $convoModel->set('deal_id', $deal_id); $conversations = $convoModel->getConversations(); $deal->conversations = $conversations; /** ------------------------------------------ * Join notes */ $notesModel = new Note(); $deal->notes = $notesModel->getNotes($deal_id, 'deal'); /** ------------------------------------------ * Join documents */ $docModel = new Document(); $docModel->set('deal_id', $deal_id); $deal->documents = $docModel->getDocuments(); /** ------------------------------------------ * Join tasks & events */ $eventModel = new Event(); $eventModel->set('deal_id', $deal_id); $events = $eventModel->getEvents(); $deal->events = $events; }
public function getCompanies($id = null, $type = null, $user = null, $team = null) { $app = \Cobalt\Container::fetch('app'); $this->_id = $id; $this->_type = $type; $this->_user = $user; $this->_team = $team; //get query string $query = $this->_buildQuery(); /** ------------------------------------------ * Set query limits and load results */ if (!TemplateHelper::isMobile()) { $limit = $this->getState($this->_view . '_limit'); $limitStart = $this->getState($this->_view . '_limitstart'); if (!$this->_id && $limit != 0) { if ($limitStart >= $this->getTotal()) { $limitStart = 0; $limit = 10; $limitStart = $limit != 0 ? floor($limitStart / $limit) * $limit : 0; $this->state->set($this->_view . '_limit', $limit); $this->state->set($this->_view . '_limitstart', $limitStart); } $query .= " LIMIT " . $limit . " OFFSET " . $limitStart; } } //run query and grab results of companies $companies = $this->db->setQuery($query)->loadAssocList(); //generate query to join people if (count($companies)) { $export = $app->input->get('export'); if (!$export) { foreach ($companies as $key => $company) { /* Tweets */ if ($company['twitter_user'] != "" && $company['twitter_user'] != " ") { $companies[$key]['tweets'] = TweetsHelper::getTweets($company['twitter_user']); } //generate people query $peopleModel = new People(); $peopleModel->set('company_id', $company['id']); $companies[$key]['people'] = $peopleModel->getContacts(); //generate deal query $dealModel = new Deal(); $dealModel->set('company_id', $company['id']); $deals = $dealModel->getDeals(); $companies[$key]['pipeline'] = 0; $companies[$key]['won_deals'] = 0; for ($i = 0; $i < count($deals); $i++) { $deal = $deals[$i]; $companies[$key]['pipeline'] += $deal->amount; if ($deal->percent == 100) { $companies[$key]['won_deals'] += $deal->amount; } } $companies[$key]['deals'] = $deals; //Get Associated Notes $notesModel = new Note(); $companies[$key]['notes'] = $notesModel->getNotes($company['id'], 'company'); // Get Associated Documents $documentModel = new Document(); $documentModel->set('company_id', $company['id']); $companies[$key]['documents'] = $documentModel->getDocuments(); $companies[$key]['address_formatted'] = strlen($company['address_1']) > 0 ? $company['address_1'] . $company['address_2'] . ", " . $company['address_city'] . ' ' . $company['address_state'] . ', ' . $company['address_zip'] . ' ' . $company['address_country'] : ""; } } } //$app->triggerEvent('onCompanyLoad',array(&$companies)); return $companies; }