diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0a5ae5df34c..cddfe13ffad 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2135,7 +2135,10 @@ abstract class CommonObject $this->array_options[$key] = null; } break; - } + case 'price': + $this->array_options[$key] = price2num($this->array_options[$key]); + break; + } } $this->db->begin(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b387537165b..2aa9f925106 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -53,7 +53,10 @@ class ExtraFields 'double'=>'Float', 'date'=>'Date', 'datetime'=>'DateAndTime', - 'boolean'=>'Boolean' + 'boolean'=>'Boolean', + 'price'=>'ExtrafieldPrice', + 'phone'=>'ExtrafieldPhone', + 'mail'=>'ExtrafieldMail' ); /** @@ -139,6 +142,15 @@ class ExtraFields if ($type=='boolean') { $typedb='int'; $lengthdb='1'; + } elseif($type=='price') { + $typedb='double'; + $lengthdb='24,8'; + } elseif($type=='phone') { + $typedb='varchar'; + $lengthdb='20'; + }elseif($type=='mail') { + $typedb='varchar'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; @@ -312,9 +324,18 @@ class ExtraFields if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { - if ($type=='boolean') { + if ($type=='boolean') { $typedb='int'; $lengthdb='1'; + } elseif($type=='price') { + $typedb='double'; + $lengthdb='24,8'; + } elseif($type=='phone') { + $typedb='varchar'; + $lengthdb='20'; + }elseif($type=='mail') { + $typedb='varchar'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; @@ -533,23 +554,23 @@ class ExtraFields $newsize=$tmp[0]; $out=''; } - else if (in_array($type,array('int','double'))) + elseif (in_array($type,array('int','double'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; $out=''; } - else if ($type == 'varchar') + elseif ($type == 'varchar') { $out=''; } - else if ($type == 'text') + elseif ($type == 'text') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('options_'.$key,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100); $out=$doleditor->Create(1); } - else if ($type == 'boolean') + elseif ($type == 'boolean') { $checked=''; if (!empty($value)) { @@ -559,6 +580,18 @@ class ExtraFields } $out=''; } + elseif ($type == 'mail') + { + $out=''; + } + elseif ($type == 'phone') + { + $out=''; + } + elseif ($type == 'price') + { + $out=' '.getCurrencySymbol($conf->currency); + } // Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; @@ -575,7 +608,8 @@ class ExtraFields */ function showOutputField($key,$value,$moreparam='') { - + global $conf; + $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; $size=$this->attribute_size[$key]; @@ -601,6 +635,18 @@ class ExtraFields $checked=' checked="checked" '; } $value=''; + } + elseif ($type == 'mail') + { + $value=dol_print_email($value); + } + elseif ($type == 'phone') + { + $value=dol_print_phone($value); + } + elseif ($type == 'price') + { + $value=price($value).' '.getCurrencySymbol($conf->currency); } else { diff --git a/htdocs/core/tpl/admin_extrafields.tpl.php b/htdocs/core/tpl/admin_extrafields.tpl.php index f2ce0efa59b..3c5ee8dfaa0 100644 --- a/htdocs/core/tpl/admin_extrafields.tpl.php +++ b/htdocs/core/tpl/admin_extrafields.tpl.php @@ -23,6 +23,8 @@ function init_typeoffields(type) { var size = jQuery("#size"); + var unique = jQuery("#unique"); + var required = jQuery("#required"); if (type == 'date') { size.val('').attr('disabled','disabled'); } else if (type == 'datetime') { size.val('').attr('disabled','disabled'); } else if (type == 'double') { size.val('24,8').removeAttr('disabled'); } @@ -30,6 +32,7 @@ else if (type == 'text') { size.val('2000').removeAttr('disabled'); } else if (type == 'varchar') { size.val('255').removeAttr('disabled'); } else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');} + else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');} else size.val('').attr('disabled','disabled'); } init_typeoffields(); diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 3215c235281..e77aac66c63 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -17,7 +17,7 @@ */ ?> - +