[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 04/12: INUM , IText and ITVAPopup add the att
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 04/12: INUM , IText and ITVAPopup add the attribute (for javascript) |
Date: |
Wed, 16 Nov 2022 14:39:14 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 450dd54a72512e5a949306dc8f13a0899cf08d3f
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Nov 6 20:20:29 2022 +0100
INUM , IText and ITVAPopup add the attribute (for javascript)
---
include/lib/inum.class.php | 7 +-
include/lib/itext.class.php | 12 ++-
include/lib/itva_popup.class.php | 199 ++++++++++++++++++++-------------------
3 files changed, 116 insertions(+), 102 deletions(-)
diff --git a/include/lib/inum.class.php b/include/lib/inum.class.php
index 20ac4dddc..28a50825e 100644
--- a/include/lib/inum.class.php
+++ b/include/lib/inum.class.php
@@ -92,12 +92,13 @@ class INum extends IText
$extra=(isset($this->extra))?$this->extra:"";
$this->value=str_replace('"', '', $this->value);
- if (!isset($this->css_size))
+ $strAttribute=$this->get_node_attribute();
+ if (!isset($this->css_size) || empty ($this->css_size))
{
$r='<INPUT '.$this->style.' TYPE="TEXT" id="'.
$this->id.'"'.$t.
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
- 'SIZE="'.$this->size.'" '.$this->javascript."
$this->extra >";
+ 'SIZE="'.$this->size.'" '.$this->javascript."
$this->extra $strAttribute >";
/* add tag for column if inside a table */
}
else
@@ -105,7 +106,7 @@ class INum extends IText
$r='<INPUT '.$this->style.' TYPE="TEXT" id="'.
$this->id.'"'.$t.
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
- ' style="width:'.$this->css_size.';" '.$this->javascript."
$this->extra >";
+ ' style="width:'.$this->css_size.';" '.$this->javascript."
$this->extra $strAttribute >";
}
if ($this->table==1)
diff --git a/include/lib/itext.class.php b/include/lib/itext.class.php
index ffc340577..08f1d377d 100644
--- a/include/lib/itext.class.php
+++ b/include/lib/itext.class.php
@@ -53,6 +53,8 @@ class IText extends HtmlInput
// Double quote makes troubles
$this->value=noalyss_str_replace('"','',$this->value);
+ // compute attribute used by javascript
+ $strAttribute=$this->get_node_attribute();
$t= 'title="'.$this->title.'" ';
$autofocus=($this->autofocus)?" autofocus ":"";
$require=($this->require)?"required":"";
@@ -60,7 +62,7 @@ class IText extends HtmlInput
{
$r= sprintf('<INPUT TYPE="TEXT" %s id="%s" name="%s" value="%s"
placeholder="%s" title="%s"
- Size="%s" %s %s %s %s>
+ Size="%s" %s %s %s %s %s>
',$this->style,
$this->id,
$this->name,
@@ -71,11 +73,12 @@ class IText extends HtmlInput
$this->javascript,
$this->extra,
$autofocus,
- $require
+ $require,
+ $strAttribute
);
} else {
$r= sprintf('<INPUT TYPE="TEXT" %s id="%s" name="%s" value="%s"
placeholder="%s" title="%s"
- style="width:%s;" %s %s %s %s>
+ style="width:%s;" %s %s %s %s %s>
',$this->style,
$this->id,
$this->name,
@@ -86,7 +89,8 @@ class IText extends HtmlInput
$this->javascript,
$this->extra,
$autofocus,
- $require
+ $require,
+ $strAttribute
);
}
diff --git a/include/lib/itva_popup.class.php b/include/lib/itva_popup.class.php
index 5181c3d1b..0f3913f6a 100644
--- a/include/lib/itva_popup.class.php
+++ b/include/lib/itva_popup.class.php
@@ -22,28 +22,29 @@
/*!\file
* \brief Html Input
*/
+
/**
- *@brief let you choose a TVA in a popup
- *@code
- $a=new IPopup('popup_tva');
- $a->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
-*/
+ * @brief let you choose a TVA in a popup
+ * @code
+ * $a=new IPopup('popup_tva');
+ * $a->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
+ * @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
@@ -52,137 +53,145 @@ class ITva_Popup extends HtmlInput
* 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="")
+
+ 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';
+ $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;
+ if ($p == true)
+ $this->button = true;
else
- $this->button=false;
+ $this->button = false;
}
+
/*!\brief show the html input of the widget*/
- public function input($p_name=null,$p_value=null)
+ 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();
-
- $str='<input type="TEXT" class="input_text" name="%s" value="%s"
id="%s" size="3" %s>';
- $r=sprintf($str,$this->name,$this->value,$this->id,$this->js);
-
- if ($this->in_table)
- $table='<table>'.'<tr>'.td($r);
+ $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();
- if ( $this->button==true && ! $this->in_table)
- $r.=$this->dbutton();
+ $this->set_attribute('gDossier', dossier::id());
+ $this->set_attribute('ctl', $this->name);
- if ( $this->button==true && $this->in_table)
- $r=$table.td($this->dbutton()).'</tr></table>';
+ $code="";
- if ( isset($this->code))
- {
- if ( $this->cn != NULL)
- {
+ // 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));
- ;
+ 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));;
}
- $r.=$this->code->input();
- if ($this->table==1) $r=td($r);
- $this->set_attribute('jcode',$this->code->name);
- $this->set_attribute('gDossier',dossier::id());
- $this->set_attribute('ctl',$this->name);
- $r.=$this->get_js_attr();
+ $this->set_attribute('jcode', $this->code->name);
+ $code = $this->code->input();
}
+ $strAttribut = $this->get_node_attribute();
+
+ $str = '<input type="TEXT" class="input_text" name="%s" value="%s"
id="%s" size="3" %s %s>';
+ $r = sprintf($str, $this->name, $this->value, $this->id, $this->js,
$strAttribut);
+ $r.=$code;
+ if ($this->in_table)
+ $table = '<table>' . '<tr>' . td($r);
+
+ if ($this->button == true && !$this->in_table)
+ $r .= $this->dbutton();
+
+ if ($this->button == true && $this->in_table)
+ $r = $table . td($this->dbutton()) . '</tr></table>';
+
+ if ($this->table == 1) $r = td($r);
return $r;
}
+
/**
- * Set a filter to limit the choice of VAT ;
- * possible values are :
+ * Set a filter to limit the choice of VAT ;
+ * possible values are :
* - sale if there is an accounting for sale
* - purchase if there is an accounting for purchase
- * - none : show VAT
- *
+ * - none : show VAT
+ *
*/
function set_filter($p_filter)
{
- $this->filter=$p_filter;
+ $this->filter = $p_filter;
}
+
/**
- *@brief show a button, if it is pushed show a popup to select the need vat
- *@note
+ * @brief show a button, if it is pushed show a popup to select the need
vat
+ * @note
* - a ipopup must be created before with the name popup_tva
* - the javascript noalyss_script.js must be loaded
- *@return string with html code
+ * @return string with html code
*/
function dbutton()
{
- if( trim($this->name)=='') throw new Exception (_('Le nom ne peut ĂȘtre
vide'));
- $this->id=($this->id=="")?$this->name:$this->id;
+ if (trim($this->name) == '') throw new Exception (_('Le nom ne peut
ĂȘtre vide'));
+ $this->id = ($this->id == "") ? $this->name : $this->id;
// button
- $bt=new ISmallButton('bt_'.$this->id);
- $bt->tabindex="-1";
- $bt->label=_(' TVA ');
- $bt->set_attribute('gDossier',dossier::id());
- $bt->set_attribute('ctl',$this->id);
- $bt->set_attribute('popup','popup_tva');
- if ( isset($this->code))
- $bt->set_attribute('jcode',$this->code->name);
- if ( isset($this->compute))
- $bt->set_attribute('compute',$this->compute);
+ $bt = new ISmallButton('bt_' . $this->id);
+ $bt->tabindex = "-1";
+ $bt->label = _(' TVA ');
+ $bt->set_attribute('gDossier', dossier::id());
+ $bt->set_attribute('ctl', $this->id);
+ $bt->set_attribute('popup', 'popup_tva');
+ if (isset($this->code))
+ $bt->set_attribute('jcode', $this->code->name);
+ if (isset($this->compute))
+ $bt->set_attribute('compute', $this->compute);
$bt->set_attribute("filter", $this->filter);
-
$bt->javascript=(isset($this->but_javascript))?$this->but_javascript:'popup_select_tva(this)';
- $r=$bt->input();
+ $bt->javascript = (isset($this->but_javascript)) ?
$this->but_javascript : 'popup_select_tva(this)';
+ $r = $bt->input();
return $r;
}
/*!\brief print in html the readonly value of the widget*/
public function display()
{
- $cn= Dossier::connect();
- $tva=new Acc_Tva($cn, $this->value);
-
- $comment=($tva->load() != "-1")? $tva->tva_label:"";
- $res=sprintf('<input type="text" name="%s" size="6"
class="input_text_ro" value="%s" id="%s"
readonly="">%s',$this->name,$this->value,$this->name,$comment);
+ $cn = Dossier::connect();
+ $tva = new Acc_Tva($cn, $this->value);
+
+ $comment = ($tva->load() != "-1") ? $tva->tva_label : "";
+ $res = sprintf('<input type="text" name="%s" size="6"
class="input_text_ro" value="%s" id="%s" readonly="">%s', $this->name,
$this->value, $this->name, $comment);
return $res;
}
+
/**
- *@brief add a field to show the selected tva's label
- *@param $p_code is the name of the label where you can see the label of
VAT
- *@param $p_cn is a database connection if NULL it doesn't seek in the
database
+ * @brief add a field to show the selected tva's label
+ * @param $p_code is the name of the label where you can see the label of
VAT
+ * @param $p_cn is a database connection if NULL it doesn't seek in the
database
*/
- public function add_label($p_code,$p_cn=null)
+ public function add_label($p_code, $p_cn = null)
{
- $this->cn=$p_cn;
- $this->code=new ISpan($p_code);
+ $this->cn = $p_cn;
+ $this->code = new ISpan($p_code);
}
+
static public function test_me()
{
- $a=new IPopup('popup_tva');
+ $a = new IPopup('popup_tva');
$a->set_title('Choix de la tva');
echo $a->input();
- $tva=new ITva_Popup("tva1");
+ $tva = new ITva_Popup("tva1");
$tva->with_button(true);
// We can add a label for the code
$tva->add_label('code');
- $tva->js='onchange="set_tva_label(this);"';
+ $tva->js = 'onchange="set_tva_label(this);"';
echo $tva->input();
echo $tva->dbutton();
}
- [Noalyss-commit] [noalyss] branch master updated (7749f97eb -> 1a1bcd567), Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 02/12: code cleaning : rename search_poste to search_accounting, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 03/12: TVA javascript : add callback function, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 08/12: Set current user in PostGresql session (config) so it can be directly used directly by triggers and pgplsql to track user's changes, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 09/12: Fix typo due to code cleaning, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 06/12: Add function __toString, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 04/12: INUM , IText and ITVAPopup add the attribute (for javascript),
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 01/12: WYSIWYG Editor integration and improve of waiting_box, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 05/12: set require to falser and add function __toString, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 10/12: useless file, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 11/12: Clean code : dead code, improve debug, comments, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 12/12: Save the current user in a PostgreSQL session variable noalyss.user_login, Dany De Bontridder, 2022/11/16
- [Noalyss-commit] [noalyss] 07/12: Tag : add color when selected, Dany De Bontridder, 2022/11/16