public function execute() { $sampleIds = array(); $importModel = new ImportModel(); $sampleCsvFiles = array('sample-company' => "companies", 'sample-person' => "people", 'sample-deal' => "deals"); foreach ($sampleCsvFiles as $file => $table) { $importData = $importModel->readCSVFile(JPATH_COBALT . '/Sample/' . $file . '.csv', $table, false); switch ($table) { case "companies": $model = "company"; break; case "people": $model = "people"; break; case "deals": $model = "deal"; break; } unset($importData['headers']); $ids = $importModel->importCSVData($importData, $model, true); $sampleIds[$table] = $ids; } $data = array('import_sample' => serialize($sampleIds)); $configModel = new ConfigModel(); $configModel->store($data); $msg = TextHelper::_('COBALT_SAMPLE_DATA_INSTALLED'); $this->getApplication()->redirect('index.php?view=import', $msg); }
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(); /** 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 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); } }
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); } }
public function execute() { $company_name = $this->getInput()->getString('company_name'); $companyModel = new CompanyModel(); $existingCompany = $companyModel->checkCompanyName($company_name); if ($existingCompany != "") { echo json_encode(array('success' => true, 'company_id' => $existingCompany, 'message' => "")); } else { echo json_encode(array('success' => true, 'message' => ucwords(TextHelper::_('COBALT_COMPANY_WILL_BE_CREATED')))); } }
public function execute() { $person_name = $this->getInput()->getString('person_name'); $personModel = new PeopleModel(); $existingPerson = $personModel->checkPersonName($person_name); if ($existingPerson != "") { echo json_encode(array('success' => true, 'person_id' => $existingPerson, 'message' => "")); } else { echo json_encode(array('success' => true, 'message' => ucwords(TextHelper::_('COBALT_PERSON_WILL_BE_CREATED')))); } }
public function execute() { $deal_name = $this->getInput()->get('deal_name'); $dealModel = new DealModel(); $existingDeal = $dealModel->checkDealName($deal_name); if ($existingDeal != "") { echo json_encode(array('success' => true, 'deal_id' => $existingDeal, 'message' => "")); } else { echo json_encode(array('success' => true, 'message' => ucwords(TextHelper::_('COBALT_DEAL_WILL_BE_CREATED')))); } }
public function execute() { $emailExists = CobaltHelper::checkEmailName($this->getInput()->get('email')); if ($emailExists) { $success = true; $msg = TextHelper::_('COBALT_EMAIL_EXISTS'); } else { $success = true; $msg = TextHelper::_('COBALT_EMAIL_IS_AVAILABLE'); } echo json_encode(array('success' => $success, 'message' => $msg, 'email_exists' => $emailExists)); }
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 execute() { $model = new ReportModel(); //store data $link = 'index.php?view=reports&layout=custom_reports'; if ($model->store()) { $msg = TextHelper::_('COBALT_CUSTOM_REPORT_SUCCESSFULLY_ADDED'); $this->getApplication()->redirect($link, $msg); } else { $msg = TextHelper::_('COBALT_PROBLEM_CREATING_CUSTOM_REPORT'); $this->getApplication()->redirect($link, $msg); } }
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(); }
public function removeSampleData() { $sampleIds = unserialize(ConfigHelper::getConfigValue('import_sample')); $db = $this->container->resolve('db'); $query = $db->getQuery(true); foreach ($sampleIds as $table => $ids) { $query->clear()->delete("#__" . $table)->where("id IN(" . implode(',', $ids) . ")"); $db->setQuery($query); $db->query(); } $data = array('import_sample' => "0"); $configModel = new ConfigModel(); $configModel->store($data); $msg = TextHelper::_('COBALT_SAMPLE_DATA_REMOVED'); $this->getApplication()->redirect('index.php?view=import', $msg); }
public function execute() { $modelName = 'Cobalt\\Model\\' . ucwords($this->getInput()->get('model')); $controllerName = $this->getInput()->get('controller'); $objectName = $this->getInput()->get('model'); $model = new $modelName(); $ids = $this->getInput()->get('id'); if (is_array($ids)) { foreach ($ids as $id) { $model->remove($id); } } else { $model->remove($this->id); } $msg = TextHelper::_('COBALT_' . strtoupper($objectName) . '_REMOVED'); $this->getApplication()->redirect('index.php?view=' . $controllerName, $msg); }
/** * Saves the manually set order of records. * * @param array $pks An array of primary key ids. * @param integer $order +1 or -1 * * @return mixed * * @since 11.1 */ public function saveorder($pks = null, $order = null) { // Initialise variables. $app = \Cobalt\Container::fetch('app'); $data = $app->input->getRequest('post'); $tableClass = 'Cobalt\\Table\\' . ucfirst($data['view']) . 'Table'; if (!class_exists()) { return false; } $table = new $tableClass(); $conditions = array(); if (empty($pks)) { $app->enqueueMessage(TextHelper::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED'), 'error'); return false; } // update ordering values foreach ($pks as $i => $pk) { $table->load((int) $pk); if ($table->ordering != $order[$i]) { $table->ordering = $order[$i]; if (!$table->store()) { $this->setError($table->getError()); return false; } // Remember to reorder within position and client_id $condition = $this->getReorderConditions($table); $found = false; foreach ($conditions as $cond) { if ($cond[1] == $condition) { $found = true; break; } } if (!$found) { $key = $table->getKeyName(); $conditions[] = array($table->{$key}, $condition); } } } // Execute reorder for each category. foreach ($conditions as $cond) { $table->load($cond[0]); $table->reorder($cond[1]); } return true; }
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() { $model = $this->getModel('Avatar'); /** @var \Joomla\Registry\Registry $state */ $state = $model->getState(); $state->set('item_type', $app->input->get('item_type')); $state->set('item_id', $app->input->get('item_id')); $model->setState($state); $avatar = $model->saveAvatar(); if (empty($avatar)) { echo '<script type="text/javascript"> window.top.window.modalMessage("' . TextHelper::_('COBALT_ERROR') . '","' . TextHelper::_('COBALT_AVATAR_UPLOAD_ERROR') . '"); </script>'; } else { echo '<script type="text/javascript"> window.top.window.modalMessage("' . TextHelper::_('COBALT_SUCCESS_MESSAGE') . '","' . TextHelper::_('COBALT_AVATAR_UPLOAD_SUCCESS') . '"); window.top.window.updateAvatar(' . $state->get('item_id') . ',"' . $avatar . '"); </script>'; } }
public function execute() { $modelName = 'Cobalt\\Model\\' . ucwords($this->getInput()->get('model')); $controllerName = $this->getInput()->get('controller'); $objectName = $this->getInput()->get('model'); $model = new $modelName(); $ids = $this->getInput()->get('id'); if (is_array($ids)) { foreach ($ids as $id) { $deleted = $model->remove($id); } } else { $deleted = $model->remove($ids); } $response = new \stdClass(); $response->alert = new \stdClass(); $response->alert->message = TextHelper::_('COBALT_' . strtoupper($objectName) . '_REMOVED'); $response->alert->type = $deleted ? 'success' : 'error'; echo json_encode($response); }
public static function sendMail($layout, $recipient) { $mailer = JFactory::getMailer(); $mailer->isHTML(true); $mailer->Encoding = 'base64'; $config = JFactory::getConfig(); $sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname')); $mailer->setSender($sender); $mailer->addRecipient($recipient); $mailer->setSubject(TextHelper::_('COBALT_COFFEE_REPORT_SUBJECT') . ' ' . DateHelper::formatDate(date('Y-m-d'))); ob_start(); $layout->display(); $body = ob_get_contents(); ob_end_clean(); $mailer->setBody($body); $send = $mailer->Send(); if ($send !== true) { echo 'Error sending email: ' . $send->message; } }
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(); }
public function execute() { $response = array(); $start = $this->getInput()->getInt('start', 0); $limit = $this->getInput()->getInt('limit', 4); $object_id = $this->getInput()->getInt('object_id', 0); $item_type = $this->getInput()->getCmd('item_type'); if ($start < 0) { $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_LIMIT_START_SHOULD_BE_POSITIVE'), 'type' => 'error'); } else { if ($limit < 1) { $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_LIMIT_SHOULD_BE_POSITIVE'), 'type' => 'error'); } else { if (empty($item_type)) { $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_ITEM_TYPE_MUST_BE_NOT_EMPTY'), 'type' => 'error'); } } } //Always object_id 0 return empty notes $load_more = false; if ($object_id && !empty($item_type)) { $model = new Note(); $notes = $model->getNotes($object_id, $item_type, false); $total = count($notes); //filter notes by limits $items = array_slice($notes, $start, $limit); $view = ViewHelper::getView('note', 'default', 'phtml', array('notes' => $items)); $load_more = $start + $limit >= $total ? false : true; $response['html'] = ''; foreach ($items as $note) { $view = ViewHelper::getView('note', 'entry', 'phtml', array('note' => $note)); $response['html'] .= $view->render(); } } if ($load_more) { $response['loadmore'] = array('limit' => count($items) + $limit); } echo json_encode($response); }
public function execute() { $template_type = $this->getInput()->get('template_type'); $path = JPATH_SITE . '/media/import_templates/import_' . $template_type . '.csv'; if (!file_exists($path)) { $msg = TextHelper::_('COBALT_EXPORT_MISSING_FILE') . ' (' . $path . ')'; $this->getApplication()->redirect('index.php?view=import&import_type=' . $template_type, $msg, 'danger'); } else { ob_start(); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="import_' . $template_type . '.csv"'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($path)); ob_clean(); flush(); readfile($path); exit; } }
public function execute() { $modelName = ucwords($this->getInput()->get('model')); $modelPath = "Cobalt\\Model\\" . $modelName; $model = new $modelPath(); $view = $this->getInput()->get('view'); $response = new \stdClass(); $link = $this->getInput()->get('return', Router::to('index.php?view=' . $view)); if ($itemId = $model->store()) { $msg = TextHelper::_('COBALT_SUCCESSFULLY_SAVED'); $getItem = 'get' . $modelName; if ($this->isAjaxRequest()) { $response->item = $model->{$getItem}($itemId); $response->alert = new \stdClass(); $response->alert->message = $msg; $response->alert->type = 'success'; // just send reload page if send refresh_page=1 if ($this->getInput()->getInt('refresh_page', 0)) { $response->reload = '3000'; } $this->getApplication()->close(json_encode($response)); } else { $this->getApplication()->redirect($link, $msg); } } else { $msg = TextHelper::_('COBALT_ERROR_SAVING'); if ($this->isAjaxRequest()) { $this->getApplication()->redirect($link, $msg); } else { $response->alert = new \stdClass(); $response->alert->message = $msg; $response->alert->type = 'danger'; $this->getApplication()->close(json_encode($response)); } } }
public function upload() { //this is the name of the field in the html form, filedata is the default name for swfupload //so we will leave it as that $fieldName = 'document'; //any errors the server registered on uploading $fileError = $_FILES[$fieldName]['error']; if ($fileError > 0) { switch ($fileError) { case 1: echo TextHelper::_('FILE TO LARGE THAN PHP INI ALLOWS'); return; case 2: echo TextHelper::_('FILE TO LARGE THAN HTML FORM ALLOWS'); return; case 3: echo TextHelper::_('ERROR PARTIAL UPLOAD'); return; case 4: echo TextHelper::_('ERROR NO FILE'); return; } } //check for filesize $fileSize = $_FILES[$fieldName]['size']; if ($fileSize > 2000000) { echo TextHelper::_('FILE BIGGER THAN 2MB'); } //check the file extension is ok $fileName = $_FILES[$fieldName]['name']; $uploadedFileNameParts = explode('.', $fileName); $uploadedFileExtension = array_pop($uploadedFileNameParts); $validFileExts = explode(',', 'jpeg,jpg,png,gif,pdf,doc,docx,odt,rtf,ppt,xls,txt'); //assume the extension is false until we know its ok $extOk = false; //go through every ok extension, if the ok extension matches the file extension (case insensitive) //then the file extension is ok foreach ($validFileExts as $key => $value) { if (preg_match("/{$value}/i", $uploadedFileExtension)) { $extOk = true; } } if ($extOk == false) { echo TextHelper::_('INVALID EXTENSION'); return; } //the name of the file in PHP's temp directory that we are going to move to our folder $fileTemp = $_FILES[$fieldName]['tmp_name']; //for security purposes, we will also do a getimagesize on the temp file (before we have moved it //to the folder) to check the MIME type of the file, and whether it has a width and height $imageinfo = getimagesize($fileTemp); //lose any special characters in the filename $fileName = ereg_replace("[^A-Za-z0-9.]", "-", $fileName); $hash = md5($fileName) . "." . $uploadedFileExtension; //always use constants when making file paths, to avoid the possibilty of remote file inclusion $uploadPath = JPATH_SITE . '/uploads/' . $hash; $app = \Cobalt\Container::fetch('app'); if (!File::upload($fileTemp, $uploadPath)) { $msg = TextHelper::_('COBALT_DOC_UPLOAD_FAIL'); $app->redirect('index.php?view=admindocuments', $msg); } else { //update the database //date generation $date = date('Y-m-d H:i:s'); $data = array('name' => $fileName, 'filename' => $hash, 'filetype' => $uploadedFileExtension, 'size' => $fileSize / 1024, 'created' => $date, 'shared' => 1, 'is_image' => is_array(getimagesize($uploadPath)) ? true : false); $model = new static(); $session = JFactory::getSession(); if ($model->store($data)) { $msg = TextHelper::_('COM_CRMERY_DOC_UPLOAD_SUCCESS'); $app->redirect('index.php?view=admindocuments&layout=upload_success&format=raw', $msg); $session->set("upload_success", true); } else { $msg = TextHelper::_('COM_CRMERY_DOC_UPLOAD_FAIL'); $app->redirect('index.php?view=admindocuments&layout=upload_success&format=raw', $msg); $session->set("upload_success", false); } } }
/** * 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; }
public static function getColumnFilters() { return array('company' => ucwords(TextHelper::_('COBALT_DEALS_COMPANY')), 'primary_contact' => ucwords(TextHelper::_('COBALT_PRIMARY_CONTACT')), 'contacts' => ucwords(TextHelper::_('COBALT_DEALS_CONTACTS')), 'summary' => ucwords(TextHelper::_('COBALT_DEALS_SUMMARY')), 'amount' => ucwords(TextHelper::_('COBALT_DEALS_AMOUNT')), 'status' => ucwords(TextHelper::_('COBALT_DEALS_STATUS')), 'stage' => ucwords(TextHelper::_('COBALT_DEALS_STAGE')), 'source' => ucwords(TextHelper::_('COBALT_DEAL_SOURCE')), 'expected_close' => ucwords(TextHelper::_('COBALT_DEALS_EXPECTED_CLOSE')), 'actual_close' => ucwords(TextHelper::_('COBALT_DEALS_ACTUAL_CLOSE')), 'owner' => ucwords(TextHelper::_('COBALT_DEALS_OWNER')), 'next_action' => ucwords(TextHelper::_('COBALT_DEALS_NEXT')), 'deals_due' => ucwords(TextHelper::_('COBALT_DEALS_DUE')), 'notes' => ucwords(TextHelper::_('COBALT_DEALS_NOTES')), 'created' => ucwords(TextHelper::_('COBALT_PEOPLE_ADDED')), 'modified' => ucwords(TextHelper::_('COBALT_PEOPLE_UPDATED'))); }
public function render() { $app = \Cobalt\Container::fetch('app'); //retrieve deal list from model $model = new DealModel(); $state = $model->getState(); $dealList = array(); $deal = array(); $doc = JFactory::getDocument(); //session info $session = JFactory::getSession(); $member_role = UsersHelper::getRole(); $user_id = UsersHelper::getUserId(); $team_id = UsersHelper::getTeamId(); //determine if we are requesting a specific deal or all deals //if id requested if ($app->input->get('id')) { $model->set('_id', $app->input->get('id')); $dealList = $model->getDeals(); if (is_null($dealList[0]->id)) { $app->redirect(RouteHelper::_('index.php?view=deals'), TextHelper::_('COBALT_NOT_AUTHORIZED')); } //display remove and assign primary contact to deal $app->input->set('loc', 'deal'); } else { //else load all deals if ($app->input->get('layout') != 'edit') { if (TemplateHelper::isMobile()) { $model->set('ordering', 'd.name ASC'); } $dealList = $model->getDeals(); } } //determine if we are editing an existing deal entry if (count($dealList) == 1) { //grab deal object $deal = $dealList[0]; $deal->header = ucwords(TextHelper::_('COBALT_DEAL_EDIT')); } else { //else we are creating a new entry $deal = new \stdClass(); $deal->name = ""; $deal->summary = ""; $deal->company_id = $app->input->get('company_id') ? $app->input->get('company_id') : null; $deal->person_id = $app->input->get('person_id') ? $app->input->get('person_id') : null; //get company name to prefill data and hidden fields if ($deal->company_id) { $company = CompanyHelper::getCompany($deal->company_id); $deal->company_name = $company[0]['name']; $deal->company_id = $company[0]['id']; } //if a person is specified prefill data if ($deal->person_id) { $person = PeopleHelper::getPerson($deal->person_id); $deal->person_name = $person[0]['last_name'] . ', ' . $person[0]['first_name']; $deal->person_id = $person[0]['id']; //assign company if person is associated with company if ($person[0]['company_id']) { $deal->company_id = $person[0]['company_id']; $deal->company_name = $person[0]['company_name']; } } //assign rest of null data $deal->amount = ""; $deal->stage_id = 0; $deal->source_id = 0; $deal->probability = 0; $deal->status_id = 0; $deal->expected_close = ""; $deal->header = ucwords(TextHelper::_('COBALT_DEAL_HEADER')); } //load javalibs if (!TemplateHelper::isMobile()) { $doc->addScript(JURI::base() . 'src/Cobalt/media/js/deal_manager.js'); } //dropdown info //get deal type filters $deal_types = DealHelper::getDealTypes(); $deal_type_name = $session->get('deal_type_filter'); $deal_type_name = array_key_exists($deal_type_name, $deal_types) ? $deal_types[$deal_type_name] : $deal_types['']; //get column filters $column_filters = DealHelper::getColumnFilters(); $selected_columns = DealHelper::getSelectedColumnFilters(); //get member access info $teams = UsersHelper::getTeams(); $users = UsersHelper::getUsers(); $stages = DealHelper::getStages(); //get deal stage filters $stage_name = $session->get('deal_stage_filter'); $stage_name = $stage_name ? $stages[$stage_name] : $stages['all']; //get session data to prefill filters $user_filter = $session->get('deal_user_filter'); $team_filter = $session->get('deal_team_filter'); if ($user_filter == "all" && $user_filter != $user_id) { $user_name = TextHelper::_('COBALT_ALL_USERS'); } elseif ($user_filter == "all") { $user_name = TextHelper::_('COBALT_ME'); } elseif ($user_filter and $user_filter != $user_id and $user_filter != 'all') { $user_info = UsersHelper::getUsers($user_filter); $user_info = $user_info[0]; $user_name = $user_info['first_name'] . " " . $user_info['last_name']; } elseif ($team_filter) { $team_info = UsersHelper::getTeams($team_filter); $team = $team_info[0]; $user_name = $team['team_name'] . TextHelper::_('COBALT_TEAM_APPEND'); } else { $user_name = TextHelper::_('COBALT_ME'); } //get closing time filters $closing_names = DealHelper::getClosing(); $closing_name = $session->get('deal_close_filter'); $closing_name = $closing_name ? $closing_names[$closing_name] : $closing_names['all']; //get total deals associated with user $total_deals = UsersHelper::getDealCount($user_id, $team_id, $member_role); //Load Events & Tasks for person $layout = $this->getLayout(); if ($layout == "deal") { $model = new EventModel(); $events = $model->getEvents("deal", null, $app->input->get('id')); $this->event_dock = ViewHelper::getView('events', 'event_dock', 'phtml', array('events' => $events)); $primary_contact_id = DealHelper::getPrimaryContact($dealList[0]->id); $this->contact_info = ViewHelper::getView('contacts', 'default', 'phtml', array('contacts' => $dealList[0]->people, 'primary_contact_id' => $primary_contact_id)); $this->document_list = ViewHelper::getView('documents', 'list', 'phtml', array('documents' => $deal->documents, 'total' => $total, 'pagination' => $pagination)); //$this->document_list = ViewHelper::getView('documents','document_row','phtml',array('documents'=>$deal->documents)); $this->custom_fields_view = ViewHelper::getView('custom', 'default', 'phtml', array('type' => 'deal', 'item' => $dealList[0])); } if ($layout == "default") { $this->dataTableColumns = $model->getDataTableColumns(); $pagination = $model->getPagination(); $total = $model->getTotal(); $this->deal_list = ViewHelper::getView('deals', 'list', 'phtml', array('dealList' => $dealList, 'total' => $total, 'pagination' => $pagination)); $this->state = $state; $doc->addScriptDeclaration("\n loc = 'deals';\n order_url = 'index.php?view=deals&layout=list&format=raw&tmpl=component';\n order_dir = '" . $state->get('Deal.filter_order_Dir') . "';\n order_col = '" . $state->get('Deal.filter_order') . "';\n var dataTableColumns = " . json_encode($this->dataTableColumns) . ";"); $deal_name = $state->get('Deal.deals_name'); $this->deal_filter = $deal_name; } if (TemplateHelper::isMobile()) { $this->add_note = ViewHelper::getView('note', 'edit', 'phtml'); $this->add_task = ViewHelper::getView('events', 'edit_task', 'phtml', array('association_type' => 'deal', 'assocation_id' => $app->input->get('id'))); } if ($layout == "edit") { $item = $app->input->get('id') && array_key_exists(0, $dealList) ? $dealList[0] : array('id' => ''); $this->edit_custom_fields_view = ViewHelper::getView('custom', 'edit', 'phtml', array('type' => 'deal', 'item' => $item)); $json = TRUE; $companyModel = new CompanyModel(); $companyNames = $companyModel->getCompanyNames($json); $doc->addScriptDeclaration("var company_names=" . $companyNames . ";"); $peopleModel = new PeopleModel(); $peopleNames = $peopleModel->getPeopleNames($json); $doc->addScriptDeclaration("var people_names=" . $peopleNames . ";"); } $closed_stages = DealHelper::getClosedStages(); //assign results to view $this->closed_stages = $closed_stages; $this->dealList = $dealList; $this->totalDeals = $total_deals; $this->deal = $deal; $this->deal_types = $deal_types; $this->deal_type_name = $deal_type_name; $this->user_id = $user_id; $this->member_role = $member_role; $this->teams = $teams; $this->users = $users; $this->stages = $stages; $this->stage_name = $stage_name; $this->user_name = $user_name; $this->closing_names = $closing_names; $this->closing_name = $closing_name; $this->state = $state; $this->column_filters = $column_filters; $this->selected_columns = $selected_columns; //display return parent::render(); }
public function render() { $app = JFactory::getApplication(); //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(); }
public static function generateDealStatuses($selected = null, $name = "status_id", $class = "class='inputbox form-control'") { $db = \Cobalt\Container::fetch('db'); $query = $db->getQuery(true); $query->select("id,name")->from("#__deal_status"); $db->setQuery($query); $statuses = $db->loadAssocList(); $options = array(); $options[0] = TextHelper::_('COBALT_NONE_STATUS'); if (count($statuses) > 0) { foreach ($statuses as $status) { $options[$status['id']] = TextHelper::_('COBALT_' . strtoupper($status['name']) . "_STATUS"); } } $arr = array(); foreach ($options as $value => $label) { $arr[] = JHtml::_('select.option', $value, $label); } return JHtml::_('select.genericlist', $arr, $name, $class, 'value', 'text', $selected); }
/** * 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; }