27 require_once(
'class_listing.php');
28 require_once(NOALYSS_INCLUDE.
'/class/class_fiche.php');
29 require_once(
'class_tva_parameter.php');
34 "date_decl"=>
"date_decl",
35 "start_periode"=>
"start_periode",
36 "end_periode"=>
"end_periode",
37 "xml_file"=>
"xml_file",
42 "flag_periode"=>
"flag_periode",
43 "exercice"=>
"exercice",
44 "periode_dec"=>
"periode_dec"
49 if( isset($p_array[
'name_child'])) {
50 $name=$p_array[
'name_child'];
51 $qcode=$p_array[
'qcode'];
52 $code=$p_array[
'tvacode'];
53 $tva_num=$p_array[
'tva_num_child'];
58 for ($i=0;$i<count(
$name);$i++){
60 $child->set_parameter(
'amount',
$amount[$i]);
61 $child->set_parameter(
'periode',
$periode[$i]);
62 $child->set_parameter(
'qcode',$qcode[$i]);
63 $child->set_parameter(
'code',$code[$i]);
64 $child->set_parameter(
'name_child',
$name[$i]);
65 $child->set_parameter(
'tva_num',$tva_num[$i]);
71 $this->aChild=array();
73 $this->start_periode=$p_array[
'start_periode'];
74 $this->end_periode=$p_array[
'end_periode'];
75 $this->flag_periode=$p_array[
'flag_periode'];
76 $this->tva_name=$p_array[
'name'];
77 $this->num_tva=$p_array[
'num_tva'];
78 $this->adress=$p_array[
'adress'];
79 $this->country=$p_array[
'country'];
80 $this->periode_dec=$p_array[
'periode_dec'];
81 $this->exercice=$p_array[
'exercice'];
85 $r=
'<form class="print" id="readonly">';
87 $r.=HtmlInput::request_to_hidden(array(
'ac'));
90 $js_remove=sprintf(
"onclick=\"if ( confirm('%s')){remove_form('%s',%d,%d,'li');}\"",
91 "Vous confirmez vouloir effacer ?",
96 $r.=HtmlInput::button(
'Effacer',
'Effacer',$js_remove);
97 $r.= create_script(
"$('readonly').disable();");
101 $sql=
"select * from tva_belge.intracomm where i_id=$1";
103 $res=$this->db->get_array(
107 if ( $this->db->count() == 0 )
return 0;
108 foreach (
$res[0] as $idx=>$value) { $this->$idx=$value; }
110 $sql=
"select * from tva_belge.intracomm_chld where i_id=$1";
111 $res=$this->db->get_array(
115 $nb=$this->db->count();
118 for ($i=0;$i<$nb;$i++){
120 foreach (
$res[$i] as $idx=>$value){
137 INSERT INTO tva_belge.intracomm(
138 start_date, end_date, periodicity, tva_name,
139 num_tva, adress, country, periode_dec,exercice)
140 VALUES (to_date($1,
'DD.MM.YYYY'),to_date($2,
'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9) returning i_id;
142 $this->i_id=$this->db->get_value(
$sql,
144 $this->start_periode,
156 for ($e=0;$e<count($this->aChild);$e++){
157 $this->aChild[$e]->set_parameter(
'depend',$this->i_id);
158 $this->aChild[$e]->insert();
168 $code_customer=
new Acc_Parm_Code($this->db);
169 $code_customer->p_code=
'CUSTOMER';
170 $code_customer->load();
173 if (trim(
$a)==
'')
$a=-1;
175 select sum(j_montant) as amount,j_qcode
177 where j_grpt in (select distinct j_grpt from quant_sold join jrnx
using (j_id) where qs_vat_code in (
$a) )
178 and j_poste::text like $1||
'%'
179 and (j_date >= to_date($2,
'DD.MM.YYYY') and j_date <= to_date($3,
'DD.MM.YYYY'))
183 $all=$this->db->get_array(
$sql,array($code_customer->p_value,
184 $this->start_periode,
191 for ($i=0;$i<count($all);$i++){
193 $child->set_parameter(
'amount',$all[$i][
'amount']);
194 switch ($this->flag_periode) {
197 $child->set_parameter(
'periode',sprintf(
'%02d%s',$this->periode_dec,$this->exercice));
201 $child->set_parameter(
'periode',sprintf(
'3%d%s',$this->periode_dec,$this->exercice));
205 $child->set_parameter(
'periode',sprintf(
'00%s',$this->periode_dec,$this->exercice));
209 $child->set_parameter(
'qcode',$all[$i][
'j_qcode']);
210 $fiche=
new Fiche($this->db);
211 $fiche->get_by_qcode($all[$i][
'j_qcode'],
false);
212 $num_tva=
$fiche->strAttribut(ATTR_DEF_NUMTVA);
214 if ( trim($num_tva) ===
"") {
continue;}
215 $child->set_parameter(
'tva_num',$num_tva);
217 $child->set_parameter(
'name_child',
$fiche->strAttribut(ATTR_DEF_NAME));
218 $child->set_parameter(
'code',
'L');
228 $res=
'<fieldset><legend>Listing</legend>';
230 $res.=
'<table id="tb_dsp" class="result" style="width:80%;">';
231 $clean=
new IButton();
232 $clean->label=
'Efface ligne';
233 $clean->javascript=
"deleteRow('tb_dsp',this);";
238 $r.=th(
'Code Pays et numéro de TVA');
239 $r.=th(
'Code Pays et numéro de TVA');
245 for ($i=0;$i<count($this->aChild);$i++) {
247 $b=
new IText(
'name_child[]',$this->aChild[$i]->
get_parameter(
'name_child'));
248 $c=
new IText(
'tva_num_child[]',$this->aChild[$i]->
get_parameter(
'tva_num'));
249 $d=
new IText(
'tvacode[]',$this->aChild[$i]->
get_parameter(
'code'));
250 $e=
new INum(
'amount[]',$this->aChild[$i]->
get_parameter(
'amount'));
260 if (! $p_readonly)
$r.=td($clean->input());
284 "tva_num"=>
"ic_tvanum",
285 "amount"=>
"ic_amount",
287 "periode"=>
"ic_periode",
290 "name_child"=>
'ic_name'
294 INSERT INTO tva_belge.intracomm_chld(
295 i_id, ic_tvanum, ic_amount, ic_code, ic_periode, ic_qcode,
297 VALUES ($1, $2, $3, $4, $5, $6, $7) returning ic_id;
299 $this->ic_id=$this->db->get_value(
$sql,array(
display_info()
display the information about the company
display_declaration_amount($p_readonly=false)
if(isset($_POST['remove'])) $array