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 require_once('class_html_input.php');
00031 require_once('function_javascript.php');
00032
00033 class IAncCard extends HtmlInput
00034 {
00035 function __construct($name="",$value="",$p_id="")
00036 {
00037 parent::__construct($name,$value,$p_id);
00038 $this->fct='update_value';
00039 $this->dblclick='';
00040 $this->callback='null';
00041 $this->javascript='';
00042
00043 $this->plan=0;
00044
00045 $this->plan_ctl="";
00046 }
00047
00048
00049
00050
00051
00052 function set_callback($p_name)
00053 {
00054 $this->callback=$p_name;
00055 }
00056
00057
00058
00059
00060
00061 function set_function($p_name)
00062 {
00063 $this->fct=$p_name;
00064 }
00065
00066
00067
00068
00069
00070
00071 function set_dblclick($p_action)
00072 {
00073 $this->dblclick=$p_action;
00074 }
00075
00076 public function input($p_name=null,$p_value=null)
00077 {
00078 if ( $p_name == null && $this->name == "")
00079 throw (new Exception('Le nom d une icard doit ĂȘtre donne'));
00080
00081 $this->value=($p_value==null)?$this->value:$p_value;
00082 if ( $this->readOnly==true) return $this->display();
00083
00084 $this->id=($this->id=="")?$this->name:$this->id;
00085
00086
00087
00088 $label='';
00089 if ( $this->dblclick != '')
00090 {
00091 $e=sprintf(' ondblclick="%s" ',
00092 $this->dblclick);
00093 $this->dblclick=$e;
00094 }
00095 $input=sprintf('<INPUT TYPE="Text" class="input_text" '.
00096 ' NAME="%s" ID="%s" VALUE="%s" SIZE="%d" %s %s>',
00097 $this->name,
00098 $this->name,
00099 $this->value,
00100 $this->size,
00101 $this->dblclick,
00102 $this->javascript
00103 );
00104
00105
00106 $div=sprintf('<div id="%s_choices" class="autocomplete"></div>',
00107 $this->name);
00108 $query="op=autoanc&".dossier::get();
00109
00110
00111
00112 if ($this->plan <> 0)
00113 {
00114 $query.="&pa_id=".$this->plan;
00115 } elseif ( $this->plan_ctl <> '')
00116 {
00117 $this->set_attribute("plan_ctl", $this->plan_ctl);
00118 }
00119 $attr=$this->get_js_attr();
00120 $javascript=sprintf('try { new Ajax.Autocompleter("%s","%s_choices","ajax_misc.php?%s",'.
00121 '{paramName:"anccard",minChars:1,indicator:null, '.
00122 'callback:%s, '.
00123 ' afterUpdateElement:%s});} catch (e){alert(e.message);};',
00124 $this->name,
00125 $this->name,
00126 $query,
00127 $this->callback,
00128 $this->fct);
00129
00130 $javascript=create_script($javascript.$this->dblclick);
00131
00132 $r=$label.$input.$attr.$div.$javascript;
00133 if ( $this->table == 1 )
00134 $r=td($r);
00135 return $r;
00136
00137 }
00138
00139 public function display()
00140 {
00141 $r=sprintf('
00142 <INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">',
00143 $this->name,
00144 $this->value
00145 );
00146 $r.='<span>'.$this->value.'</span>';
00147 return $r;
00148
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 function search()
00178 {
00179 if ( $this->readOnly==true) return '';
00180
00181 $button=new IButton($this->name.'_bt');
00182 $a="";
00183 foreach (array('typecard','jrn','label','price','tvaid') as $att)
00184 {
00185 if (isset($this->$att) )
00186 $a.="this.".$att."='".$this->$att."';";
00187 }
00188 if (isset($this->name))
00189 $a.="this.inp='".$this->name."';";
00190 $a.="this.popup='ipop_card';";
00191
00192 $button->javascript=$a.' search_card(this)';
00193 return $button->input();
00194 }
00195
00196 static public function test_me()
00197 {
00198
00199 }
00200 }