protected function checkEditView($view) { if (CostbenefitprojectionHelper::checkString($view)) { $views = array('company', 'scaling_factor', 'intervention'); // check if this is a edit view if (in_array($view, $views)) { return true; } } return false; }
protected function getViewRelation($view) { if (CostbenefitprojectionHelper::checkString($view)) { $views = array('company' => 'companies', 'service_provider' => 'service_providers', 'country' => 'countries', 'causerisk' => 'causesrisks', 'health_data' => 'health_data_sets', 'scaling_factor' => 'scaling_factors', 'intervention' => 'interventions', 'currency' => 'currencies', 'help_document' => 'help_documents'); // check if this is a list view if (in_array($view, $views)) { return array('edit' => false, 'view' => array_search($view, $views), 'views' => $view); } elseif (array_key_exists($view, $views)) { return array('edit' => true, 'view' => $view, 'views' => $views[$view]); } } return false; }
/** * Setting the toolbar */ protected function addToolBar() { $canDo = CostbenefitprojectionHelper::getActions('costbenefitprojection'); JToolBarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_DASHBOARD'), 'grid-2'); // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('costbenefitprojection'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } if ($canDo->get('core.admin') || $canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } }
/** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_IMPORT_TITLE'), 'upload'); JHtmlSidebar::setAction('index.php?option=com_costbenefitprojection&view=import'); if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('import'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } }
/** * Setting the toolbar */ protected function addToolBar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; $isNew = $this->item->id == 0; JToolbarHelper::title(JText::_($isNew ? 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_NEW' : 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_EDIT'), 'pencil-2 article-add'); // Built the actions for new and existing records. if ($this->refid || $this->ref) { if ($this->canDo->get('help_document.create') && $isNew) { // We can create the record. JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); } elseif ($this->canDo->get('help_document.edit')) { // We can save the record. JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); } if ($isNew) { // Do not creat but cancel. JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); } else { // We can close it. JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); } } else { if ($isNew) { // For new records, check the create permission. if ($this->canDo->get('help_document.create')) { JToolBarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); JToolBarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); } else { if ($this->canDo->get('help_document.edit')) { // We can save the new record JToolBarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); // We can save this record, but check the create permission to see // if we can return to make a new one. if ($this->canDo->get('help_document.create')) { JToolBarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } } $canVersion = $this->canDo->get('core.version') && $this->canDo->get('help_document.version'); if ($this->state->params->get('save_history', 1) && $this->canDo->get('help_document.edit') && $canVersion) { JToolbarHelper::versions('com_costbenefitprojection.help_document', $this->item->id); } if ($this->canDo->get('help_document.create')) { JToolBarHelper::custom('help_document.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); } } JToolbarHelper::divider(); // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('help_document'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } }
/** * Method to validate the form data. * * @param JForm $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @return mixed Array of filtered data if valid, false otherwise. * * @see JFormRule * @see JFilterInput * @since 12.2 */ public function validate($form, $data, $group = null) { // check if the not_required field is set if (CostbenefitprojectionHelper::checkString($data['not_required'])) { $requiredFields = (array) explode(',', (string) $data['not_required']); $requiredFields = array_unique($requiredFields); // now change the required field attributes value foreach ($requiredFields as $requiredField) { // make sure there is a string value if (CostbenefitprojectionHelper::checkString($requiredField)) { // change to false $form->setFieldAttribute($requiredField, 'required', 'false'); // also clear the data set $data[$requiredField] = ''; } } } return parent::validate($form, $data, $group); }
// this should be save since all data passed is internal $head .= $dataSwitch[$key]; } $head .= '>' . $header . '</th>'; } $causesrisks .= '<table class="footable metro-blue toggle-circle" data-page-size="10"><thead><tr>' . $head . '</li></tr></thead><tbody>' . $body . '</tbody><tfoot class="hide-if-no-paging"><tr><td colspan="4"><div class="pagination pagination-centered"></div></td></tr></tfoot></table>'; } // setup the age groups display $agepercents = '<div class="uk-panel uk-width-1-1"><div class="uk-alert">' . JText::_('COM_COSTBENEFITPROJECTION_NO_AGE_GROUPS_HAS_BEEN_SET') . '</div></div>'; $agepercents_numbers = '<div class="uk-panel uk-width-1-1"><div class="uk-alert">' . JText::_('COM_COSTBENEFITPROJECTION_NO_AGE_GROUPS_HAS_BEEN_SET') . '</div></div>'; $genderArray = array('male', 'female'); // loading option var $both = 0; foreach ($genderArray as $gender) { // setup the related gender age groups if (isset($displayData->{'percent' . $gender}) && CostbenefitprojectionHelper::checkString($displayData->{'percent' . $gender})) { // load chart builder $chart = new Chartbuilder('PieChart'); $i = 0; $data = array(); $rowArray = array(); $rowArray_numbers = array(); $dataset = json_decode($displayData->{'percent' . $gender}); foreach ($dataset as $key => &$set) { if ('age' == $key) { $type = 'string'; $percent = false; } else { $type = 'number'; $percent = true; }
/** * Method to convert selection values to translatable string. * * @return translatable string */ public function selectionTranslationVwhcompanies($value, $name) { // Array of department language strings if ($name == 'department') { $departmentArray = array(1 => 'COM_COSTBENEFITPROJECTION_COMPANY_BASIC', 2 => 'COM_COSTBENEFITPROJECTION_COMPANY_ADVANCED'); // Now check if value is found in this array if (isset($departmentArray[$value]) && CostbenefitprojectionHelper::checkString($departmentArray[$value])) { return $departmentArray[$value]; } } // Array of per language strings if ($name == 'per') { $perArray = array(1 => 'COM_COSTBENEFITPROJECTION_COMPANY_OPEN', 0 => 'COM_COSTBENEFITPROJECTION_COMPANY_LOCKED'); // Now check if value is found in this array if (isset($perArray[$value]) && CostbenefitprojectionHelper::checkString($perArray[$value])) { return $perArray[$value]; } } return $value; }
/** * Setting the toolbar */ protected function addToolBar() { // hide the main menu $this->app->input->set('hidemainmenu', true); // add title to the page JToolbarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_COMBINEDRESULTS'), 'cogs'); // add the back button // JToolBarHelper::custom('combinedresults.back', 'undo-2', '', 'COM_COSTBENEFITPROJECTION_BACK', false); // add cpanel button JToolBarHelper::custom('combinedresults.dashboard', 'grid-2', '', 'COM_COSTBENEFITPROJECTION_DASH', false); if ($this->canDo->get('combinedresults.companies')) { // add Companies button. JToolBarHelper::custom('combinedresults.gotoCompanies', 'vcard', '', 'COM_COSTBENEFITPROJECTION_COMPANIES', false); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('combinedresults'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } }
/** * Method to convert selection values to translatable string. * * @return translatable string */ public function selectionTranslation($value, $name) { // Array of type language strings if ($name == 'type') { $typeArray = array(0 => 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_SELECT_AN_OPTION', 1 => 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_JOOMLA_ARTICLE', 2 => 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_TEXT', 3 => 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_URL'); // Now check if value is found in this array if (isset($typeArray[$value]) && CostbenefitprojectionHelper::checkString($typeArray[$value])) { return $typeArray[$value]; } } // Array of location language strings if ($name == 'location') { $locationArray = array(1 => 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_ADMIN', 2 => 'COM_COSTBENEFITPROJECTION_HELP_DOCUMENT_SITE'); // Now check if value is found in this array if (isset($locationArray[$value]) && CostbenefitprojectionHelper::checkString($locationArray[$value])) { return $locationArray[$value]; } } return $value; }
public function getIcons() { // load user for access menus $user = JFactory::getUser(); // reset icon array $icons = array(); // view groups array $viewGroups = array('main' => array('png.company.add', 'png.companies', 'png.service_provider.add', 'png.service_providers', 'png.countries', 'png.causerisk.add', 'png.causesrisks', 'png.health_data_sets', 'png.scaling_factor.add', 'png.scaling_factors', 'png.intervention.add', 'png.interventions', 'png.currencies', 'png.help_documents')); // view access array $viewAccess = array('combinedresults.dashboard_list' => 'combinedresults.dashboard_list', 'company.create' => 'company.create', 'companies.access' => 'company.access', 'company.access' => 'company.access', 'companies.submenu' => 'company.submenu', 'companies.dashboard_list' => 'company.dashboard_list', 'company.dashboard_add' => 'company.dashboard_add', 'service_provider.create' => 'service_provider.create', 'service_providers.access' => 'service_provider.access', 'service_provider.access' => 'service_provider.access', 'service_providers.submenu' => 'service_provider.submenu', 'service_providers.dashboard_list' => 'service_provider.dashboard_list', 'service_provider.dashboard_add' => 'service_provider.dashboard_add', 'country.create' => 'country.create', 'countries.access' => 'country.access', 'country.access' => 'country.access', 'countries.submenu' => 'country.submenu', 'countries.dashboard_list' => 'country.dashboard_list', 'causerisk.create' => 'causerisk.create', 'causesrisks.access' => 'causerisk.access', 'causerisk.access' => 'causerisk.access', 'causesrisks.submenu' => 'causerisk.submenu', 'causesrisks.dashboard_list' => 'causerisk.dashboard_list', 'causerisk.dashboard_add' => 'causerisk.dashboard_add', 'health_data.create' => 'health_data.create', 'health_data_sets.access' => 'health_data.access', 'health_data.access' => 'health_data.access', 'health_data_sets.submenu' => 'health_data.submenu', 'health_data_sets.dashboard_list' => 'health_data.dashboard_list', 'scaling_factor.create' => 'scaling_factor.create', 'scaling_factors.access' => 'scaling_factor.access', 'scaling_factor.access' => 'scaling_factor.access', 'scaling_factors.submenu' => 'scaling_factor.submenu', 'scaling_factors.dashboard_list' => 'scaling_factor.dashboard_list', 'scaling_factor.dashboard_add' => 'scaling_factor.dashboard_add', 'intervention.create' => 'intervention.create', 'interventions.access' => 'intervention.access', 'intervention.access' => 'intervention.access', 'interventions.submenu' => 'intervention.submenu', 'interventions.dashboard_list' => 'intervention.dashboard_list', 'intervention.dashboard_add' => 'intervention.dashboard_add', 'currency.create' => 'currency.create', 'currencies.access' => 'currency.access', 'currency.access' => 'currency.access', 'currencies.submenu' => 'currency.submenu', 'currencies.dashboard_list' => 'currency.dashboard_list', 'help_document.create' => 'help_document.create', 'help_documents.access' => 'help_document.access', 'help_document.access' => 'help_document.access', 'help_documents.submenu' => 'help_document.submenu', 'help_documents.dashboard_list' => 'help_document.dashboard_list'); foreach ($viewGroups as $group => $views) { $i = 0; if (CostbenefitprojectionHelper::checkArray($views)) { foreach ($views as $view) { $add = false; if (strpos($view, '.') !== false) { $dwd = explode('.', $view); if (count($dwd) == 3) { list($type, $name, $action) = $dwd; } elseif (count($dwd) == 2) { list($type, $name) = $dwd; $action = false; } if ($action) { $viewName = $name; switch ($action) { case 'add': $url = 'index.php?option=com_costbenefitprojection&view=' . $name . '&layout=edit'; $image = $name . '_' . $action . '.' . $type; $alt = $name . ' ' . $action; $name = 'COM_COSTBENEFITPROJECTION_DASHBOARD_' . CostbenefitprojectionHelper::safeString($name, 'U') . '_ADD'; $add = true; break; default: $url = 'index.php?option=com_categories&view=categories&extension=com_costbenefitprojection.' . $name; $image = $name . '_' . $action . '.' . $type; $alt = $name . ' ' . $action; $name = 'COM_COSTBENEFITPROJECTION_DASHBOARD_' . CostbenefitprojectionHelper::safeString($name, 'U') . '_' . CostbenefitprojectionHelper::safeString($action, 'U'); break; } } else { $viewName = $name; $alt = $name; $url = 'index.php?option=com_costbenefitprojection&view=' . $name; $image = $name . '.' . $type; $name = 'COM_COSTBENEFITPROJECTION_DASHBOARD_' . CostbenefitprojectionHelper::safeString($name, 'U'); $hover = false; } } else { $viewName = $view; $alt = $view; $url = 'index.php?option=com_costbenefitprojection&view=' . $view; $image = $view . '.png'; $name = ucwords($view) . '<br /><br />'; $hover = false; } // first make sure the view access is set if (CostbenefitprojectionHelper::checkArray($viewAccess)) { // setup some defaults $dashboard_add = false; $dashboard_list = false; $accessTo = ''; $accessAdd = ''; // acces checking start $accessCreate = isset($viewAccess[$viewName . '.create']) ? CostbenefitprojectionHelper::checkString($viewAccess[$viewName . '.create']) : false; $accessAccess = isset($viewAccess[$viewName . '.access']) ? CostbenefitprojectionHelper::checkString($viewAccess[$viewName . '.access']) : false; // set main controllers $accessDashboard_add = isset($viewAccess[$viewName . '.dashboard_add']) ? CostbenefitprojectionHelper::checkString($viewAccess[$viewName . '.dashboard_add']) : false; $accessDashboard_list = isset($viewAccess[$viewName . '.dashboard_list']) ? CostbenefitprojectionHelper::checkString($viewAccess[$viewName . '.dashboard_list']) : false; // check for adding access if ($add && $accessCreate) { $accessAdd = $viewAccess[$viewName . '.create']; } elseif ($add) { $accessAdd = 'core.create'; } // check if acces to view is set if ($accessAccess) { $accessTo = $viewAccess[$viewName . '.access']; } // set main access controllers if ($accessDashboard_add) { $dashboard_add = $user->authorise($viewAccess[$viewName . '.dashboard_add'], 'com_costbenefitprojection'); } if ($accessDashboard_list) { $dashboard_list = $user->authorise($viewAccess[$viewName . '.dashboard_list'], 'com_costbenefitprojection'); } if (CostbenefitprojectionHelper::checkString($accessAdd) && CostbenefitprojectionHelper::checkString($accessTo)) { // check access if ($user->authorise($accessAdd, 'com_costbenefitprojection') && $user->authorise($accessTo, 'com_costbenefitprojection') && $dashboard_add) { $icons[$group][$i] = new StdClass(); $icons[$group][$i]->url = $url; $icons[$group][$i]->name = $name; $icons[$group][$i]->image = $image; $icons[$group][$i]->alt = $alt; } } elseif (CostbenefitprojectionHelper::checkString($accessTo)) { // check access if ($user->authorise($accessTo, 'com_costbenefitprojection') && $dashboard_list) { $icons[$group][$i] = new StdClass(); $icons[$group][$i]->url = $url; $icons[$group][$i]->name = $name; $icons[$group][$i]->image = $image; $icons[$group][$i]->alt = $alt; } } elseif (CostbenefitprojectionHelper::checkString($accessAdd)) { // check access if ($user->authorise($accessAdd, 'com_costbenefitprojection') && $dashboard_add) { $icons[$group][$i] = new StdClass(); $icons[$group][$i]->url = $url; $icons[$group][$i]->name = $name; $icons[$group][$i]->image = $image; $icons[$group][$i]->alt = $alt; } } else { $icons[$group][$i] = new StdClass(); $icons[$group][$i]->url = $url; $icons[$group][$i]->name = $name; $icons[$group][$i]->image = $image; $icons[$group][$i]->alt = $alt; } } else { $icons[$group][$i] = new StdClass(); $icons[$group][$i]->url = $url; $icons[$group][$i]->name = $name; $icons[$group][$i]->image = $image; $icons[$group][$i]->alt = $alt; } $i++; } } else { $icons[$group][$i] = false; } } return $icons; }
/** * Method to convert selection values to translatable string. * * @return translatable string */ public function selectionTranslation($value, $name) { // Array of year language strings if ($name == 'year') { $yearArray = array(0 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_SELECT_A_YEAR', 2010 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TEN', 2011 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_ELEVEN', 2012 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TWELVE', 2013 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_THIRTEEN', 2014 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_FOURTEEN', 2015 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_FIFTEEN', 2016 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_SIXTEEN', 2017 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_SEVENTEEN', 2018 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_EIGHTEEN', 2019 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_NINETEEN', 2020 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TWENTY', 2021 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TWENTY_ONE', 2022 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TWENTY_TWO', 2023 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TWENTY_THREE', 2024 => 'COM_COSTBENEFITPROJECTION_HEALTH_DATA_TWO_THOUSAND_AND_TWENTY_FOUR'); // Now check if value is found in this array if (isset($yearArray[$value]) && CostbenefitprojectionHelper::checkString($yearArray[$value])) { return $yearArray[$value]; } } return $value; }
/** * Method to convert selection values to translatable string. * * @return translatable string */ public function selectionTranslation($value, $name) { // Array of type language strings if ($name == 'type') { $typeArray = array(1 => 'COM_COSTBENEFITPROJECTION_INTERVENTION_SINGLE', 2 => 'COM_COSTBENEFITPROJECTION_INTERVENTION_CLUSTER'); // Now check if value is found in this array if (isset($typeArray[$value]) && CostbenefitprojectionHelper::checkString($typeArray[$value])) { return $typeArray[$value]; } } return $value; }
/** * Setting the toolbar */ protected function addToolBar() { // hide the main menu $this->app->input->set('hidemainmenu', true); // set the title if (isset($this->item->name) && $this->item->name) { $title = $this->item->name; } // Check for empty title and add view name if param is set if (empty($title)) { $title = JText::_('COM_COSTBENEFITPROJECTION_COMPANYRESULTS'); } // add title to the page JToolbarHelper::title($title, 'chart'); // add the back button // JToolBarHelper::custom('companyresults.back', 'undo-2', '', 'COM_COSTBENEFITPROJECTION_BACK', false); // add cpanel button JToolBarHelper::custom('companyresults.dashboard', 'grid-2', '', 'COM_COSTBENEFITPROJECTION_DASH', false); if ($this->canDo->get('companyresults.companies')) { // add Companies button. JToolBarHelper::custom('companyresults.gotoCompanies', 'vcard', '', 'COM_COSTBENEFITPROJECTION_COMPANIES', false); } if ($this->canDo->get('companyresults.edit')) { // add Edit button. JToolBarHelper::custom('companyresults.editCompany', 'pencil', '', 'COM_COSTBENEFITPROJECTION_EDIT', false); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('companyresults'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } }
/** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_COMPANIES'), 'vcard'); JHtmlSidebar::setAction('index.php?option=com_costbenefitprojection&view=companies'); JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { JToolBarHelper::addNew('company.add'); } // Only load if there are items if (CostbenefitprojectionHelper::checkArray($this->items)) { if ($this->canEdit) { JToolBarHelper::editList('company.edit'); } if ($this->canState) { JToolBarHelper::publishList('companies.publish'); JToolBarHelper::unpublishList('companies.unpublish'); JToolBarHelper::archiveList('companies.archive'); if ($this->canDo->get('core.admin')) { JToolBarHelper::checkin('companies.checkin'); } } // Add a batch button if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) { // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); // set the batch button name $title = JText::_('JTOOLBAR_BATCH'); // Instantiate a new JLayoutFile instance and render the batch button $layout = new JLayoutFile('joomla.toolbar.batch'); // add the button to the page $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); } if ($this->canDo->get('combinedresults.access')) { // add Combined Results button. JToolBarHelper::custom('companies.redirectToCombinedresults', 'cogs', '', 'COM_COSTBENEFITPROJECTION_COMBINEDRESULTS', true); } if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) { JToolbarHelper::deleteList('', 'companies.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($this->canState && $this->canDelete) { JToolbarHelper::trash('companies.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('company.export')) { JToolBarHelper::custom('companies.exportData', 'download', '', 'COM_COSTBENEFITPROJECTION_EXPORT_DATA', true); } } if ($this->canDo->get('core.import') && $this->canDo->get('company.import')) { JToolBarHelper::custom('companies.importData', 'upload', '', 'COM_COSTBENEFITPROJECTION_IMPORT_DATA', false); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('companies'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } if ($this->canState) { JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)); // only load if batch allowed if ($this->canBatch) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_STATE'), 'batch[published]', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)); } } JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_ACCESS'), 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')); } // Set Department Selection $this->departmentOptions = $this->getTheDepartmentSelections(); if ($this->departmentOptions) { // Department Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_DEPARTMENT_LABEL') . ' -', 'filter_department', JHtml::_('select.options', $this->departmentOptions, 'value', 'text', $this->state->get('filter.department'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Department Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_DEPARTMENT_LABEL') . ' -', 'batch[department]', JHtml::_('select.options', $this->departmentOptions, 'value', 'text')); } } // Set Country Name Selection $this->countryNameOptions = JFormHelper::loadFieldType('Countries')->getOptions(); if ($this->countryNameOptions) { // Country Name Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_COUNTRY_LABEL') . ' -', 'filter_country', JHtml::_('select.options', $this->countryNameOptions, 'value', 'text', $this->state->get('filter.country'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Country Name Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_COUNTRY_LABEL') . ' -', 'batch[country]', JHtml::_('select.options', $this->countryNameOptions, 'value', 'text')); } } // Set Service Provider User Selection $this->service_providerUserOptions = JFormHelper::loadFieldType('Serviceprovider')->getOptions(); if ($this->service_providerUserOptions) { // Service Provider User Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_SERVICE_PROVIDER_LABEL') . ' -', 'filter_service_provider', JHtml::_('select.options', $this->service_providerUserOptions, 'value', 'text', $this->state->get('filter.service_provider'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Service Provider User Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_SERVICE_PROVIDER_LABEL') . ' -', 'batch[service_provider]', JHtml::_('select.options', $this->service_providerUserOptions, 'value', 'text')); } } // Set Per Selection $this->perOptions = $this->getThePerSelections(); if ($this->perOptions) { // Per Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_PER_LABEL') . ' -', 'filter_per', JHtml::_('select.options', $this->perOptions, 'value', 'text', $this->state->get('filter.per'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Per Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_COMPANY_PER_LABEL') . ' -', 'batch[per]', JHtml::_('select.options', $this->perOptions, 'value', 'text')); } } }
/** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_INTERVENTIONS'), 'wand'); JHtmlSidebar::setAction('index.php?option=com_costbenefitprojection&view=interventions'); JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { JToolBarHelper::addNew('intervention.add'); } // Only load if there are items if (CostbenefitprojectionHelper::checkArray($this->items)) { if ($this->canEdit) { JToolBarHelper::editList('intervention.edit'); } if ($this->canState) { JToolBarHelper::publishList('interventions.publish'); JToolBarHelper::unpublishList('interventions.unpublish'); JToolBarHelper::archiveList('interventions.archive'); if ($this->canDo->get('core.admin')) { JToolBarHelper::checkin('interventions.checkin'); } } // Add a batch button if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) { // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); // set the batch button name $title = JText::_('JTOOLBAR_BATCH'); // Instantiate a new JLayoutFile instance and render the batch button $layout = new JLayoutFile('joomla.toolbar.batch'); // add the button to the page $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); } if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) { JToolbarHelper::deleteList('', 'interventions.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($this->canState && $this->canDelete) { JToolbarHelper::trash('interventions.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('intervention.export')) { JToolBarHelper::custom('interventions.exportData', 'download', '', 'COM_COSTBENEFITPROJECTION_EXPORT_DATA', true); } } if ($this->canDo->get('core.import') && $this->canDo->get('intervention.import')) { JToolBarHelper::custom('interventions.importData', 'upload', '', 'COM_COSTBENEFITPROJECTION_IMPORT_DATA', false); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('interventions'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } if ($this->canState) { JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)); // only load if batch allowed if ($this->canBatch) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_STATE'), 'batch[published]', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)); } } JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_ACCESS'), 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')); } // Set Company Name Selection $this->companyNameOptions = JFormHelper::loadFieldType('Company')->getOptions(); if ($this->companyNameOptions) { // Company Name Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COMPANY_LABEL') . ' -', 'filter_company', JHtml::_('select.options', $this->companyNameOptions, 'value', 'text', $this->state->get('filter.company'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Company Name Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COMPANY_LABEL') . ' -', 'batch[company]', JHtml::_('select.options', $this->companyNameOptions, 'value', 'text')); } } // Set Type Selection $this->typeOptions = $this->getTheTypeSelections(); if ($this->typeOptions) { // Type Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_LABEL') . ' -', 'filter_type', JHtml::_('select.options', $this->typeOptions, 'value', 'text', $this->state->get('filter.type'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Type Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_LABEL') . ' -', 'batch[type]', JHtml::_('select.options', $this->typeOptions, 'value', 'text')); } } // Set Coverage Selection $this->coverageOptions = $this->getTheCoverageSelections(); if ($this->coverageOptions) { // Coverage Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_LABEL') . ' -', 'filter_coverage', JHtml::_('select.options', $this->coverageOptions, 'value', 'text', $this->state->get('filter.coverage'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Coverage Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_LABEL') . ' -', 'batch[coverage]', JHtml::_('select.options', $this->coverageOptions, 'value', 'text')); } } // Set Duration Selection $this->durationOptions = $this->getTheDurationSelections(); if ($this->durationOptions) { // Duration Filter JHtmlSidebar::addFilter('- Select ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_DURATION_LABEL') . ' -', 'filter_duration', JHtml::_('select.options', $this->durationOptions, 'value', 'text', $this->state->get('filter.duration'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { // Duration Batch Selection JHtmlBatch_::addListSelection('- Keep Original ' . JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_DURATION_LABEL') . ' -', 'batch[duration]', JHtml::_('select.options', $this->durationOptions, 'value', 'text')); } } }
/** * Setting the toolbar */ protected function addToolBar() { // adding the joomla toolbar to the front JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR . '/includes/toolbar.php'); // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('combinedresults'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // now initiate the toolbar $this->toolbar = JToolbar::getInstance(); }
/** * Method to get article data. * * @param integer $pk The id of the article. * * @return mixed Menu item data object on success, false on failure. */ public function getItem($pk = null) { $this->user = JFactory::getUser(); // check if this user has permission to access item if (!$this->user->authorise('site.companyresults.access', 'com_costbenefitprojection')) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('Not authorised!'), 'error'); // redirect away if not a correct (TODO for now we go to default view) $app->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel')); return false; } $this->userId = $this->user->get('id'); $this->guest = $this->user->get('guest'); $this->groups = $this->user->get('groups'); $this->authorisedGroups = $this->user->getAuthorisedGroups(); $this->levels = $this->user->getAuthorisedViewLevels(); $this->initSet = true; $pk = !empty($pk) ? $pk : (int) $this->getState('companyresults.id'); if (!$this->user->authorise('core.options', 'com_costbenefitprojection')) { // make absolutely sure that this company can be viewed $companies = CostbenefitprojectionHelper::hisCompanies($this->userId); if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($pk, $companies)) { JError::raiseWarning(500, JText::_('Access denied!')); // redirect away if not a correct (TODO for now we go to default view) $app = JFactory::getApplication(); if ($app->isAdmin()) { JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection'); } else { JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel'); } return false; } } if ($this->_item === null) { $this->_item = array(); } if (!isset($this->_item[$pk])) { try { // Get the advanced encription. $advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced'); // Get the encription object. $advanced = new FOFEncryptAes($advancedkey, 256); // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Get from #__costbenefitprojection_company as a $query->select($db->quoteName(array('a.id', 'a.name', 'a.user', 'a.department', 'a.per', 'a.country', 'a.service_provider', 'a.datayear', 'a.working_days', 'a.total_salary', 'a.total_healthcare', 'a.productivity_losses', 'a.males', 'a.females', 'a.medical_turnovers_males', 'a.medical_turnovers_females', 'a.sick_leave_males', 'a.sick_leave_females', 'a.percentmale', 'a.percentfemale', 'a.causesrisks', 'a.published', 'a.access'), array('id', 'name', 'user', 'department', 'per', 'country', 'service_provider', 'datayear', 'working_days', 'total_salary', 'total_healthcare', 'productivity_losses', 'males', 'females', 'medical_turnovers_males', 'medical_turnovers_females', 'sick_leave_males', 'sick_leave_females', 'percentmale', 'percentfemale', 'causesrisks', 'published', 'access'))); $query->from($db->quoteName('#__costbenefitprojection_company', 'a')); // Get from #__costbenefitprojection_country as e $query->select($db->quoteName(array('e.id', 'e.name', 'e.alias', 'e.user', 'e.currency', 'e.datayear', 'e.worldzone', 'e.codethree', 'e.codetwo', 'e.working_days', 'e.presenteeism', 'e.medical_turnovers', 'e.sick_leave', 'e.healthcare', 'e.productivity_losses', 'e.publicname', 'e.publicemail', 'e.publicnumber', 'e.publicaddress', 'e.percentmale', 'e.percentfemale', 'e.causesrisks', 'e.maledeath', 'e.femaledeath', 'e.maleyld', 'e.femaleyld', 'e.access'), array('country_id', 'country_name', 'country_alias', 'country_user', 'country_currency', 'country_datayear', 'country_worldzone', 'country_codethree', 'country_codetwo', 'country_working_days', 'country_presenteeism', 'country_medical_turnovers', 'country_sick_leave', 'country_healthcare', 'country_productivity_losses', 'country_publicname', 'country_publicemail', 'country_publicnumber', 'country_publicaddress', 'country_percentmale', 'country_percentfemale', 'country_causesrisks', 'country_maledeath', 'country_femaledeath', 'country_maleyld', 'country_femaleyld', 'country_access'))); $query->join('LEFT', $db->quoteName('#__costbenefitprojection_country', 'e') . ' ON (' . $db->quoteName('a.country') . ' = ' . $db->quoteName('e.id') . ')'); // Get from #__costbenefitprojection_currency as f $query->select($db->quoteName(array('f.id', 'f.name', 'f.alias', 'f.codethree', 'f.numericcode', 'f.symbol', 'f.thousands', 'f.decimalplace', 'f.decimalsymbol', 'f.positivestyle', 'f.negativestyle', 'f.published', 'f.access', 'f.ordering'), array('currency_id', 'currency_name', 'currency_alias', 'currency_codethree', 'currency_numericcode', 'currency_symbol', 'currency_thousands', 'currency_decimalplace', 'currency_decimalsymbol', 'currency_positivestyle', 'currency_negativestyle', 'currency_published', 'currency_access', 'currency_ordering'))); $query->join('LEFT', $db->quoteName('#__costbenefitprojection_currency', 'f') . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')'); $query->where('a.id = ' . (int) $pk); // Reset the query using our newly populated query object. $db->setQuery($query); // Load the results as a stdClass object. $data = $db->loadObject(); if (empty($data)) { $app = JFactory::getApplication(); // If no data is found redirect to default page and show warning. $app->enqueueMessage(JText::_('COM_COSTBENEFITPROJECTION_NOT_FOUND_OR_ACCESS_DENIED'), 'warning'); $app->redirect('index.php?option=com_costbenefitprojection&view=cpanel'); return false; } if (!empty($data->medical_turnovers_females) && $advancedkey && !is_numeric($data->medical_turnovers_females) && $data->medical_turnovers_females === base64_encode(base64_decode($data->medical_turnovers_females, true))) { // Decode medical_turnovers_females $data->medical_turnovers_females = rtrim($advanced->decryptString($data->medical_turnovers_females), ""); } if (!empty($data->females) && $advancedkey && !is_numeric($data->females) && $data->females === base64_encode(base64_decode($data->females, true))) { // Decode females $data->females = rtrim($advanced->decryptString($data->females), ""); } if (!empty($data->sick_leave_males) && $advancedkey && !is_numeric($data->sick_leave_males) && $data->sick_leave_males === base64_encode(base64_decode($data->sick_leave_males, true))) { // Decode sick_leave_males $data->sick_leave_males = rtrim($advanced->decryptString($data->sick_leave_males), ""); } if (CostbenefitprojectionHelper::checkString($data->causesrisks)) { // Decode causesrisks $data->causesrisks = json_decode($data->causesrisks, true); } if (!empty($data->medical_turnovers_males) && $advancedkey && !is_numeric($data->medical_turnovers_males) && $data->medical_turnovers_males === base64_encode(base64_decode($data->medical_turnovers_males, true))) { // Decode medical_turnovers_males $data->medical_turnovers_males = rtrim($advanced->decryptString($data->medical_turnovers_males), ""); } if (!empty($data->total_salary) && $advancedkey && !is_numeric($data->total_salary) && $data->total_salary === base64_encode(base64_decode($data->total_salary, true))) { // Decode total_salary $data->total_salary = rtrim($advanced->decryptString($data->total_salary), ""); } if (!empty($data->sick_leave_females) && $advancedkey && !is_numeric($data->sick_leave_females) && $data->sick_leave_females === base64_encode(base64_decode($data->sick_leave_females, true))) { // Decode sick_leave_females $data->sick_leave_females = rtrim($advanced->decryptString($data->sick_leave_females), ""); } if (!empty($data->total_healthcare) && $advancedkey && !is_numeric($data->total_healthcare) && $data->total_healthcare === base64_encode(base64_decode($data->total_healthcare, true))) { // Decode total_healthcare $data->total_healthcare = rtrim($advanced->decryptString($data->total_healthcare), ""); } if (!empty($data->males) && $advancedkey && !is_numeric($data->males) && $data->males === base64_encode(base64_decode($data->males, true))) { // Decode males $data->males = rtrim($advanced->decryptString($data->males), ""); } if (CostbenefitprojectionHelper::checkString($data->country_causesrisks)) { // Decode country_causesrisks $data->country_causesrisks = json_decode($data->country_causesrisks, true); } // Make sure the content prepare plugins fire on country_publicaddress. $data->country_publicaddress = JHtml::_('content.prepare', $data->country_publicaddress); // Checking if country_publicaddress has uikit components that must be loaded. $this->uikitComp = CostbenefitprojectionHelper::getUikitComp($data->country_publicaddress, $this->uikitComp); // set the global causesrisks value. $this->a_causesrisks = $data->causesrisks; // set the global datayear value. $this->a_datayear = $data->datayear; // set the global datayear value. $this->e_datayear = $data->country_datayear; // set the global causesrisks value. $this->e_causesrisks = $data->country_causesrisks; // set countryCountryHealth_dataB to the $data object. $data->countryCountryHealth_dataB = $this->getCountryCountryHealth_dataEbbe_B($data->country); // set idCompanyScaling_factorC to the $data object. $data->idCompanyScaling_factorC = $this->getIdCompanyScaling_factorEbbe_C($data->id); // set idCompanyInterventionD to the $data object. $data->idCompanyInterventionD = $this->getIdCompanyInterventionEbbe_D($data->id); // set causesrisksIdCauseriskG to the $data object. $data->causesrisksIdCauseriskG = $this->getCausesrisksIdCauseriskEbbe_G($data->causesrisks); // set countryCountryHealth_dataBB to the $data object. $data->countryCountryHealth_dataBB = $this->getCountryCountryHealth_dataEbbe_BB($data->country); // set causesrisksIdCauseriskGG to the $data object. $data->causesrisksIdCauseriskGG = $this->getCausesrisksIdCauseriskEbbe_GG($data->country_causesrisks); // set countryCountryInterventionDD to the $data object. $data->countryCountryInterventionDD = $this->getCountryCountryInterventionEbbe_DD($data->country); // set data object to item. $this->_item[$pk] = $data; } catch (Exception $e) { if ($e->getCode() == 404) { // Need to go thru the error handler to allow Redirect to work. JError::raiseWaring(404, $e->getMessage()); } else { $this->setError($e); $this->_item[$pk] = false; } } } return $this->_item[$pk]; }
/** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_CURRENCIES'), 'credit'); JHtmlSidebar::setAction('index.php?option=com_costbenefitprojection&view=currencies'); JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { JToolBarHelper::addNew('currency.add'); } // Only load if there are items if (CostbenefitprojectionHelper::checkArray($this->items)) { if ($this->canEdit) { JToolBarHelper::editList('currency.edit'); } if ($this->canState) { JToolBarHelper::publishList('currencies.publish'); JToolBarHelper::unpublishList('currencies.unpublish'); JToolBarHelper::archiveList('currencies.archive'); if ($this->canDo->get('core.admin')) { JToolBarHelper::checkin('currencies.checkin'); } } // Add a batch button if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) { // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); // set the batch button name $title = JText::_('JTOOLBAR_BATCH'); // Instantiate a new JLayoutFile instance and render the batch button $layout = new JLayoutFile('joomla.toolbar.batch'); // add the button to the page $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); } if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) { JToolbarHelper::deleteList('', 'currencies.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($this->canState && $this->canDelete) { JToolbarHelper::trash('currencies.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('currency.export')) { JToolBarHelper::custom('currencies.exportData', 'download', '', 'COM_COSTBENEFITPROJECTION_EXPORT_DATA', true); } } if ($this->canDo->get('core.import') && $this->canDo->get('currency.import')) { JToolBarHelper::custom('currencies.importData', 'upload', '', 'COM_COSTBENEFITPROJECTION_IMPORT_DATA', false); } // set help url for this view if found $help_url = CostbenefitprojectionHelper::getHelpUrl('currencies'); if (CostbenefitprojectionHelper::checkString($help_url)) { JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_costbenefitprojection'); } if ($this->canState) { JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)); // only load if batch allowed if ($this->canBatch) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_STATE'), 'batch[published]', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)); } } JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); if ($this->canBatch && $this->canCreate && $this->canEdit) { JHtmlBatch_::addListSelection(JText::_('COM_COSTBENEFITPROJECTION_KEEP_ORIGINAL_ACCESS'), 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')); } }
/** * Method to get an array of Intervention Objects. * * @return mixed An array of Intervention Objects on success, false on failure. * */ public function getCountryCountryInterventionBcbb_DD($country) { // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Get from #__costbenefitprojection_intervention as dd $query->select($db->quoteName(array('dd.id', 'dd.name', 'dd.type', 'dd.coverage', 'dd.duration', 'dd.share', 'dd.description', 'dd.reference', 'dd.interventions', 'dd.intervention', 'dd.published', 'dd.created_by', 'dd.modified_by', 'dd.created', 'dd.modified'), array('id', 'name', 'type', 'coverage', 'duration', 'share', 'description', 'reference', 'interventions', 'intervention', 'published', 'created_by', 'modified_by', 'created', 'modified'))); $query->from($db->quoteName('#__costbenefitprojection_intervention', 'dd')); $query->where('dd.country = ' . $db->quote($country)); $query->where('dd.published = 1'); $query->order('dd.ordering ASC'); // Reset the query using our newly populated query object. $db->setQuery($query); $db->execute(); // check if there was data returned if ($db->getNumRows()) { $items = $db->loadObjectList(); // Convert the parameter fields into objects. foreach ($items as $nr => &$item) { if (CostbenefitprojectionHelper::checkString($item->interventions)) { // Decode interventions $item->interventions = json_decode($item->interventions, true); } // Make sure the content prepare plugins fire on description. $item->description = JHtml::_('content.prepare', $item->description); // Checking if description has uikit components that must be loaded. $this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description, $this->uikitComp); // Make sure the content prepare plugins fire on reference. $item->reference = JHtml::_('content.prepare', $item->reference); // Checking if reference has uikit components that must be loaded. $this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference, $this->uikitComp); } return $items; } return false; }
/** * Get the modules published in a position */ public function getModules($position, $seperator = '', $class = '') { // set default $found = false; // check if we aleady have these modules loaded if (isset($this->setModules[$position])) { $found = true; } else { // this is where you want to load your module position $modules = JModuleHelper::getModules($position); if ($modules) { // set the place holder $this->setModules[$position] = array(); foreach ($modules as $module) { $this->setModules[$position][] = JModuleHelper::renderModule($module); } $found = true; } } // check if modules were found if ($found && isset($this->setModules[$position]) && CostbenefitprojectionHelper::checkArray($this->setModules[$position])) { // set class if (CostbenefitprojectionHelper::checkString($class)) { $class = ' class="' . $class . '" '; } // set seperating return values switch ($seperator) { case 'none': return implode('', $this->setModules[$position]); break; case 'div': return '<div' . $class . '>' . implode('</div><div' . $class . '>', $this->setModules[$position]) . '</div>'; break; case 'list': return '<ul' . $class . '><li>' . implode('</li><li>', $this->setModules[$position]) . '</li></ul>'; break; case 'array': case 'Array': return $this->setModules[$position]; break; default: return implode('<br />', $this->setModules[$position]); break; } } return false; }
public function getClusterData($idName, $cluster) { // we first build the json object from the cluster ids, then pass it to the builder $oject = ''; $oject_table = ''; if (CostbenefitprojectionHelper::isJson($cluster) && CostbenefitprojectionHelper::checkString($idName)) { $array = json_decode($cluster, true); // get te set intervention data $interventions = array(); if (CostbenefitprojectionHelper::checkArray($array)) { foreach ($array as $intervention) { $interventions[$intervention] = CostbenefitprojectionHelper::getVar('intervention', $intervention, 'id', 'intervention'); } } // sort the data $bucket = array(); if (CostbenefitprojectionHelper::checkArray($interventions)) { foreach ($interventions as $inter => $set) { if (CostbenefitprojectionHelper::isJson($set)) { $set = json_decode($set, true); if (CostbenefitprojectionHelper::checkArray($set)) { foreach ($set as $option => $values) { foreach ($values as $nr => $value) { $bucket[$inter][$nr][$option] = $value; } } } } } } // combine the data $combine = array(); if (CostbenefitprojectionHelper::checkArray($bucket)) { foreach ($bucket as $pool) { if (CostbenefitprojectionHelper::checkArray($pool)) { foreach ($pool as $headers) { if (CostbenefitprojectionHelper::checkArray($headers)) { // check if this cause is already targeted if (isset($combine[$headers['causerisk']])) { // combine $temp = $combine[$headers['causerisk']]; $temp['cpe'] = $this->combineValues($temp['cpe'], $headers['cpe']); $temp['mbr'] = $this->combineValues($temp['mbr'], $headers['mbr']); $temp['mtr'] = $this->combineValues($temp['mtr'], $headers['mtr']); // update the data $combine[$headers['causerisk']] = $temp; } else { // set for first time $combine[$headers['causerisk']] = array('cpe' => $headers['cpe'], 'mbr' => $headers['mbr'], 'mtr' => $headers['mtr']); } } } } } } // setup the object if (CostbenefitprojectionHelper::checkArray($combine)) { $oject = array(); foreach ($combine as $causerisk => $vals) { if (CostbenefitprojectionHelper::checkArray($vals)) { $oject['causerisk'][] = $causerisk; foreach ($vals as $header => $v) { // set placeholder $oject[$header][] = $v; } } } // done at last $oject = json_encode($oject); } } // return the table and values return array('table' => $this->getInterventionBuildTable($idName, $oject, 'ja'), 'values' => $oject); }