noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_inum.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief for the numeric input text field
00024  */
00025 require_once('class_itext.php');
00026 /*!\brief
00027  * This class handles only the numeric input, the input will
00028  * call a javascript
00029  * to change comma to period  and will round it (2 decimal), the precision is given by
00030  * the attribute prec
00031  * attribute
00032  *  extra = extra code (free)
00033  *  size = size of the field
00034  *  prec = precision default = 2
00035  *  name = name of the html object
00036  *  javascript = javascript to execute (default = onchange="format_number(this,2);)
00037  *  value = value of the widget
00038  *
00039  */
00040 class INum extends IText
00041 {
00042     function __construct($name='',$value='')
00043     {
00044         parent::__construct($name,$value);
00045 
00046         $this->size=9;
00047         $this->style='class="inum"';
00048         $this->javascript= 'onchange="format_number(this,2);"';
00049     }
00050     /*!\brief print in html the readonly value of the widget*/
00051     public function display()
00052     {
00053 
00054         $readonly=" readonly ";
00055                 $this->id=($this->id=="")?$this->name:$this->id;
00056 
00057         //$style='style="border:solid 1px blue;color:black;background:#EDEDED;text-align:right"';
00058         $style=' class="inum input_text_ro"';
00059         $this->value=str_replace('"','',$this->value);
00060         $r='<INPUT '.$style.' TYPE="TEXT" id="'.
00061            $this->id.'"'.
00062            'NAME="'.$this->name.'" VALUE="'.$this->value.'"  '.
00063            'SIZE="'.$this->size.'" '.$this->javascript." $readonly $this->extra >";
00064 
00065         /* add tag for column if inside a table */
00066         if ( $this->table == 1 )                  $r='<td>'.$r.'</td>';
00067 
00068         return $r;
00069 
00070     }
00071          /*!\brief show the html  input of the widget*/
00072     public function input($p_name=null,$p_value=null)
00073     {
00074                 if ( isset ($this->prec)) {
00075                         $this->javascript= 'onchange="format_number(this,'.$this->prec.');"';
00076                 }
00077         $this->name=($p_name==null)?$this->name:$p_name;
00078         $this->value=($p_value==null)?$this->value:$p_value;
00079                 $this->id=($this->id=="")?$this->name:$this->id;
00080 
00081         if ( $this->readOnly==true) return $this->display();
00082 
00083         $t= ((isset($this->title)))?'title="'.$this->title.'"   ':' ';
00084 
00085         $extra=(isset($this->extra))?$this->extra:"";
00086 
00087         $this->value=str_replace('"','',$this->value);
00088         if ( ! isset ($this->css_size))
00089         {
00090         $r='<INPUT '.$this->style.' TYPE="TEXT" id="'.
00091            $this->id.'"'.$t.
00092            'NAME="'.$this->name.'" VALUE="'.$this->value.'"  '.
00093            'SIZE="'.$this->size.'" '.$this->javascript."  $this->extra >";
00094         /* add tag for column if inside a table */
00095         } else {
00096            $r='<INPUT '.$this->style.' TYPE="TEXT" id="'.
00097            $this->id.'"'.$t.
00098            'NAME="'.$this->name.'" VALUE="'.$this->value.'"  '.
00099            ' style="width:'.$this->css_size.';" '.$this->javascript."  $this->extra >";
00100 
00101         }
00102 
00103         if ( $this->table == 1 )                  $r='<td>'.$r.'</td>';
00104 
00105         return $r;
00106 
00107     }
00108 
00109 }
00110 
00111 
 All Data Structures Namespaces Files Functions Variables Enumerations