/** * Method to get an array of data items. * * @return mixed An array of data items on success, false on failure. */ public function getItems() { $user = JFactory::getUser(); // check if this user has permission to access items if (!$user->authorise('site.combinedresults.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; } // load parent items $items = parent::getItems(); // Get the global params $globalParams = JComponentHelper::getParams('com_costbenefitprojection', true); // Get the advanced encription. $advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced'); // Get the encription object. $advanced = new FOFEncryptAes($advancedkey, 256); // Convert the parameter fields into objects. foreach ($items as $nr => &$item) { // Always create a slug for sef URL's $item->slug = isset($item->alias) ? $item->id . ':' . $item->alias : $item->id; if (!empty($item->medical_turnovers_females) && $advancedkey && !is_numeric($item->medical_turnovers_females) && $item->medical_turnovers_females === base64_encode(base64_decode($item->medical_turnovers_females, true))) { // Decode medical_turnovers_females $item->medical_turnovers_females = rtrim($advanced->decryptString($item->medical_turnovers_females), ""); } if (!empty($item->females) && $advancedkey && !is_numeric($item->females) && $item->females === base64_encode(base64_decode($item->females, true))) { // Decode females $item->females = rtrim($advanced->decryptString($item->females), ""); } if (!empty($item->sick_leave_males) && $advancedkey && !is_numeric($item->sick_leave_males) && $item->sick_leave_males === base64_encode(base64_decode($item->sick_leave_males, true))) { // Decode sick_leave_males $item->sick_leave_males = rtrim($advanced->decryptString($item->sick_leave_males), ""); } if (CostbenefitprojectionHelper::checkString($item->causesrisks)) { // Decode causesrisks $item->causesrisks = json_decode($item->causesrisks, true); } if (!empty($item->medical_turnovers_males) && $advancedkey && !is_numeric($item->medical_turnovers_males) && $item->medical_turnovers_males === base64_encode(base64_decode($item->medical_turnovers_males, true))) { // Decode medical_turnovers_males $item->medical_turnovers_males = rtrim($advanced->decryptString($item->medical_turnovers_males), ""); } if (!empty($item->total_salary) && $advancedkey && !is_numeric($item->total_salary) && $item->total_salary === base64_encode(base64_decode($item->total_salary, true))) { // Decode total_salary $item->total_salary = rtrim($advanced->decryptString($item->total_salary), ""); } if (!empty($item->sick_leave_females) && $advancedkey && !is_numeric($item->sick_leave_females) && $item->sick_leave_females === base64_encode(base64_decode($item->sick_leave_females, true))) { // Decode sick_leave_females $item->sick_leave_females = rtrim($advanced->decryptString($item->sick_leave_females), ""); } if (!empty($item->total_healthcare) && $advancedkey && !is_numeric($item->total_healthcare) && $item->total_healthcare === base64_encode(base64_decode($item->total_healthcare, true))) { // Decode total_healthcare $item->total_healthcare = rtrim($advanced->decryptString($item->total_healthcare), ""); } if (!empty($item->males) && $advancedkey && !is_numeric($item->males) && $item->males === base64_encode(base64_decode($item->males, true))) { // Decode males $item->males = rtrim($advanced->decryptString($item->males), ""); } if (CostbenefitprojectionHelper::checkString($item->country_causesrisks)) { // Decode country_causesrisks $item->country_causesrisks = json_decode($item->country_causesrisks, true); } // Make sure the content prepare plugins fire on country_publicaddress. $item->country_publicaddress = JHtml::_('content.prepare', $item->country_publicaddress); // Checking if country_publicaddress has uikit components that must be loaded. $this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->country_publicaddress, $this->uikitComp); // set the global causesrisks value. $this->a_causesrisks = $item->causesrisks; // set the global datayear value. $this->a_datayear = $item->datayear; // set the global datayear value. $this->e_datayear = $item->country_datayear; // set the global causesrisks value. $this->e_causesrisks = $item->country_causesrisks; // set countryCountryHealth_dataB to the $item object. $item->countryCountryHealth_dataB = $this->getCountryCountryHealth_dataBcbb_B($item->country); // set idCompanyScaling_factorC to the $item object. $item->idCompanyScaling_factorC = $this->getIdCompanyScaling_factorBcbb_C($item->id); // set idCompanyInterventionD to the $item object. $item->idCompanyInterventionD = $this->getIdCompanyInterventionBcbb_D($item->id); // set causesrisksIdCauseriskG to the $item object. $item->causesrisksIdCauseriskG = $this->getCausesrisksIdCauseriskBcbb_G($item->causesrisks); // set countryCountryHealth_dataBB to the $item object. $item->countryCountryHealth_dataBB = $this->getCountryCountryHealth_dataBcbb_BB($item->country); // set causesrisksIdCauseriskGG to the $item object. $item->causesrisksIdCauseriskGG = $this->getCausesrisksIdCauseriskBcbb_GG($item->country_causesrisks); // set countryCountryInterventionDD to the $item object. $item->countryCountryInterventionDD = $this->getCountryCountryInterventionBcbb_DD($item->country); } // return items return $items; }
/** * 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]; }
/** * Method to get list export data. * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks) { // setup the query if (CostbenefitprojectionHelper::checkArray($pks)) { // Set a value to know this is exporting method. $_export = true; // Get the user object. $user = JFactory::getUser(); // Create a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); // Select some fields $query->select('a.*'); // From the costbenefitprojection_company table $query->from($db->quoteName('#__costbenefitprojection_company', 'a')); $query->where('a.id IN (' . implode(',', $pks) . ')'); // Filter by companies (admin sees all) 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'); } } // Implement View Level Access if (!$user->authorise('core.options', 'com_costbenefitprojection')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ')'); } // Order the results by ordering $query->order('a.ordering ASC'); // Load the items $db->setQuery($query); $db->execute(); if ($db->getNumRows()) { $items = $db->loadObjectList(); // Get the advanced encription key. $advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced'); // Get the encription object. $advanced = new FOFEncryptAes($advancedkey, 256); // set values to display correctly. if (CostbenefitprojectionHelper::checkArray($items)) { // get user object. $user = JFactory::getUser(); foreach ($items as $nr => &$item) { $access = $user->authorise('company.access', 'com_costbenefitprojection.company.' . (int) $item->id) && $user->authorise('company.access', 'com_costbenefitprojection'); if (!$access) { unset($items[$nr]); continue; } if ($advancedkey && !is_numeric($item->medical_turnovers_females) && $item->medical_turnovers_females === base64_encode(base64_decode($item->medical_turnovers_females, true))) { // decrypt medical_turnovers_females $item->medical_turnovers_females = $advanced->decryptString($item->medical_turnovers_females); } if ($advancedkey && !is_numeric($item->females) && $item->females === base64_encode(base64_decode($item->females, true))) { // decrypt females $item->females = $advanced->decryptString($item->females); } if ($advancedkey && !is_numeric($item->sick_leave_males) && $item->sick_leave_males === base64_encode(base64_decode($item->sick_leave_males, true))) { // decrypt sick_leave_males $item->sick_leave_males = $advanced->decryptString($item->sick_leave_males); } if ($advancedkey && !is_numeric($item->medical_turnovers_males) && $item->medical_turnovers_males === base64_encode(base64_decode($item->medical_turnovers_males, true))) { // decrypt medical_turnovers_males $item->medical_turnovers_males = $advanced->decryptString($item->medical_turnovers_males); } if ($advancedkey && !is_numeric($item->total_salary) && $item->total_salary === base64_encode(base64_decode($item->total_salary, true))) { // decrypt total_salary $item->total_salary = $advanced->decryptString($item->total_salary); } if ($advancedkey && !is_numeric($item->sick_leave_females) && $item->sick_leave_females === base64_encode(base64_decode($item->sick_leave_females, true))) { // decrypt sick_leave_females $item->sick_leave_females = $advanced->decryptString($item->sick_leave_females); } if ($advancedkey && !is_numeric($item->total_healthcare) && $item->total_healthcare === base64_encode(base64_decode($item->total_healthcare, true))) { // decrypt total_healthcare $item->total_healthcare = $advanced->decryptString($item->total_healthcare); } if ($advancedkey && !is_numeric($item->males) && $item->males === base64_encode(base64_decode($item->males, true))) { // decrypt males $item->males = $advanced->decryptString($item->males); } // unset the values we don't want exported. unset($item->asset_id); unset($item->checked_out); unset($item->checked_out_time); } } // Add headers to items array. $headers = $this->getExImPortHeaders(); if (CostbenefitprojectionHelper::checkObject($headers)) { array_unshift($items, $headers); } return $items; } } return false; }
protected function setSatistics() { if (CostbenefitprojectionHelper::checkArray($this->companies)) { // Get UTC for now. $dNow = new JDate(); // set the 2 months date $d2month = clone $dNow; $d2month->modify('-2 month'); // load to string $twoMonth = $d2month->format('Y-m-d H:i:s'); // set the beginning of year date $dyear = clone $dNow; $dyear->modify('first day of January ' . date('Y')); // load to string $year = $dyear->format('Y-m-d H:i:s'); // Get the advanced encription. $advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced'); // Get the encription object. $advanced = new FOFEncryptAes($advancedkey, 256); // set some default data $this->usageData = new stdClass(); // start looping the data foreach ($this->companies as $company) { // now decrypt the company staff count if (!empty($company->males) && $advancedkey && !is_numeric($company->males) && $company->males === base64_encode(base64_decode($company->males, true))) { // Decode males $company->males = rtrim($advanced->decryptString($company->males), ""); } else { $company->males = 0; } if (!empty($company->females) && $advancedkey && !is_numeric($company->females) && $company->females === base64_encode(base64_decode($company->females, true))) { // Decode males $company->females = rtrim($advanced->decryptString($company->females), ""); } else { $company->females = 0; } // number of employees $employees = $company->males + $company->females; // set the country total companies $this->usageData->items[$company->country]['companies'][$company->id] = 1; $this->usageData->total['companies'][$company->id] = 1; $this->usageData->items[$company->country]['companies_employees'][$company->id] = $employees; $this->usageData->total['companies_employees'][$company->id] = $employees; // count the advanced department if ($company->department == 2) { // set the country total advanced companies $this->usageData->items[$company->country]['advanced_companies'][$company->id] = 1; $this->usageData->total['advanced_companies'][$company->id] = 1; $this->usageData->items[$company->country]['advanced_companies_employees'][$company->id] = $employees; $this->usageData->total['advanced_companies_employees'][$company->id] = $employees; } else { // set the country total advanced companies $this->usageData->items[$company->country]['advanced_companies'][$company->id] = 0; $this->usageData->total['advanced_companies'][$company->id] = 0; $this->usageData->items[$company->country]['advanced_companies_employees'][$company->id] = 0; $this->usageData->total['advanced_companies_employees'][$company->id] = 0; } // count the basic department if ($company->department == 1) { // set the country total basic companies $this->usageData->items[$company->country]['basic_companies'][$company->id] = 1; $this->usageData->total['basic_companies'][$company->id] = 1; $this->usageData->items[$company->country]['basic_companies_employees'][$company->id] = $employees; $this->usageData->total['basic_companies_employees'][$company->id] = $employees; } else { // set the country total basic companies $this->usageData->items[$company->country]['basic_companies'][$company->id] = 0; $this->usageData->total['basic_companies'][$company->id] = 0; $this->usageData->items[$company->country]['basic_companies_employees'][$company->id] = 0; $this->usageData->total['basic_companies_employees'][$company->id] = 0; } // count the timed usage for last 2 months if ($this->visitCheck($company->user, $twoMonth)) { // set the country total advanced companies $this->usageData->items[$company->country]['last_two_months'][$company->id] = 1; $this->usageData->total['last_two_months'][$company->id] = 1; $this->usageData->items[$company->country]['last_two_months_employees'][$company->id] = $employees; $this->usageData->total['last_two_months_employees'][$company->id] = $employees; } else { // set the country total advanced companies $this->usageData->items[$company->country]['last_two_months'][$company->id] = 0; $this->usageData->total['last_two_months'][$company->id] = 0; $this->usageData->items[$company->country]['last_two_months_employees'][$company->id] = 0; $this->usageData->total['last_two_months_employees'][$company->id] = 0; } // count the timed usage since begining of this year if ($this->visitCheck($company->user, $year)) { // set the country total basic companies $this->usageData->items[$company->country]['since_beginning_this_year'][$company->id] = 1; $this->usageData->total['since_beginning_this_year'][$company->id] = 1; $this->usageData->items[$company->country]['since_beginning_this_year_employees'][$company->id] = $employees; $this->usageData->total['since_beginning_this_year_employees'][$company->id] = $employees; } else { // set the country total basic companies $this->usageData->items[$company->country]['since_beginning_this_year'][$company->id] = 0; $this->usageData->total['since_beginning_this_year'][$company->id] = 0; $this->usageData->items[$company->country]['since_beginning_this_year_employees'][$company->id] = 0; $this->usageData->total['since_beginning_this_year_employees'][$company->id] = 0; } } // sum the item arrays foreach ($this->usageData->items as $country => $data) { // insure to set the name of the country $this->usageData->items[$country]['name'] = $this->countries[$country]; foreach ($data as $key => $array) { $this->usageData->items[$country][$key] = array_sum($array); } } // sum the total array foreach ($this->usageData->total as $tkey => $tarray) { $this->usageData->total[$tkey] = array_sum($tarray); } return true; } return false; }
/** * 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; }