/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*+++
function widget
purpose create the widget
parameters p_type the type of the widget
p_name name of widget
value widget's value
readonly true or false
+++*/
class widget {
var $type;
var $name;
var $value;
var $readonly;
var $size;
var $selected;
var $table;
var $label;
var $disabled;
var $extra;
var $extra2;
function widget($p_type="") {
$this->type=$p_type;
$this->readonly=false;
$this->size=20;
$this->width=50;
$this->heigh=20;
$this->value="";
$this->selected="";
$this->table=0;
$this->label="";
$this->disabled=false;
}
function SetReadOnly($p_read) {
$this->readonly=$p_read;
}
/*+++
function IOValue($p_name,$p_value="",$p_label="") {
purpose : create the INPUT tag
parameters: $p_name is the INPUT NAME
$p_value is the INPUT VALUE or an array for select
$p_label is the label of the INPUT
return : string containing the tag
+++*/
function IOValue($p_name=null,$p_value=null,$p_label="") {
// echo __FILE__."p_value $p_value";
if ( $p_name != null)
$this->name=$p_name;
$this->value=($p_value===null)?"":$p_value;
$this->label=($p_label == "")?$this->label:$p_label;
//echo "this->value =".$this->value;
// Input text type
$disabled = $this->disabled ? "DISABLED" : "";
if (strtoupper($this->type)=="TEXT") {
if ( $this->readonly==false) {
$r="size\" ".$disabled.">";} else {
$r=$this->value;
}
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 ){
//echo "Selected ".$this->selected;
$r="";
} else {
echo_debug(__FILE__,__LINE__,"this->selected = ".$this->selected);
for ( $i=0;$ivalue);$i++) {
echo_debug(__FILE__,__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="
";
}
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'];
// Do we need to filter ??
if ( $this->extra2 == null ) {
$r=sprintf('
%s
',
$l_sessid,
$this->name,
$this->extra,
$this->label,
$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->value
);
} //else
return $r;
} // end js_search_poste
// input type == js_search => button search for card
if ( strtolower($this->type)=="js_search") {
$l_sessid=$_REQUEST['PHPSESSID'];
$r=sprintf('