Exemple #1
0
 public function execute()
 {
     $success = false;
     $data = $this->getInput()->get('import_id', array(), 'ARRAY');
     $import_type = $this->getInput()->getString('import_type');
     if (is_array($data) && count($data) > 0) {
         switch ($import_type) {
             case "companies":
                 $import_model = "company";
                 break;
             case "deals":
                 $import_model = "deal";
                 break;
             case "people":
                 $import_model = "people";
                 break;
         }
         if (isset($import_model)) {
             $model = new ImportModel();
             if ($model->importCSVData($data, $import_model)) {
                 $success = true;
             }
         }
     }
     if ($success) {
         $msg = TextHelper::_('COBALT_IMPORT_WAS_SUCCESSFUL');
         $this->getApplication()->redirect(RouteHelper::_('index.php?view=' . $import_type), $msg);
     } else {
         $msg = TextHelper::_('COBALT_ERROR_IMPORTING');
         $this->getApplication()->redirect(RouteHelper::_('index.php?view=' . $import_type), $msg);
     }
 }
Exemple #2
0
 public function execute()
 {
     $item_id = $this->getInput()->get('item_id', null, 'array');
     $item_type = $this->getInput()->get('item_type');
     //ADD TO MODELS * trash model *
     $db = $this->container->fetch('db');
     $query = $db->getQuery(true);
     $query->update("#__" . $item_type)->set("published=-1");
     if (is_array($item_id)) {
         $query->where("id IN(" . implode(',', $item_id) . ")");
     } else {
         $query->where("id=" . $item_id);
     }
     $db->setQuery($query);
     if ($db->execute()) {
         $data['success'] = true;
         $msg = TextHelper::_('COBALT_SUCCESSULLY_REMOVED_ITEM');
     } else {
         $data['success'] = false;
         $data['error_msg'] = $db->getErrorMsg();
         $msg = TextHelper::_('COBALT_ERROR_REMOVING_ITEM');
     }
     $redirect = $this->getInput()->get('page_redirect');
     if ($redirect) {
         $this->getApplication()->redirect(RouteHelper::_('index.php?view=' . $redirect), $msg);
     } else {
         $data['remove'] = $item_id;
         echo json_encode($data);
     }
 }
Exemple #3
0
 public function render($tpl = null)
 {
     $app = \Cobalt\Container::fetch('app');
     $doc = $app->getDocument();
     $doc->addScript(JURI::base() . 'src/Cobalt/media/js/import_manager.js');
     if (count($_FILES) > 0) {
         $model = new ImportModel();
         foreach ($_FILES as $file) {
             $import_data = $model->readCSVFile($file['tmp_name']);
         }
         $this->headers = $import_data['headers'];
         unset($import_data['headers']);
         $this->import_data = $import_data;
         if (count($import_data) > 500) {
             switch ($app->input->get('import_type')) {
                 case "company":
                     $view = "companies";
                     $import_model = "company";
                     break;
                 case "people":
                     $view = "people";
                     $import_model = "people";
                     break;
                 case "deals":
                     $view = "deals";
                     $import_model = "deal";
                     break;
             }
             if ($model->importCSVData($import_data, $import_model)) {
                 $success = "SUCCESSFULLY";
             } else {
                 $success = "UNSUCCESSFULLY";
                 $view = "import&import_type=" . $app->input->get('import_type');
             }
             $msg = TextHelper::_('COBALT_' . $success . '_IMPORTED_ITEMS');
             $app->redirect(RouteHelper::_('index.php?view=' . $view), $msg);
         }
         $doc->addScriptDeclaration('import_length=' . count($import_data) . ';');
     }
     $import_type = $app->input->get('import_type');
     $import_header = ucwords(TextHelper::_('COBALT_IMPORT_' . $import_type));
     $this->import_type = $import_type;
     $this->import_header = $import_header;
     if ($this->getLayout() == 'default') {
         $this->setLayout('import');
     }
     //display
     return parent::render();
 }
Exemple #4
0
 /**
  * Execute the controller
  *
  * @return  boolean  True if controller finished execution
  *
  * @since   1.0
  */
 public function execute()
 {
     // If logged in, move on to the manager
     if ($this->getApplication()->getUser()->isAuthenticated()) {
         $this->getApplication()->redirect(RouteHelper::_('index.php?view=dashboard'));
     }
     $method = $this->getInput()->getMethod();
     $username = $this->getInput()->{$method}->get('username', false, 'username');
     $password = $this->getInput()->{$method}->get('password', false, 'raw');
     if ($username && $password) {
         $this->getApplication()->login();
     }
     $this->getInput()->set('view', 'login');
     return parent::execute();
 }
Exemple #5
0
 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()
 {
     //open model
     $model = new PeopleModel();
     //retrieve all people
     $people = $model->getPeopleList();
     if (count($people)) {
         foreach ($people as $index => $row) {
             $people[$index]['type'] = "person";
             $people[$index]['association_link'] = RouteHelper::_('index.php?view=people&layout=person&id=' . $row['id']);
         }
     }
     //open model
     $model = new DealModel();
     //retrieve all people
     $deals = $model->getDealList();
     if (count($deals)) {
         foreach ($deals as $index => $row) {
             $deals[$index]['type'] = 'deal';
             $deals[$index]['association_link'] = RouteHelper::_('index.php?view=deals&layout=deal&id=' . $row['id']);
         }
     }
     //open model
     $model = new CompanyModel();
     //retrieve all people
     $companies = $model->getCompanyList();
     if (count($companies)) {
         foreach ($companies as $index => $row) {
             $companies[$index]['type'] = 'company';
             $companies[$index]['association_link'] = RouteHelper::_('index.php?view=companies&layout=company&id=' . $row['id']);
         }
     }
     //merge our results to a grand object
     $results = array_merge($people, $deals, $companies);
     //return results as json object
     echo json_encode($results);
 }
Exemple #7
0
 /**
  * Create and return the pagination data object.
  *
  * @return object Pagination data object.
  *
  * @since   11.1
  */
 protected function _buildDataObject()
 {
     // Initialise variables.
     $data = new \stdClass();
     // Build the additional URL parameters string.
     $params = '';
     if (!empty($this->_additionalUrlParams)) {
         foreach ($this->_additionalUrlParams as $key => $value) {
             $params .= '&' . $key . '=' . $value;
         }
     }
     $data->all = new CobaltPaginationObject(TextHelper::_('JLIB_HTML_VIEW_ALL'), $this->prefix, $this->base, $this->link);
     if (!$this->_viewall) {
         $data->all->base = '0';
         $data->all->link = RouteHelper::_($this->link . '?' . $params . '&' . $this->prefix . 'limitstart=');
     }
     // Set the start and previous data objects.
     $data->start = new CobaltPaginationObject(TextHelper::_('JLIB_HTML_START'), $this->prefix, $this->base, $this->link);
     $data->previous = new CobaltPaginationObject(TextHelper::_('JPREV'), $this->prefix, $this->base, $this->link);
     if ($this->get('pages.current') > 1) {
         $page = ($this->get('pages.current') - 2) * $this->limit;
         // Set the empty for removal from route
         //$page = $page == 0 ? '' : $page;
         $data->start->base = '0';
         $data->start->link = RouteHelper::_($this->link . '?' . $params . '&' . $this->prefix . 'limitstart=0');
         $data->previous->base = $page;
         $data->previous->link = RouteHelper::_($this->link . '?' . $params . '&' . $this->prefix . 'limitstart=' . $page);
     }
     // Set the next and end data objects.
     $data->next = new CobaltPaginationObject(TextHelper::_('JNEXT'), $this->prefix, $this->base, $this->link);
     $data->end = new CobaltPaginationObject(TextHelper::_('JLIB_HTML_END'), $this->prefix, $this->base, $this->link);
     if ($this->get('pages.current') < $this->get('pages.total')) {
         $next = $this->get('pages.current') * $this->limit;
         $end = ($this->get('pages.total') - 1) * $this->limit;
         $data->next->base = $next;
         $data->next->link = RouteHelper::_($this->link . '?' . $params . '&' . $this->prefix . 'limitstart=' . $next);
         $data->end->base = $end;
         $data->end->link = RouteHelper::_($this->link . '?' . $params . '&' . $this->prefix . 'limitstart=' . $end);
     }
     $data->pages = array();
     $stop = $this->get('pages.stop');
     for ($i = $this->get('pages.start'); $i <= $stop; $i++) {
         $offset = ($i - 1) * $this->limit;
         // Set the empty for removal from route
         //$offset = $offset == 0 ? '' : $offset;
         $data->pages[$i] = new CobaltPaginationObject($i, $this->prefix, $this->base, $this->link);
         if ($i != $this->get('pages.current') || $this->_viewall) {
             $data->pages[$i]->base = $offset;
             $data->pages[$i]->link = RouteHelper::_($this->link . '?' . $params . '&' . $this->prefix . 'limitstart=' . $offset);
         }
     }
     return $data;
 }
Exemple #8
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'name':
             $template = '<a href="' . RouteHelper::_('index.php?view=deals&layout=deal&id=' . $item->id) . '">' . $item->name . '</a>';
             break;
         case 'company_name':
             $template = '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&id=' . $item->company_id) . '">' . $item->company_name . '</a>';
             break;
         case 'amount':
             $template = ConfigHelper::getCurrency() . $item->amount;
             break;
         case 'status_name':
             if (!isset($item->status_id) || !$item->status_id) {
                 $item->status_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $statuses = DealHelper::getStatuses(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_status_' . $item->id . '_link">';
             $template .= '  <span class="deal-status-' . $item->status_name . '">' . $item->status_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_status_' . $item->id . '" role="menu">';
             if (isset($statuses) && count($statuses)) {
                 foreach ($statuses as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="status_select dropdown_item" data-field="status_id" data-item="deal" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="deal-status-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'stage_name':
             if (!isset($item->stage_id) || !$item->stage_id) {
                 $item->stage_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $stages = DealHelper::getStages(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_stage_' . $item->id . '_link">';
             $template .= '  <span class="deal-stage-' . $item->stage_name . '">' . $item->stage_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_stage_' . $item->id . '" role="menu">';
             if (isset($stages) && count($stages)) {
                 foreach ($stages as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="stage_select dropdown_item" data-field="stage_id" data-item="deal" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="deal-stage-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'source_name':
             if (!isset($item->source_id) || !$item->source_id) {
                 $item->source_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $sources = DealHelper::getSources(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_source_' . $item->id . '_link">';
             $template .= '  <span class="deal-source-' . $item->source_name . '">' . $item->source_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_source_' . $item->id . '" role="menu">';
             if (isset($sources) && count($sources)) {
                 foreach ($sources as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="source_select dropdown_item" data-field="source_id" data-item="deal" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="deal-source-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'expected_close':
             if ($item->expected_close == "0000-00-00 00:00:00") {
                 $template = TextHelper::_('COBALT_NOT_SET');
             } else {
                 $template = DateHelper::formatDate($item->expected_close);
             }
             break;
         case 'actual_close':
             if ($item->actual_close == "0000-00-00 00:00:00") {
                 $template = TextHelper::_('COBALT_ACTIVE_DEAL');
             } else {
                 $template = DateHelper::formatDate($item->actual_close);
             }
             break;
         case 'action':
             $template = '<div class="btn-group">';
             // @TODO: make these 2 buttons work
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_CONTACTS').'" data-placement="bottom" class="btn" href="javascript:void(0);" onclick="Cobalt.showDealContactsDialogModal('.$item->id.');"><i class="glyphicon glyphicon-user"></i></a>';
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_NOTES').'" data-placement="bottom" class="btn" href="javascript:void(0);" onclick="openNoteModal(\'.deal->id.\',\'deal\');"><i class="glyphicon glyphicon-file"></i></a>';
             $template .= ' <a data-toggle="popover" title="' . TextHelper::_('COBALT_VIEW_DETAILS') . '" data-placement="top" data-html="true" data-content-class="extras-' . $item->id . '" class="btn btn-xs btn-default" href="#" tabindex="0"><i class="glyphicon glyphicon-info-sign"></i></a>';
             $template .= '</div>';
             $template .= '<div class="extras-' . $item->id . ' hide">';
             $template .= ' <b>' . TextHelper::_('COBALT_PRIMARY_CONTACT') . '</b>';
             $template .= ' <a href="' . RouteHelper::_('index.php?view=people&layout=person&id=' . $item->primary_contact_id) . '">' . $item->primary_contact_first_name . '</a><br>';
             $template .= ' <b>' . TextHelper::_('COBALT_NEXT_ACTION') . '</b><br>';
             $template .= '</div>';
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Exemple #9
0
 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();
 }
Exemple #10
0
 public static function getQuickMenuLinks()
 {
     return array(array('link' => RouteHelper::_('index.php?controller=users&task=add'), 'class' => 'glyphicon glyphicon-user', 'text' => TextHelper::_('COBALT_ADD_NEW_USER'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=stages&task=add'), 'class' => 'glyphicon glyphicon-tasks', 'text' => TextHelper::_('COBALT_ADD_NEW_DEAL_STAGE'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=categories&task=add'), 'class' => 'glyphicon glyphicon-th-list', 'text' => TextHelper::_('COBALT_ADD_NEW_NOTE_CATEGORY'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=sources&task=add'), 'class' => 'glyphicon glyphicon-random', 'text' => TextHelper::_('COBALT_ADD_NEW_SOURCE'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=companycustom&task=add'), 'class' => 'glyphicon glyphicon-edit', 'text' => TextHelper::_('COBALT_ADD_NEW_COMPANY_CUSTOM_FIELD'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=peoplecustom&task=add'), 'class' => 'glyphicon glyphicon-edit', 'text' => TextHelper::_('COBALT_ADD_NEW_PEOPLE_CUSTOM_FIELD'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=dealcustom&task=add'), 'class' => 'glyphicon glyphicon-edit', 'text' => TextHelper::_('COBALT_ADD_NEW_DEAL_CUSTOM_FIELD'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=statuses&task=add'), 'class' => 'glyphicon glyphicon-thumbs-up', 'text' => TextHelper::_('COBALT_ADD_NEW_PERSON_STATUS'), 'access' => array()), array('link' => RouteHelper::_('index.php?controller=templates&task=add'), 'class' => 'glyphicon glyphicon-filter', 'text' => TextHelper::_('COBALT_CREATE_NEW_WORKFLOW'), 'access' => array()));
 }
Exemple #11
0
 public static function to($url)
 {
     return RouteHelper::_(\Cobalt\Container::fetch('app')->getRouter()->getRouteFor($url));
 }
Exemple #12
0
 /**
  * Logs the user into the application
  *
  * @return  void  Redirects the application
  *
  * @since   1.0
  * @throws  AuthenticationException
  */
 public function login()
 {
     // Get the Authentication object
     $authentication = new Authentication();
     // Add our authentication strategy
     $strategy = new DatabaseStrategy($this->input, $this->getContainer()->get('db'));
     $authentication->addStrategy('database', $strategy);
     // Authenticate the user
     $authentication->authenticate(array('database'));
     switch ($strategy->getResult()) {
         case Authentication::NO_CREDENTIALS:
             throw new AuthenticationException('A username and/or password were not provided.');
         case Authentication::NO_SUCH_USER:
             throw new AuthenticationException('The username provided does not exist.');
         case Authentication::INVALID_CREDENTIALS:
             throw new AuthenticationException('The username and/or password is incorrect.');
         case Authentication::SUCCESS:
             $user = $this->getUser();
             $user->loadByUsername($this->input->{$this->input->getMethod()}->get('username', false, 'username'));
             // Set the authenticated user in the session and redirect to the manager
             $this->setUser($user)->redirect(RouteHelper::_('index.php?view=dashboard'));
     }
 }
Exemple #13
0
 /**
  * Execute the controller
  *
  * @return  void  Redirects the application
  *
  * @since   1.0
  */
 public function execute()
 {
     $this->getApplication()->setUser(null)->redirect(RouteHelper::_('index.php', false));
 }
Exemple #14
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'name':
             $class = $item->completed ? 'line-through' : '';
             $template = '<div class="dropdown"><a data-toggle="dropdown" role="button" class="dropdown-toggle ' . $class . '" id="event_menu_' . $item->id . '_link" >' . $item->name . '</a>';
             $template .= '<ul class="dropdown-menu" role="menu" aria-labelledby="event_menu_' . $item->id . '_link">';
             if ($item->completed == 1) {
                 $template .= '<li><a href="javascript:void(0);" onclick="Calendar.markEventIncomplete(this)" >' . TextHelper::_('COBALT_MARK_INCOMPLETE') . '</a></li>';
             } else {
                 $template .= '<li><a href="javascript:void(0);" onclick="Calendar.markEventComplete(this)" >' . TextHelper::_('COBALT_MARK_COMPLETE') . '</a></li>';
                 $template .= '<li><a href="javascript:void(0);" onclick="Calendar.postponeEvent(this,1)" >' . TextHelper::_('COBALT_POSTPONE_1_DAY') . '</a></li>';
                 $template .= '<li><a href="javascript:void(0);" onclick="Calendar.postponeEvent(this,7)" >' . TextHelper::_('COBALT_POSTPONE_7_DAYS') . '</a></li>';
             }
             $id = $item->parent_id != 0 ? $item->parent_id : $item->id;
             $template .= '<li><a href="javascript:void(0);" onclick="Calendar.editEvent(' . $id . ',\'' . $item->type . '\')" >' . TextHelper::_('COBALT_EDIT') . '</a></li>';
             $template .= '<li><a href="javascript:void(0);" onclick="Calendar.removeCalendarEvent(this)" >' . TextHelper::_('COBALT_DELETE') . '</a></li>';
             $template .= '</ul>';
             $template .= '</div>';
             break;
         case 'for':
             switch ($item->association_type) {
                 case 'deal':
                     $template = '<a href="' . RouteHelper::_('index.php?view=deals&layout=deal&id=' . $item->deal_id) . '">' . $item->deal_name . '</a>';
                     break;
                 case 'company':
                     $template = '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&id=' . $item->company_id) . '">' . $item->company_name . '</a>';
                     break;
                 case 'person':
                     $template = '<a href="' . RouteHelper::_('index.php?view=people&layout=person&id=' . $item->person_id) . '">' . $item->person_first_name . ' ' . $item->person_last_name . '</a>';
                     break;
                 default:
                     $template = '';
                     break;
             }
             break;
         case 'owner':
             $template = $item->owner_first_name . ' ' . $item->owner_last_name;
             break;
         case 'assigned_to':
             $template = $item->assignee_first_name . ' ' . $item->assignee_last_name;
             break;
         case 'contacts':
             $template = '<a href="javascript:void(0);" onclick="Calendar.showEventContactsDialogModal(' . $item->id . ');"><img src="' . \JURI::base() . 'src/Cobalt/media/images/card.png' . '"/></a>';
             break;
         case 'notes':
             $template = '<a href="javascript:void(0);" onclick="Calendar.openNoteModal(\'' . $item->id . '\',\'event\');"><img src="' . \JURI::base() . 'src/Cobalt/media/images/notes.png' . '"/></a>';
             $template .= '<div id="event_form_' . $item->id . '">';
             $template .= '<input type="hidden" name="event_id" value="' . $item->id . '" />';
             $template .= '<input type="hidden" name="parent_id" value="' . $item->parent_id . '" />';
             if ($item->type == "task") {
                 $template .= '<input type="hidden" name="date" value="' . $item->due_date . '" />';
             } else {
                 $template .= '<input type="hidden" name="date" value="' . $item->start_time . '" />';
             }
             $template .= '<input type="hidden" name="event_type" value="' . $item->type . '" />';
             $template .= '<input type="hidden" name="repeats" value="' . $item->repeats . '" />';
             $template .= '<input type="hidden" name="type" value="single" />';
             $template .= '</div>';
             $template .= '<div class="filters" id="event_menu_' . $item->id . '">';
             $template .= '<ul>';
             if ($item->completed == 1) {
                 $template .= '<li><a href="javascript:void(0);" onclick="markEventIncomplete(this)" >' . TextHelper::_('COBALT_MARK_INCOMPLETE') . '</a></li>';
             } else {
                 $template .= '<li><a href="javascript:void(0);" onclick="markEventComplete(this)" >' . TextHelper::_('COBALT_MARK_COMPLETE') . '</a></li>';
                 $template .= '<li><a href="javascript:void(0);" onclick="postponeEvent(this,1)" >' . TextHelper::_('COBALT_POSTPONE_1_DAY') . '</a></li>';
                 $template .= '<li><a href="javascript:void(0);" onclick="postponeEvent(this,7)" >' . TextHelper::_('COBALT_POSTPONE_7_DAYS') . '</a></li>';
             }
             $id = $item->parent_id != 0 ? $item->parent_id : $item->id;
             $template .= '<li><a href="javascript:void(0);" onclick="editEvent(' . $id . ',\'' . $item->type . '\')" >' . TextHelper::_('COBALT_EDIT') . '</a></li>';
             $template .= '<li><a href="javascript:void(0);" onclick="deleteEvent(this)" >' . TextHelper::_('COBALT_DELETE') . '</a></li>';
             $template .= '</ul>';
             $template .= '</div>';
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Exemple #15
0
 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();
 }
Exemple #16
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'name':
             $template = '<div class="title_holder">';
             $template .= '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&company_id=' . $item->id) . '">' . $item->name . '</a>';
             $template .= '</div>';
             if ($item->address_formatted != '') {
                 $template .= '<address>' . $item->address_formatted . '</address>';
             }
             $template .= '<div class="hidden"><small>' . $item->description . '</small></div>';
             break;
         case 'contact_info':
             $template = $item->phone . '<br>' . $item->email;
             break;
         case 'modified':
             $template = DateHelper::formatDate($item->modified);
             break;
         case 'created':
             $template = DateHelper::formatDate($item->created);
             break;
         case 'action':
             $template = '<div class="btn-group">';
             // @TODO: make these 2 buttons work
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_CONTACTS').'" data-placement="bottom" class="btn" href="#" onclick="showCompanyContactsDialogModal('.$item->id.')"><i class="glyphicon glyphicon-user"></i></a>';
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_NOTES').'" data-placement="bottom" class="btn" href="#" onclick="openNoteModal('.$item->id.',\'company\');"><i class="glyphicon glyphicon-file"></i></a>';
             $template .= '</div>';
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Exemple #17
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'type':
             $file_path = sprintf('%s/media/images/%s.png', JPATH_COBALT, $item->filetype);
             if (file_exists($file_path)) {
                 $file_src = sprintf('%s/src/Cobalt/media/images/%s.png', JUri::base(), $item->filetype);
                 $template = '<img src="' . $file_src . '" >';
             } else {
                 $file_src = sprintf('%s/src/Cobalt/media/images/file.png', JUri::base());
                 $template = '<img src="' . $file_src . '" >';
             }
             break;
         case 'name':
             $template = '<div class="dropdown"><span class="caret"></span><a id="' . $item->id . '" class="document_edit dropdown-toggle" data-toggle="dropdown" role="button" href="javascript:void(0);"> ' . $item->name . '</a>';
             $template .= '<ul class="dropdown-menu" role="menu">';
             $template .= '<li><a href="' . RouteHelper::_('index.php?task=PreviewDocument&format=raw&tmpl=component&document=' . $item->filename) . '" target="_blank" class="document_preview" id="preview_' . $item->id . '"><i class="glyphicon glyphicon-eye-open"></i> ' . TextHelper::_('COBALT_PREVIEW') . '</a></li>';
             $template .= '<li><a href="' . RouteHelper::_('index.php?task=DownloadDocument&format=raw&tmpl=component&document=' . $item->filename) . '" target="_blank" class="document_download" id="download_' . $item->id . '"><i class="glyphicon glyphicon-download"></i> ' . TextHelper::_('COBALT_DOWNLOAD') . '</a></li>';
             if ($item->owner_id == UsersHelper::getLoggedInUser()->id) {
                 $template .= '<li><a href="javascript:void(0);" class="document_delete" id="delete_' . $item->id . '"><i class="glyphicon glyphicon-remove"></i> ' . TextHelper::_('COBALT_DELETE') . '</a></li>';
             }
             $template .= '</ul></div>';
             break;
         case 'association':
             $association_type = $item->association_type;
             //assign association link
             switch ($association_type) {
                 case "deal":
                     $view = 'deals';
                     $association_type = "deal";
                     $item->association_name = $item->deal_name;
                     break;
                 case "person":
                     $view = "people";
                     $association_type = "person";
                     $item->association_name = $item->owner_first_name . " " . $item->owner_last_name;
                     break;
                 case "company":
                     $view = "companies";
                     $association_type = "company";
                     $item->association_name = $item->company_name;
                     break;
             }
             if (isset($item->association_name)) {
                 $template = '<a href="' . RouteHelper::_('index.php?view=' . $view . '&layout=' . $association_type . '&id=' . $item->association_id) . '" >' . $item->association_name;
             } else {
                 $template = "";
             }
             break;
         case 'owner':
             $template = $item->owner_name;
             break;
         case 'size':
             $template = FileHelper::sizeFormat($item->size);
             break;
         case 'created':
             $template = DateHelper::formatDate($item->created);
             break;
         case 'modified':
             $template = DateHelper::formatDate($item->modified);
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Exemple #18
0
 /**
  * Generate pagination
  */
 public function getPagination()
 {
     // Lets load the content if it doesn't already exist
     if (empty($this->_pagination)) {
         $this->_pagination = new Pagination($this->getTotal(), $this->getState($this->_view . '_limitstart'), $this->getState($this->_view . '_limit'), null, RouteHelper::_('index.php?view=' . $this->_view . '&layout=' . $this->_layout));
     }
     return $this->_pagination;
 }
 public static function loadReportMenu()
 {
     $app = \Cobalt\Container::fetch('app');
     $activeLayout = $app->input->get('layout');
     $layouts = array('dashboard', 'sales_pipeline', 'source_report', 'roi_report', 'deal_milestones', 'notes', 'custom_reports');
     $str = "<ul class='nav nav-tabs'>";
     foreach ($layouts as $layout) {
         $languageString = strtoupper('COBALT_' . $layout);
         if ($layout == 'dashboard') {
             $layout = 'default';
         }
         $class = $activeLayout == $layout ? 'class=active' : '';
         $str .= '<li ' . $class . '><a href="' . RouteHelper::_('index.php?view=reports&layout=' . $layout) . '" >' . ucwords(TextHelper::_($languageString)) . '</a></li>';
     }
     $str .= "</ul>";
     return $str;
 }
Exemple #20
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'avatar':
             if (isset($item->avatar) && $item->avatar) {
                 $template = '<img id="avatar_img_' . $item->id . '" data-item-type="people" data-item-id="' . $item->id . '" class="avatar" src="' . JURI::base() . 'src/Cobalt/media/avatars/' . $item->avatar . '"/>';
             } else {
                 $template = '<img id="avatar_img_' . $item->id . '" data-item-type="people" data-item-id="' . $item->id . '" class="avatar" src="' . JURI::base() . 'src/Cobalt/media/images/person.png' . '"/>';
             }
             break;
         case 'name':
             $template = '<a href="' . RouteHelper::_('index.php?view=people&layout=person&id=' . $item->id) . '">' . $item->first_name . ' ' . $item->last_name . '</a>';
             break;
         case 'company_name':
             $template = '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&id=' . $item->company_id) . '">' . $item->company_name . '</a>';
             break;
         case 'owner':
             if (!isset($item->owner_last_name) || !$item->owner_last_name) {
                 $item->status_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $me = array(array('label' => TextHelper::_('COBALT_ME'), 'value' => UsersHelper::getLoggedInUser()->id));
             $users = UsersHelper::getUsers(null, true);
             $users = array_merge($me, $users);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="oerson_owner_' . $item->id . '_link">';
             $template .= $item->owner_first_name . ' ' . $item->owner_last_name;
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_status_' . $item->id . '" role="menu">';
             if (isset($users) && count($users)) {
                 foreach ($users as $id => $user) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="owner_select dropdown_item" data-field="owner_id" data-item="person" data-item-id="' . $item->id . '" data-value="' . $user['value'] . '">';
                     $template .= '    <span class="person-owner-' . OutputFilter::stringURLUnicodeSlug($user['value']) . '">' . $user['label'] . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'status_name':
             if (!isset($item->status_id) || !$item->status_id) {
                 $item->status_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $statuses = PeopleHelper::getStatusList();
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_stage_' . $item->id . '_link">';
             $template .= '  <span class="person-status-' . $item->status_name . '">' . $item->status_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_stage_' . $item->id . '" role="menu">';
             if (isset($statuses) && count($statuses)) {
                 foreach ($statuses as $id => $status) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="status_select dropdown_item" data-field="status_id" data-item="people" data-item-id="' . $item->id . '" data-value="' . $status['id'] . '">';
                     $template .= '    <span class="person-status-' . OutputFilter::stringURLUnicodeSlug($status['id']) . '">' . $status['name'] . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'source_name':
             if (!isset($item->source_id) || !$item->source_id) {
                 $item->source_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $sources = DealHelper::getSources(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="person_source_' . $item->id . '_link">';
             $template .= '  <span class="person-source-' . $item->source_name . '">' . $item->source_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="person_source_' . $item->id . '" role="menu">';
             if (isset($sources) && count($sources)) {
                 foreach ($sources as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="source_select dropdown_item" data-field="source_id" data-item="people" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="person-source-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'type':
             if (!isset($item->type) || !$item->type) {
                 $item->type = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $types = PeopleHelper::getPeopleTypes(false);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="person_type_' . $item->id . '_link">';
             $template .= $item->type;
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="person_type_' . $item->id . '" role="menu">';
             if (isset($types) && count($types)) {
                 foreach ($types as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="type_select dropdown_item" data-field="type" data-item="people" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="person-type-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'notes':
             // $template = '<a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_NOTES').'" data-placement="bottom" class="btn" href="#" onclick="Cobalt.openNoteModal('.$item->id.', \'people\');"><i class="glyphicon glyphicon-file"></i></a>';
             $template = '';
             // @TODO: Implement notes modal
             break;
         case 'address':
             $template = $item->work_city . '<br>' . $item->work_state . '<br>' . $item->work_zip . '<br>' . $item->work_country;
             break;
         case 'created':
             $template = DateHelper::formatDate($item->created);
             break;
         case 'modified':
             $template = DateHelper::formatDate($item->modified);
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Exemple #21
0
 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();
 }