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


PHP CostbenefitprojectionHelper::isJson方法代码示例

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


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

示例1: 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

示例2: setCompany

 public function setCompany()
 {
     if (CostbenefitprojectionHelper::checkObject($this->company)) {
         // main switch
         $usecountry = false;
         // public switch
         if (isset($this->company->public)) {
             $usecountry = true;
             $cKey = 'id';
         } else {
             $cKey = 'country';
         }
         // set array of json objects to convert to array
         $jsonObjects = array('percentmale', 'percentfemale', 'country_percentmale', 'country_percentfemale', 'country_maledeath', 'country_femaledeath', 'country_maleyld', 'country_femaleyld');
         $removeArray = array('asset_id', 'not_required', 'published', 'created_by', 'country_created_by', 'country_created', 'country_version', 'country_hits', 'country_ordering', 'modified_by', 'country_asset_id', 'created', 'modified', 'version', 'hits', 'ordering', 'country_published', 'country_modified_by', 'country_modified', 'country_maledeath', 'country_femaledeath', 'country_maleyld', 'country_femaleyld', 'idCompanyScaling_factorC', $cKey . 'CountryHealth_dataB', $cKey . 'CountryHealth_dataBB', 'causesrisksIdCauseriskG', 'causesrisksIdCauseriskGG', 'idCompanyInterventionD', 'countryCountryInterventionDD', 'idCountryInterventionDD');
         foreach ($jsonObjects as $jsonObject) {
             if (isset($this->company->{$jsonObject}) && CostbenefitprojectionHelper::isJson($this->company->{$jsonObject})) {
                 // convert to array
                 $array = json_decode($this->company->{$jsonObject}, true);
                 if (CostbenefitprojectionHelper::checkArray($array)) {
                     $this->company->{$jsonObject} = array();
                     foreach ($array as $option => $values) {
                         if (CostbenefitprojectionHelper::checkArray($values)) {
                             foreach ($values as $nr => $value) {
                                 $this->company->{$jsonObject}[$nr][$option] = $value;
                             }
                         }
                     }
                 }
             }
         }
         // if company has not causerisks selected fall back on country
         if ($usecountry || isset($this->company->causesrisks) && !CostbenefitprojectionHelper::checkArray($this->company->causesrisks) || $this->company->department == 1) {
             $this->company->causesrisks = $this->company->country_causesrisks;
             $this->company->medical_turnovers_males = $this->company->males * ($this->company->country_medical_turnovers / 100000);
             $this->company->medical_turnovers_females = $this->company->females * ($this->company->country_medical_turnovers / 100000);
             $this->company->sick_leave_males = $this->company->males * $this->company->country_sick_leave;
             $this->company->sick_leave_females = $this->company->females * $this->company->country_sick_leave;
             $this->company->datayear = $this->company->country_datayear;
             $this->company->total_healthcare = $this->company->country_healthcare / 100 * $this->company->total_salary;
             $this->company->working_days = $this->company->country_working_days;
             $this->company->productivity_losses = $this->company->country_productivity_losses;
             $usecountry = true;
         }
         // percent sorting
         $percentSort = array('percentmale', 'percentfemale', 'country_percentmale', 'country_percentfemale');
         foreach ($percentSort as $sort) {
             $point = $sort;
             if (isset($this->company->{$sort}) && !CostbenefitprojectionHelper::checkArray($this->company->{$sort}) && strpos($sort, 'country') === false) {
                 $sort = 'country_' . $sort;
             }
             if (isset($this->company->{$sort}) && CostbenefitprojectionHelper::checkArray($this->company->{$sort})) {
                 $bucket = array();
                 foreach ($this->company->{$sort} as $value) {
                     $bucket[$value['age']] = (int) $value['percent'];
                 }
                 $this->company->{$point} = $bucket;
             }
         }
         // country totals sorting
         $countrySort = array('country_maledeath' => array('gender' => 'male', 'type' => 'death'), 'country_femaledeath' => array('gender' => 'female', 'type' => 'death'), 'country_maleyld' => array('gender' => 'male', 'type' => 'yld'), 'country_femaleyld' => array('gender' => 'female', 'type' => 'yld'));
         $this->company->country_yld = 0;
         $this->company->country_death = 0;
         foreach ($countrySort as $sort => $tar) {
             if (isset($this->company->{$sort}) && CostbenefitprojectionHelper::checkArray($this->company->{$sort})) {
                 foreach ($this->company->{$sort} as $value) {
                     if ($this->company->datayear == $value['year']) {
                         $this->company->{'country_' . $tar['type']} += $value['number'];
                     }
                 }
             }
         }
         // country health totals sorting
         $specialSort = array('maledeath', 'maleyld', 'femaledeath', 'femaleyld');
         $keepData = array();
         if (isset($this->company->{$cKey . 'CountryHealth_dataB'}) && CostbenefitprojectionHelper::checkArray($this->company->{$cKey . 'CountryHealth_dataB'}) && !$usecountry) {
             $healthBucket = array();
             foreach ($this->company->{$cKey . 'CountryHealth_dataB'} as $healthData) {
                 $healthBucket[$healthData->causerisk] = new stdClass();
                 foreach ($specialSort as $sort) {
                     if (isset($healthData->{$sort}) && CostbenefitprojectionHelper::isJson($healthData->{$sort})) {
                         // convert to array
                         $array = json_decode($healthData->{$sort}, true);
                         if (CostbenefitprojectionHelper::checkArray($array)) {
                             foreach ($array as $option => $values) {
                                 if (CostbenefitprojectionHelper::checkArray($values)) {
                                     foreach ($values as $nr => $value) {
                                         $healthBucket[$healthData->causerisk]->{$sort}[$nr][$option] = $value;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // number sorting
                 foreach ($specialSort as $sort) {
                     if (isset($healthBucket[$healthData->causerisk]->{$sort}) && CostbenefitprojectionHelper::checkArray($healthBucket[$healthData->causerisk]->{$sort})) {
                         $bucket = array();
                         foreach ($healthBucket[$healthData->causerisk]->{$sort} as $value) {
                             if (CostbenefitprojectionHelper::checkArray($value)) {
//.........这里部分代码省略.........
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:sum.php

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