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