Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes
Ext_List_Assujetti Class Reference
Inheritance diagram for Ext_List_Assujetti:
Inheritance graph
Collaboration diagram for Ext_List_Assujetti:
Collaboration graph

Public Member Functions

 from_array ($p_array)
 
 display ()
 
 load ()
 
 verify ()
 
 insert ()
 
 update ()
 
 compute ()
 
 display_declaration_amount ($readonly=false)
 
 find_tva_code ($p_array)
 
 get_parameter ($p_string)
 
 set_parameter ($p_string, $p_value)
 
 get_info ()
 
 save ()
 
 blank ($p_year, $p_periode, $p_flag_quaterly)
 
 display_info ()
 display the information about the company More...
 

Static Public Member Functions

static choose_periode ($by_year=false)
 

Protected Attributes

 $variable
 

Private Attributes

 $aChild =array()
 

Detailed Description

Definition at line 30 of file class_ext_list_assujetti.php.

Member Function Documentation

Ext_Tva_Gen::blank (   $p_year,
  $p_periode,
  $p_flag_quaterly 
)
inherited

Definition at line 132 of file class_ext_tvagen.php.

References $GLOBALS, $p_year, and Ext_Tva_Gen\set_parameter().

132  {
133  // load parameter from myown
134  $own=new Own($this->db);
135  $this->set_parameter("name",$own->MY_NAME);
136  $this->set_parameter("num_tva",$own->MY_TVA);
137  $this->set_parameter('adress',$own->MY_STREET.",".$own->MY_NUMBER);
138  $this->set_parameter('country',$own->MY_COUNTRY." ".$own->MY_CP." ".$own->MY_COMMUNE);
139  $this->set_parameter('flag_periode',$p_flag_quaterly);
140  $this->set_parameter('periode_dec',$p_periode);
141  $this->set_parameter('exercice',$p_year);
142 
143  try {
144  $this->verify() ;
145  } catch ( Exception $e) {
146  echo $e->getMessage();
147  throw $e;
148  }
149  // by month
150  if ( $p_flag_quaterly == 1) {
151  // start periode = 01 to 31, $p_periode contains the month
152  $per_start="01.".$p_periode.".".$p_year;
153  $day=31;
154  $per_end="31".".".$p_periode.".".$p_year;
155  while ( checkdate($p_periode,$day,$p_year) == false && $day > 25) {
156  $day--;
157  $per_end=$day.".".$p_periode.".".$p_year;
158  }
159  if ($day < 28 ) { echo __FILE__.__LINE__." Erreur de date $day"; exit;}
160  }
161 
162  if ( $p_flag_quaterly == 2 ) {
163  // compute start periode
164  $per_start=$GLOBALS['quaterly_limit'][$p_periode][0].".".$p_year;
165  $per_end=$GLOBALS['quaterly_limit'][$p_periode][1].".".$p_year;
166 
167  }
168  if ( $p_flag_quaterly == 3 ) {
169  // compute start periode
170  $per_start='01.01.'.$p_year;
171  $per_end='31.12.'.$p_year;
172  }
173 
174  $this->set_parameter('start_periode',$per_start);
175  $this->set_parameter('end_periode',$per_end);
176 
177  }
$GLOBALS['quaterly_limit']
set_parameter($p_string, $p_value)
static Ext_List_Assujetti::choose_periode (   $by_year = false)
static

Definition at line 46 of file class_ext_list_assujetti.php.

References $_REQUEST, $r, $str_hidden, $str_submit, $str_year, and $year.

46  {
47 
48  // year
49  $year = new IText('year');
50  $year->size=4;
51  $str_year=$year->input();
52 
53 
54  $str_submit=HtmlInput::submit('decl',_('Afficher'));
55  $str_hidden=HtmlInput::extension().dossier::hidden();
56  if (isset($_REQUEST['sa']))
57  $str_hidden.=HtmlInput::hidden('sa',$_REQUEST['sa']);
58  $r='<form class="print" method="get">';
59  $r.="Année :".$str_year;
60  $r.=$str_submit;
61  $r.=$str_hidden;
62  $r.=HtmlInput::request_to_hidden(array('ac'));
63  $r.='</form>';
64  return $r;
65  }
$r
$_REQUEST['sb']
Definition: am_print.php:39
Ext_List_Assujetti::compute ( )

Definition at line 183 of file class_ext_list_assujetti.php.

References $a, $amount, $array, $fiche, $sql, and Listing\find_tva_code().

183  {
184  /* retrieve accounting customer */
185  $code_customer=new Acc_Parm_Code($this->db);
186  $code_customer->p_code='CUSTOMER';
187  $code_customer->load();
188  $a=$this->find_tva_code('ASSUJETTI');
189  if (trim($a)=='') $a=-1;
190  $sql=<<<EOF
191  select sum(j_montant) as amount,j_qcode
192  from jrnx
193  where j_grpt in (select distinct j_grpt from quant_sold join jrnx using (j_id) where qs_vat_code in ($a) )
194  and j_poste::text like $1||'%'
195  and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date($3,'DD.MM.YYYY'))
196  group by j_qcode
197 EOF;
198  // get all of them
199  $all=$this->db->get_array($sql,array($code_customer->p_value,
200  $this->start_periode,
201  $this->end_periode
202  )
203  );
204  $array=array();
205 
206  // retrieve missing and compute an array
207  for ($i=0;$i<count($all);$i++){
208  $child=new Ext_List_Assujetti_Child($this->db);
209 
210 
211  $child->set_parameter('qcode',$all[$i]['j_qcode']);
212  $fiche=new Fiche($this->db);
213  $fiche->get_by_qcode($all[$i]['j_qcode'],false);
214  $num_tva=$fiche->strAttribut(ATTR_DEF_NUMTVA);
215  $child->set_parameter('tva_num',$num_tva);
216  $sq="select sum(qs_vat) from quant_sold
217 where qs_client = $1 and j_id in (select distinct j_id from jrnx where j_date >= to_date($2,'DD.MM.YYYY')
218  and j_date <= to_date($3,'DD.MM.YYYY')
219  )
220  and qs_vat_code in ($a)
221 ";
222  // if in the same operation, we use 2 different tva code, the amount is incorrect if one of them is
223  // excluded
224  $exclude="select coalesce(sum(qs_price),0) from quant_sold
225 where qs_client = $1 and j_id in (select distinct j_id from jrnx where j_date >= to_date($2,'DD.MM.YYYY')
226  and j_date <= to_date($3,'DD.MM.YYYY')
227  )
228  and qs_vat_code not in ($a)
229 ";
230  $excl=$this->db->get_value($exclude,array($fiche->id,
231  $this->start_periode,
232  $this->end_periode));
233  $amount_vat=$this->db->get_value($sq,array($fiche->id,
234  $this->start_periode,
235  $this->end_periode));
236  $amount=$all[$i]['amount']-$amount_vat-$excl;
237  $child->set_parameter('amount',$amount);
238  $child->set_parameter('amount_vat',$amount_vat);
239 
240  $child->set_parameter('name_child',$fiche->strAttribut(ATTR_DEF_NAME));
241 
242  $array[]=$child;
243  }//end for
244  $this->aChild=$array;
245  }
for($i=0;$i<$max;$i++)
Definition: test_file.php:62
if(isset($_POST['remove'])) $array
find_tva_code($p_array)
$sql
Ext_List_Assujetti::display ( )

Definition at line 101 of file class_ext_list_assujetti.php.

References $_REQUEST, $r, a_id, display_declaration_amount(), Ext_Tva_Gen\display_info(), and id.

101  {
102  $r= '<form class="print" id="readonly">';
103  $r.=HtmlInput::request_to_hidden(array('ac'));
104  $r.=$this->display_info();
105  $r.=$this->display_declaration_amount(true);
106  $r.='</form>';
107  $js_remove=sprintf("onclick=\"if ( confirm('%s')){remove_form('%s',%d,%d,'lc');}\"",
108  "Vous confirmez vouloir effacer ?",
109  $_REQUEST['plugin_code'],
110  dossier::id(),
111  $this->a_id);
112  $r.=HtmlInput::button('Effacer','Effacer',$js_remove);
113 
114  $r.= create_script("$('readonly').disable();");
115  return $r;
116  }
$select_type id
$r
display_info()
display the information about the company
$_REQUEST['sb']
Definition: am_print.php:39
display_declaration_amount($readonly=false)
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id
Ext_List_Assujetti::display_declaration_amount (   $readonly = false)
Todo:
finish it

Definition at line 249 of file class_ext_list_assujetti.php.

References $a, $amount, $r, $res, and Ext_Tva_Gen\get_parameter().

Referenced by display().

249  {
250  $res='<fieldset><legend>Listing</legend>';
251  $res.= '<table id="tb_dsp" class="result" style="width:80%;">';
252  $clean=new IButton('rm_b');
253  $clean->label='Efface ligne';
254  $clean->javascript="deleteRow('tb_dsp',this);";
255 
256  $r='';
257  $r.=th('QuickCode');
258  $r.=th('Name');
259  $r.=th('Code Pays et numéro de TVA');
260  $r.=th('montant CA');
261  $r.=th('montant TVA');
262  $r.=th('');
263  $amount=0;$amount_vat=0;
264  $res.=tr($r);
265  for ($i=0;$i<count($this->aChild);$i++) {
266  $a=new IText('qcode[]',$this->aChild[$i]->get_parameter('qcode'));
267  $b=new IText('name_child[]',$this->aChild[$i]->get_parameter('name_child'));
268  $c=new IText('tva_num_child[]',$this->aChild[$i]->get_parameter('tva_num'));
269  $e=new INum('amount[]',$this->aChild[$i]->get_parameter('amount'));
270  $d=new INum('amount_vat[]',$this->aChild[$i]->get_parameter('amount_vat'));
271 
272  $amount+=round($this->aChild[$i]->get_parameter('amount'),2);
273  $amount_vat+=round($this->aChild[$i]->get_parameter('amount_vat'),2);
274  $r=td($a->input());
275  $r.=td($b->input());
276  $r.=td($c->input());
277  $r.=td($e->input());
278  $r.=td($d->input());
279  if (! $readonly) $r.=td($clean->input());
280  $res.=tr($r);
281 
282  }
283  if ( $readonly )
284  {
285  $r=td('');
286  $r.=td('');
287  $r.=td(hb('Total'));
288  $r.=td(hb(sprintf('%.02f',$amount)));
289  $r.=td(hb(sprintf('%.02f',$amount_vat)));
290  $res.=tr($r);
291  }
292 
293  $res.='</table>';
294  $res.='</fieldset>';
295  return $res;
296  }
$r
$res
get_parameter($p_string)
Ext_Tva_Gen::display_info ( )
inherited

display the information about the company

Definition at line 182 of file class_ext_tvagen.php.

References $exercice, $r, and $str_date.

Referenced by Ext_List_Intra\display(), display(), and Ext_Tva\display().

182  {
183  $itva=new IText('num_tva',$this->num_tva);$str_tva=$itva->input();
184  $iname=new IText('name',$this->tva_name); $str_name=$iname->input();
185  $iadress=new IText('adress',$this->adress);$str_adress=$iadress->input();
186  $icountry=new IText('country',$this->country);$str_country=$icountry->input();
187 
188  /* date */
189 
190  if (isset($this->date_decl)) { $idate=new IText('date',format_date($this->date_decl));$str_date=$idate->input();}
191 
192  /* periode */
193 
194  if ( isset($this->start_date) ){
195  $str_start=format_date($this->start_date);
196  $str_end=format_date($this->end_date);
197 
198  }
199  $ianne=$this->exercice;
200  ob_start();
201  require_once('form_decl_info.php');
202  $r=ob_get_contents();
203  ob_end_clean();
204  return $r;
205  }
if(isset($_POST['save'])) $exercice
$r
switch($sep_field->selected) $str_date
Listing::find_tva_code (   $p_array)
inherited

Definition at line 29 of file class_listing.php.

References $array.

Referenced by Ext_List_Intra\compute(), and compute().

30  {
31  $array=$this->db->make_list("
32  select distinct tva_id from tva_belge.parameter_chld
33  where
34  pcode=$1",
35  array($p_array));
36 
37  return $array;
38  }
if(isset($_POST['remove'])) $array
Ext_List_Assujetti::from_array (   $p_array)

Definition at line 67 of file class_ext_list_assujetti.php.

References $amount, $array, and $name.

67  {
68  if ( isset($p_array['name_child'])) {
69  $name=$p_array['name_child'];
70  $qcode=$p_array['qcode'];
71  $code=$p_array['plugin_code'];
72  $tva_num=$p_array['tva_num_child'];
73  $amount=$p_array['amount'];
74  $amount_vat=$p_array['amount_vat'];
75 
76  // retrieve missing and compute an array
77  for ($i=0;$i<count($name);$i++){
78  $child=new Ext_List_Assujetti_Child($this->db);
79  $child->set_parameter('amount',$amount[$i]);
80  $child->set_parameter('amount_vat',$amount_vat[$i]);
81  $child->set_parameter('qcode',$qcode[$i]);
82  $child->set_parameter('name_child',$name[$i]);
83  $child->set_parameter('tva_num',$tva_num[$i]);
84 
85  $array[]=$child;
86  }//end for
87  $this->aChild=$array;
88  } else
89  $this->aChild=array();
90 
91  $this->start_periode=$p_array['start_periode'];
92  $this->end_periode=$p_array['end_periode'];
93  $this->flag_periode=$p_array['flag_periode'];
94  $this->tva_name=$p_array['name'];
95  $this->num_tva=$p_array['num_tva'];
96  $this->adress=$p_array['adress'];
97  $this->country=$p_array['country'];
98  $this->periode_dec=$p_array['periode_dec'];
99  $this->exercice=$p_array['exercice'];
100  }
if(isset($_POST['remove'])) $array
$name
Ext_Tva_Gen::get_info ( )
inherited

Definition at line 72 of file class_ext_tvagen.php.

72 { return var_export(self::$variable,true); }
Ext_Tva_Gen::get_parameter (   $p_string)
inherited

Definition at line 54 of file class_ext_tvagen.php.

Referenced by Ext_List_Intra\display_declaration_amount(), display_declaration_amount(), Ext_Tva\display_declaration_amount(), and Ext_Tva_Gen\save().

54  {
55  if ( array_key_exists($p_string,$this->variable) ) {
56  $idx=$this->variable[$p_string];
57  return $this->$idx;
58  }
59  else
60  throw new Exception (__FILE__.":".__LINE__.'Erreur attribut inexistant');
61  }
Ext_List_Assujetti::insert ( )

Definition at line 149 of file class_ext_list_assujetti.php.

References $sql, and a_id.

149  {
150  $this->db->start();
151 
152  /* insert into the first table */
153  $sql=<<<EOF
154  INSERT INTO tva_belge.assujetti(
155  start_date, end_date, periodicity, tva_name,
156  num_tva, adress, country, periode_dec,exercice)
157  VALUES (to_date($1,'DD.MM.YYYY'),to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9) returning a_id;
158 EOF;
159  $this->a_id=$this->db->get_value($sql,
160  array(
161  $this->start_periode, /* 1 */
162  $this->end_periode,
163  $this->flag_periode, /* 3 */
164  $this->tva_name,
165  $this->num_tva, /* 5 */
166  $this->adress,
167  $this->country, /* 7 */
168  $this->periode_dec,
169  $this->exercice /* 9 */
170  )
171  );
172  /* insert into the child table */
173  for ($e=0;$e<count($this->aChild);$e++){
174  $this->aChild[$e]->set_parameter('depend',$this->a_id);
175  $this->aChild[$e]->insert();
176  }
177  $this->db->commit();
178 
179  }
for($i=0;$i<$max;$i++)
Definition: test_file.php:62
$sql
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id
Ext_List_Assujetti::load ( )

Definition at line 117 of file class_ext_list_assujetti.php.

References $array, $res, $sql, and a_id.

117  {
118  $sql="select * from tva_belge.assujetti where a_id=$1";
119 
120  $res=$this->db->get_array(
121  $sql,
122  array($this->a_id)
123  );
124  if ( $this->db->count() == 0 ) return 0;
125  foreach ($res[0] as $idx=>$value) { $this->$idx=$value; }
126  // load child
127  $sql="select * from tva_belge.assujetti_chld where a_id=$1";
128  $res=$this->db->get_array(
129  $sql,
130  array($this->a_id)
131  );
132  $nb=$this->db->count();
133  $array=array();
134  // retrieve missing and compute an array
135  for ($i=0;$i<$nb;$i++){
136  $child=new Ext_List_Assujetti_Child($this->db);
137  foreach ($res[$i] as $idx=>$value){
138  $child->$idx=$value;
139  }
140  $array[]=$child;
141  }//end for
142  $this->aChild=$array;
143 
144  return 1;
145  }
if(isset($_POST['remove'])) $array
$res
$sql
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id
Ext_Tva_Gen::save ( )
inherited

Definition at line 74 of file class_ext_tvagen.php.

References Ext_Tva_Gen\get_parameter().

74  {
75  /* please adapt */
76  if ( $this->get_parameter("id") == 0 )
77  $this->insert();
78  else
79  $this->update();
80  }
get_parameter($p_string)
Ext_Tva_Gen::set_parameter (   $p_string,
  $p_value 
)
inherited

Definition at line 62 of file class_ext_tvagen.php.

Referenced by Ext_Tva_Gen\blank(), and Ext_Tva\compute().

62  {
63  if ( array_key_exists($p_string,$this->variable) ) {
64  $idx=$this->variable[$p_string];
65  $this->$idx=$p_value;
66  }
67  else
68  throw new Exception (__FILE__.":".__LINE__.'Erreur attribut inexistant');
69 
70 
71  }
Ext_List_Assujetti::update ( )

Definition at line 180 of file class_ext_list_assujetti.php.

180  {
181  }
Ext_List_Assujetti::verify ( )

Definition at line 146 of file class_ext_list_assujetti.php.

146  {
147  return 0;
148  }

Field Documentation

Ext_List_Assujetti::$aChild =array()
private

Definition at line 45 of file class_ext_list_assujetti.php.

Ext_List_Assujetti::$variable
protected
Initial value:
= array(
"id"=>"a_id",
"date_decl"=>"date_decl",
"start_periode"=>"start_periode",
"end_periode"=>"end_periode",
"xml_file"=>"xml_file",
"num_tva"=>"num_tva",
"name"=>"tva_name",
"adress"=>"adress",
"country"=>"country",
"flag_periode"=>"flag_periode",
"exercice"=>"exercice",
"periode_dec"=>"periode_dec"
)

Definition at line 31 of file class_ext_list_assujetti.php.


The documentation for this class was generated from the following file: