60 $this->
name = $p_name;
62 $this->in_table =
false;
63 $this->
value = $p_value;
65 $this->filter =
'none';
77 $cn=Dossier::connect();
79 switch ($this->filter) {
81 $sql=
"select tva_code,tva_label
84 tva_purchase <> '#' and tva_sale <> '#'
88 $sql=
"select tva_code,tva_label
95 $sql=
"select tva_code,tva_label
102 $a_tva_code=
$cn->get_array(
$sql);
103 if ( empty($a_tva_code))
return "";
104 $r.=sprintf(
'<datalist id="dl_tva_%s"">',$this->
id);
105 foreach ($a_tva_code as $item) {
106 $r.=sprintf(
'<option value="%s">%s %s</option>'
107 ,$item[
'tva_code'],$item[
'tva_code']
108 ,htmlentities($item[
'tva_label']));
117 public function input($p_name =
null, $p_value =
null)
119 $this->
name = ($p_name ==
null) ? $this->
name : $p_name;
120 $this->
value = ($p_value ==
null) ? $this->
value : $p_value;
121 $this->
js = (isset($this->
js)) ? $this->
js :
'';
131 if (isset($this->code)) {
132 if ($this->
cn != NULL) {
133 $cnx=Dossier::connect();
136 $this->code->value = $cnx->get_value(
'select tva_label from tva_rate where tva_id=$1',
137 array($this->
value));;
140 $code = $this->code->input();
145 if ( self::$vat_code == 1) {
147 $cnx=Dossier::connect();
148 $this->
value=$cnx->get_value(
'select tva_code from tva_rate where tva_id=$1',[$this->
value]);
152 $str =
'<input type="TEXT" class="input_text" name="%s" value="%s" id="%s" placeholder="%s" size="6" %s %s
153list="dl_tva_%s" autocomplete="off">';
154 $r = sprintf(
$str, $this->
name, $this->
value, $this->
id,
_(
"C.TVA"),$this->
js, $strAttribut,$this->
id);
160 if ($this->
button ==
true && !$this->in_table)
163 if ($this->
button ==
true && $this->in_table)
194 if (trim($this->
name) ==
'')
throw new Exception (
_(
'Le nom ne peut ĂȘtre vide'));
199 $bt->tabindex =
"-1";
202 $bt->set_attribute(
'gDossier', dossier::id());
203 $bt->set_attribute(
'ctl', $this->
id);
204 $bt->set_attribute(
'popup',
'popup_tva');
205 if (isset($this->code))
206 $bt->set_attribute(
'jcode', $this->code->name);
207 if (isset($this->compute))
208 $bt->set_attribute(
'compute', $this->compute);
209 $bt->set_attribute(
"filter", $this->filter);
210 $bt->javascript = (isset($this->but_javascript)) ? $this->but_javascript :
'popup_select_tva(this)';
218 $cn = Dossier::connect();
221 $comment = ($tva->load() !=
"-1") ? $tva->tva_label :
"";
222 $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);
234 $this->code =
new ISpan($p_code);
246 throw new Exception(
"VAT_CODE [{$vat_code}]: invalide data",
EXC_INVALID);
254 $tva->with_button(
true);
256 $tva->add_label(
'code');
257 $tva->js =
'onchange="set_tva_label(this);"';
261 echo $tva->dbutton();
td($p_string='', $p_extra='')
surround the string with td
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.