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
* - JS_LEDGER_CTRL like js_search_only but the tag to update is given
* - 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 HtmlInput {
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; /*!< $javascript is the javascript to add to the widget */
var $ctrl; /*!<$ctrl is the control to update (see js_search_card_control) */
var $tabindex;
function __construct($p_name="",$p_value="") {
$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->disabled=false;
$this->javascript="";
$this->extra2="all";
$this->attribute=array();
}
function setReadOnly($p_read) {
$this->readonly=$p_read;
}
/*!\brief set the extra javascript property for the INPUT field
*\param $p_name name of the parameter
*\param $p_value default value of this parameter
*/
public function set_attribute($p_name,$p_value) {
$this->attribute[]=array($p_name,$p_value);
$this->$p_name=$p_value;
}
/**
*@brief you can add attribute to this in javascript
* this function is a wrapper and create a script (in js) to modify
* "this" (in javascript) with the value of obj->attribute from PHP
*@return return string with the javascript code
*/
public function get_js_attr(){
require_once('function_javascript.php');
$attr="";
if ( count($this->attribute) == 0) return "";
/* Add properties at the widget */
for ($i=0;$i< count($this->attribute);$i++){
list($name,$value)=$this->attribute[$i];
$tmp1=sprintf("$('%s').%s='%s';",
$this->name,
$name,
$value);
$attr.=$tmp1;
}
$attr=create_script($attr);
return $attr;
}
/**
* Make a JSON object, this method create a javascript object
* with the attribute set, it returns a javascript string with the object
* @param $p_name : name of the object
* @return javascript string with the object
* @code
$a=new IButton()
$a->set_attribute('prop','1');
$a->set_attribute('prop','2');
$a->set_attribute('prop','3');
$string = $a->make_object('property');
echo $string => property={'prop':'1','prop2':'2','prop3':'3'};
@endcode
*/
public function make_object($p_name) {
if ( count($this->attribute) == 0) return "$p_name={}";
$ret="$p_name={"; $and='';
for ($i=0;$i< count($this->attribute);$i++){
list($name,$value)=$this->attribute[$i];
$tmp1=sprintf($and."'%s':'%s'",
$name,
$value);
$ret.=$tmp1; $and=',';
}
$ret.='}';
return $ret;
}
//#####################################################################
/* 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." ";
}
static function submit ($p_name,$p_value,$p_javascript="") {
return '';
}
static function button ($p_name,$p_value,$p_javascript="") {
return '';
}
static function reset ($p_value) {
return '';
}
static function hidden($p_name,$p_value) {
return '';
}
static function phpsessid() {
return self::hidden('phpsessid',$_REQUEST['PHPSESSID']);
}
static function extension() {
return self::hidden('code',$_REQUEST['code']);
}
/*!\brief create a button with a ref
*\param $p_label the text
*\param $p_value the location of the window, the PHPSESSID is added, but not the gDossier
*\param $p_name the id of the span
*\return string with htmlcode
*/
static function button_anchor($p_label,$p_value,$p_name="") {
$str='&PHPSESSID='.$_REQUEST['PHPSESSID'];
$r=sprintf('%s',
$p_name,
$p_value.$str,
$p_label);
return $r;
}
static function infobulle($p_comment){
$r='?';
return $r;
}
static function warnbulle($p_comment){
$r='XX';
return $r;
}
}