Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once ('class_ipopup.php');
00026 require_once('class_ibutton.php');
00027 require_once('class_ispan.php');
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 class ITva_Popup extends HtmlInput
00047 {
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 public function __construct($p_name=null,$p_value="",$p_id="")
00058 {
00059 $this->name=$p_name;
00060 $this->button=true;
00061 $this->in_table=false;
00062 $this->value=$p_value;
00063 $this->id=$p_id;
00064 }
00065 function with_button($p)
00066 {
00067 if ($p == true )
00068 $this->button=true;
00069 else
00070 $this->button=false;
00071 }
00072
00073 public function input($p_name=null,$p_value=null)
00074 {
00075 $this->name=($p_name==null)?$this->name:$p_name;
00076 $this->value=($p_value==null)?$this->value:$p_value;
00077 $this->js=(isset($this->js))?$this->js:'onchange="format_number(this);"';
00078 $this->id=($this->id=="")?$this->name:$this->id;
00079
00080 if ( $this->readOnly==true) return $this->display();
00081
00082 $str='<input type="TEXT" class="input_text" name="%s" value="%s" id="%s" size="3" %s>';
00083 $r=sprintf($str,$this->name,$this->value,$this->id,$this->js);
00084
00085 if ($this->in_table)
00086 $table='<table>'.'<tr>'.td($r);
00087
00088 if ( $this->button==true && ! $this->in_table)
00089 $r.=$this->dbutton();
00090
00091 if ( $this->button==true && $this->in_table)
00092 $r=$table.td($this->dbutton()).'</tr></table>';
00093
00094 if ( isset($this->code))
00095 {
00096 if ( $this->cn != NULL)
00097 {
00098
00099 if (trim($this->value)!='' && isNumber($this->value)==1 && strpos($this->value,',') === false)
00100 $this->code->value=$this->cn->get_value('select tva_label from tva_rate where tva_id=$1',
00101 array($this->value));
00102 ;
00103 }
00104 $r.=$this->code->input();
00105 if ($this->table==1) $r=td($r);
00106 $this->set_attribute('jcode',$this->code->name);
00107 $this->set_attribute('gDossier',dossier::id());
00108 $this->set_attribute('ctl',$this->name);
00109 $r.=$this->get_js_attr();
00110
00111 }
00112
00113 return $r;
00114
00115 }
00116
00117
00118
00119
00120
00121
00122
00123 function dbutton()
00124 {
00125 if( trim($this->name)=='') throw new Exception (_('Le nom ne peut ĂȘtre vide'));
00126 $this->id=($this->id=="")?$this->name:$this->id;
00127
00128
00129 $bt=new ISmallButton('bt_'.$this->id);
00130 $bt->tabindex="-1";
00131 $bt->label=_(' TVA ');
00132 $bt->set_attribute('gDossier',dossier::id());
00133 $bt->set_attribute('ctl',$this->id);
00134 $bt->set_attribute('popup','popup_tva');
00135 if ( isset($this->code))
00136 $bt->set_attribute('jcode',$this->code->name);
00137 if ( isset($this->compute))
00138 $bt->set_attribute('compute',$this->compute);
00139 $bt->javascript=(isset($this->but_javascript))?$this->but_javascript:'popup_select_tva(this)';
00140 $r=$bt->input();
00141 return $r;
00142 }
00143
00144
00145 public function display()
00146 {
00147 $cn= new Database(Dossier::id());
00148 $tva=new Acc_Tva($cn, $this->value);
00149
00150 $comment=($tva->load() != "-1")? $tva->tva_label:"";
00151 $res=sprintf('<input type="text" name="%s" size="6" class="input_text_ro" value="%s" id="%s" readonly="">%s',$this->name,$this->value,$this->name,$comment);
00152 return $res;
00153 }
00154
00155
00156
00157
00158
00159 public function add_label($p_code,$p_cn=null)
00160 {
00161 $this->cn=$p_cn;
00162 $this->code=new ISpan($p_code);
00163 }
00164 static public function test_me()
00165 {
00166 $a=new IPopup('popup_tva');
00167 $a->set_title('Choix de la tva');
00168 echo $a->input();
00169 $tva=new ITva_Popup("tva1");
00170 $tva->with_button(true);
00171
00172 $tva->add_label('code');
00173 $tva->js='onchange="set_tva_label(this);"';
00174 echo $tva->input();
00175 echo $tva->dbutton();
00176 }
00177 }