00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00061 class widget {
00077 var $type;
00078 var $name;
00079 var $value;
00080 var $readonly;
00081 var $size;
00082 var $selected;
00083 var $table;
00084 var $label;
00085 var $disabled;
00086 var $extra;
00087 var $extra2;
00088 var $tabindex;
00089 function widget($p_type="") {
00090 $this->type=$p_type;
00091 $this->readonly=false;
00092 $this->size=20;
00093 $this->width=50;
00094 $this->heigh=20;
00095 $this->value="";
00096 $this->selected="";
00097 $this->table=0;
00098 $this->label="";
00099 $this->disabled=false;
00100 $this->tabindex=32767;
00101 }
00102 function SetReadOnly($p_read) {
00103 $this->readonly=$p_read;
00104 }
00114 function IOValue($p_name=null,$p_value=null,$p_label="") {
00115
00116 if ( $p_name != null)
00117 $this->name=$p_name;
00118 $this->value=($p_value===null)?$this->value:$p_value;
00119 $this->label=($p_label == "")?$this->label:$p_label;
00120
00121
00122 $disabled = $this->disabled ? "DISABLED" : "";
00123 if (strtoupper($this->type)=="TEXT") {
00124 if ( $this->readonly==false) {
00125 $r="<INPUT style=\"border:solid 1px blue;\" TYPE=\"TEXT\" NAME=\"$this->name\" VALUE=\"$this->value\" TABINDEX=\"$this->tabindex\" SIZE=\"$this->size\" ".$disabled.">";} else {
00126 $r=sprintf('<span>%s</span><input type="hidden" name="%s" value="%s">', $this->value,$this->name,$this->value);
00127 }
00128
00129 if ($this->table==1) {
00130 if ( $this->label != "") {
00131 $r="<TD style=\"border:groove 1px blue;\">".$this->label."</TD><TD>".$r."</TD>";
00132 }else {
00133 $r="<TD>".$r."</TD>";
00134 }
00135 }
00136 return $r;
00137 }
00138
00139 if (strtoupper($this->type)=="HIDDEN") {
00140 $r='<INPUT TYPE="HIDDEN" name="'.$this->name.'" value="'.$this->value.'">';
00141 if ( $this->readonly==true) return "";
00142 return $r;
00143 }
00144
00145 if ( strtoupper($this->type) == "SELECT") {
00146 if ($this->readonly==false )
00147 {
00148
00149 $r="<SELECT NAME=\"$this->name\">";
00150 for ( $i=0;$i<sizeof($this->value);$i++)
00151 {
00152 $checked=($this->selected==$this->value[$i]['value'])?"SELECTED":"";
00153 $r.='<OPTION VALUE="'.$this->value[$i]['value'].'" '.$checked.'>';
00154 $r.=$this->value[$i]['label'];
00155 }
00156 $r.="</SELECT>";
00157 } else
00158 {
00159 $r="";
00160 echo_debug('class_widget.php',__LINE__,"this->selected = ".$this->selected);
00161 for ( $i=0;$i<sizeof($this->value);$i++)
00162 {
00163 echo_debug('class_widget.php',__LINE__,"check for ".$this->value[$i]['value']);
00164 if ($this->selected==$this->value[$i]['value'] )
00165 {
00166 $r=$this->value[$i]['label'];
00167
00168 }
00169 }
00170 }
00171 if ( $this->table==1) {
00172 $r="<TD> $r </TD>";
00173 if ( $this->label != "") $r="<TD> $this->label</TD>".$r;
00174 }
00175 return $r;
00176 }
00177
00178 if (strtoupper($this->type)=="PASSWORD") {
00179 if ( $this->readonly==true) return "";
00180 $r='<input type="password" name="'.$this->name;
00181 $r.='">';
00182 if ($this->table==1) {
00183 $r="<TD> $this->label </TD><TD> $r </TD>";
00184 }
00185 return $r;
00186 }
00187
00188
00189 if (strtoupper($this->type)=="CHECKBOX") {
00190 if ( $this->readonly == true) {
00191 $check=( $this->selected==true )?"checked":"unchecked";
00192 $r='<input type="CHECKBOX" name="'.$this->name.'"';
00193 $r.=" $check";
00194 $r.=' disabled>';
00195
00196 } else {
00197 $check=( $this->selected==true )?"checked":"unchecked";
00198 $r='<input type="CHECKBOX" name="'.$this->name.'"';
00199 $r.=" $check";
00200 $r.=' '.$disabled.'>';
00201 }
00202 if ($this->table==1) {
00203 $r="<TD> $this->label </TD><TD> $r </TD>";
00204 } else {
00205 $r=$r." $this->label";
00206 }
00207 return $r;
00208 }
00209
00210
00211 if (strtoupper($this->type)=="RADIO") {
00212 if ( $this->readonly == true) {
00213 $check=( $this->selected==true || $this->selected=='t' )?"Yes":"no";
00214 $r=$check;
00215 } else {
00216 $check=( $this->selected==true||$this->selected=='t' )?"checked":"unchecked";
00217 $r='<input type="RADIO" name="'.$this->name.'"';
00218 $r.=" VALUE=\"$this->value\"";
00219 $r.=" $check";
00220 $r.=' '.$disabled.'>';
00221 }
00222 if ($this->table==1) {
00223 $r="<TD> $this->label </TD><TD> $r </TD>";
00224 } else {
00225 $r=$this->label.$r;
00226 }
00227 return $r;
00228 }
00229
00230
00231 if (strtoupper($this->type)=="TEXTAREA") {
00232 if ( $this->readonly == false ) {
00233 $r="";
00234 $r.='<TEXTAREA name="'.$this->name.'"';
00235 $r.=" rows=\"$this->heigh\" ";
00236 $r.=" cols=\"$this->width\" ";
00237 $r.=' '.$disabled.'>';
00238 $r.=$this->value;
00239
00240 $r.="</TEXTAREA>";
00241 } else {
00242 $r='<p>';
00243 $r.=$this->value;
00244 $r.=sprintf('<input type="hidden" name="%s" value="%s">',
00245 $this->name,urlencode($this->value));
00246 $r.='</p>';
00247
00248 }
00249 if ($this->table==1) {
00250 $r="<TD> $this->label </TD><TD> $r </TD>";
00251 }
00252 return $r;
00253 }
00254
00255
00256
00257
00258
00264 if ( strtoupper($this->type)=='RICHTEXT')
00265 {
00266 $r= ' <script language="JavaScript" type="text/javascript"> '.
00267 '<!-- '."\n".
00268 "\nfunction submitForm() {\n".
00269 " updateRTE('".$this->name."');\n ".
00270 " return true; \n".
00271 "} \n".
00272 'initRTE("images/", "", "");'."\n".
00273 '
00274 '</script>'.
00275 '<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>'.
00276 'Note Interne : '.
00277 '<script language="JavaScript" type="text/javascript">'."\n".
00278 '<!--'."\n";
00279
00280
00281 echo_debug('class_widget',__LINE__,'to write is '.$this->name);
00282
00283
00284
00285
00286
00287
00288 $msg=$this->value;
00289 $msg=str_replace("%OA","",$msg);
00290 $msg=str_replace("%OD","",$msg);
00291 $msg=str_replace("\n","",$msg);
00292 $msg=str_replace("\r","",$msg);
00293
00294 $read=($this->readonly==false)?"false":"true";
00295
00296
00297 $r.=sprintf(" writeRichText('%s','%s',%d,%d,true,%s);\n",
00298 $this->name,
00299 $msg,
00300 $this->width,
00301 $this->heigh,
00302 $read);
00303 $r.= "\n//-->".
00304 "</script>";
00305 echo_debug ('class_widget',__LINE__,"writeRichText '$r'");
00306
00307 return $r;
00308
00309 }
00310
00311
00312
00313 if (strtoupper($this->type)=="FILE") {
00314 if ( $this->readonly == false ) {
00315 $r='<INPUT TYPE="file" name="'.$this->name.'" VALUE="'.$this->value.'">';
00316
00317 }
00318 if ( $this->table==1) $r="<TD>$this->label</TD><TD>$r</TD>";
00319 return $r;
00320 }
00321
00322 if ( strtolower($this->type)=="js_search_poste") {
00323
00324 $l_sessid=$_REQUEST['PHPSESSID'];
00325 if ( $this->readonly == false ) {
00326
00327 if ( $this->extra2 == null ) {
00328 $r=sprintf('<TD>
00329 <INPUT TYPE="button" onClick=SearchPoste(\'%s\',\'%s\',\'%s\') value="Search">
00330 %s</TD><TD>
00331
00332 <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
00333 </TD>',
00334 $l_sessid,
00335 $this->name,
00336 $this->extra,
00337 $this->label,
00338 $this->name,
00339 $this->value
00340 );
00341
00342 } else {
00343 $r=sprintf('<TD>
00344 <INPUT TYPE="button" onClick=SearchPosteFilter(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
00345 %s</TD><TD>
00346
00347 <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
00348 </TD>',
00349 $l_sessid,
00350 $this->name,
00351 $this->extra2,
00352 $this->extra,
00353 $this->label,
00354 $this->name,
00355 $this->value
00356 );
00357
00358 }
00359 } else {
00360 $r=sprintf('<TD><input type="hidden" name="%s" value="%s">
00361 %s
00362
00363 </TD>',
00364 $this->name,
00365 $this->value ,
00366 $this->value
00367 );
00368
00369 }
00370 return $r;
00371
00372 }
00373
00374
00375 if ( strtolower($this->type)=="js_search") {
00376 $l_sessid=$_REQUEST['PHPSESSID'];
00377 if ( $this->readonly == false ) {
00378 $r=sprintf('<TD>
00379 <INPUT TYPE="button" onClick=NewCard(\'%s\',\'%s\',\'%s\',\'%s\') value="New">
00380 </TD><TD>
00381 <INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Search">
00382 %s <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s">
00383 ',
00384 $l_sessid,
00385 $this->extra,
00386 $this->name,
00387 $this->extra2,
00388 $l_sessid,
00389 $this->extra,
00390 $this->name,
00391 $this->extra2,
00392 $this->label,
00393 $this->name,
00394 $this->value,
00395 $this->tabindex
00396 );
00397 } else {
00398
00399 $r=sprintf('<TD> %s</TD>
00400 <TD>
00401 <INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">
00402 </TD>',
00403 $this->label,
00404 $this->name,
00405 $this->value
00406 );
00407
00408 }
00409 return $r;
00410 }
00411
00412
00413
00416 if ( strtolower($this->type)=="js_search_only") {
00417 $l_sessid=$_REQUEST['PHPSESSID'];
00418 if ( $this->readonly == false ) {
00419 if ( $this->table==1)
00420 {
00421 $r=sprintf('<TD>
00422 <INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="QuickCode">
00423 %s</TD><TD> <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s">
00424 ',
00425 $l_sessid,
00426 $this->extra,
00427 $this->name,
00428 $this->extra2,
00429 $this->label,
00430 $this->name,
00431 $this->value,
00432 $this->tabindex
00433 );
00434 }
00435 else
00436 {
00437 $r=sprintf('
00438 <INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="QuickCode">
00439 %s <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8" TABINDEX="%s"> ',
00440 $l_sessid,
00441 $this->extra,
00442 $this->name,
00443 $this->extra2,
00444 $this->label,
00445 $this->name,
00446 $this->value,
00447 $this->tabindex
00448 );
00449 }
00450 } else {
00451
00452 if ( $this->table == 1 )
00453 {
00454
00455 $r=sprintf('<TD> %s</TD>
00456 <TD> %s
00457 <INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">
00458 ',
00459 $this->label,
00460 $this->value,
00461 $this->name,
00462 $this->value
00463 );
00464 }
00465 else {
00466
00467 $r=sprintf('%s',
00468 $this->value
00469 );
00470
00471 }
00472
00473 }
00474 return $r;
00475 }
00476
00477
00478
00479
00480
00481
00482 if ( strtolower($this->type)=="span") {
00483 $r=sprintf('<span id="%s" >%s </span>',
00484 $this->name,
00485 $this->value
00486 );
00487
00488 return $r;
00489 }
00490
00491
00492 if ( strtolower($this->type)=="js_tva") {
00493 $id=sprintf("<span id=%s></span>",$this->label);
00494 $r=sprintf('%s<TD> <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="3" onChange="ChangeTVA(\'%s\',\'%s\');">',
00495 $id,
00496 $this->name,
00497 $this->value,
00498 $this->label,
00499 $this->name);
00500 $l_sessid=$_REQUEST['PHPSESSID'];
00501 $r.=sprintf("<input type=\"button\" value=\"Tva\"
00502 onClick=\"
00503 ShowTva('%s','%s');\"></TD>",
00504 $l_sessid,$this->name);
00505 return $r;
00506 }
00507
00508
00509 if ( strtolower($this->type)=="js_concerned") {
00510 if ( $this->readonly == false) {
00511 $l_sessid=$_REQUEST['PHPSESSID'];
00512 $r=sprintf('<TD>
00513 <INPUT TYPE="button" onClick=SearchJrn(\'%s\',\'%s\') value="Search">
00514 %s</TD><TD>
00515
00516 <INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
00517 </TD>',
00518 $l_sessid,
00519 $this->name,
00520 $this->label,
00521 $this->name,
00522 $this->value
00523 );
00524 } else {
00525 $r=sprintf("<TD><span>%s</span>",$this->value);
00526 $r.=sprintf('<input type="hidden" name="%s" value="%s"></TD>', $this->name,$this->value);
00527 }
00528
00529 return $r;
00530 }
00531 return "INVALID WIDGET $this->type ";
00532 }
00533
00534
00535 function debug() {
00536 echo "Type ".$this->type."<br>";
00537 echo "name ".$this->name."<br>";
00538 echo "value". $this->value."<br>";
00539 $readonly=($this->readonly==false)?"false":"true";
00540 echo "read only".$readonly."<br>";
00541 }
00542 function Submit ($p_name,$p_value) {
00543 return '<INPUT TYPE="SUBMIT" NAME="'.$p_name.'" VALUE="'.$p_value.'">';
00544 }
00545 function Reset ($p_value) {
00546 return '<INPUT TYPE="SUBMIT" VALUE="'.$p_value.'">';
00547 }
00548
00549 }