60 $this->
name = $p_name;
62 $this->in_table =
false;
63 $this->
value = $p_value;
66 $this->filter =
'none';
78 $cn=Dossier::connect();
80 switch ($this->filter) {
82 $sql=
"select tva_code,tva_label
85 tva_purchase <> '#' and tva_sale <> '#'
89 $sql=
"select tva_code,tva_label
96 $sql=
"select tva_code,tva_label
103 $a_tva_code=
$cn->get_array(
$sql);
104 if ( empty($a_tva_code))
return "";
105 $r.=sprintf(
'<datalist id="dl_tva_%s"">',$this->
id);
106 foreach ($a_tva_code as $item) {
107 $r.=sprintf(
'<option value="%s">%s %s</option>'
108 ,$item[
'tva_code'],$item[
'tva_code']
109 ,htmlentities($item[
'tva_label']));
118 public function input($p_name =
null, $p_value =
null)
120 $this->
name = ($p_name ==
null) ? $this->
name : $p_name;
121 $this->
value = ($p_value ==
null) ? $this->
value : $p_value;
122 $this->
js = (isset($this->
js)) ? $this->
js :
'';
132 if (isset($this->code)) {
133 if ($this->
cn != NULL) {
134 $cnx=Dossier::connect();
137 $this->code->value = $cnx->get_value(
'select tva_label from tva_rate where tva_id=$1',
138 array($this->
value));;
141 $code = $this->code->input();
146 if ( self::$vat_code == 1) {
148 $cnx=Dossier::connect();
149 $this->
value=$cnx->get_value(
'select tva_code from tva_rate where tva_id=$1',[$this->
value]);
153 $str =
'<input type="TEXT" class="input_text" name="%s" value="%s" id="%s" placeholder="%s" size="6" %s %s
154list="dl_tva_%s" autocomplete="off">';
155 $r = sprintf(
$str, $this->
name, $this->
value, $this->
id,
_(
"C.TVA"),$this->
js, $get_attribute,$this->
id);
161 if ($this->
button ==
true && !$this->in_table)
164 if ($this->
button ==
true && $this->in_table)
195 if (trim($this->
name) ==
'')
throw new Exception (
_(
'Le nom ne peut ĂȘtre vide'));
200 $bt->tabindex =
"-1";
203 $bt->set_attribute(
'gDossier', dossier::id());
204 $bt->set_attribute(
'ctl', $this->
id);
205 $bt->set_attribute(
'popup',
'popup_tva');
206 if (isset($this->code))
207 $bt->set_attribute(
'jcode', $this->code->name);
208 if (isset($this->compute))
209 $bt->set_attribute(
'compute', $this->compute);
210 $bt->set_attribute(
"filter", $this->filter);
211 $bt->javascript = (isset($this->but_javascript)) ? $this->but_javascript :
'popup_select_tva(this)';
219 $cn = Dossier::connect();
222 $comment = ($tva->load() !=
"-1") ? $tva->tva_label :
"";
223 $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);
235 $this->code =
new ISpan($p_code);
247 throw new Exception(
"VAT_CODE [{$vat_code}]: invalide data",
EXC_INVALID);
255 $tva->with_button(
true);
257 $tva->add_label(
'code');
258 $tva->js =
'onchange="set_tva_label(this);"';
262 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.