当前位置: 首页>>代码示例>>PHP>>正文


PHP CostbenefitprojectionHelper::getVar方法代码示例

本文整理汇总了PHP中CostbenefitprojectionHelper::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP CostbenefitprojectionHelper::getVar方法的具体用法?PHP CostbenefitprojectionHelper::getVar怎么用?PHP CostbenefitprojectionHelper::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CostbenefitprojectionHelper的用法示例。


在下文中一共展示了CostbenefitprojectionHelper::getVar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveObject

 /**
  * Save the data from the file to the database
  *
  * @param array  $data The values to save
  *
  * @return  boolean false on failure
  *
  **/
 protected function saveObject(&$db, $data, $type)
 {
     if ($type == 'health_data') {
         // first we check if the data is already set
         $id = $this->getHealthDataId($db, $data->causerisk, $data->year, $data->country);
     }
     // if new then insert data
     if ($type == 'health_data' && !$id && $this->canCreate) {
         // build some extra data
         $data->created_by = $this->user->id;
         $data->created = $this->dateSql;
         $data->version = 1;
         $data->published = 1;
         $data->access = 1;
         $done = $db->insertObject('#__costbenefitprojection_' . $type, $data);
         if ($done) {
             $aId = $db->insertid();
             // make sure the access of asset is set
             return CostbenefitprojectionHelper::setAsset($aId, $type);
         }
     } elseif ($this->canEdit) {
         // build some extra data
         if ($type == 'health_data' && $id > 0) {
             $data->id = $id;
         }
         if ($data->id > 0) {
             $version = CostbenefitprojectionHelper::getVar($type, $data->id, 'id', 'version');
             $data->version = $version + 1;
             $data->modified_by = $this->user->id;
             $data->modified = $this->dateSql;
             return $db->updateObject('#__costbenefitprojection_' . $type, $data, 'id');
         }
     }
     return false;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:43,代码来源:import_health_data_sets.php

示例2: getClusterData

 public function getClusterData($idName, $cluster)
 {
     // we first build the json object from the cluster ids, then pass it to the builder
     $oject = '';
     $oject_table = '';
     if (CostbenefitprojectionHelper::isJson($cluster) && CostbenefitprojectionHelper::checkString($idName)) {
         $array = json_decode($cluster, true);
         // get te set intervention data
         $interventions = array();
         if (CostbenefitprojectionHelper::checkArray($array)) {
             foreach ($array as $intervention) {
                 $interventions[$intervention] = CostbenefitprojectionHelper::getVar('intervention', $intervention, 'id', 'intervention');
             }
         }
         // sort the data
         $bucket = array();
         if (CostbenefitprojectionHelper::checkArray($interventions)) {
             foreach ($interventions as $inter => $set) {
                 if (CostbenefitprojectionHelper::isJson($set)) {
                     $set = json_decode($set, true);
                     if (CostbenefitprojectionHelper::checkArray($set)) {
                         foreach ($set as $option => $values) {
                             foreach ($values as $nr => $value) {
                                 $bucket[$inter][$nr][$option] = $value;
                             }
                         }
                     }
                 }
             }
         }
         // combine the data
         $combine = array();
         if (CostbenefitprojectionHelper::checkArray($bucket)) {
             foreach ($bucket as $pool) {
                 if (CostbenefitprojectionHelper::checkArray($pool)) {
                     foreach ($pool as $headers) {
                         if (CostbenefitprojectionHelper::checkArray($headers)) {
                             // check if this cause is already targeted
                             if (isset($combine[$headers['causerisk']])) {
                                 // combine
                                 $temp = $combine[$headers['causerisk']];
                                 $temp['cpe'] = $this->combineValues($temp['cpe'], $headers['cpe']);
                                 $temp['mbr'] = $this->combineValues($temp['mbr'], $headers['mbr']);
                                 $temp['mtr'] = $this->combineValues($temp['mtr'], $headers['mtr']);
                                 // update the data
                                 $combine[$headers['causerisk']] = $temp;
                             } else {
                                 // set for first time
                                 $combine[$headers['causerisk']] = array('cpe' => $headers['cpe'], 'mbr' => $headers['mbr'], 'mtr' => $headers['mtr']);
                             }
                         }
                     }
                 }
             }
         }
         // setup the object
         if (CostbenefitprojectionHelper::checkArray($combine)) {
             $oject = array();
             foreach ($combine as $causerisk => $vals) {
                 if (CostbenefitprojectionHelper::checkArray($vals)) {
                     $oject['causerisk'][] = $causerisk;
                     foreach ($vals as $header => $v) {
                         // set placeholder
                         $oject[$header][] = $v;
                     }
                 }
             }
             // done at last
             $oject = json_encode($oject);
         }
     }
     // return the table and values
     return array('table' => $this->getInterventionBuildTable($idName, $oject, 'ja'), 'values' => $oject);
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:74,代码来源:ajax.php

示例3: setInterventions

 /**
  * Set the interventions related to this Company.
  *
  * @return array
  *
  */
 protected function setInterventions()
 {
     // now set the result set
     if (CostbenefitprojectionHelper::checkArray($this->company->causesrisks) && isset($this->company->interventions) && CostbenefitprojectionHelper::checkArray($this->company->interventions)) {
         $i = 0;
         foreach ($this->company->interventions as $mainkey => $item) {
             // make sure duration is set
             if (!isset($item->duration) || !is_numeric($item->duration) || 1 > $item->duration) {
                 $item->duration = 1;
             }
             $this->interventions[$i]["id"] = $item->id;
             $this->interventions[$i]["name"] = $item->name;
             $this->interventions[$i]["description"] = $item->description;
             $this->interventions[$i]["duration"] = $item->duration;
             $this->interventions[$i]["coverage"] = $item->coverage;
             $this->interventions[$i]["type"] = $item->type;
             $this->interventions[$i]['found'] = array();
             $this->interventions[$i]['not_found'] = array();
             // set totals
             $this->interventions[$i]['totals']['cost_per_employee'] = 0;
             $this->interventions[$i]['totals']['costmoney_per_employee'] = 0;
             $this->interventions[$i]['totals']['cost_of_problem_scaled'] = 0;
             $this->interventions[$i]['totals']['cost_of_problem_unscaled'] = 0;
             $this->interventions[$i]['totals']['costmoney_of_problem_scaled'] = 0;
             $this->interventions[$i]['totals']['costmoney_of_problem_unscaled'] = 0;
             $this->interventions[$i]['totals']['contribution_to_cost_scaled'] = 0;
             $this->interventions[$i]['totals']['contribution_to_cost_unscaled'] = 0;
             $this->interventions[$i]['totals']['cost'] = 0;
             $this->interventions[$i]['totals']['costmoney'] = 0;
             $this->interventions[$i]['totals']['benefit_scaled'] = 0;
             $this->interventions[$i]['totals']['benefit_unscaled'] = 0;
             $this->interventions[$i]['totals']['benefitmoney_scaled'] = 0;
             $this->interventions[$i]['totals']['benefitmoney_unscaled'] = 0;
             $this->interventions[$i]['totals']['net_benefit_scaled'] = 0;
             $this->interventions[$i]['totals']['net_benefit_unscaled'] = 0;
             $this->interventions[$i]['totals']['net_benefitmoney_scaled'] = 0;
             $this->interventions[$i]['totals']['net_benefitmoney_unscaled'] = 0;
             // now load the cause/risk that are linked to this user
             $a = 0;
             // set values
             foreach ($item->data as $key => $value) {
                 if (in_array($value['id'], $this->company->causesrisks)) {
                     // set array of causes/risk ids
                     $this->interventions[$i]['found'][$value['id']] = $this->items[$value['id']]->details->name;
                     // set local cause/risk values
                     $this->interventions[$i]['items'][$a] = $value;
                     $this->interventions[$i]['items'][$a]['name'] = $this->items[$value['id']]->details->name;
                     $this->interventions[$i]['items'][$a]['cost_of_problem_unscaled'] = $this->items[$value['id']]->subtotal_cost_unscaled * $item->duration;
                     $this->interventions[$i]['items'][$a]['cost_of_problem_scaled'] = $this->items[$value['id']]->subtotal_cost_scaled * $item->duration;
                     $this->interventions[$i]['items'][$a]['costmoney_of_problem_unscaled'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['cost_of_problem_unscaled']);
                     $this->interventions[$i]['items'][$a]['costmoney_of_problem_scaled'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['cost_of_problem_scaled']);
                     $this->interventions[$i]['items'][$a]['cost'] = $this->interventions[$i]["coverage"] / 100 * $value['cpe'] * ($this->company->males + $this->company->females);
                     // turn into money
                     $this->interventions[$i]['items'][$a]['costmoney'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['cost']);
                     $this->interventions[$i]['items'][$a]['benefit_unscaled'] = $this->interventions[$i]["coverage"] / 100 * ($value['mbr'] / 100) * ($this->items[$value['id']]->subtotal_cost_morbidity_unscaled + $this->items[$value['id']]->subtotal_cost_presenteeism_unscaled) + $value['mtr'] / 100 * $this->items[$value['id']]->subtotal_cost_mortality_unscaled * $item->duration;
                     $this->interventions[$i]['items'][$a]['benefit_scaled'] = $this->interventions[$i]["coverage"] / 100 * ($value['mbr'] / 100) * ($this->items[$value['id']]->subtotal_cost_morbidity_scaled + $this->items[$value['id']]->subtotal_cost_presenteeism_scaled) + $value['mtr'] / 100 * $this->items[$value['id']]->subtotal_cost_mortality_scaled * $item->duration;
                     // turn into money
                     $this->interventions[$i]['items'][$a]['benefitmoney_unscaled'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['benefit_unscaled']);
                     $this->interventions[$i]['items'][$a]['benefitmoney_scaled'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['benefit_scaled']);
                     $this->interventions[$i]['items'][$a]['net_benefit_unscaled'] = $this->interventions[$i]['items'][$a]['benefit_unscaled'] - $this->interventions[$i]['items'][$a]['cost'];
                     $this->interventions[$i]['items'][$a]['net_benefit_scaled'] = $this->interventions[$i]['items'][$a]['benefit_scaled'] - $this->interventions[$i]['items'][$a]['cost'];
                     // turn into money
                     $this->interventions[$i]['items'][$a]['net_benefitmoney_unscaled'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['net_benefit_unscaled']);
                     $this->interventions[$i]['items'][$a]['net_benefitmoney_scaled'] = $this->makeMoney((double) $this->interventions[$i]['items'][$a]['net_benefit_scaled']);
                     // set ratio
                     $this->interventions[$i]['items'][$a]['benefit_ratio_unscaled'] = $this->interventions[$i]['items'][$a]['benefit_unscaled'] / $this->interventions[$i]['items'][$a]['cost'];
                     $this->interventions[$i]['items'][$a]['benefit_ratio_scaled'] = $this->interventions[$i]['items'][$a]['benefit_scaled'] / $this->interventions[$i]['items'][$a]['cost'];
                     $this->interventions[$i]['items'][$a]['costmoney_per_employee'] = $this->makeMoney((double) $value['cpe']);
                     // set totals
                     $this->interventions[$i]['totals']['cost'] = $this->interventions[$i]['totals']['cost'] + $this->interventions[$i]['items'][$a]['cost'];
                     $this->interventions[$i]['totals']['benefit_scaled'] = $this->interventions[$i]['totals']['benefit_scaled'] + $this->interventions[$i]['items'][$a]['benefit_scaled'];
                     $this->interventions[$i]['totals']['benefit_unscaled'] = $this->interventions[$i]['totals']['benefit_unscaled'] + $this->interventions[$i]['items'][$a]['benefit_unscaled'];
                     $this->interventions[$i]['totals']['net_benefit_scaled'] = $this->interventions[$i]['totals']['net_benefit_scaled'] + $this->interventions[$i]['items'][$a]['net_benefit_scaled'];
                     $this->interventions[$i]['totals']['net_benefit_unscaled'] = $this->interventions[$i]['totals']['net_benefit_unscaled'] + $this->interventions[$i]['items'][$a]['net_benefit_unscaled'];
                     $this->interventions[$i]['totals']['cost_per_employee'] = $this->interventions[$i]['totals']['cost_per_employee'] + $value['cpe'];
                     $this->interventions[$i]['totals']['cost_of_problem_scaled'] = $this->interventions[$i]['totals']['cost_of_problem_scaled'] + $this->interventions[$i]['items'][$a]['cost_of_problem_scaled'];
                     $this->interventions[$i]['totals']['cost_of_problem_unscaled'] = $this->interventions[$i]['totals']['cost_of_problem_unscaled'] + $this->interventions[$i]['items'][$a]['cost_of_problem_unscaled'];
                 } else {
                     $this->interventions[$i]['not_found'][$value['id']] = CostbenefitprojectionHelper::getVar('causerisk', $value['id'], 'id', 'name');
                 }
                 $a++;
             }
             // contribution_to_cost
             $a = 0;
             foreach ($item->data as $key => $value) {
                 if (in_array($value['id'], $this->company->causesrisks)) {
                     $this->interventions[$i]['items'][$a]['contribution_to_cost_unscaled'] = $this->interventions[$i]['items'][$a]['cost_of_problem_unscaled'] / $this->interventions[$i]['totals']['cost_of_problem_unscaled'] * 100;
                     $this->interventions[$i]['items'][$a]['contribution_to_cost_scaled'] = $this->interventions[$i]['items'][$a]['cost_of_problem_scaled'] / $this->interventions[$i]['totals']['cost_of_problem_scaled'] * 100;
                     // set totals
                     $this->interventions[$i]['totals']['contribution_to_cost_scaled'] = $this->interventions[$i]['totals']['contribution_to_cost_scaled'] + $this->interventions[$i]['items'][$a]['contribution_to_cost_scaled'];
                     $this->interventions[$i]['totals']['contribution_to_cost_unscaled'] = $this->interventions[$i]['totals']['contribution_to_cost_unscaled'] + $this->interventions[$i]['items'][$a]['contribution_to_cost_unscaled'];
                 }
                 $a++;
             }
//.........这里部分代码省略.........
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:sum.php

示例4: setIntervention

function setIntervention($item)
{
    if (CostbenefitprojectionHelper::isJson($item->intervention)) {
        $bucket = array();
        $bucketsmall = array();
        $interventions = json_decode($item->intervention);
        foreach ($interventions as $name => $values) {
            if (CostbenefitprojectionHelper::checkArray($values)) {
                foreach ($values as $pointer => $value) {
                    if (!isset($bucket[$pointer])) {
                        $bucket[$pointer] = '';
                        $bucketsmall[$pointer] = '';
                    }
                    switch ($name) {
                        case 'causerisk':
                            $causeName = CostbenefitprojectionHelper::getVar('causerisk', $value, 'id', 'name');
                            $bucket[$pointer] .= '<td>' . $causeName . "</td>";
                            $bucketsmall[$pointer] .= $causeName . ': ';
                            break;
                        case 'cpe':
                            $bucket[$pointer] .= '<td class="uk-text-center"><span class="uk-badge uk-badge-notification uk-badge-success">' . $value . '</span></td>';
                            $bucketsmall[$pointer] .= '<span class="uk-badge uk-badge-success">' . $name . ' ' . $value . '</span> ';
                            break;
                        case 'mbr':
                            $bucket[$pointer] .= '<td class="uk-text-center"><span class="uk-badge uk-badge-notification uk-badge-success">' . $value . '</span></td>';
                            $bucketsmall[$pointer] .= '<span class="uk-badge uk-badge-success">' . $name . ' ' . $value . '</span> ';
                            break;
                        case 'mtr':
                            $bucket[$pointer] .= '<td class="uk-text-center"><span class="uk-badge uk-badge-notification uk-badge-success">' . $value . '</span></td>';
                            $bucketsmall[$pointer] .= '<span class="uk-badge uk-badge-success">' . $name . ' ' . $value . '</span>';
                            break;
                    }
                }
            }
        }
    }
    return '<td><table class="uk-table  uk-table-hover uk-table-striped uk-table-condensed uk-hidden-small"><thead><tr><th>' . JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK') . '</th><th>' . JText::_('COM_COSTBENEFITPROJECTION_COST_PER_EMPLOYEE') . '</th><th>' . JText::_('COM_COSTBENEFITPROJECTION_MORBIDITY_REDUCTION') . '</th><th>' . JText::_('COM_COSTBENEFITPROJECTION_MORTALITY_REDUCTION') . '</th></tr></thead><tbody><tr>' . implode('</tr><tr>', $bucket) . '</tr></tbody></table><div class="uk-visible-small">' . implode('<br />', $bucketsmall) . '</div></td>';
}
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:38,代码来源:default.php


注:本文中的CostbenefitprojectionHelper::getVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。