</dd> <dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_SALARY'); ?> </dt><dd><?php echo costbenefitprojectionHelper::makeMoney($displayData->total_salary); ?> </dd> <?php if ($displayData->total_healthcare && 2 == $displayData->department) { ?> <dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_HEALTHCARE_COSTS'); ?> </dt><dd><?php echo costbenefitprojectionHelper::makeMoney($displayData->total_healthcare); ?> </dd> <?php } if ($displayData->productivity_losses && 2 == $displayData->department) { ?> <dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_MEDICAL_TURNOVER_COST_FACTOR'); ?> </dt><dd><?php echo $displayData->productivity_losses; ?> </dd> <?php }
/** * 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 service_provider $query->select($db->quoteName(array('id'))); $query->from($db->quoteName('#__costbenefitprojection_service_provider')); $query->where($db->quoteName('publicemail') . ' = ' . $db->quote($validData['publicemail'])); $query->where($db->quoteName('publicname') . ' = ' . $db->quote($validData['publicname'])); $query->where($db->quoteName('country') . ' = ' . (int) $validData['country']); $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']) { // setup config array $newUser = array('name' => $validData['publicname'], 'email' => $validData['publicemail']); $userId = costbenefitprojectionHelper::createUser($newUser); if (!is_int($userId)) { $this->setMessage($userId, 'error'); } else { // get params $params = JComponentHelper::getParams('com_costbenefitprojection'); // get groups for members $groups = (array) $params->get('serviceprovideruser'); // update the user groups JUserHelper::setUserGroups($userId, $groups); // add this user id to this serviceprovider $validData['user'] = $userId; $model->save($validData); } } } return; }
/** * 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) { // user setup if not set if (0 >= (int) $validData['user']) { // setup config array $newUser = array('name' => $validData['publicname'], 'email' => $validData['publicemail']); $userId = costbenefitprojectionHelper::createUser($newUser); if (!is_int($userId)) { $this->setMessage($userId, 'error'); } else { // get params $params = JComponentHelper::getParams('com_costbenefitprojection'); // get groups for members $groups = (array) $params->get('countryuser'); // update the user groups JUserHelper::setUserGroups($userId, $groups); // add this user id to this country $validData['user'] = $userId; $model->save($validData); } } // 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('country') . ' = ' . (int) $validData['id']); $query->where($db->quoteName('company') . ' = 0'); $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 = 0; $country = $validData['id']; // Create a new query object. $query = $db->getQuery(true); // Insert columns. $columns = array('causerisk', 'company', 'country', '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, $country, 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') . ' = 0'); $query->where($db->quoteName('country') . ' = ' . (int) $country); $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; }
// page loading pause jQuery(window).load(function() { jQuery('#loading').fadeOut( 'fast', function() { jQuery('#main_costbenefitprojection').fadeIn( 'fast', function() { <?php if (isset($this->items) && costbenefitprojectionHelper::checkArray($this->items) && $useris) { ?> jQuery('.footable').footable(); <?php } ?> }); }); }); <?php if (isset($this->items) && costbenefitprojectionHelper::checkArray($this->items) && $useris) { ?> // foo table trigger on click jQuery('.footabletab').click(function(e){ // use setTimeout() to execute setTimeout( resizeFooTable, 300); }); // funtion to resize the foo table function resizeFooTable() { jQuery('.footable').trigger('footable_resize'); } // update the value of combined function setCombined(id) { jQuery('#combined_'+id).toggleClass('uk-button-success'); jQuery('#icon_'+id).toggleClass('uk-icon-toggle-off uk-icon-toggle-on');