00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00032 class widget {
00053 var $type;
00054 var $name;
00055 var $value;
00056 var $readonly;
00057 var $size;
00058 var $selected;
00059 var $table;
00060 var $label;
00061 var $disabled;
00062 var $extra;
00063 var $extra2;
00064 var $tabindex;
00065 function widget($p_type="") {
00066 $this->type=$p_type;
00067 $this->readonly=false;
00068 $this->size=20;
00069 $this->width=50;
00070 $this->heigh=20;
00071 $this->value="";
00072 $this->selected="";
00073 $this->table=0;
00074 $this->label="";
00075 $this->disabled=false;
00076 $this->tabindex=32767;
00077 }
00078 function SetReadOnly($p_read) {
00079 $this->readonly=$p_read;
00080 }
00090 function IOValue($p_name=null,$p_value=null,$p_label="") {
00091
00092 if ( $p_name != null)
00093 $this->name=$p_name;
00094 $this->value=($p_value===null)?$this->value:$p_value;
00095 $this->label=($p_label == "")?$this->label:$p_label;
00096
00097
00098 $disabled = $this->disabled ? "DISABLED" : "";
00099 if (strtoupper($this->type)=="TEXT") {
00100 if ( $this->readonly==false) {
00101 $r="<INPUT TYPE=\"TEXT\" NAME=\"$this->name\" VALUE=\"$this->value\" TABINDEX=\"$this->tabindex\" SIZE=\"$this->size\" ".$disabled.">";} else {
00102 $r=sprintf('<span>%s</span><input type="hidden" name="%s" value="%s">', $this->value,$this->name,$this->value);
00103 }
00104
00105 if ($this->table==1) {
00106 if ( $this->label != "") {
00107 $r="<TD style=\"border:solid 1px blue;\">".$this->label."</TD><TD>".$r."</TD>";
00108 }else {
00109 $r="<TD>".$r."</TD>";
00110 }
00111 }
00112 return $r;
00113 }
00114
00115 if (strtoupper($this->type)=="HIDDEN") {
00116 $r='<INPUT TYPE="HIDDEN" name="'.$this->name.'" value="'.$this->value.'">';
00117 if ( $this->readonly==true) return "";
00118 return $r;
00119 }
00120
00121 if ( strtoupper($this->type) == "SELECT") {
00122 if ($this->readonly==false ){
00123
00124 $r="<SELECT NAME=\"$this->name\">";
00125 for ( $i=0;$i<sizeof($this->value);$i++) {
00126 $checked=($this->selected==$this->value[$i]['value'])?"SELECTED":"";
00127 $r.='<OPTION VALUE="'.$this->value[$i]['value'].'" '.$checked.'>';
00128 $r.=$this->value[$i]['label'];
00129 }
00130 $r.="</SELECT>";
00131 } else {
00132 echo_debug('class_widget.php',__LINE__,"this->selected = ".$this->selected);
00133 for ( $i=0;$i<sizeof($this->value);$i++) {
00134 echo_debug('class_widget.php',__LINE__,"check for ".$this->value[$i]['value']);
00135 if ($this->selected==$this->value[$i]['value'] ) {
00136 $r=$this->value[$i]['label'];
00137
00138 }
00139 }
00140 }
00141 if ( $this->table==1) {
00142 $r="<TD> $r </TD>";
00143 if ( $this->label != "") $r="<TD> $this->label</TD>".$r;
00144 }
00145 return $r;
00146 }
00147
00148 if (strtoupper($this->type)=="PASSWORD") {
00149 if ( $this->readonly==true) return "";
00150 $r='<input type="password" name="'.$this->name;
00151 $r.='">';
00152 if ($this->table==1) {
00153 $r="<TD> $this->label </TD><TD> $r </TD>";
00154 }
00155 return $r;
00156 }
00157
00158
00159 if (strtoupper($this->type)=="CHECKBOX") {
00160 if ( $this->readonly == true) {
00161 $check=( $this->selected==true )?"checked":"unchecked";
00162 $r='<input type="CHECKBOX" name="'.$this->name.'"';
00163 $r.=" $check";
00164 $r.=' disabled>';
00165
00166 } else {
00167 $check=( $this->selected==true )?"checked":"unchecked";
00168 $r='<input type="CHECKBOX" name="'.$this->name.'"';
00169 $r.=" $check";
00170 $r.=' '.$disabled.'>';
00171 }
00172 if ($this->table==1) {
00173 $r="<TD> $this->label </TD><TD> $r </TD>";
00174 } else {
00175 $r=$r." $this->label";
00176 }
00177 return $r;
00178 }
00179
00180
00181 if (strtoupper($this->type)=="RADIO") {
00182 if ( $this->readonly == true) {
00183 $check=( $this->selected==true || $this->selected=='t' )?"Yes":"no";
00184 $r=$check;
00185 } else {
00186 $check=( $this->selected==true||$this->selected=='t' )?"checked":"unchecked";
00187 $r='<input type="RADIO" name="'.$this->name.'"';
00188 $r.=" VALUE=\"$this->value\"";
00189 $r.=" $check";
00190 $r.=' '.$disabled.'>';
00191 }
00192 if ($this->table==1) {
00193 $r="<TD> $this->label </TD><TD> $r </TD>";
00194 } else {
00195 $r=$this->label.$r;
00196 }
00197 return $r;
00198 }
00199
00200
00201 if (strtoupper($this->type)=="TEXTAREA") {
00202 if ( $this->readonly == false ) {
00203 $r="";
00204 $r.='<TEXTAREA name="'.$this->name.'"';
00205 $r.=" rows=\"$this->heigh\" ";
00206 $r.=" cols=\"$this->width\" ";
00207 $r.=' '.$disabled.'>';
00208 $r.=$this->value;
00209
00210 $r.="</TEXTAREA>";
00211 } else {
00212 $r='<p>';
00213 $r.=$this->value;
00214 $r.=sprintf('<input type="hidden" name="%s" value="%s">',
00215 $this->name,urlencode($this->value));
00216 $r.='</p>';
00217
00218 }
00219 if ($this->table==1) {
00220 $r="<TD> $this->label </TD><TD> $r </TD>";
00221 }
00222 return $r;
00223 }
00224
00225
00226 if (strtoupper($this->type)=="FILE") {
00227 if ( $this->readonly == false ) {
00228 $r='<INPUT TYPE="file" name="'.$this->name.'" VALUE="'.$this->value.'">';
00229
00230 }
00231 if ( $this->table==1) $r="<TD>$this->label</TD><TD>$r</TD>";
00232 return $r;
00233 }
00234
00235 if ( strtolower($this->type)=="js_search_poste") {
00236
00237 $l_sessid=$_REQUEST['PHPSESSID'];
00238 if ( $this->readonly == false ) {
00239
00240 if ( $this->extra2 == null ) {
00241 $r=sprintf('<TD>
00242 <INPUT TYPE="button" onClick=SearchPoste(\'%s\',\'%s\',\'%s\') value="Search">
00243 %s</TD><TD>
00244
00245 <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
00246 </TD>',
00247 $l_sessid,
00248 $this->name,
00249 $this->extra,
00250 $this->label,
00251 $this->name,
00252 $this->value
00253 );
00254
00255 } else {
00256 $r=sprintf('<TD>
00257 <INPUT TYPE="button" onClick=SearchPosteFilter(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
00258 %s</TD><TD>
00259
00260 <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
00261 </TD>',
00262 $l_sessid,
00263 $this->name,
00264 $this->extra2,
00265 $this->extra,
00266 $this->label,
00267 $this->name,
00268 $this->value
00269 );
00270
00271 }
00272 } else {
00273 $r=sprintf('<TD><input type="hidden" name="%s" value="%s">
00274 %s
00275
00276 </TD>',
00277 $this->name,
00278 $this->value ,
00279 $this->value
00280 );
00281
00282 }
00283 return $r;
00284
00285 }
00286
00287
00288 if ( strtolower($this->type)=="js_search") {
00289 $l_sessid=$_REQUEST['PHPSESSID'];
00290 if ( $this->readonly == false ) {
00291 $r=sprintf('<TD>
00292 <INPUT TYPE="button" onClick=NewCard(\'%s\',\'%s\',\'%s\',\'%s\') value="New">
00293 <INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
00294 %s</TD><TD> <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s">
00295 ',
00296 $l_sessid,
00297 $this->extra,
00298 $this->name,
00299 $this->extra2,
00300 $l_sessid,
00301 $this->extra,
00302 $this->name,
00303 $this->extra2,
00304 $this->label,
00305 $this->name,
00306 $this->value,
00307 $this->tabindex
00308 );
00309 } else {
00310
00311 $r=sprintf('<TD> %s</TD>
00312 <TD>
00313 <INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">
00314 </TD>',
00315 $this->label,
00316 $this->name,
00317 $this->value
00318 );
00319
00320 }
00321 return $r;
00322 }
00323
00324
00325
00328 if ( strtolower($this->type)=="js_search_only") {
00329 $l_sessid=$_REQUEST['PHPSESSID'];
00330 if ( $this->readonly == false ) {
00331 if ( $this->table==1)
00332 {
00333 $r=sprintf('<TD>
00334 <INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
00335 %s</TD><TD> <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s">
00336 ',
00337 $l_sessid,
00338 $this->extra,
00339 $this->name,
00340 $this->extra2,
00341 $this->label,
00342 $this->name,
00343 $this->value,
00344 $this->tabindex
00345 );
00346 }
00347 else
00348 {
00349 $r=sprintf('
00350 <INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
00351 %s <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s"> ',
00352 $l_sessid,
00353 $this->extra,
00354 $this->name,
00355 $this->extra2,
00356 $this->label,
00357 $this->name,
00358 $this->value,
00359 $this->tabindex
00360 );
00361 }
00362 } else {
00363
00364 $r=sprintf('<TD> %s</TD>
00365 <TD>
00366 <INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">
00367 </TD>',
00368 $this->label,
00369 $this->name,
00370 $this->value
00371 );
00372
00373 }
00374 return $r;
00375 }
00376
00377
00378
00379
00380
00381
00382 if ( strtolower($this->type)=="span") {
00383 $r=sprintf('<span id="%s" >%s </span>',
00384 $this->name,
00385 $this->value
00386 );
00387
00388 return $r;
00389 }
00390
00391
00392 if ( strtolower($this->type)=="js_tva") {
00393 $id=sprintf("<span id=%s></span>",$this->label);
00394 $r=sprintf('%s<TD> <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="3" onChange="ChangeTVA(\'%s\',\'%s\');">',
00395 $id,
00396 $this->name,
00397 $this->value,
00398 $this->label,
00399 $this->name);
00400 $l_sessid=$_REQUEST['PHPSESSID'];
00401 $r.=sprintf("<input type=\"button\" value=\"Tva\"
00402 onClick=\"
00403 ShowTva('%s','%s');\"></TD>",
00404 $l_sessid,$this->name);
00405 return $r;
00406 }
00407
00408
00409 if ( strtolower($this->type)=="js_concerned") {
00410 if ( $this->readonly == false) {
00411 $l_sessid=$_REQUEST['PHPSESSID'];
00412 $r=sprintf('<TD>
00413 <INPUT TYPE="button" onClick=SearchJrn(\'%s\',\'%s\') value="Search">
00414 %s</TD><TD>
00415
00416 <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
00417 </TD>',
00418 $l_sessid,
00419 $this->name,
00420 $this->label,
00421 $this->name,
00422 $this->value
00423 );
00424 } else {
00425 $r=sprintf("<TD><span>%s</span>",$this->value);
00426 $r.=sprintf('<input type="hidden" name="%s" value="%s"></TD>', $this->name,$this->value);
00427 }
00428
00429 return $r;
00430 }
00431 return "INVALID WIDGET ";
00432 }
00433
00434
00435 function debug() {
00436 echo "Type ".$this->type."<br>";
00437 echo "name ".$this->name."<br>";
00438 echo "value". $this->value."<br>";
00439 $readonly=($this->readonly==false)?"false":"true";
00440 echo "read only".$readonly."<br>";
00441 }
00442 function Submit ($p_name,$p_value) {
00443 return '<INPUT TYPE="SUBMIT" NAME="'.$p_name.'" VALUE="'.$p_value.'">';
00444 }
00445 function Reset ($p_value) {
00446 return '<INPUT TYPE="SUBMIT" VALUE="'.$p_value.'">';
00447 }
00448
00449 }