diff --git a/html/admin/sql/patch/upgrade102.sql b/html/admin/sql/patch/upgrade102.sql index e2829ab5a..02206ab0f 100644 --- a/html/admin/sql/patch/upgrade102.sql +++ b/html/admin/sql/patch/upgrade102.sql @@ -55,7 +55,7 @@ INSERT INTO profile_menu( VALUES ('BK', 'GESTION', 2, 35, 'E', 0); - + update menu_ref set me_description='Grand livre analytique' where me_code='ANCGL'; alter table action_gestion add ag_remind_date date; @@ -491,6 +491,8 @@ drop table user_sec_extension; update attr_def set ad_type='card', ad_extra='[sql] frd_id in (4,8,9,14)' where ad_id=25; +update attr_Def set ad_extra='2' where ad_type='numeric'; +update attr_Def set ad_extra='4' where ad_id=31; update version set val=103; diff --git a/include/class_fiche.php b/include/class_fiche.php index 5c2df3b63..369e471fc 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -467,7 +467,7 @@ class Fiche $w=new ITva_Popup('popup_tva'); $w->table=1; } - + else { switch ($attr->ad_type) @@ -478,7 +478,7 @@ class Fiche break; case 'numeric': $w = new INum(); - $w->javascript='onchange="format_number(this,4);"'; + $w->prec=($attr->ad_extra=="")?2:$attr->ad_extra; $w->size = $attr->ad_size; break; case 'date': @@ -603,7 +603,7 @@ class Fiche case 'numeric': $w = new INum('av_text' . $r->ad_id); $w->size = $r->ad_size; - $w->javascript='onchange="format_number(this,4);"'; + $w->prec=($attr->ad_extra=="")?2:$attr->ad_extra; $w->value = $r->av_text; break; case 'date': diff --git a/include/class_fiche_attr.php b/include/class_fiche_attr.php index 1bb12dd8e..186513424 100644 --- a/include/class_fiche_attr.php +++ b/include/class_fiche_attr.php @@ -87,7 +87,11 @@ class Fiche_Attr $this->ad_size=22; } } + if ( $this->ad_type == 'numeric' ) { + $this->ad_extra=(trim($this->ad_extra)=='')?'2':$this->ad_extra; + if (isNumber($this->ad_extra) == 0) throw new Exception ("La précision doit être un chiffre"); + } if ( $this->ad_type == 'select') { if (trim($this->ad_extra)=="") throw new Exception ("La requête SQL est vide "); diff --git a/include/class_inum.php b/include/class_inum.php index d81607d95..58adabdf8 100644 --- a/include/class_inum.php +++ b/include/class_inum.php @@ -35,13 +35,15 @@ class INum extends IText function __construct($name='',$value='') { parent::__construct($name,$value); - $this->javascript='onchange="format_number(this);"'; + $this->size=9; $this->style='style="text-align:right;border:1px solid blue;margin:2px"'; + $this->javascript= 'onchange="format_number(this,2);"'; } /*!\brief print in html the readonly value of the widget*/ public function display() { + $readonly=" readonly "; $style='style="border:solid 1px blue;color:black;background:#EDEDED;text-align:right"'; $this->value=str_replace('"','',$this->value); @@ -55,6 +57,41 @@ class INum extends IText return $r; + } + /*!\brief show the html input of the widget*/ + public function input($p_name=null,$p_value=null) + { + if ( isset ($this->prec)) { + $this->javascript= 'onchange="format_number(this,'.$this->prec.');"'; + } + $this->name=($p_name==null)?$this->name:$p_name; + $this->value=($p_value==null)?$this->value:$p_value; + if ( $this->readOnly==true) return $this->display(); + + $t= ((isset($this->title)))?'title="'.$this->title.'" ':' '; + + $extra=(isset($this->extra))?$this->extra:""; + + $this->value=str_replace('"','',$this->value); + if ( ! isset ($this->css_size)) + { + $r='style.' TYPE="TEXT" id="'. + $this->name.'"'.$t. + 'NAME="'.$this->name.'" VALUE="'.$this->value.'" '. + 'SIZE="'.$this->size.'" '.$this->javascript." $this->extra >"; + /* add tag for column if inside a table */ + } else { + $r='style.' TYPE="TEXT" id="'. + $this->name.'"'.$t. + 'NAME="'.$this->name.'" VALUE="'.$this->value.'" '. + ' style="width:'.$this->css_size.';" '.$this->javascript." $this->extra >"; + + } + + if ( $this->table == 1 ) $r=''.$r.''; + + return $r; + } }