js you have the javascript code * - SELECT the options are passed via this->value, this array is * build thanks the make_array function, each array (of the * array) aka row must contains a field value and a field label * - PASSWORD * - CHECKBOX * - RADIO * - TEXTAREA * - RICHTEXT * - FILE * - JS_SEARCH_POSTE call a popup window for searching the account * - JS_SEARCH call a popup window for searching a quickcode or to add one * - JS_SEARCH_ONLY like JS_SEARCH but without adding a quickcode * - SPAN * - JS_TVA open a popup window for the VAT * - JS_CONCERNED open a popup window for search a operation, if extra == 0 then * get the amount thx javascript * - js_DATE show a calendar * * For JS_SEARCH_POST,JS_SEARCH or JS_SEARCH_ONLY * - $extra contains 'cred', 'deb', 'all' or a list of fiche_def_ref (frd_id) * to filter the search/add for the card * * - $extra2 filter on the card parameter, which are given in Avance->journaux menu, * it is the journal id. If empty, there is no link with a ledger * */ class widget { var $type; /*!< $type type of the widget */ var $name; /*!< $name field NAME of the INPUT */ var $value; /*!< $value what the INPUT contains */ var $readonly; /*!< $readonly true : we cannot change value */ var $size; /*!< $size size of the input */ var $selected; /*!< $selected for SELECT RADIO and CHECKBOX the selected value */ var $table; /*!< $table =1 add the table tag */ var $label; /*!< $label the question before the input */ var $disabled; /*!< $disabled poss. value == true or nothing, to disable INPUT*/ var $extra; /*!< $extra different usage, it depends of the $type */ var $extra2; /*!< $extra2 different usage, it depends of the $type */ var $javascript; var $tabindex; function widget($p_type="",$p_label="",$p_name="",$p_value="") { $this->type=$p_type; $this->name=$p_name; $this->readonly=false; $this->size=20; $this->width=50; $this->heigh=20; $this->value=$p_value; $this->selected=""; $this->table=0; $this->label=$p_label; $this->disabled=false; $this->javascript=""; $this->extra2="all"; } function SetReadOnly($p_read) { $this->readonly=$p_read; } /*! function IOValue($p_name,$p_value="",$p_label="") ***************************************************** * \brief create the corresponding INPUT tag * * \param $p_name is the INPUT NAME * \param $p_value is the INPUT VALUE or an array for select * \param $p_label is the label of the INPUT * \return string containing the tag */ function IOValue($p_name=null,$p_value=null,$p_label="") { if ( $p_name != null) $this->name=$p_name; $this->value=($p_value===null)?$this->value:$p_value; $this->label=($p_label == "")?$this->label:$p_label; // Input text type $disabled = $this->disabled ? "readonly" : ""; if (strtoupper($this->type)=="TEXT") { $extra=(isset($this->extra))?$this->extra:""; if ( $this->readonly==true ){ $readonly=" readonly ";$style='style="border:solid 1px grey;color:black;background:lightblue;"'; } else { $readonly=" ";$style='style="border:solid 1px blue;"'; } $this->value=str_replace('"','',$this->value); $r='javascript." ".$disabled." $readonly $this->extra >"; if ($this->table==1) { if ( $this->label != "") { $r="".$this->label."".$r.""; }else { $r="".$r.""; } } return $r; } // Hidden field if (strtoupper($this->type)=="HIDDEN") { $r=''; if ( $this->readonly==true) return ""; return $r; } // Select value if ( strtoupper($this->type) == "SELECT") { if ($this->readonly==false ) { $disabled=($this->disabled==true)?"disabled":""; //echo "Selected ".$this->selected; $r=""; } if ( $this->readonly==true) { $r=""; echo_debug('class_widget.php',__LINE__,"this->selected = ".$this->selected); for ( $i=0;$ivalue);$i++) { echo_debug('class_widget.php',__LINE__,"check for ".$this->value[$i]['value']); if ($this->selected==$this->value[$i]['value'] ) { $r=$this->value[$i]['label']; } } } if ( $this->table==1) { $r=" $r "; if ( $this->label != "") $r=" $this->label".$r; } return $r; } // Password if (strtoupper($this->type)=="PASSWORD") { if ( $this->readonly==true) return ""; $r=''; if ($this->table==1) { $r=" $this->label $r "; } return $r; } // Checkbox if (strtoupper($this->type)=="CHECKBOX") { if ( $this->readonly == true) { $check=( $this->selected==true )?"checked":"unchecked"; $r='selected==true )?"checked":"unchecked"; $r='javascript.'>'; } if ($this->table==1) { $r=" $this->label $r "; } else { $r=$r." $this->label"; } return $r; } //radio if (strtoupper($this->type)=="RADIO") { if ( $this->readonly == true) { $check=( $this->selected==true || $this->selected=='t' )?"Yes":"no"; $r=$check; } else { $check=( $this->selected==true||$this->selected=='t' )?"checked":"unchecked"; $r='value\""; $r.=" $check"; $r.=' '.$disabled.'>'; } if ($this->table==1) { $r=" $this->label $r "; } else { $r=$this->label.$r; } return $r; } //textarea if (strtoupper($this->type)=="TEXTAREA") { if ( $this->readonly == false ) { $r=""; $r.='"; } else { $r='

'; $r.=$this->value; $r.=sprintf('', $this->name,urlencode($this->value)); $r.='

'; } if ($this->table==1) { $r=" $this->label $r "; } return $r; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- // Rich Text /*!\brief * \note for the type RICHTEXT we need to include the javascript file * into the head \see commercial.php html_page_start($_SESSION['g_theme'],"","richtext.js"); */ if ( strtoupper($this->type)=='RICHTEXT') { $r= ' '. ''. 'Note Interne : '. '"; echo_debug ('class_widget',__LINE__,"writeRichText '$r'"); return $r; } //---------------------------------------------------------------------- //file if (strtoupper($this->type)=="FILE") { if ( $this->readonly == false ) { $r=''; } if ( $this->table==1) $r="$this->label$r"; return $r; } //---------------------------------------------------------------------- // input type == js_search_poste => button search for the account if ( strtolower($this->type)=="js_search_poste") { $l_sessid=$_REQUEST['PHPSESSID']; if ( $this->readonly == false ) { // Do we need to filter ?? if ( $this->extra2 == null ) { $r=sprintf(' %s ', $l_sessid, $this->name, $this->extra, $this->label, $this->name, $this->name, $this->value ); } else { // $p_list is not null, so we have a filter $r=sprintf(' %s ', $l_sessid, $this->name, $this->extra2, $this->extra, $this->label, $this->name, $this->name, $this->value ); } //else } else { $r=sprintf(' %s ', $this->name, $this->value , $this->value ); } //else if readonly == true if ( $this->table==0) { $r=str_replace ('','',$r); $r=str_replace ('','',$r); } return $r; } // end js_search_poste // input type == js_search => button search for card if ( strtolower($this->type)=="js_search") { $l_sessid=$_REQUEST['PHPSESSID']; if ( $this->readonly == false ) { $r=sprintf(' %s ', $l_sessid, $this->extra, // deb or cred $this->name, $this->extra2, //jrn $l_sessid, $this->extra, $this->name, $this->extra2, $this->label, $this->name, $this->name, $this->value, $this->name, $this->extra, //deb or cred $this->extra2 //jrn ); } else { // readonly == true $r=sprintf(' %s ', $this->label, $this->name, $this->value ); } return $r; }// poste==js_search // input type == js_search => button search for card /*!\brief js_search_only only for searching a card no new button */ if ( strtolower($this->type)=="js_search_only") { $l_sessid=$_REQUEST['PHPSESSID']; if ( $this->readonly == false ) { if ( $this->table==1) { $r=sprintf(' %s ', $l_sessid, $this->extra, $this->name, $this->extra2, $this->label, $this->name, $this->name, $this->value, $this->name, $this->extra, //deb or cred $this->extra2 //jrn ); } else { $r=sprintf(' %s ', $l_sessid, $this->extra, $this->name, $this->extra2, $this->label, $this->name, $this->name, $this->value, $this->name, $this->extra, //deb or cred $this->extra2 //jrn ); } } else { // readonly == true if ( $this->table == 1 ) { $r=sprintf(' %s %s ', $this->label, $this->value, $this->name, $this->value ); } else { // readonly == true and table == 0 $r=sprintf('%s', $this->value ); } } return $r; }// poste==js_search_only // type=span if ( strtolower($this->type)=="span") { $r=sprintf('%s ', $this->name, $this->value ); return $r; }// end type = span // input type == js_tva if ( strtolower($this->type)=="js_tva") { $id=sprintf("",$this->label); $r=sprintf('%sTva ', $id, $this->name, $this->value, $this->label, $this->name); $l_sessid=$_REQUEST['PHPSESSID']; $r.=sprintf("", $l_sessid,dossier::id(),$this->name); return $r; } // input type == js_concerned => button search for the concerned operations if ( strtolower($this->type)=="js_concerned") { $td="";$etd=""; if ( $this->table == 1 ) { $td=''; $etd='';} if ( $this->readonly == false) { $l_sessid=$_REQUEST['PHPSESSID']; $r=sprintf("$td %s $etd $td $etd", $l_sessid, $this->name, $this->extra, $this->extra2, $this->label, $this->name, $this->name, $this->value ); } else { $r=sprintf("$td%s %s",$this->label,$this->value); $r.=sprintf(''.$etd, $this->name,$this->value); } return $r; }// end js_concerned //---------------------------------------------------------------------- // BUTTON //---------------------------------------------------------------------- if ( strtolower($this->type)=="button") { $extra= ( isset($this->extra))?$this->extra:""; if ( $this->readonly==true) return ""; $r=''; return $r; } //---------------------------------------------------------------------- // JS_BUD_SEARCH_POSTE //---------------------------------------------------------------------- if ( strtolower($this->type)=="js_bud_search_poste") { if ( $this->readonly==true) return ""; $dis= ( $this->disabled==true) ? "disabled":""; $this->javascript="bud_search_poste('".$_REQUEST['PHPSESSID']."',".dossier::id().",'$this->name')"; $r=''; $r.=''; $r.=''; return $r; } //------------------------------------------------------------------------ // JS_DATE //------------------------------------------------------------------------ if ( strtolower($this->type)=="js_date") { if ( $this->readonly) { $r=" Date : ".$this->value; $r=''; } else { $r=''. ''; $r.=' '; } if ($this->table==1) { if ( $this->label != "") { $r="".$this->label."".$r.""; }else { $r="".$r.""; } } return $r; } return "INVALID WIDGET $this->type "; } //end function /* Debug */ function debug() { echo "Type ".$this->type."
"; echo "name ".$this->name."
"; echo "value". $this->value."
"; $readonly=($this->readonly==false)?"false":"true"; echo "read only".$readonly."
"; } function Submit ($p_name,$p_value) { return ''; } static function submit_button ($p_name,$p_value,$p_javascript="") { return ''; } function Reset ($p_value) { return ''; } static function hidden($p_name,$p_value) { return ''; } static function button_href($p_name,$p_value) { return sprintf('', $p_value, $p_name); } }