/** * display task * * @return void */ function display($cachable = false, $urlparams = false) { // set default view if not set $view = $this->input->getCmd('view', 'Costbenefitprojection'); $data = $this->getViewRelation($view); $layout = $this->input->get('layout', null, 'WORD'); $id = $this->input->getInt('id'); // Check for edit form. if (CostbenefitprojectionHelper::checkArray($data)) { if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_costbenefitprojection.edit.' . $data['view'], $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); // check if item was opend from other then its own list view $ref = $this->input->getCmd('ref', 0); $refid = $this->input->getInt('refid', 0); // set redirect if ($refid > 0 && CostbenefitprojectionHelper::checkString($ref)) { // redirect to item of ref $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=' . (string) $ref . '&layout=edit&id=' . (int) $refid, false)); } elseif (CostbenefitprojectionHelper::checkString($ref)) { // redirect to ref $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=' . (string) $ref, false)); } else { // normal redirect back to the list view $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=' . $data['views'], false)); } return false; } } return parent::display($cachable, $urlparams); }
public function exportData() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // check if export is allowed for this user. $user = JFactory::getUser(); if ($user->authorise('help_document.export', 'com_costbenefitprojection') && $user->authorise('core.export', 'com_costbenefitprojection')) { // Get the input $input = JFactory::getApplication()->input; $pks = $input->post->get('cid', array(), 'array'); // Sanitize the input JArrayHelper::toInteger($pks); // Get the model $model = $this->getModel('Help_documents'); // get the data to export $data = $model->getExportData($pks); if (CostbenefitprojectionHelper::checkArray($data)) { // now set the data to the spreadsheet $date = JFactory::getDate(); CostbenefitprojectionHelper::xls($data, 'Help_documents_' . $date->format('jS_F_Y'), 'Help documents exported (' . $date->format('jS F, Y') . ')', 'help documents'); } } // Redirect to the list screen with error. $message = JText::_('COM_COSTBENEFITPROJECTION_EXPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error'); return; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { // Get the user object. $user = JFactory::getUser(); // Create a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id', 'a.name'), array('id', 'testcompanies_name'))); $query->from($db->quoteName('#__costbenefitprojection_company', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); if (!$user->authorise('core.options', 'com_costbenefitprojection')) { $companies = CostbenefitprojectionHelper::hisCompanies($user->id); if (CostbenefitprojectionHelper::checkArray($companies)) { $companies = implode(',', $companies); // only load this users companies $query->where('a.id IN (' . $companies . ')'); } else { // dont allow user to see any companies $query->where('a.id = -4'); } } $query->order('a.name ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); if ($items) { foreach ($items as $item) { $tmp = array('value' => $item->id, 'text' => ' <strong>' . $item->testcompanies_name . '</strong>', 'checked' => false); $options[] = (object) $tmp; } } return $options; }
/** * Method override to check if you can edit an existing record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; // get company id $company = CostbenefitprojectionHelper::getId('intervention', $recordId, 'id', 'company'); if (!$user->authorise('core.options', 'com_costbenefitprojection')) { // make absolutely sure that this intervention can be edited $companies = CostbenefitprojectionHelper::hisCompanies($user->id); if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company, $companies)) { return false; } } // now check the access by sharing if (!CostbenefitprojectionHelper::checkIntervetionAccess($recordId, null, $company)) { return false; } // Access check. $access = $user->authorise('intervention.access', 'com_costbenefitprojection.intervention.' . (int) $recordId) && $user->authorise('intervention.access', 'com_costbenefitprojection'); if (!$access) { return false; } if ($recordId) { // The record has been set. Check the record permissions. $permission = $user->authorise('intervention.edit', 'com_costbenefitprojection.intervention.' . (int) $recordId); if (!$permission && !is_null($permission)) { if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection.intervention.' . $recordId)) { // Now test the owner is the user. $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; if (empty($ownerId)) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if (empty($record)) { return false; } $ownerId = $record->created_by; } // If the owner matches 'me' then allow. if ($ownerId == $user->id) { if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection')) { return true; } } } return false; } } // Since there is no permission, revert to the component permissions. return $user->authorise('intervention.edit', $this->option); }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id', 'a.name', 'a.ref'), array('id', 'causesrisks_name', 'ref'))); $query->from($db->quoteName('#__costbenefitprojection_causerisk', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); $query->order('a.ref ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); $counter = 0; if ($items) { foreach ($items as $item) { $ref = explode('.', $item->ref); $target_id = implode('-', $ref); $key = explode('.0', $item->ref); $key = implode('.', $key); $spacer = array(); $sub = ''; $sub_ = ''; foreach ($ref as $nr => $space) { if ($nr > 1) { $spacer[] = '<span class=\'gi\'>|—</span>'; } if ($nr > 2) { $sub = '<em>'; $sub_ = '</em>'; } } if (CostbenefitprojectionHelper::checkArray($spacer)) { $tmp = array('value' => $item->id, 'text' => '<span id=' . $target_id . ' style=\'color:' . $color . ';\'> ' . implode('', $spacer) . ' ' . $sub . $item->causesrisks_name . $sub_ . ' <small>(' . $key . ')</small></span>', 'checked' => false); $options[] = (object) $tmp; } else { if ($counter & 1) { $color = '#0C5B00'; } else { $color = '#1A3867'; } $tmp = array('value' => $item->id, 'text' => '<span id=' . $target_id . ' style=\'color:' . $color . ';\'> <strong>' . strtoupper($item->causesrisks_name) . '</strong> <small>(' . $key . ')</small></span>', 'checked' => false); $options[] = (object) $tmp; $counter++; } } } return $options; }
<div id="j-sidebar-container" class="span2"> <?php echo $this->sidebar; ?> </div> <div id="j-main-container" class="span10"> <?php } else { ?> <div id="j-main-container"> <?php } ?> <?php if ($this->hasPackage && CostbenefitprojectionHelper::checkArray($this->headerList) && CostbenefitprojectionHelper::checkArray($this->headers)) { ?> <fieldset class="uploadform"> <legend><?php echo JText::_('COM_COSTBENEFITPROJECTION_IMPORT_LINK_FILE_TO_TABLE_COLUMNS'); ?> </legend> <div class="control-group"> <label class="control-label" ><h4><?php echo JText::_('COM_COSTBENEFITPROJECTION_IMPORT_TABLE_COLUMNS'); ?> </h4></label> <div class="controls"> <label class="control-label" ><h4><?php echo JText::_('COM_COSTBENEFITPROJECTION_IMPORT_FILE_COLUMNS'); ?>
/** * Function that allows child controller access to model data * after the data has been saved. * * @param JModel &$model The data model object. * @param array $validData The validated data. * * @return void * * @since 11.1 */ protected function postSaveHook(JModelLegacy $model, $validData = array()) { if ($validData['id'] >= 0) { // get user object $user = JFactory::getUser(); // if id is 0 get id if (0 >= (int) $validData['id']) { // Get the created by id $created_by = isset($validData['created_by']) && $validData['created_by'] > 0 ? $validData['created_by'] : $user->id; // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select id of this company $query->select($db->quoteName(array('id'))); $query->from($db->quoteName('#__costbenefitprojection_company')); $query->where($db->quoteName('name') . ' = ' . $db->quote($validData['name'])); $query->where($db->quoteName('email') . ' = ' . $db->quote($validData['email'])); $query->where($db->quoteName('country') . ' = ' . (int) $validData['country']); $query->where($db->quoteName('service_provider') . ' = ' . (int) $validData['service_provider']); $query->where($db->quoteName('created_by') . ' = ' . (int) $created_by); if (isset($validData['created'])) { $query->where($db->quoteName('created') . ' = ' . $db->quote($validData['created'])); } $db->setQuery($query); $db->execute(); if ($db->getNumRows()) { $validData['id'] = $db->loadResult(); } else { return; } } // user setup if not set if (0 >= (int) $validData['user'] && (int) $validData['id'] > 0) { $userIs = CostbenefitprojectionHelper::userIs($user->id); if (1 == $userIs) { // this is a company so just use its id $userId = $user->id; // add this user id to this company $validData['user'] = $userId; $model->save($validData); } else { // setup config array $newUser = array('name' => $validData['name'], 'email' => $validData['email']); $userId = CostbenefitprojectionHelper::createUser($newUser); if (!is_int($userId)) { $this->setMessage($userId, 'error'); } else { // add this user id to this company $validData['user'] = $userId; $model->save($validData); } } } // only continue if we have a company id if ((int) $validData['id'] > 0) { // get params $params = JComponentHelper::getParams('com_costbenefitprojection'); // get all this users companies $hisCompanies = CostbenefitprojectionHelper::hisCompanies($validData['user']); if (CostbenefitprojectionHelper::checkArray($hisCompanies)) { // set the user group based on the overall status of its companies $departments = CostbenefitprojectionHelper::getVars('company', $hisCompanies, 'id', 'department'); if (in_array(2, $departments)) { $memberGroups = $params->get('advancedmembergroup'); } else { $memberGroups = $params->get('memberbasicgroup'); } } else { // first company so act simply on this company department status if (2 == $validData['department']) { $memberGroups = $params->get('advancedmembergroup'); } else { $memberGroups = $params->get('memberbasicgroup'); } } // update the user groups JUserHelper::setUserGroups((int) $validData['user'], (array) $memberGroups); // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select all records in scaling factors the belong to this company $query->select($db->quoteName(array('id', 'causerisk', 'published'))); $query->from($db->quoteName('#__costbenefitprojection_scaling_factor')); $query->where($db->quoteName('company') . ' = ' . (int) $validData['id']); $db->setQuery($query); $db->execute(); if ($db->getNumRows()) { // load the scaling factors already set $already = $db->loadObjectList(); $publish = array(); $archive = array(); $bucket = array(); foreach ($already as $scale) { if (CostbenefitprojectionHelper::checkArray($validData['causesrisks'])) { if (in_array($scale->causerisk, $validData['causesrisks']) && $scale->published != 1) { // publish the scaling factor (update) $publish[$scale->id] = $scale->id; } elseif (!in_array($scale->causerisk, $validData['causesrisks'])) { // archive the scaling factor (update) $archive[$scale->id] = $scale->id; } $bucket[] = $scale->causerisk; } else { // archive the scaling factor (update) $archive[$scale->id] = $scale->id; } } // update the needed records $types = array('publish' => 1, 'archive' => 2); foreach ($types as $type => $int) { if (CostbenefitprojectionHelper::checkArray(${$type})) { foreach (${$type} as $id) { $query = $db->getQuery(true); // Fields to update. $fields = array($db->quoteName('published') . ' = ' . (int) $int); // Conditions for which records should be updated. $conditions = array($db->quoteName('id') . ' = ' . (int) $id); $query->update($db->quoteName('#__costbenefitprojection_scaling_factor'))->set($fields)->where($conditions); $db->setQuery($query); $db->execute(); } } } } if (CostbenefitprojectionHelper::checkArray($validData['causesrisks'])) { // remove those already set from the saved list of causesrisks if (CostbenefitprojectionHelper::checkArray($bucket)) { $insert = array(); foreach ($validData['causesrisks'] as $causerisk) { if (!in_array($causerisk, $bucket)) { $insert[] = $causerisk; } } } else { $insert = $validData['causesrisks']; } } // insert the new records if (CostbenefitprojectionHelper::checkArray($insert)) { $created = $db->quote(JFactory::getDate()->toSql()); $created_by = JFactory::getUser()->get('id'); $company = $validData['id']; // Create a new query object. $query = $db->getQuery(true); // Insert columns. $columns = array('causerisk', 'company', 'mortality_scaling_factor_females', 'mortality_scaling_factor_males', 'presenteeism_scaling_factor_females', 'presenteeism_scaling_factor_males', 'yld_scaling_factor_females', 'yld_scaling_factor_males', 'published', 'created_by', 'created'); // setup the values $values = array(); foreach ($insert as $new) { $array = array($new, $company, 1, 1, 1, 1, 1, 1, 1, $created_by, $created); $values[] = implode(',', $array); } // Prepare the insert query. $query->insert($db->quoteName('#__costbenefitprojection_scaling_factor'))->columns($db->quoteName($columns))->values(implode('), (', $values)); // Set the query using our newly populated query object and execute it. $db->setQuery($query); $done = $db->execute(); if ($done) { // we must set the assets foreach ($insert as $causerisk) { // get all the ids. Create a new query object. $query = $db->getQuery(true); $query->select($db->quoteName(array('id'))); $query->from($db->quoteName('#__costbenefitprojection_scaling_factor')); $query->where($db->quoteName('causerisk') . ' = ' . (int) $causerisk); $query->where($db->quoteName('company') . ' = ' . (int) $company); $db->setQuery($query); $db->execute(); if ($db->getNumRows()) { $aId = $db->loadResult(); // make sure the access of asset is set CostbenefitprojectionHelper::setAsset($aId, 'scaling_factor'); } } } } } } return; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { // Get the user object. $user = JFactory::getUser(); // Create a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id', 'a.user'), array('id', 'service_provider_user'))); $query->from($db->quoteName('#__costbenefitprojection_service_provider', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); if (!$user->authorise('core.options', 'com_costbenefitprojection')) { $serviceProviders = CostbenefitprojectionHelper::hisServiceProviders($user->id); if (CostbenefitprojectionHelper::checkArray($serviceProviders)) { $serviceProviders = implode(',', $serviceProviders); // only load this users service providers $query->where('a.id IN (' . $serviceProviders . ')'); } else { // don't allow user to see any service providers $query->where('a.id = -4'); } } $query->order('a.user ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); if ($items) { foreach ($items as $item) { $options[] = JHtml::_('select.option', $item->id, JFactory::getUser($item->service_provider_user)->name); } } return $options; }
/** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $input = JFactory::getApplication()->input; $filter = JFilterInput::getInstance(); // set the metadata to the Item Data if (isset($data['metadata']) && isset($data['metadata']['author'])) { $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); $metadata = new JRegistry(); $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; } // Set the empty testcompanies item to data if (!isset($data['testcompanies'])) { $data['testcompanies'] = ''; } // Set the testcompanies string to JSON string. if (isset($data['testcompanies'])) { $data['testcompanies'] = (string) json_encode($data['testcompanies']); } // Set the Params Items to data if (isset($data['params']) && is_array($data['params'])) { $params = new JRegistry(); $params->loadArray($data['params']); $data['params'] = (string) $params; } // Alter the uniqe field for save as copy if ($input->get('task') == 'save2copy') { // Automatic handling of other uniqe fields $uniqeFields = $this->getUniqeFields(); if (CostbenefitprojectionHelper::checkArray($uniqeFields)) { foreach ($uniqeFields as $uniqeField) { $data[$uniqeField] = $this->generateUniqe($uniqeField, $data[$uniqeField]); } } } if (parent::save($data)) { return true; } return false; }
/** * Prepares the document */ protected function setDocument() { // always make sure jquery is loaded. JHtml::_('jquery.framework'); // Load the header checker class. require_once JPATH_COMPONENT_SITE . '/helpers/headercheck.php'; // Initialize the header checker. $HeaderCheck = new HeaderCheck(); // Load uikit options. $uikit = $this->params->get('uikit_load'); // Set script size. $size = $this->params->get('uikit_min'); // Set css style. $style = $this->params->get('uikit_style'); // The uikit css. if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) { $this->document->addStyleSheet(JURI::root(true) . '/media/com_costbenefitprojection/uikit/css/uikit' . $style . $size . '.css'); } // The uikit js. if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) { $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/uikit/js/uikit' . $size . '.js'); } // Load the needed uikit components in this view. $uikitComp = $this->get('UikitComp'); if ($uikit != 2 && isset($uikitComp) && CostbenefitprojectionHelper::checkArray($uikitComp)) { // load just in case. jimport('joomla.filesystem.file'); // loading... foreach ($uikitComp as $class) { foreach (CostbenefitprojectionHelper::$uk_components[$class] as $name) { // check if the CSS file exists. if (JFile::exists(JPATH_ROOT . '/media/com_costbenefitprojection/uikit/css/components/' . $name . $style . $size . '.css')) { // load the css. $this->document->addStyleSheet(JURI::root(true) . '/media/com_costbenefitprojection/uikit/css/components/' . $name . $style . $size . '.css'); } // check if the JavaScript file exists. if (JFile::exists(JPATH_ROOT . '/media/com_costbenefitprojection/uikit/js/components/' . $name . $size . '.js')) { // load the js. $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/uikit/js/components/' . $name . $size . '.js'); } } } } // add the google chart builder class. require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/chartbuilder.php'; // load the google chart js. $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/js/google.jsapi.js'); $this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js'); $this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js'); // Add the CSS for Footable. $this->document->addStyleSheet(JURI::root() . 'media/com_costbenefitprojection/footable/css/footable.core.min.css'); // Use the Metro Style if (!isset($this->fooTableStyle) || 0 == $this->fooTableStyle) { $this->document->addStyleSheet(JURI::root() . 'media/com_costbenefitprojection/footable/css/footable.metro.min.css'); } elseif (isset($this->fooTableStyle) && 1 == $this->fooTableStyle) { $this->document->addStyleSheet(JURI::root() . 'media/com_costbenefitprojection/footable/css/footable.standalone.min.css'); } // Add the JavaScript for Footable $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.js'); $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.sort.js'); $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.filter.js'); $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.paginate.js'); // set header JToolbarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_COMBINED_RESULTS_OF') . ' (' . $this->names . ')', 'cogs'); // add custom css $this->document->addStyleSheet(JURI::root(true) . "/administrator/components/com_costbenefitprojection/assets/css/dashboard.css"); // add custom js $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/js/chartMenu.js'); $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/js/table2excel.js'); // set chart stuff $this->Chart['backgroundColor'] = $this->params->get('admin_chartbackground'); $this->Chart['width'] = $this->params->get('admin_mainwidth'); $this->Chart['chartArea'] = array('top' => $this->params->get('admin_chartareatop'), 'left' => $this->params->get('admin_chartarealeft'), 'width' => $this->params->get('admin_chartareawidth') . '%'); $this->Chart['legend'] = array('textStyle' => array('fontSize' => $this->params->get('admin_legendtextstylefontsize'), 'color' => $this->params->get('admin_legendtextstylefontcolor'))); $this->Chart['vAxis'] = array('textStyle' => array('color' => $this->params->get('admin_vaxistextstylefontcolor'))); $this->Chart['hAxis']['textStyle'] = array('color' => $this->params->get('admin_haxistextstylefontcolor')); $this->Chart['hAxis']['titleTextStyle'] = array('color' => $this->params->get('admin_haxistitletextstylefontcolor')); // notice session controller $session = JFactory::getSession(); $this->menuNotice = $session->get('CT_SubMenuNotice', 'empty'); if ($this->menuNotice == 'empty') { $session->set('CT_SubMenuNotice', '1'); } elseif ($this->menuNotice < 6) { $this->menuNotice++; $session->set('CT_SubMenuNotice', $this->menuNotice); } // add the document default css file $this->document->addStyleSheet(JURI::root(true) . '/administrator/components/com_costbenefitprojection/assets/css/combinedresults.css'); }
/** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $input = JFactory::getApplication()->input; $filter = JFilterInput::getInstance(); // set the metadata to the Item Data if (isset($data['metadata']) && isset($data['metadata']['author'])) { $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); $metadata = new JRegistry(); $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; } // Set the empty causesrisks item to data if (!isset($data['causesrisks'])) { $data['causesrisks'] = ''; } // Set the causesrisks string to JSON string. if (isset($data['causesrisks'])) { $data['causesrisks'] = (string) json_encode($data['causesrisks']); } // Set the Params Items to data if (isset($data['params']) && is_array($data['params'])) { $params = new JRegistry(); $params->loadArray($data['params']); $data['params'] = (string) $params; } // Alter the name for save as copy if ($input->get('task') == 'save2copy') { $origTable = clone $this->getTable(); $origTable->load($input->getInt('id')); if ($data['name'] == $origTable->name) { list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']); $data['name'] = $name; $data['alias'] = $alias; } else { if ($data['alias'] == $origTable->alias) { $data['alias'] = ''; } } $data['published'] = 0; } // Automatic handling of alias for empty fields if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0) { if ($data['alias'] == null) { if (JFactory::getConfig()->get('unicodeslugs') == 1) { $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['name']); } else { $data['alias'] = JFilterOutput::stringURLSafe($data['name']); } $table = JTable::getInstance('country', 'costbenefitprojectionTable'); if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) { $msg = JText::_('COM_COSTBENEFITPROJECTION_COUNTRY_SAVE_WARNING'); } list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']); $data['alias'] = $alias; if (isset($msg)) { JFactory::getApplication()->enqueueMessage($msg, 'warning'); } } } // Alter the uniqe field for save as copy if ($input->get('task') == 'save2copy') { // Automatic handling of other uniqe fields $uniqeFields = $this->getUniqeFields(); if (CostbenefitprojectionHelper::checkArray($uniqeFields)) { foreach ($uniqeFields as $uniqeField) { $data[$uniqeField] = $this->generateUniqe($uniqeField, $data[$uniqeField]); } } } if (parent::save($data)) { return true; } return false; }
protected function getDummyComp() { // insure we only get this once if (!CostbenefitprojectionHelper::checkArray($this->dummyComp)) { // Create a new query object. $query = $this->db->getQuery(true); // Get from #__costbenefitprojection_service_provider as a $query->select($this->db->quoteName(array('a.testcompanies'), array('testcompanies'))); $query->from($this->db->quoteName('#__costbenefitprojection_service_provider', 'a')); // load the query $this->db->setQuery($query); $this->db->execute(); if ($this->db->getNumRows()) { // get the test companies $testcompanies = $this->db->loadColumn(); // global Ids $global = array(); // okay now we loop the test companies to build a global id set foreach ($testcompanies as $json) { if (CostbenefitprojectionHelper::checkJson($json)) { $global = array_merge($global, json_decode($json, true)); } } // now insure the ids are unique $this->dummyComp = array_unique($global); } } return $this->dummyComp; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { $jinput = JFactory::getApplication()->input; $client = $jinput->get('id', 0, 'INT'); $countries = CostbenefitprojectionHelper::hisCountries(null, $client, 'company'); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.year', 'a.country'), array('year', 'country'))); $query->from($db->quoteName('#__costbenefitprojection_health_data', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); if (CostbenefitprojectionHelper::checkArray($countries)) { $query->where($db->quoteName('a.country') . ' IN (' . implode(',', $countries) . ')'); } $query->order('a.country ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); if ($items) { $years = array(); foreach ($items as $item) { if (!CostbenefitprojectionHelper::checkArray($years) || !in_array($item->year . '_' . $item->country, $years)) { if (!CostbenefitprojectionHelper::checkArray($countries) || $client == 0) { $countryName = ' (' . CostbenefitprojectionHelper::getCountryName($item->country) . ')'; } else { $countryName = ''; } $options[] = JHtml::_('select.option', $item->year, $item->year . $countryName); $years[$item->year] = $item->year . '_' . $item->country; } } } return $options; }
/** * Method to get header. * * @return mixed An array of data items on success, false on failure. */ public function getExImPortHeaders() { // Get a db connection. $db = JFactory::getDbo(); // get the columns $columns = $db->getTableColumns("#__costbenefitprojection_causerisk"); if (CostbenefitprojectionHelper::checkArray($columns)) { // remove the headers you don't import/export. unset($columns['asset_id']); unset($columns['checked_out']); unset($columns['checked_out_time']); $headers = new stdClass(); foreach ($columns as $column => $type) { $headers->{$column} = $column; } return $headers; } return false; }
} if (array_key_exists($key, $datatype)) { // this should be save since all data passed is internal $head .= $datatype[$key]; } if (array_key_exists($key, $datahide)) { // this should be save since all data passed is internal $head .= $datahide[$key]; } $head .= '>' . $header . '</th>'; } $scalingfactors = '<table class="footable metro-blue toggle-circle" data-page-size="10"><thead><tr>' . $head . '</tr></thead><tbody>' . $body . '</tbody><tfoot class="hide-if-no-paging"><tr><td colspan="10"><div class="pagination pagination-centered"></div></td></tr></tfoot></table>'; } // set interventions $interventions = '<div class="uk-alert">' . JText::_('COM_COSTBENEFITPROJECTION_NO_INTERVENTIONS_SET') . '</div>'; if (isset($displayData->idCompanyInterventionE) && CostbenefitprojectionHelper::checkArray($displayData->idCompanyInterventionE)) { // the values to display $keys = array('id' => JText::_('ID'), 'name' => JText::_('COM_COSTBENEFITPROJECTION_NAME'), 'type' => JText::_('COM_COSTBENEFITPROJECTION_TYPE'), 'coverage' => JText::_('COM_COSTBENEFITPROJECTION_COVERAGE'), 'share' => JText::_('COM_COSTBENEFITPROJECTION_SHARE'), 'description' => JText::_('COM_COSTBENEFITPROJECTION_DESCRIPTION'), 'reference' => JText::_('COM_COSTBENEFITPROJECTION_REFERENCE'), 'intervention' => JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION'), 'published' => JText::_('COM_COSTBENEFITPROJECTION_STATUS')); $rows = array('published' => 'setPublised', 'intervention' => 'setIntervention', 'name' => 'setInterventionLink', 'type' => 'setInterventionType', 'share' => 'setInterventionShare'); // header switces $datahide = array('id' => ' data-ignore="true" data-hide="all"', 'share' => ' data-hide="phone,tablet"', 'description' => ' data-hide="all"', 'reference' => ' data-hide="all"', 'intervention' => ' data-hide="all"'); $datatype = array('id' => ' data-type="numeric"', 'coverage' => ' data-type="numeric"'); $datatoggle = array('name' => ' data-toggle="true"'); // set the body $body = ''; foreach ($displayData->idCompanyInterventionE as $details) { if (CostbenefitprojectionHelper::checkObject($details)) { // build the dl list $body .= '<tr>'; foreach ($keys as $key => $header) { if (array_key_exists($key, $rows)) {
/** * Get the uikit needed components * * @return mixed An array of objects on success. * */ public function getUikitComp() { if (isset($this->uikitComp) && CostbenefitprojectionHelper::checkArray($this->uikitComp)) { return $this->uikitComp; } return false; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { // Get the user object. $user = JFactory::getUser(); // Create a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id', 'a.name'), array('id', 'country_name'))); $query->from($db->quoteName('#__costbenefitprojection_country', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); if (!$user->authorise('core.options', 'com_costbenefitprojection')) { $countries = CostbenefitprojectionHelper::hisCountries($user->id); if (CostbenefitprojectionHelper::checkArray($countries)) { $countries = implode(',', $countries); // only load this users companies $query->where('a.id IN (' . $countries . ')'); } else { // dont allow user to see any countries $query->where('a.id = -4'); } } $query->order('a.name ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); if ($items) { $options[] = JHtml::_('select.option', '', 'Select a country'); foreach ($items as $item) { $options[] = JHtml::_('select.option', $item->id, $item->country_name); } } return $options; }
/** * Save the data from the file to the database * * @param string $package Paths to the uploaded package file * * @return boolean false on failure * **/ protected function save($data, $table) { // import the data if there is any if (CostbenefitprojectionHelper::checkArray($data['array'])) { // get user object $user = JFactory::getUser(); // remove header if it has headers $id_key = $data['target_headers']['id']; $published_key = $data['target_headers']['published']; $ordering_key = $data['target_headers']['ordering']; // get the first array set $firstSet = reset($data['array']); // check if first array is a header array and remove if true if ($firstSet[$id_key] == 'id' || $firstSet[$published_key] == 'published' || $firstSet[$ordering_key] == 'ordering') { array_shift($data['array']); } // make sure there is still values in array and that it was not only headers if (CostbenefitprojectionHelper::checkArray($data['array']) && $user->authorise($table . '.import', 'com_costbenefitprojection') && $user->authorise('core.import', 'com_costbenefitprojection')) { // set target. $target = array_flip($data['target_headers']); // Get a db connection. $db = JFactory::getDbo(); // set some defaults $todayDate = JFactory::getDate()->toSql(); // get global action permissions $canDo = CostbenefitprojectionHelper::getActions($table); $canEdit = $canDo->get('core.edit'); $canState = $canDo->get('core.edit.state'); $canCreate = $canDo->get('core.create'); $hasAlias = $this->getAliasesUsed($table); // prosses the data foreach ($data['array'] as $row) { $found = false; if (isset($row[$id_key]) && is_numeric($row[$id_key]) && $row[$id_key] > 0) { // raw items import & update! $query = $db->getQuery(true); $query->select('version')->from($db->quoteName('#__costbenefitprojection_' . $table))->where($db->quoteName('id') . ' = ' . $db->quote($row[$id_key])); // Reset the query using our newly populated query object. $db->setQuery($query); $db->execute(); $found = $db->getNumRows(); } if ($found && $canEdit) { // update item $id = $row[$id_key]; $version = $db->loadResult(); // reset all buckets $query = $db->getQuery(true); $fields = array(); // Fields to update. foreach ($row as $key => $cell) { // ignore column if ('IGNORE' == $target[$key]) { continue; } // update modified if ('modified_by' == $target[$key]) { continue; } // update modified if ('modified' == $target[$key]) { continue; } // update version if ('version' == $target[$key]) { $cell = (int) $version + 1; } // verify publish authority if ('published' == $target[$key] && !$canState) { continue; } // set to update array if (in_array($key, $data['target_headers']) && is_numeric($cell)) { $fields[] = $db->quoteName($target[$key]) . ' = ' . $cell; } elseif (in_array($key, $data['target_headers']) && is_string($cell)) { $fields[] = $db->quoteName($target[$key]) . ' = ' . $db->quote($cell); } elseif (in_array($key, $data['target_headers']) && is_null($cell)) { // if import data is null then set empty $fields[] = $db->quoteName($target[$key]) . " = ''"; } } // load the defaults $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id); $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate); // Conditions for which records should be updated. $conditions = array($db->quoteName('id') . ' = ' . $id); $query->update($db->quoteName('#__costbenefitprojection_' . $table))->set($fields)->where($conditions); $db->setQuery($query); $db->execute(); } elseif ($canCreate) { // insert item $query = $db->getQuery(true); // reset all buckets $columns = array(); $values = array(); $version = false; // Insert columns. Insert values. foreach ($row as $key => $cell) { // ignore column if ('IGNORE' == $target[$key]) { continue; } // remove id if ('id' == $target[$key]) { continue; } // update created if ('created_by' == $target[$key]) { continue; } // update created if ('created' == $target[$key]) { continue; } // Make sure the alias is incremented if ('alias' == $target[$key]) { $cell = $this->getAlias($cell, $table); } // update version if ('version' == $target[$key]) { $cell = 1; $version = true; } // set to insert array if (in_array($key, $data['target_headers']) && is_numeric($cell)) { $columns[] = $target[$key]; $values[] = $cell; } elseif (in_array($key, $data['target_headers']) && is_string($cell)) { $columns[] = $target[$key]; $values[] = $db->quote($cell); } elseif (in_array($key, $data['target_headers']) && is_null($cell)) { // if import data is null then set empty $columns[] = $target[$key]; $values[] = "''"; } } // load the defaults $columns[] = 'created_by'; $values[] = $db->quote($user->id); $columns[] = 'created'; $values[] = $db->quote($todayDate); if (!$version) { $columns[] = 'version'; $values[] = 1; } // Prepare the insert query. $query->insert($db->quoteName('#__costbenefitprojection_' . $table))->columns($db->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db->setQuery($query); $done = $db->execute(); if ($done) { $aId = $db->insertid(); // make sure the access of asset is set CostbenefitprojectionHelper::setAsset($aId, $table); } } else { return false; } } return true; } } return false; }
/** * 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')); } } }
} } } } ?> <div id="view_icb"> <div style="margin:0 auto; width: <?php echo $this->Chart['width']; ?> px; height: 100%;"> <h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COST_BENEFIT'); ?> </h1> <?php if (isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)) { ?> <?php $intervention_number = 0; ?> <?php foreach ($this->results->interventions as $intervention) { ?> <?php if (isset($intervention->items)) { ?> <?php foreach ($scaled as $scale) { ?> <div id="icb_<?php echo $intervention_number;
echo JText::_('COM_COSTBENEFITPROJECTION_RELEASE_DATE'); ?> <em><?php echo $manifest->creationDate; ?> </em></li> <li><i class="uk-icon-copyright"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_COPYRIGHT_GIZ'); ?> </li> <li><i class="uk-icon-legal"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_LICENSE_A_TARGET_BLANK_HREFHTTPSWWWGNUORGLICENSESGPLTWOZEROHTMLGNUGPLA_COMMERCIAL'); ?> </li> <?php if (CostbenefitprojectionHelper::checkArray($contributors)) { foreach ($contributors as $contributor) { ?> <li><i class="uk-icon-stack-overflow"></i> <?php echo $contributor['title']; ?> <br /><?php echo $contributor['name']; ?> </li> <?php } } ?> <li><i class="uk-icon-code"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_APPLICATION_DEVELOPER');
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id', 'a.name', 'a.ref'), array('id', 'causerisk_name', 'ref'))); $query->from($db->quoteName('#__costbenefitprojection_causerisk', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); $query->order('a.ref ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); if ($items) { foreach ($items as $item) { $ref = explode('.', $item->ref); $key = explode('.0', $item->ref); $key = implode('.', $key); $spacer = array(); foreach ($ref as $nr => $space) { if ($nr > 1) { $spacer[] = '|—'; } } if (CostbenefitprojectionHelper::checkArray($spacer)) { $options[] = JHtml::_('select.option', $item->id, implode('', $spacer) . ' ' . $item->causerisk_name . ' (' . $key . ')'); } else { $options[] = JHtml::_('select.option', $item->id, $item->causerisk_name . ' (' . $key . ')'); } } } return $options; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { // get the input from url $jinput = JFactory::getApplication()->input; // get the view name & id $interId = $jinput->getInt('id', 0); // Get the user object. $user = JFactory::getUser(); $userIs = CostbenefitprojectionHelper::userIs($user->id); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id', 'a.name', 'a.company', 'a.share'), array('id', 'interventions_name', 'company', 'share'))); $query->from($db->quoteName('#__costbenefitprojection_intervention', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); $query->where($db->quoteName('a.id') . ' != ' . $interId); if (!$user->authorise('core.admin')) { $companies = CostbenefitprojectionHelper::hisCompanies($user->id); if (CostbenefitprojectionHelper::checkArray($companies)) { $companies = implode(',', $companies); // only load this users companies $query->where('a.company IN (' . $companies . ')'); } else { // dont allow user to see any companies $query->where('a.company = -4'); } } $query->order('a.name ASC'); $db->setQuery((string) $query); $items = $db->loadObjectList(); $options = array(); if ($items) { foreach ($items as $item) { if (!CostbenefitprojectionHelper::checkIntervetionAccess($item->id, $item->share, $item->company)) { continue; } if (1 == $userIs) { $options[] = JHtml::_('select.option', $item->id, $item->interventions_name); } else { $compName = CostbenefitprojectionHelper::getId('company', $item->company, 'id', 'name'); $options[] = JHtml::_('select.option', $item->id, $item->interventions_name . ' (' . $compName . ')'); } } } return $options; }
/** * 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; }
/** * 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 save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $input = JFactory::getApplication()->input; $filter = JFilterInput::getInstance(); // set the metadata to the Item Data if (isset($data['metadata']) && isset($data['metadata']['author'])) { $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); $metadata = new JRegistry(); $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; } // Set the empty causesrisks item to data if (!isset($data['causesrisks'])) { $data['causesrisks'] = ''; } // Set the causesrisks string to JSON string. if (isset($data['causesrisks'])) { $data['causesrisks'] = (string) json_encode($data['causesrisks']); } // Get the advanced encription key. $advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced'); // Get the encription object $advanced = new FOFEncryptAes($advancedkey, 256); // Encript data medical_turnovers_females. if (isset($data['medical_turnovers_females']) && $advancedkey) { $data['medical_turnovers_females'] = $advanced->encryptString($data['medical_turnovers_females']); } // Encript data females. if (isset($data['females']) && $advancedkey) { $data['females'] = $advanced->encryptString($data['females']); } // Encript data sick_leave_males. if (isset($data['sick_leave_males']) && $advancedkey) { $data['sick_leave_males'] = $advanced->encryptString($data['sick_leave_males']); } // Encript data medical_turnovers_males. if (isset($data['medical_turnovers_males']) && $advancedkey) { $data['medical_turnovers_males'] = $advanced->encryptString($data['medical_turnovers_males']); } // Encript data total_salary. if (isset($data['total_salary']) && $advancedkey) { $data['total_salary'] = $advanced->encryptString($data['total_salary']); } // Encript data sick_leave_females. if (isset($data['sick_leave_females']) && $advancedkey) { $data['sick_leave_females'] = $advanced->encryptString($data['sick_leave_females']); } // Encript data total_healthcare. if (isset($data['total_healthcare']) && $advancedkey) { $data['total_healthcare'] = $advanced->encryptString($data['total_healthcare']); } // Encript data males. if (isset($data['males']) && $advancedkey) { $data['males'] = $advanced->encryptString($data['males']); } // make sure new company does not get locked $user = JFactory::getUser(); if ($data['id'] == 0 && !$user->authorise('company.edit.per', 'com_costbenefitprojection')) { $data['per'] = 1; } // Set the Params Items to data if (isset($data['params']) && is_array($data['params'])) { $params = new JRegistry(); $params->loadArray($data['params']); $data['params'] = (string) $params; } // Alter the uniqe field for save as copy if ($input->get('task') == 'save2copy') { // Automatic handling of other uniqe fields $uniqeFields = $this->getUniqeFields(); if (CostbenefitprojectionHelper::checkArray($uniqeFields)) { foreach ($uniqeFields as $uniqeField) { $data[$uniqeField] = $this->generateUniqe($uniqeField, $data[$uniqeField]); } } } if (parent::save($data)) { return true; } return false; }
$can = CostbenefitprojectionHelper::getActions('company'); ?> <div class="form-vertical"> <?php if ($can->get('company.create')) { ?> <a class="btn btn-small btn-success" href="<?php echo $new; ?> "><span class="icon-new icon-white"></span> <?php echo JText::_('COM_COSTBENEFITPROJECTION_NEW'); ?> </a><br /><br /> <?php } if (CostbenefitprojectionHelper::checkArray($items)) { ?> <table class="footable table data companies metro-blue" data-page-size="20" data-filter="#filter_companies"> <thead> <tr> <th data-toggle="true"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_COMPANY_NAME_LABEL'); ?> </th> <th data-hide="phone"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_COMPANY_USER_LABEL'); ?> </th> <th data-hide="phone">
protected function setMoney($target) { if (CostbenefitprojectionHelper::checkArray($this->moneyMachine[$target])) { $targets = false; if (strpos($target, '_') !== false) { $targets = explode('_', $target); } foreach ($this->moneyMachine[$target] as $store => $value) { if ($targets && count($targets) == 2) { $this->{$targets}[0]->{$targets}[1]->{$store} = CostbenefitprojectionHelper::makeMoney($this->{$targets}[0]->{$targets}[1]->{$value}, $this->currencyDetails); } else { $this->{$target}->{$store} = CostbenefitprojectionHelper::makeMoney($this->{$target}->{$value}, $this->currencyDetails); } } } }
<?php /*----------------------------------------------------------------------------------| www.giz.de |----/ Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb /-------------------------------------------------------------------------------------------------------/ @version 3.4.2 @build 16th August, 2016 @created 15th June, 2012 @package Cost Benefit Projection @subpackage default_cbpmenumodule.php @author Llewellyn van der Merwe <http://www.vdm.io> @owner Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /-------------------------------------------------------------------------------------------------------/ Cost Benefit Projection Tool. /------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // get the login module $modules = $this->getModules('CBP-MENU', 'array'); if (CostbenefitprojectionHelper::checkArray($modules)) { ?> <div class="uk-panel"><?php echo implode('</div><br /><div class="uk-panel">', $modules); ?> </div> <?php }
/** * 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')); } } }