26require_once NOALYSS_INCLUDE.
"/database/v_tva_rate_sql.class.php";
27require_once NOALYSS_INCLUDE.
"/database/tva_rate_sql.class.php";
48 parent::__construct($p_table);
58 [
"value"=>0,
"label"=>_(
"Non")],
59 [
"value"=>1,
"label"=>_(
"Oui")]
62 $this->
set_col_label(
"tva_payment_purchase",_(
"Exigible achat"));
65 array(
"value"=>
'O',
"label"=>
"Opération"),
66 array(
"value"=>
'P',
"label"=>
"Paiement")
72 array(
"value"=>
'O',
"label"=>
"Opération"),
73 array(
"value"=>
'P',
"label"=>
"Paiement")
76 $this->a_info=[
"tva_purchase"=>44,
"tva_both_side"=>43,
"tva_sale"=>45
77 ,
"tva_payment_sale"=>74,
"tva_payment_purchase"=>74];
78 $this->previous_id=
null;
106 $nb_order=count($this->a_order);
108 for (
$i=0;
$i<$nb_order;
$i++)
111 $key=$this->a_order[
$i];
112 $label=$this->a_label_displaid[$key];
120 if ( isset($this->a_info[$key])) {
124 echo
"<td> {$label} {$info} {$error}</td>";
129 if ($this->a_type[$key]==
"select")
132 $select->value=$this->a_select[$key];
142 $text->size=$min_size;
145 elseif ($key==
'tva_purchase')
150 $text->size=$min_size;
152 $text->set_attribute(
'jrn', 0);
153 $text->set_attribute(
'account',
'tva_purchase');
155 $url=
"do.php?".http_build_query(array(
"gDossier"=>
Dossier::id(),
"ac"=>
'CFGPCMN',
'p_start'=>4));
164 $text->set_attribute(
'jrn', 0);
165 $text->set_attribute(
'account',
'tva_sale');
166 $text->size=$min_size;
169 elseif ($this->a_type[$key]==
"text")
174 $text->size=$min_size;
176 }
elseif ($key ==
"tva_id") {
179 echo \HtmlInput::hidden(
"old_tva_id",
$value);
186 printf(
'<td>%s %s</td>',
h(
$value),
204 if ( $this->previous_id ==
null ) {
205 throw new \Exception (
"TVA184: no previous TVA id");
210 if ($this->
table->tva_both_side==1)
212 if ($this->
table->tva_purchase==
"#"||trim($this->
table->tva_purchase)
215 $this->
table->tva_purchase=$this->
table->tva_sale;
217 if ($this->
table->tva_sale==
"#"||trim($this->
table->tva_sale)==
"#")
219 $this->
table->tva_sale=$this->
table->tva_purchase;
222 $new_tva_id=$this->
table->tva_id;
231 $tva_purchase=(trim($this->
table->tva_purchase)==
"")?
"#":$this->
table->tva_purchase;
232 $tva_sale=(trim($this->
table->tva_sale)==
"")?
"#":$this->
table->tva_sale;
233 $tva_rate->setp(
"tva_poste", $tva_purchase.
",".$tva_sale);
234 $tva_rate->setp(
"tva_payment_sale", $this->
table->tva_payment_sale);
235 $tva_rate->setp(
"tva_payment_purchase", $this->
table->tva_payment_purchase);
236 if ( $this->previous_id == -1 ) {
241 if ( $this->previous_id != - 1 && $this->previous_id != $new_tva_id) {
242 $cn->exec_sql(
"update tva_rate set tva_id = $1 where tva_id = $2",[$new_tva_id,$this->previous_id]);
243 $this->
table->setp(
"tva_id",$new_tva_id);
257 if ( $this->previous_id ==
null ) {
258 throw new \Exception (
"TVA184: no previous TVA id");
261 if (trim($this->
table->tva_purchase)==
""&&trim($this->
table->tva_sale)==
"")
264 _(
"Les 2 postes comptables ne peuvent être nuls"));
266 _(
"Les 2 postes comptables ne peuvent être nuls"));
270 if (trim($this->
table->tva_rate)==
""||
isNumber($this->
table->tva_rate)==0||$this->table->tva_rate>1)
272 $this->
set_error(
"tva_rate", _(
"Taux de TVA invalide"));
276 $count=
$cn->get_value(
"select count(*) from tva_rate where tva_id<>$1 and lower(tva_label)=lower($2)",
280 $this->
set_error(
"tva_label", _(
"Ce nom est déjà utilisé"));
284 if (trim($this->
table->tva_purchase)!=
""&&$this->table->tva_purchase!=
"#")
286 $count=
$cn->get_value(
"select count(*) from tmp_pcmn where pcm_val = $1",
287 [$this->
table->tva_purchase]);
290 $this->
set_error(
"tva_purchase", _(
"Poste comptable inexistant"));
294 if (trim($this->
table->tva_sale)!=
""&&$this->table->tva_sale!=
"#")
296 $count=
$cn->get_value(
"select count(*) from tmp_pcmn where pcm_val = $1",
297 [$this->
table->tva_sale]);
300 $this->
set_error(
"tva_sale", _(
"Poste comptable inexistant"));
305 if ($this->
table->tva_both_side!=0&&$this->table->tva_both_side!=1)
307 $this->
set_error(
"tva_both_side", _(
"Choix incorrect"));
310 if (
isNumber($this->
table->tva_id) == 0 || $this->table->tva_id != round($this->
table->tva_id) )
312 $this->
set_error(
"tva_id",_(
"Valeur invalide"));
316 if (
$flag && $this->previous_id != $this->
table->tva_id &&
$cn->get_value(
"select count(*) from tva_rate where tva_id=$1",[$this->table->tva_id]) > 0)
318 $this->
set_error(
"tva_id",_(
"Code TVA déjà utilisé"));
332 $count_purchase=
$cn->get_value(
"select count(*) from quant_purchase where qp_vat_code = $1",[$this->
table->tva_id]);
333 $count_sale=
$cn->get_value(
"select count(*) from quant_sold where qs_vat_code = $1",[$this->
table->tva_id]);
334 if ( $count_purchase > 0 || $count_sale > 0) {
335 throw new Exception(_(
"Effacement interdit : TVA utilisée"));
339 $count=
$cn->get_value(
"select count(*) from tva_rate");
341 throw new Exception(_(
"Vous ne pouvez pas effacer tous les taux. Si votre société n'utilise pas la TVA, changer dans le menu société"));
343 $cn->exec_sql(
"delete from tva_rate where tva_id=$1", [$this->
table->tva_id]);
h( $row[ 'oa_description'])
catch(Exception $e) $tva_rate
static id()
return the 'gDossier' value after a check
This class handles only the numeric input, the input will call a javascript to change comma to period...
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
count_error()
returns the nb of errors found
get_property_updatable($p_key)
return True if the column is updatable otherwise false
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_col_type($p_key, $p_value, $p_array=NULL)
set the type of a column , it will change in the input db box , the select must supply an array of po...
get_property_visible($p_key)
return True if the column is visible otherwise false
get_error($p_col)
retrieve the error message
set_error($p_col, $p_message)
set the error message for a wrong input
set_col_label($p_key, $p_display)
set the name to display for a column
Configure the tva : code , rate, label ... When using Manage_Table_SQL.
$previous_id
< previous tva_id, used to know if we update or insert,
__construct(V_Tva_rate_SQL $p_table)
input()
display into a dialog box the datarow in order to be appended or modified.
save()
save the data in TVA_RATE if tva_both_side is 1 and tva_purchase or tva_sale is empty then it is equa...
check()
Check data are valid.
setPreviousId($previous_id)
abstract of the table public.tva_rate
if( $delta< 0) elseif( $delta==0)