public function render($tpl = null) { //get model and retrieve info $model = new EventModel(); if (TemplateHelper::isMobile()) { $model->set('current_events', true); } $events = $model->getEvents(); $eventDock = ViewHelper::getView('events', 'dashboard_event_dock', 'phtml', array('events' => $events)); $dealModel = new DealModel(); $dealModel->set('_view', 'dashboard'); $dealModel->set('recent', true); $dealModel->set('archived', 0); $recentDeals = $dealModel->getDeals(); $doc = JFactory::getDocument(); //get data for sales graphs $model = new GraphsModel(); $graph_data = $model->getGraphData(); $activityHelper = new ActivityHelper(); $activity = $activityHelper->getActivity(); //assign results to view $this->eventDock = $eventDock; $this->graph_data = $graph_data; $this->recentDeals = $recentDeals; $this->activity = $activity; $json = TRUE; $peopleModel = new PeopleModel(); if (TemplateHelper::isMobile()) { $dealModel->set('recent', false); $totalDeals = $dealModel->getTotal(); $peopleModel->set('type', 'leads'); $totalLeads = $peopleModel->getTotal(); $peopleModel->set('type', 'not_leads'); $totalContacts = $peopleModel->getTotal(); $companyModel = new CompanyModel(); $totalCompanies = $companyModel->getTotal(); $user = UsersHelper::getLoggedInUser(); $this->first_name = $user->first_name; $this->numEvents = count($events); $this->numDeals = $totalDeals; $this->numLeads = $totalLeads; $this->numContacts = $totalContacts; $this->numCompanies = $totalCompanies; } $peopleNames = $peopleModel->getPeopleNames($json); $doc->addScriptDeclaration("var people_names=" . $peopleNames . ";"); $dealModel = new DealModel(); $dealNames = $dealModel->getDealNames($json); $doc->addScriptDeclaration("var deal_names=" . $dealNames . ";"); /** get latest activities **/ $this->latest_activities = ViewHelper::getView('dashboard', 'latest_activities', 'phtml'); $this->latest_activities->activity = $activity; $activityHelper = new ActivityHelper(); $activity = $activityHelper->getActivity(); //display return parent::render(); }
public function render($tpl = null) { $app = JFactory::getApplication(); $id = $app->input->get('id', null); $company_id = $app->input->get('company_id'); $person_id = $app->input->get('person_id'); //get deals $model = new DealModel(); if ($company_id) { $model->set('company_id', $company_id); } elseif ($person_id) { $model->set('person_id', $person_id); } elseif ($id) { $model->set('_id', $id); } $layout = $this->getLayout(); $total = $model->getTotal(); $this->total = $total; $pagination = $model->getPagination(); $this->pagination = $pagination; //assign references switch ($layout) { case "entry": $this->stages = DealHelper::getStages(null, true, false); $this->statuses = DealHelper::getStatuses(null, true); $this->sources = DealHelper::getSources(null); $this->users = UsersHelper::getUsers(null, true); $this->k = 0; $this->deal = $model->getDeal(); break; case "deal": $this->deal = $model->getDeal($id); $this->dealList = $model->getDeals(); $primary_contact_id = DealHelper::getPrimaryContact($this->deal->id); $this->closed_stages = DealHelper::getClosedStages(); $model = new EventModel(); $events = $model->getEvents("deal", null, $app->input->get('id')); $this->event_dock = ViewHelper::getView('events', 'event_dock', 'phtml', array('events' => $events)); $this->document_list = ViewHelper::getView('documents', 'document_row', 'phtml', array('documents' => $this->deal->documents)); $this->custom_fields_view = ViewHelper::getView('custom', 'default', 'phtml', array('type' => 'deal', 'item' => $this->deal)); $this->contact_info = ViewHelper::getView('contacts', 'default', 'phtml', array('contacts' => $this->deal->people, 'primary_contact_id' => $primary_contact_id)); break; case "deal_dock_list": $this->deals = $model->getDeals(); break; case "add": case "edit": $this->deal = $model->getDeal($id); $this->edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'phtml', array('type' => 'deal', 'item' => $this->deal)); break; case "edit_conversation": $model = new ConversationModel(); $conversation = $model->getConversation($id); $this->conversation = $conversation[0]; break; case "conversation_entry": $model = new ConversationModel(); $conversation = $model->getConversation($id); $this->conversation = $conversation[0]; break; default: $this->dealList = $model->getDeals(); $state = $model->getState(); $this->state = $state; break; } //display view echo parent::render(); }