set_title('Choix de la tva'); * echo $a->input(); * $tva=new ITva_Popup("tva1"); * $tva->with_button(true); * // You must add the attributes gDossier, popup * $tva->set_attribute('popup','popup_tva'); * $tva->set_attribute('gDossier',dossier::id()); * * // We can add a label for the code * $tva->add_label('code'); * $tva->js='onchange="set_tva_label(this);"'; * echo $tva->input(); * @endcode */ class ITva_Popup extends HtmlInput { /** * @brief by default, the p_name is the name/id of the input type * the this->button is false (control if a button is visible) and * this->in_table=false (return the widget inside a table) * this->code is a span widget to display the code (in this case, you will * to set this->cn as database connexion) * to have its own javascript for the button you can use this->but_javascript) * by default it is 'popup_select_tva(this)'; */ private $filter; //!< filter the VAT by ledger PURCHASE or SALE or NO FILTER, default=NO public function __construct($p_name = null, $p_value = "", $p_id = "") { $this->name = $p_name; $this->button = true; $this->in_table = false; $this->value = $p_value; $this->id = $p_id; $this->filter = 'none'; } function with_button($p) { if ($p == true) $this->button = true; else $this->button = false; } /*!\brief show the html input of the widget*/ public function input($p_name = null, $p_value = null) { $this->name = ($p_name == null) ? $this->name : $p_name; $this->value = ($p_value == null) ? $this->value : $p_value; $this->js = (isset($this->js)) ? $this->js : ''; $this->id = ($this->id == "") ? $this->name : $this->id; if ($this->readOnly == true) return $this->display(); $this->set_attribute('gDossier', dossier::id()); $this->set_attribute('ctl', $this->name); $code=""; // code is a span containing the label of the VAT (see add_label) if (isset($this->code)) { if ($this->cn != NULL) { /* check if tva_id == integer */ if (trim($this->value) != '' && isNumber($this->value) == 1 && strpos($this->value, ',') === false) $this->code->value = $this->cn->get_value('select tva_label from tva_rate where tva_id=$1', array($this->value));; } $this->set_attribute('jcode', $this->code->name); $code = $this->code->input(); } $strAttribut = $this->get_node_attribute(); $str = ''; $r = sprintf($str, $this->name, $this->value, $this->id, $this->js, $strAttribut); $r.=$code; if ($this->in_table) $table = '