コード例 #1
0
ファイル: eco_utils.php プロジェクト: r3-gis/EcoGIS
/**
 * Replace the null value with an emptyt string (IE problems)
 *
 * @param mixed $data               the data to adjust
 * return mixed                     the adjusted data
 */
function Null2Str($data)
{
    if (is_array($data)) {
        foreach ($data as $key => $val) {
            $data[$key] = Null2Str($val);
        }
    } else {
        if ($data === null) {
            return '';
        }
    }
    return $data;
}
コード例 #2
0
 /**
  * Return the UDM
  * @param array $request    the request
  * @return array            the result data
  */
 public function performEnergySourceRowCalc($request)
 {
     $db = ezcDbInstance::get();
     $lang = R3Locale::getLanguageID();
     $request = R3Locale::convert2PHP($request, true);
     $result = array();
     foreach (R3EcoGisGlobalConsumptionHelper::getEnergySourceList($_SESSION['do_id'], $this->kind) as $key => $value) {
         if (!isset($request["udm_id_{$key}"]) && isset($value['source'][$request["es_id_{$key}"]]['udm']) && count($value['source'][$request["es_id_{$key}"]]['udm']) == 1) {
             $request["udm_id_{$key}"] = key($value['source'][$request["es_id_{$key}"]]['udm']);
         }
         if (isset($request["es_id_{$key}"]) && $request["es_id_{$key}"] != '' && isset($request["udm_id_{$key}"]) && $request["udm_id_{$key}"] != '' && isset($request["co_value_{$key}"]) && $request["co_value_{$key}"] != '') {
             $result["popup_co_{$key}_kwh"] = R3NumberFormat(forceFloat($request["co_value_{$key}"], null, '.') * $value['source'][$request["es_id_{$key}"]]['udm'][$request["udm_id_{$key}"]]['kwh_factor'], 0, true);
             $result["popup_co_{$key}_co2"] = R3NumberFormat(forceFloat($request["co_value_{$key}"], null, '.') * $value['source'][$request["es_id_{$key}"]]['udm'][$request["udm_id_{$key}"]]['co2_factor'], 0, true);
         } else {
             $result["popup_co_{$key}_co2"] = null;
             $result["popup_co_{$key}_kwh"] = null;
         }
     }
     return array('status' => R3_AJAX_NO_ERROR, 'data' => Null2Str($result));
 }