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 * - SPAN */ 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, can be null. If the name is not null, return * $p_name={} otherwise only the object {} * @return javascript string with the object * @note: there is not check on the key->value, so you could need to escape * special char as quote, single-quote... * @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'}; $string = $a->make_object(null); echo $string => {'prop':'1','prop2':'2','prop3':'3'}; @endcode */ public function make_object($p_name=null) { $name=($p_name != null)?$p_name.'=':''; if ( count($this->attribute) == 0) return $name."{}"; $ret=$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 extension() { return self::hidden('plugin_code',$_REQUEST['plugin_code']); } /*!\brief create a button with a ref *\param $p_label the text *\param $p_value the location of the window, *\param $p_name the id of the span *\param $p_javascript javascript for this button *\return string with htmlcode */ static function button_anchor($p_label,$p_value,$p_name="",$p_javascript="") { $r=sprintf(' %s', $p_name, $p_value, $p_javascript, $p_label); return $r; } static function infobulle($p_comment) { $r='?'; return $r; } static function warnbulle($p_comment) { $r='XX'; return $r; } /** * return a string containing the html code for calling the modifyOperation */ static function detail_op($p_jr_id,$p_mesg) { return sprintf('%s', $p_jr_id,dossier::id(),$p_mesg); } /** * return a string containing the html code for calling the modifyModeleDocument */ static function detail_modele_document($p_id,$p_mesg) { return sprintf('%s', $p_id,dossier::id(),$p_mesg); } /** * return a string containing the html code for calling the removeStock */ static function remove_stock($p_id,$p_mesg) { return sprintf('%s', $p_id,dossier::id(),$p_mesg); } /** * display a div with the history of the card */ static function history_card($f_id,$p_mesg,$p_style="") { $view_history= sprintf('%s', $p_style,$f_id, dossier::id(), $p_mesg); return $view_history; } /** * display a div with the history of the card */ static function history_card_button($f_id,$p_mesg) { static $e=0; $e++; $js= sprintf('onclick="view_history_card(\'%s\',\'%s\')"', $f_id, dossier::id()); $view_history=HtmlInput::button("hcb"+$e,$p_mesg,$js); return $view_history; } /** * display a div with the history of the account */ static function history_account($p_account,$p_mesg,$p_style="") { $view_history= sprintf('%s', $p_style,$p_account, dossier::id(), $p_mesg); return $view_history; } /** * return the html code to create an hidden div and a button * to show this DIV. This contains all the available ledgers * for the user in READ or RW *@param $p_array is an array obtains thanks User::get_ledger *@param $selected is an array of checkbox *@note the choosen ledger are stored in the array r_jrn (_GET) */ static function select_ledger($p_array,$p_selected,$div='') { ob_start(); $ledger=new IButton('l'); $ledger->label="choix des journaux"; $ledger->javascript=" show_ledger_choice()"; echo $ledger->input(); /* create a hidden div for the ledger */ echo '
'; echo '

Choix des journaux

'; echo ''; $hide=new IButton('l'); $hide->label="Valider"; $hide->javascript=" hide_ledger_choice() "; echo $hide->input(); echo '
'; $ret=ob_get_contents(); ob_clean(); return $ret; } /** *create a hidden plus button to select the cat of ledger *@note the selected value is stored in the array p_cat */ static function select_cat($array_cat) { ob_start(); $ledger=new IButton('l'); $ledger->label="Catégorie"; $ledger->javascript=" show_cat_choice()"; echo $ledger->input(); /* create a hidden div for the ledger */ echo '
'; echo '

Choix des categories

'; $selected=(isset($_GET['r_cat']))?$_GET['r_cat']:null; echo ''; $hide=new IButton('l'); $hide->label="Valider"; $hide->javascript=" hide_cat_choice() "; echo $hide->input(); echo '
'; $r=ob_get_contents(); ob_clean(); return $r; } static function display_periode($p_id) { $r=sprintf('Modifier', dossier::id(), $p_id); return $r; } /** *close button for the HTML popup *@see add_div modify_operation *@param $div_name is the name of the div to remove */ static function button_close($div_name) { $a=new IButton('Fermer','Fermer'); $a->label="Fermer"; $a->javascript="removeDiv('".$div_name."')"; $html=$a->input(); return $html; } /** * Return a html string with an anchor which close the inside popup. (top-right corner) *@param name of the DIV to close */ static function anchor_close($div) { $r=''; $r.='
'; $r.= 'Fermer'; $r.='
'; return $r; } /** * button Html with an action in the top *@param $action action action to perform (message) *@param $javascript javascript of the DIV to close *@see Acc_Ledger::display_search_form *@note not protected against html *@param $div_name is the name of the div to remove */ static function button_action($action,$javascript) { } /** * Return a html string with an anchor looking like anchor_button in the right corner *@param $action action action to perform (message) *@param $javascript javascript *@note not protected against html *@see Acc_Ledger::display_search_form */ static function anchor_action($action,$javascript) { $r=''; $r.='
'; $r.= ''.$action.''; $r.='
'; return $r; } /** * Javascript to print the current window */ static function print_window() { $r=''; $r.=HtmlInput::button('print','Imprimer','onclick="window.print();"'); return $r; } /** *show the detail of a card */ static function card_detail($p_qcode,$pname='',$p_style="") { if ($pname=='')$pname=$p_qcode; $r=""; $r.=sprintf('%s[%s]', $p_qcode,$pname,$p_qcode,$p_style); return $r; } /** *transform request data to hidden *@param $array is an of indices *@param $request name of the superglobal $_POST $_GET $_REQUEST(default) *@return html string with the hidden data */ static function array_to_hidden($array,$global_array ) { $r=""; if ( count($global_array )==0) return ''; foreach ($array as $a) { if (isset($global_array [$a])) $r.=HtmlInput::hidden($a,$global_array [$a]); } return $r; } /** *transform $_GET data to hidden *@param $array is an of indices *@see HtmlInput::request_to_hidden *@return html string with the hidden data */ static function get_to_hidden($array) { $r=self::array_to_hidden($array,$_GET ); return $r; } /** *transform $_POST data to hidden *@param $array is an of indices *@see HtmlInput::request_to_hidden *@return html string with the hidden data */ static function post_to_hidden($array) { $r=self::array_to_hidden($array,$_POST ); return $r; } /** *transform $_REQUEST data to hidden *@param $array is an of indices *@see HtmlInput::request_to_hidden *@return html string with the hidden data */ static function request_to_hidden($array) { $r=self::array_to_hidden($array,$_REQUEST ); return $r; } /** *transform request data to string *@param $array is an of indices *@param $request name of the superglobal $_POST $_GET $_REQUEST(default) *@return html string with the string data */ static function array_to_string($array,$global_array ) { $r="?"; if ( count($global_array )==0) return ''; $and=""; foreach ($array as $a) { if (isset($global_array [$a])) $r.=$and."$a=".$global_array [$a]; $and="&"; } return $r; } /** *transform $_GET data to string *@param $array is an of indices *@see HtmlInput::request_to_string *@return html string with the string data */ static function get_to_string($array) { $r=self::array_to_string($array,$_GET ); return $r; } /** *transform $_POST data to string *@param $array is an of indices *@see HtmlInput::request_to_string *@return html string with the string data */ static function post_to_string($array) { $r=self::array_to_string($array,$_POST ); return $r; } /** *transform $_REQUEST data to string *@param $array is an of indices *@see HtmlInput::request_to_string *@return html string with the string data */ static function request_to_string($array) { $r=self::array_to_string($array,$_REQUEST ); return $r; } /** * generate an unique id for a widget, *@param $p_prefix prefix *@see HtmlInput::IDate *@return string with a unique id */ static function generate_id($p_prefix) { $r=sprintf('%s_%d',$p_prefix,mt_rand(0,999999)); return $r; } /** * return default if the value if the array doesn't exist *@param $ind the index to check *@param $default the value to return *@param $array the array */ static function default_value($ind,$default,$array) { if ( ! isset($array[$ind])) { return $default; } return $array[$ind]; } static function title_box($name,$div) { $r=HtmlInput::anchor_close($div); $r.=h2info($name); return $r; } }