public static function loadStats($person_id) { //Load stats model $statsModel = new StatsModel(); $statsModel->set('person_id', $person_id); //Load view $coffeeView = ViewHelper::getView('emails', 'coffee.report'); //Get Total Deals Amount $activeDeals = $statsModel->getActiveDealsAmount(); $coffeeView->totalDealsAmount = $activeDeals; //Get Stage Details $stages = $statsModel->getStages(); $coffeeView->stages = $stages; //Get Number of Converted Leads $leads = $statsModel->getLeads(); $coffeeView->numConvertedLeads = $leads['contact']; //Get Number of New Leads $coffeeView->numNewLeads = $leads['lead']; //Get Note Details $notes = $statsModel->getNotes(); $coffeeView->notes = $notes; //Get ToDo Details $todos = $statsModel->getTodos(); $coffeeView->todos = $todos; //Get Deal Activity $dealActivity = $statsModel->getDealActivity(); $coffeeView->dealActivity = $dealActivity; //Get Lead Activity $coffeeView->leadActivity = $leadActivity; //Get Contact Activity $coffeeView->contactActivity = $contactActivity; return $coffeeView; }
public function render() { //japplication $app = JFactory::getApplication(); $id = $app->input->get('id') ? $app->input->get('id') : null; $layout = $this->getLayout(); //get model $model = new CompanyModel(); //layout switch ($layout) { case "add": case "edit": $this->company = $model->getCompany(); $edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'html'); $edit_custom_fields_view->type = "company"; $edit_custom_fields_view->item = $this->company; $this->edit_custom_fields_view = $edit_custom_fields_view; break; case "entry": $this->company = $model->getCompany(); $this->k = 0; break; case "list": $this->companies = $model->getCompanies($id); $this->total = $model->getTotal(); $this->pagination = $model->getPagination(); $this->state = $model->getState(); break; } //display view echo parent::render(); }
public function execute() { $note_id = $this->getInput()->get('note_id'); $model = new NoteModel(); $note = $model->getNote($note_id); $note_view = ViewHelper::getView('note', 'entry', 'phtml', array('note' => $note[0])); echo $note_view->render(); }
public function execute() { $convo_id = $this->getInput()->get('convo_id'); $model = new ConversationModel(); $convo = $model->getConversation($convo_id); $convo_view = ViewHelper::getView('deals', 'conversation_entry', 'phtml', array('conversation' => $convo[0])); echo $convo_view->render(); }
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 execute() { //get model $model = new GoalModel(); //get data $goals = $model->getIndividualGoals($this->getInput()->get('id')); //pass data to view $view = ViewHelper::getView('goals', 'filters', 'raw', array('goals' => $goals)); //display view echo $view->render(); }
public function execute() { //get model $model = new GoalModel(); //get data $leaderboard = $model->getLeaderBoards($this->getInput()->get('id')); //pass data to view $view = ViewHelper::getView('goals', 'leaderboard', 'raw', array('leaderboard' => $leaderboard)); //display view echo $view->render(); }
public function execute() { //set view $view = ViewHelper::getView('people', 'raw'); $view->setLayout('list'); //get deals $model = new PeopleModel(); $people = $model->getPeople(); //assign references $view->people = $people; //display echo $view->render(); }
public function execute() { //set view $view = ViewHelper::getView('companies', 'raw', 'html'); $view->setLayout('list'); //get filters $type = $this->getInput()->get('type'); $user = $this->getInput()->get('user'); $team = $this->getInput()->get('team_id'); //get deals $model = new CompanyModel(); $companies = $model->getCompanies(null, $type, $user, $team); //assign references $view->companies = $companies; //display echo $view->render(); }
public static function getMenuModules() { $modules = array(); $app = \Cobalt\Container::fetch('app'); /** Side menu links **/ $menu_links = MenuHelper::getMenuLinks(); $menu = ViewHelper::getView('cobalt', 'menu', 'phtml'); $menu->menu_links = $menu_links; $modules['menu'] = $menu; /** Quick Menu Links **/ $quick_menu_links = MenuHelper::getQuickMenuLinks(); $quick_menu = ViewHelper::getView('cobalt', 'quick_menu', 'phtml'); $quick_menu->quick_menu_links = $quick_menu_links; $modules['quick_menu'] = $quick_menu; /** Determine help type on page **/ $help_type_1 = $app->input->get('view') != '' || !is_null($app->input->get('view')) ? $app->input->get('view') : $app->input->get('controller'); $help_type_2 = $app->input->get('layout') != '' || !is_null($app->input->get('layout')) ? $app->input->get('layout') : $app->input->get('task'); $help_type_1 = $help_type_1 == "" || is_null($help_type_1) ? "" : $help_type_1; $help_type_2 = $help_type_2 == "" || is_null($help_type_2) ? "" : '_' . $help_type_2; $help_type = str_replace(".", "_", $help_type_1 . $help_type_2); $help_types = self::getHelpTypes(); $show_help = ConfigHelper::getConfigValue('show_help'); $launch_default = ConfigHelper::getConfigValue('launch_default'); $step_completed = ConfigHelper::getConfigValue($help_type); $show_update_buttons = in_array($help_type, $help_types); /** Help Menu Links **/ $help_menu_links = MenuHelper::getHelpMenuLinks(); $help_menu = ViewHelper::getView('cobalt', 'help_menu', 'phtml'); $help_menu->help_menu_links = $help_menu_links; $help_menu->help_type = $help_type; $help_menu->show_help = $show_help; $help_menu->launch_default = $launch_default; $help_menu->step_completed = $step_completed; $help_menu->show_update_buttons = $show_update_buttons; $modules['help_menu'] = $help_menu; $count = count($help_menu_links) - 1; $completed = 0; foreach ($help_menu_links as $link) { if ($link['completed_status'] == 1) { $completed++; } } $modules['percentage'] = number_format($completed / $count * 100, 0); return $modules; }
public function execute() { //set view $view = ViewHelper::getView('deals', 'raw'); $view->setLayout('list'); //get filters $type = $this->getInput()->get('type'); $stage = $this->getInput()->get('stage'); $user = $this->getInput()->get('user'); $close = $this->getInput()->get('close'); $team = $this->getInput()->get('team_id'); //get deals $model = new DealModel(); $deals = $model->getDeals(null, $type, $user, $stage, $close, $team); //assign references $view->deals = $deals; $view->pagination = $model->getPagination(); //display echo $view->render(); }
public function render() { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $id = $app->input->get('id') ? $app->input->get('id') : null; $company_id = $app->input->get('company_id'); //retrieve people from model $model = new PeopleModel(); $model->set('company_id', $company_id); $layout = $this->getLayout(); $this->total = $model->getTotal(); $this->pagination = $model->getPagination(); //assign refs switch ($layout) { case "entry": $this->k = 0; $this->person = $model->getPerson(); break; case "add": case "edit": $this->person = $model->getPerson(); $this->edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'phtml', array('type' => 'people', 'item' => $this->person)); $companyModel = new CompanyModel(); $json = TRUE; $companyNames = $companyModel->getCompanyNames($json); $document->addScriptDeclaration("var company_names=" . $companyNames . ";"); break; case "people_dock_list": $people = $model->getPeople($id); $this->people = $people; break; default: $people = $model->getPeople($id); $this->people = $people; $this->state = $model->getState(); break; } //display view echo parent::render(); }
public function execute() { $response = array(); $start = $this->getInput()->getInt('start', 0); $limit = $this->getInput()->getInt('limit', 4); $object_id = $this->getInput()->getInt('object_id', 0); $item_type = $this->getInput()->getCmd('item_type'); if ($start < 0) { $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_LIMIT_START_SHOULD_BE_POSITIVE'), 'type' => 'error'); } else { if ($limit < 1) { $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_LIMIT_SHOULD_BE_POSITIVE'), 'type' => 'error'); } else { if (empty($item_type)) { $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_ITEM_TYPE_MUST_BE_NOT_EMPTY'), 'type' => 'error'); } } } //Always object_id 0 return empty notes $load_more = false; if ($object_id && !empty($item_type)) { $model = new Note(); $notes = $model->getNotes($object_id, $item_type, false); $total = count($notes); //filter notes by limits $items = array_slice($notes, $start, $limit); $view = ViewHelper::getView('note', 'default', 'phtml', array('notes' => $items)); $load_more = $start + $limit >= $total ? false : true; $response['html'] = ''; foreach ($items as $note) { $view = ViewHelper::getView('note', 'entry', 'phtml', array('note' => $note)); $response['html'] .= $view->render(); } } if ($load_more) { $response['loadmore'] = array('limit' => count($items) + $limit); } echo json_encode($response); }
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(); }
public function render() { $app = \Cobalt\Container::fetch('app'); //retrieve deal list from model $model = new DealModel(); $state = $model->getState(); $dealList = array(); $deal = array(); $doc = JFactory::getDocument(); //session info $session = JFactory::getSession(); $member_role = UsersHelper::getRole(); $user_id = UsersHelper::getUserId(); $team_id = UsersHelper::getTeamId(); //determine if we are requesting a specific deal or all deals //if id requested if ($app->input->get('id')) { $model->set('_id', $app->input->get('id')); $dealList = $model->getDeals(); if (is_null($dealList[0]->id)) { $app->redirect(RouteHelper::_('index.php?view=deals'), TextHelper::_('COBALT_NOT_AUTHORIZED')); } //display remove and assign primary contact to deal $app->input->set('loc', 'deal'); } else { //else load all deals if ($app->input->get('layout') != 'edit') { if (TemplateHelper::isMobile()) { $model->set('ordering', 'd.name ASC'); } $dealList = $model->getDeals(); } } //determine if we are editing an existing deal entry if (count($dealList) == 1) { //grab deal object $deal = $dealList[0]; $deal->header = ucwords(TextHelper::_('COBALT_DEAL_EDIT')); } else { //else we are creating a new entry $deal = new \stdClass(); $deal->name = ""; $deal->summary = ""; $deal->company_id = $app->input->get('company_id') ? $app->input->get('company_id') : null; $deal->person_id = $app->input->get('person_id') ? $app->input->get('person_id') : null; //get company name to prefill data and hidden fields if ($deal->company_id) { $company = CompanyHelper::getCompany($deal->company_id); $deal->company_name = $company[0]['name']; $deal->company_id = $company[0]['id']; } //if a person is specified prefill data if ($deal->person_id) { $person = PeopleHelper::getPerson($deal->person_id); $deal->person_name = $person[0]['last_name'] . ', ' . $person[0]['first_name']; $deal->person_id = $person[0]['id']; //assign company if person is associated with company if ($person[0]['company_id']) { $deal->company_id = $person[0]['company_id']; $deal->company_name = $person[0]['company_name']; } } //assign rest of null data $deal->amount = ""; $deal->stage_id = 0; $deal->source_id = 0; $deal->probability = 0; $deal->status_id = 0; $deal->expected_close = ""; $deal->header = ucwords(TextHelper::_('COBALT_DEAL_HEADER')); } //load javalibs if (!TemplateHelper::isMobile()) { $doc->addScript(JURI::base() . 'src/Cobalt/media/js/deal_manager.js'); } //dropdown info //get deal type filters $deal_types = DealHelper::getDealTypes(); $deal_type_name = $session->get('deal_type_filter'); $deal_type_name = array_key_exists($deal_type_name, $deal_types) ? $deal_types[$deal_type_name] : $deal_types['']; //get column filters $column_filters = DealHelper::getColumnFilters(); $selected_columns = DealHelper::getSelectedColumnFilters(); //get member access info $teams = UsersHelper::getTeams(); $users = UsersHelper::getUsers(); $stages = DealHelper::getStages(); //get deal stage filters $stage_name = $session->get('deal_stage_filter'); $stage_name = $stage_name ? $stages[$stage_name] : $stages['all']; //get session data to prefill filters $user_filter = $session->get('deal_user_filter'); $team_filter = $session->get('deal_team_filter'); if ($user_filter == "all" && $user_filter != $user_id) { $user_name = TextHelper::_('COBALT_ALL_USERS'); } elseif ($user_filter == "all") { $user_name = TextHelper::_('COBALT_ME'); } elseif ($user_filter and $user_filter != $user_id and $user_filter != 'all') { $user_info = UsersHelper::getUsers($user_filter); $user_info = $user_info[0]; $user_name = $user_info['first_name'] . " " . $user_info['last_name']; } elseif ($team_filter) { $team_info = UsersHelper::getTeams($team_filter); $team = $team_info[0]; $user_name = $team['team_name'] . TextHelper::_('COBALT_TEAM_APPEND'); } else { $user_name = TextHelper::_('COBALT_ME'); } //get closing time filters $closing_names = DealHelper::getClosing(); $closing_name = $session->get('deal_close_filter'); $closing_name = $closing_name ? $closing_names[$closing_name] : $closing_names['all']; //get total deals associated with user $total_deals = UsersHelper::getDealCount($user_id, $team_id, $member_role); //Load Events & Tasks for person $layout = $this->getLayout(); if ($layout == "deal") { $model = new EventModel(); $events = $model->getEvents("deal", null, $app->input->get('id')); $this->event_dock = ViewHelper::getView('events', 'event_dock', 'phtml', array('events' => $events)); $primary_contact_id = DealHelper::getPrimaryContact($dealList[0]->id); $this->contact_info = ViewHelper::getView('contacts', 'default', 'phtml', array('contacts' => $dealList[0]->people, 'primary_contact_id' => $primary_contact_id)); $this->document_list = ViewHelper::getView('documents', 'list', 'phtml', array('documents' => $deal->documents, 'total' => $total, 'pagination' => $pagination)); //$this->document_list = ViewHelper::getView('documents','document_row','phtml',array('documents'=>$deal->documents)); $this->custom_fields_view = ViewHelper::getView('custom', 'default', 'phtml', array('type' => 'deal', 'item' => $dealList[0])); } if ($layout == "default") { $this->dataTableColumns = $model->getDataTableColumns(); $pagination = $model->getPagination(); $total = $model->getTotal(); $this->deal_list = ViewHelper::getView('deals', 'list', 'phtml', array('dealList' => $dealList, 'total' => $total, 'pagination' => $pagination)); $this->state = $state; $doc->addScriptDeclaration("\n loc = 'deals';\n order_url = 'index.php?view=deals&layout=list&format=raw&tmpl=component';\n order_dir = '" . $state->get('Deal.filter_order_Dir') . "';\n order_col = '" . $state->get('Deal.filter_order') . "';\n var dataTableColumns = " . json_encode($this->dataTableColumns) . ";"); $deal_name = $state->get('Deal.deals_name'); $this->deal_filter = $deal_name; } if (TemplateHelper::isMobile()) { $this->add_note = ViewHelper::getView('note', 'edit', 'phtml'); $this->add_task = ViewHelper::getView('events', 'edit_task', 'phtml', array('association_type' => 'deal', 'assocation_id' => $app->input->get('id'))); } if ($layout == "edit") { $item = $app->input->get('id') && array_key_exists(0, $dealList) ? $dealList[0] : array('id' => ''); $this->edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'phtml', array('type' => 'deal', 'item' => $item)); $json = TRUE; $companyModel = new CompanyModel(); $companyNames = $companyModel->getCompanyNames($json); $doc->addScriptDeclaration("var company_names=" . $companyNames . ";"); $peopleModel = new PeopleModel(); $peopleNames = $peopleModel->getPeopleNames($json); $doc->addScriptDeclaration("var people_names=" . $peopleNames . ";"); } $closed_stages = DealHelper::getClosedStages(); //assign results to view $this->closed_stages = $closed_stages; $this->dealList = $dealList; $this->totalDeals = $total_deals; $this->deal = $deal; $this->deal_types = $deal_types; $this->deal_type_name = $deal_type_name; $this->user_id = $user_id; $this->member_role = $member_role; $this->teams = $teams; $this->users = $users; $this->stages = $stages; $this->stage_name = $stage_name; $this->user_name = $user_name; $this->closing_names = $closing_names; $this->closing_name = $closing_name; $this->state = $state; $this->column_filters = $column_filters; $this->selected_columns = $selected_columns; //display return parent::render(); }
public function render() { $app = JFactory::getApplication(); ///retrieve task list from model $model = new PeopleModel(); $state = $model->getState(); //session data $session = JFactory::getSession(); $user_id = UsersHelper::getUserId(); $team_id = UsersHelper::getTeamId(); $member_role = UsersHelper::getRole(); $people_type_name = $session->get('people_type_filter'); $user = $session->get('people_user_filter'); $team = $session->get('people_team_filter'); $stage = $session->get('people_stage_filter'); $tag = $session->get('people_tag_filter'); $status = $session->get('people_status_filter'); //load java $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/people_manager.js'); //get list of people $people = $model->getPeople(); $person = array(); //Pagination $this->pagination = $model->getPagination(); //determine if we are editing an existing person entry if ($app->input->get('id')) { //grab deal object $person = $people[0]; if (is_null($person['id'])) { $app->redirect(RouteHelper::_('index.php?view=people'), TextHelper::_('COBALT_NOT_AUTHORIZED')); } $person['header'] = TextHelper::_('COBALT_EDIT') . ' ' . $person['first_name'] . ' ' . $person['last_name']; } else { //else we are creating a new entry $person = array(); $person['id'] = ''; $person['first_name'] = ""; $person['last_name'] = ""; $person['company_id'] = $app->input->get('company_id') ? $app->input->get('company_id') : null; $person['deal_id'] = $app->input->get('deal_id') ? $app->input->get('deal_id') : null; //get company name to prefill data on page and hidden fields if ($person['company_id']) { $company = CompanyHelper::getCompany($person['company_id']); $person['company_name'] = $company[0]['name']; $person['company_id'] = $company[0]['id']; } //get deal name to prefill data on page and hidden fields if ($person['deal_id']) { $deal = DealHelper::getDeal($person['deal_id']); $person['deal_name'] = $deal[0]['name']; $person['deal_id'] = $deal[0]['id']; } $person['position'] = ""; $person['phone'] = ""; $person['email'] = ""; $person['type'] = ''; $person['source_id'] = null; $person['status_id'] = null; $person['header'] = TextHelper::_('COBALT_PERSON_ADD'); } //get total people associated with users account $total_people = UsersHelper::getPeopleCount($user_id, $team_id, $member_role); //get filter types $people_types = PeopleHelper::getPeopleTypes(); $people_type_name = $people_type_name && array_key_exists($people_type_name, $people_types) ? $people_types[$people_type_name] : $people_types['all']; //get column filters $column_filters = PeopleHelper::getColumnFilters(); $selected_columns = PeopleHelper::getSelectedColumnFilters(); //get user filter //get associated users//teams $teams = UsersHelper::getTeams(); $users = UsersHelper::getUsers(); if ($user and $user != $user_id and $user != 'all') { $user_info = UsersHelper::getUsers($user); $user_info = $user_info[0]; $user_name = $user_info['first_name'] . " " . $user_info['last_name']; } elseif ($team) { $team_info = UsersHelper::getTeams($team); $team_info = $team_info[0]; $user_name = $team_info['team_name'] . TextHelper::_('COBALT_TEAM_APPEND'); } elseif ($user == 'all') { $user_name = TextHelper::_('COBALT_ALL_USERS'); } else { $user_name = TextHelper::_('COBALT_ME'); } //get stage filter $stages = PeopleHelper::getStages(); $stages_name = $stage ? $stages[$stage] : $stages['past_thirty']; //get tag filter $tag_list = PeopleHelper::getTagList(); for ($i = 0; $i < count($tag_list); $i++) { if ($tag_list[$i]['id'] == $tag and $tag != 'any') { $tag_name = $tag_list[$i]['name']; break; } } $tag_name = ($tag and $tag != 'any') ? $tag_name : 'all tags'; //get status filter $status_list = PeopleHelper::getStatusList(); for ($i = 0; $i < count($status_list); $i++) { if ($status_list[$i]['id'] == $status and $status != 'any') { $status_name = $status_list[$i]['name']; break; } } $status_name = ($status and $status != 'any') ? $status_name : 'any status'; $dropdowns = $model->getDropdowns(); //Load Events & Tasks for person $layout = $this->getLayout(); if ($layout == "person") { $model = new EventModel(); $events = $model->getEvents("person", null, $app->input->get('id')); $this->event_dock = ViewHelper::getView('events', 'event_dock', 'phtml', array('events' => $events)); $this->deal_dock = ViewHelper::getView('deals', 'deal_dock', 'phtml', array('deals' => $person['deals'])); $this->document_list = ViewHelper::getView('documents', 'document_row', 'phtml', array('documents' => $person['documents'])); $this->custom_fields_view = ViewHelper::getView('custom', 'default', 'phtml', array('type' => 'people', 'item' => $person)); } if ($layout == "default") { $total = $model->getTotal(); $pagination = $model->getPagination(); $this->people_list = ViewHelper::getView('people', 'list', 'phtml', array('people' => $people, 'total' => $total, 'pagination' => $pagination)); $this->people_filter = $state->get('Deal.people_name'); $this->dataTableColumns = $model->getDataTableColumns(); JFactory::getDocument()->addScriptDeclaration("\n var loc = 'people';\n var order_dir = '" . $state->get('People.filter_order_Dir') . "';\n var order_col = '" . $state->get('People.filter_order') . "';\n var dataTableColumns = " . json_encode($this->dataTableColumns) . ";"); } if ($layout == "edit") { $item = $app->input->get('id') && array_key_exists(0, $people) ? $people[0] : array('id' => ''); $this->edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'phtml', array('type' => 'people', 'item' => $item)); $companyModel = new CompanyModel(); $json = TRUE; $companyNames = $companyModel->getCompanyNames($json); $document->addScriptDeclaration("var company_names=" . $companyNames . ";"); } if (TemplateHelper::isMobile() && $app->input->get('id')) { $this->add_note = ViewHelper::getView('note', 'edit', 'phtml', array('add_note' => $add_note)); $this->add_task = ViewHelper::getView('events', 'edit_task', 'phtml', array('association_type' => 'person', 'assocation_id' => $app->input->get('id'))); } //assign results to view $this->people = $people; $this->person = $person; $this->totalPeople = $total_people; $this->people_type_name = $people_type_name; $this->people_types = $people_types; $this->user_id = $user_id; $this->team_id = $team_id; $this->member_role = $member_role; $this->user_name = $user_name; $this->teams = $teams; $this->users = $users; $this->stages = $stages; $this->stages_name = $stages_name; $this->tag_list = $tag_list; $this->tag_name = $tag_name; $this->status_list = $status_list; $this->status_name = $status_name; $this->state = $state; $this->column_filters = $column_filters; $this->selected_columns = $selected_columns; $this->dropdown = $dropdowns; //display return parent::render(); }
public function render() { $layout = $this->getLayout(); //get model $model = new DocumentModel(); $documents = $model->getDocuments(); $state = $model->getState(); //add js $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/document_manager.js'); //session data $session = JFactory::getSession(); $member_role = UsersHelper::getRole(); $user_id = UsersHelper::getUserId(); //associations $assoc = $session->get('document_assoc_filter'); $assoc_names = DocumentHelper::getAssocTypes(); $assoc_name = $assoc ? $assoc_names[$assoc] : $assoc_names['all']; //users $user_id = UsersHelper::getUserId(); $user = $session->get('document_user_filter'); $team = $session->get('document_team_filter'); if ($user == "all") { $user_name = TextHelper::_('COBALT_ALL_USERS'); } elseif ($user && $user != $user_id) { $user_info = UsersHelper::getUser($user); $user_name = $user_info->first_name . " " . $user_info->last_name; } elseif ($team) { $team_info = UsersHelper::getTeams($team); $team_info = $team_info[0]; $user_name = $team_info['team_name'] . TextHelper::_('COBALT_TEAM_APPEND'); } else { $user_name = TextHelper::_('COBALT_ME'); } if ($layout == 'default') { $total = $model->getTotal(); $pagination = $model->getPagination(); $this->dataTableColumns = $model->getDataTableColumns(); JFactory::getDocument()->addScriptDeclaration("\n var loc = 'documents';\n var order_dir = '" . $state->get('People.filter_order_Dir') . "';\n var order_col = '" . $state->get('People.filter_order') . "';\n var dataTableColumns = " . json_encode($this->dataTableColumns) . ";"); } //type $type = $session->get('document_type_filter'); $type_names = DocumentHelper::getDocTypes(); $type_name = $type && array_key_exists($type, $type_names) ? $type_names[$type] : $type_names['all']; //teams $teams = UsersHelper::getTeams(); //users $users = UsersHelper::getUsers(); //list view $document_list = ViewHelper::getView('documents', 'list', 'phtml', array('documents' => $documents, 'state' => $state, 'total' => $total, 'pagination' => $pagination)); if ($layout == "download") { DealHelper::downloadDocument(); } //assign ref $this->state = $state; $this->document_list = $document_list; $this->assoc_names = $assoc_names; $this->assoc_name = $assoc_name; $this->user_name = $user_name; $this->type_names = $type_names; $this->type_name = $type_name; $this->member_role = $member_role; $this->user_id = $user_id; $this->teams = $teams; $this->users = $users; //display return parent::render(); }
public function getNotes($object_id = NULL, $type = NULL, $display = true) { $app = \Cobalt\Container::fetch('app'); //grab db $db = JFactory::getDBO(); //initialize query $query = $db->getQuery(true); //gen query string $query->select("n.*,cat.name as category_name,comp.name as company_name,\n comp.id as company_id,deal.name as deal_name,deal.id as deal_id,\n person.id as person_id,person.first_name as person_first_name,\n person.last_name as person_last_name, owner.first_name as owner_first_name,\n event.name as event_name, event.id as event_id,\n owner.last_name as owner_last_name, author.email"); $query->from("#__notes as n"); $query->leftJoin("#__notes_categories AS cat ON cat.id = n.category_id"); $query->leftJoin("#__companies AS comp ON comp.id = n.company_id AND comp.published>0"); $query->leftJoin("#__events AS event ON event.id = n.event_id AND event.published>0"); $query->leftJoin("#__deals AS deal ON deal.id = n.deal_id AND deal.published>0"); $query->leftJoin("#__people AS person on n.person_id = person.id AND person.published>0"); $query->leftJoin("#__users AS owner ON n.owner_id = owner.id"); $query->leftJoin("#__users AS author ON author.id = owner.id"); $company_filter = $this->getState('Note.company_name'); if ($company_filter != null) { $query->where("comp.name LIKE '%" . $company_filter . "%'"); } //deal $deal_filter = $this->getState('Note.deal_name'); if ($deal_filter != null) { $query->where("deal.name LIKE '%" . $deal_filter . "%'"); } //person $person_filter = $this->getState('Note.person_name'); if ($person_filter != null) { } if ($object_id) { switch ($type) { case 'person': case 'people': $query->where('n.person_id =' . $object_id); break; case 'company': $query->where('(n.company_id =' . $object_id . ' OR deal.company_id = ' . $object_id . ' OR person.company_id = ' . $object_id . ")"); break; case 'deal': $query->where('n.deal_id=' . $object_id); break; case "event": $query->where("n.event_id={$object_id}"); break; } } //owner $owner_filter = $this->getState('Note.owner_id'); if ($owner_filter != null && $owner_filter != "all") { $owner_type = $this->getState('Note.owner_type'); switch ($owner_type) { case "team": $team_member_ids = UsersHelper::getTeamUsers($owner_filter, TRUE); $query->where("n.owner_id IN (" . implode(',', $team_member_ids) . ")"); break; case "member": $query->where("n.owner_id=" . $owner_filter); break; } } //created $created_filter = $this->getState('Note.created'); if ($company_filter != null) { } //category $category_filter = $this->getState('Note.category_id'); if ($category_filter != null) { $query->where("n.category_id=" . $category_filter); } if ($this->_id) { if (is_array($this->_id)) { $query->where("n.id IN (" . implode(',', $this->_id) . ")"); } else { $query->where("n.id={$this->_id}"); } } /** --------------------------------------------------------------- * Filter data using member role permissions */ $member_id = UsersHelper::getUserId(); $member_role = UsersHelper::getRole(); $team_id = UsersHelper::getTeamId(); if ($this->public_notes != true) { if ($member_role != 'exec') { //manager filter if ($member_role == 'manager') { $query->where('owner.team_id = ' . $team_id); } else { //basic user filter $query->where(array('n.owner_id = ' . $member_id)); } } } $query->where("n.published=" . $this->published); $query->order("n.modified DESC"); //load results $db->setQuery($query); $results = $db->loadAssocList(); //clean results if (count($results) > 0) { foreach ($results as $key => $note) { $results[$key]['created_formatted'] = DateHelper::formatDate($note['created']); $results[$key]['owner_avatar'] = CobaltHelper::getGravatar($note['email']); } } //$app->triggerEvent('onNoteLoad', array(&$results)); if (!$display) { //return results return $results; } else { $notesView = ViewHelper::getView('note', 'default', 'phtml', array('notes' => $results)); return $notesView; } }
public function _display_sales_pipeline() { //get deals for reports $dealModel = new DealModel(); $dealModel->set('archived', 0); $dealModel->set('limit', 0); $reports = $dealModel->getReportDeals(); // Initialise state variables. $state = $dealModel->getState(); //info for dropdowns $deal_amounts = DealHelper::getAmounts(); $deal_stages = DealHelper::getActiveStages(TRUE); $deal_statuses = DealHelper::getStatuses(); $deal_close_dates = DealHelper::getClosing(); $modified_dates = DealHelper::getModified(); //list view $sales_pipeline_header = ViewHelper::getView('reports', 'sales_pipeline_header', 'phtml', array('state' => $state, 'reports' => $reports)); $sales_pipeline_list = ViewHelper::getView('reports', 'sales_pipeline_filter', 'phtml', array('reports' => $reports)); $sales_pipeline_footer = ViewHelper::getView('reports', 'sales_pipeline_footer', 'phtml'); $sales_pipeline_header->deal_amounts = $deal_amounts; $sales_pipeline_header->deal_stages = $deal_stages; $sales_pipeline_header->deal_statuses = $deal_statuses; $sales_pipeline_header->deal_close_dates = $deal_close_dates; $sales_pipeline_header->modified_dates = $modified_dates; $sales_pipeline_header->created_dates = DateHelper::getCreatedDates(); $sales_pipeline_header->team_names = DropdownHelper::getTeamNames(); $sales_pipeline_header->user_names = DropdownHelper::getUserNames(); $sales_pipeline_header->state = $state; //assign refs to view $this->sales_pipeline_header = $sales_pipeline_header; $this->sales_pipeline_list = $sales_pipeline_list; $this->sales_pipeline_footer = $sales_pipeline_footer; $this->state = $state; $this->reports = $reports; }
public function render($tpl = null) { //app $app = JFactory::getApplication(); /* Model // function info */ $model_name = $app->input->get('model'); //layout $layout = $this->getLayout(); //document $document = JFactory::getDocument(); if (!$model_name) { switch ($layout) { case "person": $model_name = "people"; break; case "company": $model_name = "companies"; break; case "deal": $model_name = "deal"; break; } } if ($layout != "report") { $className = "CobaltModel" . ucwords($model_name); $model = new $className(); $params = NULL; switch ($model_name) { case "company": $func = "companies"; break; case "deal": $func = "deals"; break; case "people": $func = "people"; break; case "event": case "events": $func = "events"; if ($layout == "calendar") { $params = "calendar"; //load js libs $document->addScript(JURI::base() . 'src/Cobalt/media/js/fullcalendar.js'); $document->addScript(JURI::base() . 'src/Cobalt/media/js/calendar_manager.js'); //load required css for calendar $document->addStyleSheet(JURI::base() . 'src/Cobalt/media/css/fullcalendar.css'); } break; } } switch ($layout) { case "report": $report = $app->input->get('report'); $item_id = $app->input->get('ids') ? $app->input->get('ids') : NULL; if (is_array($item_id)) { $items = array(); foreach ($item_id as $key => $item) { $items[] = $item; } } else { $items = $item_id; } switch ($report) { case "sales_pipeline": $model = new CobaltModelDeal(); $model->set('_id', $items); $state = $model->getState(); $reports = $model->getReportDeals(); $header = ViewHelper::getView('reports', 'sales_pipeline_header', array('state' => $state, 'reports' => $reports)); $table = ViewHelper::getView('reports', 'sales_pipeline_filter', array('reports' => $reports)); $footer = ViewHelper::getView('reports', 'sales_pipeline_footer'); break; case "source_report": $model = new CobaltModelDeal(); $model->set('_id', $items); $reports = $model->getDeals(); $state = $model->getState(); $header = ViewHelper::getView('reports', 'sales_pipeline_header', array('state' => $state, 'reports' => $reports)); $table = ViewHelper::getView('reports', 'sales_pipeline_filter', array('reports' => $reports)); $footer = ViewHelper::getView('reports', 'source_report_footer'); break; case "roi_report": $model = new CobaltModelSource(); $model->set('_id', $items); $sources = $model->getRoiSources(); $header = ViewHelper::getView('reports', 'roi_report_header'); $table = ViewHelper::getView('reports', 'roi_report_filter', array('sources' => $sources)); $footer = ViewHelper::getView('reports', 'roi_report_footer'); break; case "notes": $model = new CobaltModelNote(); $model->set('_id', $items); $note_entries = $model->getNotes(NULL, NULL, FALSE); $state = $model->getState(); $header = ViewHelper::getView('reports', 'notes_header', array('state' => $state, 'note_entries' => $note_entries)); $table = ViewHelper::getView('reports', 'notes_filter', array('note_entries' => $note_entries)); $footer = ViewHelper::getView('reports', 'notes_footer'); break; case "custom_report": $model = new CobaltModelReport(); $report = $model->getCustomReports($app->input->get('custom_report')); $report_data = $model->getCustomReportData($app->input->get('custom_report')); $state = $model->getState(); $data = array('report_data' => $report_data, 'report' => $report, 'state' => $state); $header = ViewHelper::getView('reports', 'custom_report_header', $data); $table = ViewHelper::getView('reports', 'custom_report_filter', $data); $footer = ViewHelper::getView('reports', 'custom_report_footer'); break; } $this->header = $header; $this->table = $table; $this->footer = $footer; break; default: /* Item info */ $function = "get" . ucwords($func); $item_id = $app->input->get('item_id') ? $app->input->get('item_id') : NULL; $ids = $app->input->get('ids') ? $app->input->get('ids') : NULL; $item_id = $item_id ? $item_id : $ids; if (is_array($item_id)) { $items = array(); if ($app->input->get('item_id')) { foreach ($item_id as $key => $item) { $items[] = $key; } } else { foreach ($item_id as $key => $item) { $items[] = $item; } } } else { $items = $item_id; } $model->set('_id', $items); $model->set("completed", null); $info = $model->{$function}($params); /* Event list */ $model = new CobaltModelEvent(); $events = $model->getEvents("deal", NULL, $item_id); if (count($events) > 0) { $ref = array('events' => $events, 'print' => TRUE); $eventDock = ViewHelper::getView('events', 'event_dock', $ref); $this->event_dock = $eventDock; } /* Contact info */ if (is_array($info) && array_key_exists(0, $info) && array_key_exists('people', $info[0]) && count($info[0]['people']) > 0) { $peopleModel = new CobaltModelPeople(); $peopleModel->set('deal_id', $info[0]['id']); $contacts = $peopleModel->getContacts(); $ref = array('contacts' => $contacts, 'print' => TRUE); $contact_info = ViewHelper::getView('contacts', 'default', $ref); $this->contact_info = $contact_info; } $this->info = $info; break; } $custom_fields = array('deal', 'company', 'person'); if (in_array($layout, $custom_fields)) { $this->custom_fields = ViewHelper::getView('print', 'custom_fields', 'phtml'); $this->custom_fields->item_type = $layout; $this->custom_fields->item = $info[0]; } $js = "jQuery(document).ready(function(){\n window.print();\n })"; $document->addScriptDeclaration($js); //display return parent::render(); }
public function render() { $app = JFactory::getApplication(); $app->input->set('view', 'companies'); $app->input->set('layout', $app->input->get('layout', 'default')); //get model $model = new CompanyModel(); $state = $model->getState(); //session data $session = JFactory::getSession(); $member_role = UsersHelper::getRole(); $user_id = UsersHelper::getUserId(); $team_id = UsersHelper::getTeamId(); $company = $session->get('company_type_filter'); $user = $session->get('company_user_filter'); $team = $session->get('company_team_filter'); //load java libs $doc = JFactory::getDocument(); $doc->addScript(JURI::base() . 'src/Cobalt/media/js/company_manager.js'); //determine if we are requesting a specific company or all companies //if id requested if ($app->input->get('id')) { $companies = $model->getCompanies($app->input->get('id')); if (is_null($companies[0]['id'])) { $app = JFactory::getApplication(); $app->redirect(RouteHelper::_('index.php?view=companies'), TextHelper::_('COBALT_NOT_AUTHORIZED')); } } else { //else load all companies if ($app->input->get('layout') != 'edit') { $companies = $model->getCompanies(); } } //assign pagination $pagination = $model->getPagination(); $this->pagination = $pagination; //get company type filters $company_types = CompanyHelper::getTypes(); $company_type = $company ? $company_types[$company] : $company_types['all']; //get user filter if ($user and $user != $user_id and $user != 'all') { $user_info = UsersHelper::getUsers($user); $user_info = $user_info[0]; $user_name = $user_info['first_name'] . " " . $user_info['last_name']; } elseif ($team) { $team_info = UsersHelper::getTeams($team); $team_info = $team_info[0]; $user_name = $team_info['team_name'] . TextHelper::_('COBALT_TEAM_APPEND'); } elseif ($user == 'all' || $user == "") { $user_name = TextHelper::_('COBALT_ALL_USERS'); } else { $user_name = TextHelper::_('COBALT_ME'); } //get associated members and teams $teams = UsersHelper::getTeams(); $users = UsersHelper::getUsers(); //get total associated companies for count display $company_count = UsersHelper::getCompanyCount($user_id, $team_id, $member_role); //Load Events & Tasks for person $layout = $app->input->get('layout'); switch ($layout) { case 'company': $model = new EventModel(); $events = $model->getEvents("company", null, $app->input->get('id')); $this->event_dock = ViewHelper::getView('events', 'event_dock', 'phtml', array('events' => $events)); $this->deal_dock = ViewHelper::getView('deals', 'deal_dock', 'phtml', array('deals' => $companies[0]['deals'])); $this->document_list = ViewHelper::getView('documents', 'document_row', 'phtml', array('documents' => $companies[0]['documents'])); $this->people_dock = ViewHelper::getView('people', 'people_dock', 'html', array('people' => $companies[0]['people'])); $custom_fields_view = ViewHelper::getView('custom', 'default', 'html'); $type = "company"; $custom_fields_view->type = $type; $custom_fields_view->item = $companies[0]; $this->custom_fields_view = $custom_fields_view; if (TemplateHelper::isMobile()) { $add_note = ViewHelper::getView('note', 'edit', 'html'); $this->add_note = $add_note; } break; case 'default': default: //get column filters $this->column_filters = CompanyHelper::getColumnFilters(); $this->selected_columns = CompanyHelper::getSelectedColumnFilters(); $company_list = ViewHelper::getView('companies', 'list', 'html', array('companies' => $companies)); $total = $model->getTotal(); $pagination = $model->getPagination(); $company_list->total = $total; $company_list->pagination = $pagination; $this->company_list = $company_list; $company_name = $state->get('Company.companies_name'); $this->company_filter = $company_name; $this->dataTableColumns = $model->getDataTableColumns(); $doc->addScriptDeclaration("\n var loc = 'companies';\n var order_dir = '" . $state->get('Company.filter_order_Dir') . "';\n var order_col = '" . $state->get('Company.filter_order') . "';\n var dataTableColumns = " . json_encode($this->dataTableColumns) . ";"); break; case 'edit': $item = $app->input->get('id') && array_key_exists(0, $companies) ? $companies[0] : array('id' => ''); $edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'html'); $type = "company"; $edit_custom_fields_view->type = $type; $edit_custom_fields_view->item = $item; $this->edit_custom_fields_view = $edit_custom_fields_view; break; } //ref assignments $this->companies = $companies; $this->user_id = $user_id; $this->member_role = $member_role; $this->teams = $teams; $this->users = $users; $this->company_types = $company_types; $this->company_type = $company_type; $this->user_name = $user_name; $this->company_count = $company_count; $this->state = $state; //display return parent::render(); }