Example #1
0
	function getFrozenHtml() {
		$val = Utils_CurrencyFieldCommon::get_values(str_replace(Utils_CurrencyFieldCommon::get_decimal_point(), '.', $this->getValue()));
		return Utils_CurrencyFieldCommon::format($val[0], isset($this->currency)?$this->currency:1);
	}
Example #2
0
 public static function get_val($tab, $field, $record, $links_not_recommended = false, $args = null)
 {
     static $recurrence_call_stack = array();
     self::init($tab);
     $commondata_sep = '/';
     if (!isset(self::$table_rows[$field])) {
         if (!isset(self::$hash[$field])) {
             trigger_error('Unknown field "' . $field . '" for recordset "' . $tab . '"', E_USER_ERROR);
         }
         $field = self::$hash[$field];
     }
     if ($args === null) {
         $args = self::$table_rows[$field];
     }
     if (!array_key_exists('id', $record)) {
         $record['id'] = null;
     }
     if (!array_key_exists($args['id'], $record)) {
         trigger_error($args['id'] . ' - unknown field for record ' . serialize($record), E_USER_ERROR);
     }
     $val = $record[$args['id']];
     $function_call_id = implode('|', array($tab, $field, serialize($val)));
     if (isset($recurrence_call_stack[$function_call_id])) {
         return '!! ' . __('recurrence issue') . ' !!';
     } else {
         $recurrence_call_stack[$function_call_id] = true;
     }
     self::display_callback_cache($tab);
     if (isset(self::$display_callback_table[$tab][$field])) {
         $ret = self::call_display_callback(self::$display_callback_table[$tab][$field], $record, $links_not_recommended, self::$table_rows[$field], $tab);
     } else {
         $ret = $val;
         if ($args['type'] == 'select' || $args['type'] == 'multiselect') {
             if (is_array($val) && empty($val) || !is_array($val) && $val == '') {
                 $ret = '---';
                 unset($recurrence_call_stack[$function_call_id]);
                 return $ret;
             }
             $param = explode(';', $args['param']);
             $pp = explode('::', $param[0]);
             $tab = $pp[0];
             if (isset($pp[1])) {
                 $col = $pp[1];
             } else {
                 $col = null;
             }
             //return;//trigger_error("\"param\" attribute of field \"$field\" is not valid. Please set <recordset>::<field>");
             if (!$col && $tab == '__COMMON__') {
                 unset($recurrence_call_stack[$function_call_id]);
                 return;
             }
             if (!is_array($val)) {
                 $val = array($val);
             }
             //              if ($tab=='__COMMON__') $data = Utils_CommonDataCommon::get_translated_array($col, true);
             if ($tab == '__RECORDSETS__') {
                 $single_tab = false;
             } else {
                 $tabs = explode(',', $tab);
                 $single_tab = count($tabs) == 1;
             }
             $ret = '';
             $first = true;
             foreach ($val as $k => $v) {
                 //                  if ($tab=='__COMMON__' && !isset($data[$v])) continue;
                 if ($tab == '__COMMON__') {
                     $path = explode('/', $v);
                     $tooltip = '';
                     $res = '';
                     if (count($path) > 1) {
                         $res .= Utils_CommonDataCommon::get_value($col . '/' . $path[0], true);
                         if (count($path) > 2) {
                             $res .= $commondata_sep . '...';
                             $tooltip = '';
                             $full_path = $col;
                             foreach ($path as $w) {
                                 $full_path .= '/' . $w;
                                 $tooltip .= ($tooltip ? $commondata_sep : '') . Utils_CommonDataCommon::get_value($full_path, true);
                             }
                         }
                         $res .= $commondata_sep;
                     }
                     $val = Utils_CommonDataCommon::get_value($col . '/' . $v, true);
                     if (!$val) {
                         continue;
                     }
                     $res .= $val;
                     if ($first) {
                         $first = false;
                     } else {
                         $ret .= '<br>';
                     }
                     $res = self::no_wrap($res);
                     if ($tooltip) {
                         $res = '<span ' . Utils_TooltipCommon::open_tag_attrs($tooltip, false) . '>' . $res . '</span>';
                     }
                     $ret .= $res;
                 } else {
                     if (!$single_tab) {
                         list($tab, $v) = explode('/', $v, 2);
                     }
                     if ($first) {
                         $first = false;
                     } else {
                         $ret .= '<br>';
                     }
                     if ($col) {
                         $columns = explode('|', $col);
                         $ret .= Utils_RecordBrowserCommon::create_linked_label($tab, $columns, $v, $links_not_recommended);
                     } else {
                         $ret .= Utils_RecordBrowserCommon::create_default_linked_label($tab, $v, $links_not_recommended);
                     }
                 }
             }
             if ($ret == '') {
                 $ret = '---';
             }
         } elseif ($args['type'] == 'commondata') {
             if (!isset($val) || $val === '') {
                 $ret = '';
             } else {
                 $arr = explode('::', $args['param']['array_id']);
                 $path = array_shift($arr);
                 foreach ($arr as $v) {
                     $path .= '/' . $record[self::get_field_id($v)];
                 }
                 $path .= '/' . $record[$args['id']];
                 $ret = Utils_CommonDataCommon::get_value($path, true);
             }
             /*            } elseif ($args['type']=='record') {
                           if (!isset($val) || $val==='') {
                               $ret = '';
                           } else {
                               @list($rs,$rid) = explode('#',$record[$args['id']],2);
                               if(!$rid) $ret = '';
                               else {
                                   $ret = self::create_default_linked_label($rs,$rid,$links_not_recommended);
                               }
                           }*/
         } elseif ($args['type'] == 'autonumber') {
             if (!$links_not_recommended && isset($record['id']) && $record['id']) {
                 $ret = self::record_link_open_tag_r($tab, $record) . $val . self::record_link_close_tag();
             }
         } elseif ($args['type'] == 'currency') {
             $val = Utils_CurrencyFieldCommon::get_values($val);
             $ret = Utils_CurrencyFieldCommon::format($val[0], $val[1]);
         } elseif ($args['type'] == 'checkbox') {
             $ret = $ret ? __('Yes') : __('No');
         } elseif ($args['type'] == 'date') {
             if ($val != '') {
                 $ret = Base_RegionalSettingsCommon::time2reg($val, false, true, false);
             }
         } elseif ($args['type'] == 'timestamp') {
             if ($val != '') {
                 $ret = Base_RegionalSettingsCommon::time2reg($val, 'without_seconds');
             }
         } elseif ($args['type'] == 'time') {
             if ($val != '') {
                 $ret = Base_RegionalSettingsCommon::time2reg($val, 'without_seconds', false);
             }
         } elseif ($args['type'] == 'long text') {
             $ret = htmlspecialchars($val);
             $ret = str_replace("\n", '<br>', $ret);
             $ret = Utils_BBCodeCommon::parse($ret);
         }
     }
     unset($recurrence_call_stack[$function_call_id]);
     return $ret;
 }
Example #3
0
 public static function from_string($string)
 {
     list($amount, $currency) = Utils_CurrencyFieldCommon::get_values($string);
     return new self($amount, $currency);
 }