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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 require_once('class_html_input.php');
00118 require_once('function_javascript.php');
00119
00120 class ICard extends HtmlInput
00121 {
00122 function __construct($name="",$value="",$p_id="")
00123 {
00124 parent::__construct($name,$value);
00125 $this->fct='update_value';
00126 $this->dblclick='';
00127 $this->callback='null';
00128 $this->javascript='';
00129 $this->autocomplete=1;
00130 $this->id=($p_id != "")?$p_id:$name;
00131 }
00132
00133
00134
00135
00136
00137 function set_callback($p_name)
00138 {
00139 $this->callback=$p_name;
00140 }
00141
00142
00143
00144
00145
00146 function set_function($p_name)
00147 {
00148 $this->fct=$p_name;
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 static function ipopup($p_name)
00168 {
00169 $ip_card=new IPopup ($p_name);
00170 $ip_card->drag=true;
00171 $ip_card->set_width('45%');
00172 $ip_card->title='Fiche ';
00173 $ip_card->value='';
00174 return $ip_card->input();
00175 }
00176
00177
00178
00179
00180
00181 function set_dblclick($p_action)
00182 {
00183 $this->dblclick=$p_action;
00184 }
00185
00186 public function input($p_name=null,$p_value=null)
00187 {
00188 if ( $p_name == null && $this->name == "")
00189 throw (new Exception('Le nom d une icard doit être donne'));
00190
00191 $this->value=($p_value==null)?$this->value:$p_value;
00192 if ( $this->readOnly==true) return $this->display();
00193
00194 $this->id=($this->id=="")?$this->name:$this->id;
00195
00196 $attr=$this->get_js_attr();
00197
00198 $label='';
00199 if ( $this->dblclick != '')
00200 {
00201 $e=sprintf(' ondblclick="%s" ',
00202 $this->dblclick);
00203 $this->dblclick=$e;
00204 }
00205 $input=sprintf('<INPUT TYPE="Text" class="input_text" '.
00206 ' NAME="%s" ID="%s" VALUE="%s" SIZE="%d" %s %s>',
00207 $this->name,
00208 $this->id,
00209 $this->value,
00210 $this->size,
00211 $this->dblclick,
00212 $this->javascript
00213 );
00214 if ( $this->autocomplete == 1)
00215 {
00216 $ind=sprintf('<span id="%s_ind" class="autocomplete" style="display:none">Un instant... <img src="image/loading.gif" alt="Chargement..."/>'.
00217 '</span>',
00218 $this->id);
00219
00220 $div=sprintf('<div id="%s_choices" class="autocomplete"></div>',
00221 $this->id);
00222
00223 $query=dossier::get().'&e='.urlencode($this->typecard);
00224
00225 $javascript=sprintf('try { new Ajax.Autocompleter("%s","%s_choices","fid_card.php?%s",'.
00226 '{paramName:"FID",minChars:1,indicator:null, '.
00227 'callback:%s, '.
00228 ' afterUpdateElement:%s});} catch (e){alert(e.message);};',
00229 $this->id,$this->id,$query,
00230 $this->callback,
00231 $this->fct);
00232
00233 $javascript=create_script($javascript.$this->dblclick);
00234
00235 $r=$label.$input.$attr.$ind.$div.$javascript;
00236 }
00237 else
00238 {
00239 $r=$label.$input;
00240 }
00241 if ( $this->table == 1 )
00242 $r=td($r);
00243 return $r;
00244
00245 }
00246
00247 public function display()
00248 {
00249 $r=sprintf(' <INPUT TYPE="hidden" NAME="%s" id="%s" VALUE="%s" SIZE="8">',
00250 $this->name,
00251 $this->name,
00252 $this->value
00253 );
00254 $r.='<span>'.$this->value.'</span>';
00255 return $r;
00256
00257 }
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 function search()
00286 {
00287 if ( $this->readOnly==true) return '';
00288 if ( ! isset($this->id )) $this->id=$this->name;
00289 $button=new ISmallButton($this->name.'_bt',"","","smallbutton");
00290 $button->label=_('Recherche');
00291 $a="";
00292 foreach (array('typecard','jrn','label','price','tvaid') as $att)
00293 {
00294 if (isset($this->$att) )
00295 $a.="this.".$att."='".$this->$att."';";
00296 }
00297 if (isset($this->id) && $this->id != "")
00298 $a.="this.inp='".$this->id."';";
00299 else
00300 $a.="this.inp='".$this->name."';";
00301 $a.="this.popup='ipop_card';";
00302 $button->tabindex=-1;
00303 $button->javascript=$a.' search_card(this)';
00304 return $button->input();
00305 }
00306
00307 static public function test_me()
00308 {
00309 require_once('class_itext.php');
00310 $_SESSION['isValid']=1;
00311 $a=new ICard('testme');
00312 $a->extra="all";
00313 $a->set_attribute('label','ctl_label');
00314 $a->set_attribute('tvaid','ctl_tvaid');
00315 $a->set_attribute('price','ctl_price');
00316 $a->set_attribute('purchase','ctl_purchase');
00317 $a->set_attribute('type','all');
00318 echo <<<EOF
00319 <div id="debug" style="border:solid 1px black;overflow:auto"></div>
00320 <script type="text/javascript" language="javascript" src="js/prototype.js">
00321 </script>
00322 <script type="text/javascript" language="javascript" src="js/scriptaculous.js">
00323 </script>
00324 <script type="text/javascript" language="javascript" src="js/effects.js">
00325 </script>
00326 <script type="text/javascript" language="javascript" src="js/controls.js">
00327 </script>
00328 <script type="text/javascript" language="javascript" src="js/ajax_fid.js">
00329 </script>
00330 <script type="text/javascript" language="javascript" >
00331 function test_value(text,li)
00332 {
00333 alert("premier"+li.id);
00334
00335 str="";
00336 str=text.id+'<hr>';
00337 if ( text.js_attr1)
00338 {
00339 str+=text.js_attr1;
00340 str+='<hr>';
00341 }
00342 if ( text.js_attr2)
00343 {
00344 str+=text.js_attr2;
00345 str+='<hr>';
00346 }
00347 if ( text.js_attr3)
00348 {
00349 str+=text.js_attr3;
00350 str+='<hr>';
00351 }
00352 for (var i in text)
00353 {
00354 str+=i+'<br>';
00355 }
00356
00357
00358 ajaxFid(text);
00359 }
00360 </script>
00361
00362 EOF;
00363 echo "<form>";
00364 $l=new IText('ctl_label');
00365 $t=new IText('ctl_tvaid');
00366 $p=new IText('ctl_price');
00367 $b=new IText('ctl_purchase');
00368
00369 echo "Label ".$l->input().'<br>';
00370 echo "Tva id ".$t->input().'<br>';
00371 echo "Price ".$p->input().'<br>';
00372 echo "Purchase ".$b->input().'<br>';
00373
00374 if ( isset($_REQUEST['test_select']) )
00375 echo HtmlInput::hidden('test_select',$_REQUEST['test_select']);
00376 $a->set_function('test_value');
00377 $a->javascript=' onchange="alert(\'onchange\');" onblur="alert(\'onblur\');" ';
00378 echo $a->input();
00379 echo dossier::hidden();
00380 echo HtmlInput::submit('Entree','entree');
00381 echo '</form>';
00382 echo <<<EOF
00383 EOF;
00384 }
00385 }