/** * Here we use multiple models to gather data for displaying graphs * @param $type type to filter by 'member','team','company' * @param $id id of type to filter by * @return $graph_data gathered graph data */ public function getGraphData($type = null, $id = null) { //set default search data if ($type == null) { $type = 'member'; $id = UsersHelper::getUserId(); } //deal data $model = new Deal(); $model->set('archived', 0); $deals_by_stage = $model->getGraphDeals('stage', $type, $id); $deals_by_status = $model->getGraphDeals('status', $type, $id); $lead_sources = $model->getLeadSources($type, $id); $stage_names = array(); $stage_totals = array(); $status_names = array(); $status_totals = array(); $lead_source_names = array(); $lead_totals = array(); //revenue data $model = new Revenue(); $monthly_revenue = $model->getMonthlyRevenue($type, $id); $yearly_revenue = $model->getYearlyRevenue($type, $id); //commission data $model = new Commission(); $monthly_commissions = $model->getMonthlyCommission($type, $id); $yearly_commissions = $model->getYearlyCommission($type, $id); //get lead source names if (count($lead_sources) > 0) { foreach ($lead_sources as $lead) { $lead_source_names[] = $lead['name']; $lead_totals[] = $lead['y']; } } //get weeks $weeks = array(); $count = 0; if ($monthly_revenue) { foreach ($monthly_revenue as $week) { $count++; $weeks[] = "Week " . $count; } } //get months $months = DateHelper::getMonthNamesShort(); //generate graph data $graph_data = array('deal_stage' => $deals_by_stage, 'stage_names' => $stage_names, 'stage_totals' => $stage_totals, 'deal_status' => $deals_by_status, 'status_names' => $status_names, 'status_totals' => $status_totals, 'lead_sources' => $lead_sources, 'lead_source_names' => $lead_source_names, 'lead_totals' => $lead_totals, 'monthly_revenue' => $monthly_revenue, 'yearly_revenue' => $yearly_revenue, 'monthly_commissions' => $monthly_commissions, 'yearly_commissions' => $yearly_commissions, 'months' => $months, 'weeks' => $weeks); return $graph_data; }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //menu Links $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //add javascript $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/branding_manager.js'); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); //view refs $model = new BrandingModel(); $themes = $model->getThemes(); //toolbar buttons ToolbarHelper::save('save', 'Save'); //toolbar items $list = array('dashboard', 'deals', 'people', 'companies', 'calendar', 'documents', 'goals', 'reports'); $this->toolbar_list = $list; $this->themes = $themes; $this->site_logo = StylesHelper::getSiteLogo(); $this->site_name = StylesHelper::getSiteName(); //assign default theme foreach ($this->themes as $key => $row) { if ($row['assigned']) { $document->addScriptDeclaration("var assigned_theme=" . $row['id'] . ";"); } } //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); $app = \Cobalt\Container::fetch('app'); $document = $app->getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; $configModel = new ConfigModel(); /** Component version **/ $installedVersion = ConfigHelper::getVersion(); $latestVersion = VersionHelper::getLatestVersion(); $updateUrl = "http://www.cobaltcrm.org/support/login"; $updatesFeed = $configModel->getUpdatesRSS(); /** Launch completion **/ $config = $configModel->getConfig(); $this->launch_default = $config->launch_default; $percentage = $menu['percentage']; $this->setup_percent = $percentage; /** php version check **/ $this->php_version = (double) phpversion(); $this->php_version_check = $this->php_version >= 5.3 ? TRUE : FALSE; /** View Ref **/ $this->installedVersion = $installedVersion; $this->latestVersion = $latestVersion; $this->updateUrl = $updateUrl; $this->updatesFeed = $updatesFeed; //display return parent::render(); }
public static function getTotalDocuments() { //db $db = \Cobalt\Container::fetch('db'); $query = $db->getQuery(true); //select $query->select("count(*)"); $query->from("#__documents AS d"); //filter depending on user access $role = UsersHelper::getRole(); $user_id = UsersHelper::getUserId(); $team_id = UsersHelper::getTeamId(); if ($role != 'exec') { if ($role == 'manager') { $query->join('inner', '#__users AS u ON d.owner_id = u.id'); $query->where('u.team_id=' . $team_id); } else { $query->where(array("d.owner_id=" . $user_id, 'd.shared=1'), 'OR'); } } //return count $db->setQuery($query); $result = $db->loadResult(); return $result; }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //app $app = \Cobalt\Container::fetch('app'); if ($app->input->get('layout') == 'sample') { $this->_displaySample($tpl); return; } /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //javascripts $doc = $app->getDocument(); $doc->addScript(JURI::base() . "/src/Cobalt/media/js/cobalt-admin.js"); $doc->addScript(JURI::base() . "/src/Cobalt/media/js/document_manager.js"); //import data $import_post = FALSE; if (count($_FILES) > 0) { $import_post = TRUE; $import_data = array(); $import_type = $app->input->get('import_type'); $model = new ImportModel(); foreach ($_FILES as $file) { $data = $model->readCSVFile($file['tmp_name']); $import_data = array_merge($import_data, $data); } if (count($import_data) > 500) { switch ($app->input->get('import_type')) { case "company": $import_model = "company"; break; case "people": $import_model = "people"; break; case "deals": $import_model = "deal"; break; } if ($model->importCSVData($import_data, $import_model)) { $success = "SUCCESSFULLY"; } else { $success = "UNSUCCESSFULLY"; } $view = "import"; $msg = TextHelper::_('COBALT_' . $success . '_IMPORTED_ITEMS'); $app->redirect('index.php?view=' . $view, $msg); } $this->headers = $import_data['headers']; unset($import_data['headers']); $this->import_data = $import_data; $this->import_type = $import_type; $doc->addScriptDeclaration('import_length=' . count($import_data) . ';'); $doc->addScriptDeclaration("show_tab='import_review';"); } $this->import_post = $import_post; //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //display toolbar $this->toolbar = new Toolbar(); $this->toolbar->save(); //document $document = JFactory::getDocument(); $document->addScript(JURI::base() . "/src/Cobalt/media/js/cobalt-admin.js"); /* Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //get model $model = new ConfigModel(); $layout = $this->getLayout(); $model->set("_layout", $layout); //get config $config = $model->getConfig(); //generate timezones $list = timezone_identifiers_list(); $timezones = array(); foreach ($list as $zone) { $timezones[$zone] = $zone; } //view references $this->imap_found = function_exists('imap_open') ? TRUE : FALSE; $this->config = $config; $this->timezones = $timezones; $this->time_formats = DateHelper::getTimeFormats(); $this->languages = ConfigHelper::getLanguages(); $this->language = ConfigHelper::getLanguage(); //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //site document $document = JFactory::getDocument(); $document->addScript(JURI::base() . "/src/Cobalt/media/js/cobalt-admin.js"); //gather information for view $model = new CategoriesModel(); $layout = $this->getLayout(); $model->set("_layout", $layout); if ($layout && $layout == 'edit') { ToolbarHelper::cancel('cancel'); ToolbarHelper::save('save'); $this->category = $model->getCategory(); } else { //buttons ToolbarHelper::addNew('edit'); ToolbarHelper::editList('edit'); ToolbarHelper::deleteList(TextHelper::_('COBALT_CONFIRMATION'), 'remove'); //view references $categories = $model->getCategories(); $this->categories = $categories; // Initialise state variables. $state = $model->getState(); $this->state = $state; $this->listOrder = $state->get('Categories.filter_order'); $this->listDirn = $state->get('Categories.filter_order_Dir'); } //display return parent::render(); }
public function render($tpl = null) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); //event model $model = new EventModel(); $view = $app->input->get('view'); $layout = $this->getLayout(); switch ($layout) { case 'event_dock': break; case 'edit_event': case 'edit_task': break; case 'default': default: $event_id = $app->input->get('id'); if ($app->input->get('loc')) { $events = $model->getEvents($app->input->get('loc'), null, $app->input->get($app->input->get('loc') . '_id')); } else { $events = $model->getEvents(); } $state = $model->getState(); $this->event_statuses = EventHelper::getEventStatuses(); $this->event_types = EventHelper::getEventTypes(); $this->event_categories = EventHelper::getCategories(TRUE); $this->event_due_dates = EventHelper::getEventDueDates(); $this->event_associations = EventHelper::getEventAssociations(); $this->event_users = UsersHelper::getUsers(NULL, TRUE); $this->event_teams = UsersHelper::getTeams(); $this->dataTableColumns = $model->getDataTableColumns(); $document->addScriptDeclaration("\n loc = 'events';\n order_url = 'index.php?view=events&layout=list&format=raw&tmpl=component';\n order_dir = '" . $state->get('Event.' . $view . '_' . $layout . '_' . 'filter_order_Dir') . "';\n order_col = '" . $state->get('Event.' . $view . '_' . $layout . '_' . 'filter_order') . "';\n var dataTableColumns = " . json_encode($this->dataTableColumns) . ";"); $this->state = $state; break; } if ($layout != 'edit_task' || $layout != "edit_event") { if (TemplateHelper::isMobile()) { $model->set('current_events', true); $document->addScriptDeclaration('loc="events";'); } } if (TemplateHelper::isMobile() && isset($event_id)) { $person_model = new PeopleModel(); $person_model->set('event_id', $event_id); $person_model->set('recent', false); $person_model->set('_id', null); $this->people = $person_model->getPeople(); } $document->addScriptDeclaration('var layout="' . $layout . '"'); //assign results to view $this->events = $events; $this->member_role = UsersHelper::getRole(); $this->user_id = UsersHelper::getUserId(); $this->team_id = UsersHelper::getTeamId(); //display return parent::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 render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); /** Menu Links **/ $side_menu = MenuHelper::getMenuModules(); $this->side_menu = $side_menu; //display return parent::render(); }
public function render() { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //load model $layout = $this->getLayout(); $model = new FormWizardModel(); $model->set("_layout", $layout); //document $document = JFactory::getDocument(); // Create the toolbar object $this->toolbar = new Toolbar(); //add toolbar buttons to manage users if ($layout == 'default') { //buttons $this->toolbar->addNew(); $this->toolbar->addDeleteRow(); ToolbarHelper::addNew('edit'); ToolbarHelper::editList('edit'); ToolbarHelper::deleteList(TextHelper::_('COBALT_CONFIRMATION'), 'remove'); // Initialise variables. $this->state = $model->getState(); $this->forms = $model->getForms(); $this->listOrder = $this->state->get('Formwizard.filter_order'); $this->listDirn = $this->state->get('Formwizard.filter_order_Dir'); } elseif ($layout == 'edit') { //buttons $this->toolbar->save(); $this->toolbar->cancel(); //form $form_id = $model->getTempFormId(); $this->form_id = $form_id; $this->form = $model->getForm(); //form types $this->form_types = DropdownHelper::getFormTypes($this->form['type']); $fields = array('lead' => DropdownHelper::getFormFields('people'), 'contact' => DropdownHelper::getFormFields('people'), 'deal' => DropdownHelper::getFormFields('deal'), 'company' => DropdownHelper::getFormFields('company')); $this->fields = $fields; $document->addScriptDeclaration('var fields=' . json_encode($fields)); //get joomla users to add $model = new UsersModel(); $user_list = $model->getUsers(); $document->addScriptDeclaration('var user_list=' . json_encode($user_list) . ';'); } //javascripts $document->addScript(JURI::base() . 'src/Cobalt/media/js/jquery.base64.js'); $document->addScript(JURI::base() . 'src/Cobalt/media/js/formwizard.js'); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //display return parent::render(); }
public function render() { //load model and retrieve events to pass to calendar $model = new EventModel(); $events = $model->getEvents('calendar'); //pass reference vars to view $this->events = json_encode($events); $team_members = UsersHelper::getUsers(); $this->team_members = $team_members; //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //application $app = \Cobalt\Container::fetch('app'); //display title $document = JFactory::getDocument(); //load model $layout = $this->getLayout(); $model = new UsersModel(); $model->set("_layout", $layout); //add toolbar buttons to manage users if ($layout == 'default') { $this->toolbar = new Toolbar(); $this->toolbar->addNew(); $this->toolbar->addDeleteRow(); //get users $users = $model->getUsers(); // Initialise variables. $this->state = $model->getState(); //assign refs $this->users = $users; $this->listOrder = $this->state->get('Users.filter_order'); $this->listDirn = $this->state->get('Users.filter_order_Dir'); } elseif ($this->getLayout() == 'edit') { $model = new UserModel(); $model->set("_layout", $layout); $this->toolbar = new Toolbar(); $this->toolbar->save(); $this->toolbar->cancel(); //get id $id = $app->input->getInt('id', null); //plugins //$app->triggerEvent('onBeforeCRMUserEdit', array(&$id)); //get user $this->user = $model->getUser($id); //view data $roles = DropdownHelper::getMemberRoles(); $teamId = UsersHelper::getTeamId($id); $teams = UsersHelper::getTeams($teamId); $managers = DropdownHelper::getManagers($id); $this->member_roles = $roles; $this->teams = $teams; $this->managers = $managers; } /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //display return parent::render(); }
public function render() { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); // Create toolbar $this->toolbar = new Toolbar(); //document $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; $layout = $this->getLayout(); //gather information for view $model = new StatusesModel(); $model->set("_layout", $layout); $this->pagination = $model->getPagination(); if ($layout && $layout == 'edit') { //toolbar buttons $this->toolbar->cancel(); $this->toolbar->save(); //javascripts $document->addScript(JURI::base() . 'src/Cobalt/media/js/bootstrap-colorpicker.js'); //stylesheets $document->addStylesheet(JURI::base() . 'src/Cobalt/media/css/bootstrap-colorpicker.css'); //get status $this->status = $model->getStatus(); //script declarations if ($this->status['color'] != null) { $document->addScriptDeclaration('var status_color = "' . $this->status['color'] . '";'); } else { $document->addScriptDeclaration('var status_color = "ff0000";'); } } else { //buttons $this->toolbar->addNew(); ToolbarHelper::editList('edit'); $this->toolbar->addDeleteRow(); //statuses $statuses = $model->getStatuses(); $this->statuses = $statuses; // Initialise state variables. $state = $model->getState(); $this->state = $state; $this->listOrder = $this->state->get('Statuses.filter_order'); $this->listDirn = $this->state->get('Statuses.filter_order_Dir'); $this->saveOrder = $this->listOrder == 'c.ordering'; } //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //Add styles for iframe popup echo "<link href='" . JURI::base() . "src/Cobalt/media/css/style.css' type='text/css' rel='stylesheet' />"; echo "<link href='" . JURI::base() . "src/Cobalt/media/css/bootstrap.min.css' type='text/css' rel='stylesheet' />"; //import document if (is_array($_FILES) && count($_FILES) > 0) { $model = new DocumentsModel(); $model->upload(); } //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //document $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); $document->addScript(JURI::base() . 'src/Cobalt/media/js/custom_manager.js'); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //model $model = new DealCustomModel(); //gather information for view $layout = $this->getLayout(); $model->set("_layout", $layout); $this->pagination = $model->getPagination(); if ($layout && $layout == 'edit') { //toolbar ToolbarHelper::cancel('cancel'); ToolbarHelper::save('save'); //assign view info $this->custom_types = DropdownHelper::getCustomTypes('deal'); $this->custom = $model->getItem(); if ($this->custom['type'] != null) { $document->addScriptDeclaration('var type = "' . $this->custom['type'] . '";'); } } else { //buttons ToolbarHelper::addNew('edit'); ToolbarHelper::editList('edit'); ToolbarHelper::deleteList(TextHelper::_('COBALT_CONFIRMATION'), 'delete'); //assign view info $custom = $model->getCustom(); $this->custom_fields = $custom; // Initialise state variables. $state = $model->getState(); $this->state = $state; $this->listOrder = $this->state->get('Dealcustom.filter_order'); $this->listDirn = $this->state->get('Dealcustom.filter_order_Dir'); $this->saveOrder = $this->listOrder == 'c.ordering'; } //display return parent::render(); }
public function execute() { //set error $error = true; $data['id'] = UsersHelper::getUserId(); //get model and store data $model = new UserModel(); if ($model->store()) { $error = false; } //return results $results = array('error' => $error); if (array_key_exists('fullscreen', $data)) { $append = UsersHelper::isFullscreen() ? "/?&tmpl=component" : ""; $results['url'] = RouteHelper::_($data['url'] . $append); } echo json_encode($results); }
public function execute() { $loc = $this->makeSingular($this->getInput()->getString('loc')); $modelPath = "Cobalt\\Model\\" . ucwords($loc); $model = new $modelPath(); $start = $this->getInput()->getInt('start', 0); $length = $this->getInput()->getInt('length', 0); $orderArr = $this->getInput()->get('order', array(array('column' => 1, 'dir' => 'asc')), 'ARRAY'); $searchArr = $this->getInput()->get('search', array('value' => '', 'regex' => false), 'ARRAY'); $columns = $model->getDataTableColumns(); $user = $this->getApplication()->getUser(); $teamId = UsersHelper::getTeamId(); $memberRole = UsersHelper::getRole(); $countFunc = 'get' . ucwords($loc) . 'Count'; // Set request variables which models will understand if (isset($columns[$orderArr[0]['column']]['ordering'])) { $order = $columns[$orderArr[0]['column']]['ordering']; $this->getInput()->set('filter_order', $order); } if (isset($orderArr[0]['dir'])) { $dir = $orderArr[0]['dir']; $this->getInput()->set('filter_order_Dir', $dir); } if (isset($searchArr['value'])) { $value = $this->setFilters($searchArr['value']); } $this->getInput()->set('limit', $length); $this->getInput()->set('limitstart', $start); // Prepare response $response = new \stdClass(); $response->data = $model->getDataTableItems(); $response->draw = $this->getInput()->getInt('draw'); $response->recordsTotal = UsersHelper::$countFunc($user->get('id'), $teamId, $memberRole); $response->recordsFiltered = $model->getTotal(); $alerts = $this->getApplication()->getMessageQueue(); if (isset($alerts[0])) { $response->alert = new \stdClass(); $response->alert->message = $alerts[0]; $response->alert->type = 'alert'; $this->getApplication()->clearMessageQueue(); } $this->getApplication()->close(json_encode($response)); }
public static function getSelectedColumnFilters() { //get the user session data $db = \Cobalt\Container::fetch('db'); $query = $db->getQuery(true); $query->select("companies_columns"); $query->from("#__users"); $query->where("id=" . UsersHelper::getUserId()); $db->setQuery($query); $results = $db->loadResult(); //unserialize columns $columns = unserialize($results); if (is_array($columns)) { return $columns; } else { //if it is empty then load a default set return CompanyHelper::getDefaultColumnFilters(); } }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); // Create toolbar $this->toolbar = new Toolbar(); //javascripts $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //gather information for view $model = new TemplatesModel(); //get layout $layout = $this->getLayout(); $model->set("_layout", $layout); //filter for layout type if ($layout == "edit") { //toolbar buttons $this->toolbar->cancel(); $this->toolbar->save(); //javascripts $document->addScript(JURI::base() . 'src/Cobalt/media/js/template_manager.js'); //assign view data $this->template_types = DropdownHelper::getTemplateTypes(); $this->template = $model->getTemplate(); } else { //buttons $this->toolbar->addNew(); ToolbarHelper::editList('edit'); $this->toolbar->addDeleteRow(); $templates = $model->getTemplates(); $this->templates = $templates; // Initialise state variables. $state = $model->getState(); $this->state = $state; $this->listOrder = $this->state->get('Templates.filter_order'); $this->listDirn = $this->state->get('Templates.filter_order_Dir'); } //display return parent::render(); }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); $document = JFactory::getDocument(); $document->addScript(JURI::base() . "/src/Cobalt/media/js/cobalt-admin.js"); /** Menu Links **/ $side_menu = MenuHelper::getMenuModules(); $this->side_menu = $side_menu; // Create toolbar $this->toolbar = new Toolbar(); $this->toolbar->save(); $model = new MenuModel(); $menu = $model->getMenu(); $menu_template = $model->getMenuTemplate(); $this->menu = $menu; $this->menu_template = $menu_template; //display return parent::render(); }
public function getUsers($user_id, $user_role) { if ($user_role != 'basic') { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select("id"); $query->from("#__users"); //if manager if ($user_role == "manager") { $team_id = UsersHelper::getTeamId($user_id); $query->where('team_id=' . $team_id); } //if exec there is no where clause, load all users //load results $db->setQuery($query); $results = $db->loadColumn(); } else { $results = array($user_id); } return $results; }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //document $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js'); /** Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //gather information for view $model = new SourcesModel(); $layout = $this->getLayout(); $model->set("_layout", $layout); $this->pagination = $model->getPagination(); if ($layout && $layout == 'edit') { //toolbar ToolbarHelper::cancel('cancel'); ToolbarHelper::save('save'); //information for view $this->source_types = DropdownHelper::getSources(); $this->source = $model->getSource(); } else { //buttons ToolbarHelper::addNew('edit'); ToolbarHelper::editList('edit'); ToolbarHelper::deleteList(TextHelper::_('COBALT_CONFIRMATION'), 'delete'); //get sources $sources = $model->getSources(); $this->sources = $sources; // Initialise state variables. $state = $model->getState(); $this->state = $state; $this->listOrder = $this->state->get('Sources.filter_order'); $this->listDirn = $this->state->get('Sources.filter_order_Dir'); $this->saveOrder = $this->listOrder == 's.ordering'; } //display return parent::render(); }
/** * Get sources for return on investment reports * @param none * @return mixed $results */ public function getRoiSources() { //get DBO $db = JFactory::getDBO(); $query = $db->getQuery(true); //construct query string $query->select("s.id,s.name,count(d.id) as number_of_deals,sum(d.amount) as revenue,s.type,s.cost"); $query->select("IF ( s.type <> 'per', ( ( ( ( sum(d.amount) - s.cost ) / s.cost ) * 100 ) ), ( ( sum(d.amount) - ( s.cost * count(d.id) ) ) / ( s.cost * count(d.id) ) * 100 ) ) AS roi"); $query->from("#__sources AS s"); //left join data $won_stage_ids = DealHelper::getWonStages(); $query->leftJoin("#__deals AS d ON d.source_id = s.id AND d.stage_id IN (" . implode(',', $won_stage_ids) . ") AND d.published=1 AND d.archived=0"); $query->leftJoin("#__users AS u ON u.id = d.owner_id"); //set our sorting direction if set via post $query->order($this->getState('Source.filter_order') . ' ' . $this->getState('Source.filter_order_Dir')); //group data $query->group("s.id"); if ($this->_id) { if (is_array($this->_id)) { $query->where("s.id IN (" . implode(',', $this->_id) . ")"); } else { $query->where("s.id={$this->_id}"); } } //filter based on member access roles $user_id = UsersHelper::getUserId(); $member_role = UsersHelper::getRole(); $team_id = UsersHelper::getTeamId(); if ($member_role != 'exec') { if ($member_role == 'manager') { $query->where("u.team_id={$team_id}"); } else { $query->where("(d.owner_id={$user_id})"); } } //set query and load results $db->setQuery($query); $results = $db->loadAssocList(); return $results; }
/** * Method to store a record * * @return boolean True on success */ public function store() { $app = \Cobalt\Container::fetch('app'); //Load Tables $row = new ConversationTable(); $oldRow = new ConversationTable(); $data = $app->input->getRequest('post'); //date generation $date = DateHelper::formatDBDate(date('Y-m-d H:i:s')); if (!array_key_exists('id', $data)) { $data['created'] = $date; $status = "created"; } else { $row->load($data['id']); $oldRow->load($data['id']); $status = "updated"; } $data['modified'] = $date; $data['author'] = UsersHelper::getUserId(); // Bind the form fields to the table if (!$row->bind($data)) { $this->setError($this->db->getErrorMsg()); return false; } // Make sure the record is valid if (!$row->check()) { $this->setError($this->db->getErrorMsg()); return false; } // Store the web link table to the database if (!$row->store()) { $this->setError($this->db->getErrorMsg()); return false; } $id = array_key_exists('id', $data) ? $data['id'] : $this->db->insertId(); ActivityHelper::saveActivity($oldRow, $row, 'conversation', $status); return $id; }
public function render() { //app $this->app = JFactory::getApplication(); //load reports menu bar $this->menu = TemplateHelper::loadReportMenu(); //get document $this->document = JFactory::getDocument(); //determine view layout $this->layout = $this->getLayout(); $func = "_display_" . $this->layout; if (method_exists($this, $func)) { $this->{$func}(); } //assign user filter priviliges $this->member_role = UsersHelper::getRole(); $this->user_id = UsersHelper::getUserId(); $this->team_id = UsersHelper::getTeamId(); //if the user is not basic then they are able to filter through company/team/user data if ($this->member_role != 'basic') { //exec can see teams if ($this->member_role == 'exec') { $this->teams = UsersHelper::getTeams(); } //manager and exec users $this->users = UsersHelper::getUsers(); } //assign team names for drop downs $this->team_names = DropdownHelper::getTeamNames(); //assign user names for drop downs $this->user_names = DropdownHelper::getUserNames(); //assign categories for drop downs $this->categories = NoteHelper::getCategories(); //display return parent::render(); }
/** * Populate user state requests */ public function populateState() { //get states $app = \Cobalt\Container::fetch('app'); //determine view so we set correct states $view = $this->view; $layout = $this->layout; // if ( $view == "events" && ( $layout == "default" || $layout == "list" || $layout == null ) ) { // Get pagination request variables $limit = $app->getUserStateFromRequest("Event." . $view . '_' . $layout . '_limit', 'limit', 10); $limitstart = $app->getUserStateFromRequest("Event." . $view . '_' . $layout . '_limitstart', 'limitstart', 0); // In case limit has been changed, adjust it $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $state = new Registry(); $state->set("Event." . $view . '_limit', $limit); $state->set("Event." . $view . '_limitstart', $limitstart); //set default filter states for reports $filterOrder = "CASE e.type WHEN 'event' THEN e.start_time WHEN 'task' THEN e.due_date ELSE e.due_date END"; $filterOrderDir = "ASC"; $filter_order = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_filter_order', 'filter_order', $filterOrder); $filter_order_Dir = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_filter_order_Dir', 'filter_order_Dir', $filterOrderDir); $status_filter = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_status', 'status', 0); $type_filter = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_type', 'type', 'all'); $category_filter = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_category', 'category', 'any'); $due_date_filter = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_due_date', 'due_date', 'any'); $association_type_filter = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_association_type', 'association_type', 'any'); $assignee_id_filter = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_assignee_id', 'assignee_id', UsersHelper::getUserId()); $assignee_filter_type = $app->getUserStateFromRequest('Event.' . $view . '_' . $layout . '_assignee_filter_type', 'assignee_filter_type', 'individual'); //set states for reports $state->set('Event.' . $view . '_' . $layout . '_filter_order', $filter_order); $state->set('Event.' . $view . '_' . $layout . '_filter_order_Dir', $filter_order_Dir); $state->set('Event.' . $view . '_' . $layout . '_status', $status_filter); $state->set('Event.' . $view . '_' . $layout . '_type', $type_filter); $state->set('Event.' . $view . '_' . $layout . '_category', $category_filter); $state->set('Event.' . $view . '_' . $layout . '_due_date', $due_date_filter); $state->set('Event.' . $view . '_' . $layout . '_association_type', $association_type_filter); $state->set('Event.' . $view . '_' . $layout . '_assignee_id', $assignee_id_filter); $state->set('Event.' . $view . '_' . $layout . '_assignee_filter_type', $assignee_filter_type); $this->setState($state); //} }
<?php defined('_CEXEC') or die; use Cobalt\Helper\UsersHelper; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <jdoc:include type="head" /> <link rel="stylesheet" href="<?php echo $this->baseurl; ?> /themes/default/css/default.css" /> </head> <body class="contentpane"> <jdoc:include type="message" /> <?php if (UsersHelper::isAdmin() && count(JToolbar::getInstance()->getItems()) > 0) { echo '<div class="container">' . JToolbar::getInstance()->render() . '</div>'; } ?> <jdoc:include type="crm" /> </body> </html>
public function render() { $app = JFactory::getApplication(); //determine the type of goal we are creating//editing $type = $app->input->get('type'); //edit layout if ($this->getLayout() == 'edit') { switch ($type) { case "win_cash": $header = ucwords(TextHelper::_('COBALT_WIN_MORE_CASH')); break; case "win_deals": $header = ucwords(TextHelper::_('COBALT_WIN_MORE_DEALS')); break; case "move_deals": $header = ucwords(TextHelper::_('COBALT_MOVE_DEALS_FORWARD')); break; case "complete_tasks": $header = ucwords(TextHelper::_('COBALT_COMPLETE_TASKS')); break; case "write_notes": $header = ucwords(TextHelper::_('COBALT_WRITE_NOTES')); break; case "create_deals": $header = ucwords(TextHelper::_('COBALT_CREATE_DEALS')); break; default: $app->redirect('index.php?view=goals'); break; } $this->header = $header; } elseif ($this->getLayout() != 'add') { //load model $model = new GoalModel(); //get all goals from model depending on user type $member_role = UsersHelper::getRole(); //basic members if ($member_role == 'basic') { $individual_goals = $model->getIndividualGoals(); $team_goals = $model->getTeamGoals(); $company_goals = $model->getCompanyGoals(); $leaderboards = $model->getLeaderBoards(); } //managers if ($member_role == 'manager') { // $individual_goals = $model->getManagerIndividualGoals(); $individual_goals = $model->getIndividualGoals(); $team_goals = $model->getTeamGoals(); $company_goals = $model->getCompanyGoals(); $leaderboards = $model->getLeaderBoards(); } //executives if ($member_role == 'exec') { // $individual_goals = $model->getExecIndividualGoals(); $individual_goals = $model->getIndividualGoals(); // $team_goals = $model->getExecTeamGoals(); $team_goals = $model->getTeamGoals(); $company_goals = $model->getCompanyGoals(); $leaderboards = $model->getLeaderBoards(); } //assign goals to global goal object to pass through to view $goals = new \stdClass(); $goals->individual_goals = $individual_goals; $goals->team_goals = $team_goals; $goals->company_goals = $company_goals; $goals->leaderboards = $leaderboards; //if we get results then load the default goals page else show the add goals page $goal_count = false; foreach ($goals as $goal_list) { if (count($goal_list) > 0) { $goal_count = true; } } if ($goal_count) { //set layout $this->setLayout('default'); //assign view refs $this->goals = $goals; } else { //add goal layout $this->setLayout('add'); } } //load java libs $doc = JFactory::getDocument(); $doc->addScript(JURI::base() . 'src/Cobalt/media/js/goal_manager.js'); //get associated members and teams $teams = UsersHelper::getTeams(); $users = UsersHelper::getUsers(); $member_role = UsersHelper::getRole(); $user_id = UsersHelper::getUserId(); $team_id = UsersHelper::getTeamId(); //assign view refs $this->type = $type; $this->teams = $teams; $this->users = $users; $this->user_id = $user_id; $this->team_id = $team_id; $this->member_role = $member_role; $this->leaderboard_list = DropdownHelper::getLeaderBoards(); //display return parent::render(); }