30 require_once
'class_rapav_formulaire.php';
31 require_once
'class_formulaire_param_detail.php';
32 require_once
'class_rapport_avance_sql.php';
43 parent::__construct();
57 static function to_csv($p_id,$p_orient=
"list")
61 $a_title = $cn->get_array(
"select d_title
62 ,to_char(d_start,'DD.MM.YYYY') as start
63 ,to_char(d_end,'DD.MM.YYYY') as end
65 rapport_advanced.declaration
67 d_id=$1 ", array($p_id));
68 $title = $a_title[0][
'd_title'] .
"-" . $a_title[0][
'start'] .
"-" . $a_title[0][
'end'];
70 $title = str_replace(array(
'/',
'*',
'<',
'>',
'*',
'.',
'+',
':',
'?',
'!',
" ",
";"),
"_",
$title);
71 $out = fopen(
"php://output",
"w");
73 header(
'Pragma: public');
74 header(
'Content-type: application/csv');
75 header(
'Content-Disposition: attachment;filename="' .
$title .
'.csv"', FALSE);
76 if ($p_orient ==
"list")
78 fputcsv($out, $a_title[0],
";");
80 $a_row = $cn->get_array(
'select dr_code,dr_libelle,dr_amount,dr_start,dr_end,dr_account
81 from rapport_advanced.declaration_row
82 where d_id=$1 order by dr_order,dr_start', array($p_id));
84 for ($i = 0; $i < count($a_row); $i++)
86 printf(
'"%s";"%s";"%s";%s;"%s";"%s"' .
"\r\n", $a_row[$i][
'dr_code'],$a_row[$i][
'dr_account'],$a_row[$i][
'dr_libelle'], nb($a_row[$i][
'dr_amount']), format_date($a_row[$i][
'dr_start']), format_date($a_row[$i][
'dr_end'])
90 elseif ($p_orient==
"table")
92 fputcsv($out, $a_title[0],
";");
94 $a_periode = $cn->get_array(
'select distinct dr_start,dr_end
95 from rapport_advanced.declaration_row
96 where d_id=$1 order by dr_start', array($p_id));
100 for ($i = 0; $i < count($a_periode); $i++)
102 printf(
';"%s-%s"', format_date($a_periode[$i][
'dr_start']), format_date($a_periode[$i][
'dr_end']));
107 $a_row = $cn->get_array(
'select dr_code,dr_libelle,dr_amount,dr_start,dr_end,dr_account
108 from rapport_advanced.declaration_row
109 where d_id=$1 order by dr_order,dr_start', array($p_id));
110 $last_code=
""; $last_lib=
"";
111 for ($i = 0; $i < count($a_row); $i++)
113 if ( $last_code != $a_row[$i][
'dr_code'] || $last_lib != $a_row[$i][
'dr_libelle'])
115 if ($last_code!=
""){ printf(
"\r\n"); }
116 printf(
'"%s";"%s";"%s"', $a_row[$i][
'dr_account'],$a_row[$i][
'dr_code'],$a_row[$i][
'dr_libelle']);
117 $last_code=$a_row[$i][
'dr_code'];
118 $last_lib=$a_row[$i][
'dr_libelle'];
120 printf(
';%s',nb($a_row[$i][
'dr_amount']));
130 $dirname = tempnam($_ENV[
'TMP'],
'rapav_');
140 $filename = $this->d_filename;
141 $exp = $cn->lo_export($this->d_lob, $dirname . DIRECTORY_SEPARATOR . $filename);
144 echo_warning(__FILE__ .
":" . __LINE__ .
"Export NOK $filename");
149 if (strpos($this->d_mimetype,
'vnd.oasis') != 0)
152 $zip =
new Zip_Extended;
153 if ($zip->open($filename) === TRUE)
155 $zip->extractTo($dirname . DIRECTORY_SEPARATOR);
159 echo __FILE__ .
":" . __LINE__ .
"cannot unzip model " . $filename;
165 $file_to_parse =
"content.xml";
168 $file_to_parse = $filename;
171 return array($file_to_parse, $dirname,
$type);
177 if ($this->d_filename ==
"")
192 $zip =
new Zip_Extended;
193 $res = $zip->open($this->d_filename, ZipArchive::CREATE);
196 echo __FILE__ .
":" . __LINE__ .
"cannot recreate zip";
199 $zip->add_recurse_folder($dirname . DIRECTORY_SEPARATOR);
204 $file_to_save = $this->d_filename;
207 $file_to_save = $file_to_parse;
210 $this->
load_document($dirname . DIRECTORY_SEPARATOR . $file_to_save);
219 $array = $cn->get_array(
"select '<<'||dr_code||'>>' as code,dr_amount from rapport_advanced.declaration_row where d_id=$1 and dr_type=3", array($this->
d_id));
220 $array_mult = $cn->get_array(
"select '<<'||dr_code||'>>' as code,
221 '<<'||dr_code||'_LIB>>' as code_lib,
222 '<<'||dr_code||'_ACC>>' as code_acc,
224 dr_amount,dr_libelle from rapport_advanced.declaration_row where d_id=$1 and dr_type=9 and dr_amount <> 0", array($this->
d_id));
227 $array = $cn->get_array(
"select '<<'||dr_code||'>>' as code,dr_amount from rapport_advanced.declaration_row where d_id=$1 and dr_type=3", array($this->
d_id));
228 $array_mult = $cn->get_array(
"select '<<'||dr_code||'>>' as code,
229 '<<'||dr_code||'_LIB>>' as code_lib,
230 '<<'||dr_code||'_ACC>>' as code_acc,
232 dr_amount,dr_libelle from rapport_advanced.declaration_row where d_id=$1 and dr_type=9 and dr_amount <> 0 order by dr_order", array($this->
d_id));
236 $ifilename=$p_dir .
'/' . $p_filename;
237 $ifile = fopen($ifilename,
'r');
240 $temp_dir = $_ENV[
'TMP'];
241 if (is_dir($temp_dir) ==
false)
243 if (mkdir($temp_dir) ==
false)
245 echo
"Ne peut pas créer le répertoire " . $temp_dir;
250 $oname = tempnam($temp_dir,
"rapport_avance_");
251 $ofile = fopen($oname,
"w+");
254 $buffer = fread(
$ifile, filesize($ifilename));
258 if (is_numeric($value[
'dr_amount']))
261 $searched =
'office:value-type="string"><text:p>' . $value[
'code'];
262 $replaced =
'office:value-type="float" office:value="' . $value[
'dr_amount'] .
'"><text:p>' . $value[
'code'];
263 $buffer = str_replace($searched, $replaced, $buffer);
265 $buffer = str_replace($value[
'code'], $value[
'dr_amount'], $buffer);
268 if ($array_mult==
false)
274 $a_code_clean=array();
275 $a_code_lib_clean=array();
276 $a_code_acc_clean=array();
278 foreach ($array_mult as
$key=> $value)
283 $a_code_clean[$idx]=$value[
'code'];
284 $a_code_lib_clean[$idx]=$value[
'code_lib'];
285 $a_code_acc_clean[$idx]=$value[
'code_acc'];
288 if ( ! in_array($value[
'code'], $a_code_clean)){
289 $a_code_clean[$idx]=$value[
'code'];
290 $a_code_lib_clean[$idx]=$value[
'code_lib'];
291 $a_code_acc_clean[$idx]=$value[
'code_acc'];
295 if (is_numeric($value[
'dr_amount']))
298 $searched=
'office:value-type="string"><text:p>'.$value[
'code'];
299 $replaced=
'office:value-type="float" office:value="'.$value[
'dr_amount'].
'"><text:p>'.$value[
'code'];
300 $buffer=preg_replace(
"/".$searched.
"/", $replaced, $buffer,1);
302 $buffer=preg_replace(
"/".$value[
'code'].
"/", $value[
'dr_amount'],$buffer,1);
303 $buffer=preg_replace(
"/".$value[
'code_lib'].
"/", $value[
'dr_libelle'],$buffer,1);
304 $buffer=preg_replace(
"/".$value[
'code_acc'].
"/", $value[
'dr_account'],$buffer,1);
307 for ($k=0;$k<$idx;$k++){
308 $code=$a_code_clean[$k];
309 $code_lib=$a_code_lib_clean[$k];
310 $code_acc=$a_code_acc_clean[$k];
311 $buffer=preg_replace(
"/".$code.
"/",
"",$buffer);
312 $buffer=preg_replace(
"/".$code_lib.
"/",
"",$buffer);
313 $buffer=preg_replace(
"/".$code_acc.
"/",
"",$buffer);
319 fwrite($ofile, $buffer);
326 if ((
$ret = copy($oname, $p_dir .
'/' . $p_filename)) == FALSE)
328 echo _(
'Ne peut pas sauver ' . $oname .
' vers ' . $p_dir .
'/' . $p_filename .
' code d\'erreur =' .
$ret);
337 $array[] = array(
'code' =>
'PERIODE_DECLARATION',
'value' => format_date($this->d_start) .
" - " . format_date($this->d_end));
338 $array[] = array(
'code' =>
'TITRE',
'value' => $this->d_title);
339 $array[] = array(
'code' =>
'DOSSIER',
'value' => $cn->format_name(
$_REQUEST[
'gDossier'],
'dos'));
340 $array[] = array(
'code' =>
'NAME',
'value' => $g_parameter->MY_NAME);
341 $array[] = array(
'code' =>
'STREET',
'value' => $g_parameter->MY_STREET);
342 $array[] = array(
'code' =>
'NUMBER',
'value' => $g_parameter->MY_NUMBER);
343 $array[] = array(
'code' =>
'LOCALITE',
'value' => $g_parameter->MY_COMMUNE);
344 $array[] = array(
'code' =>
'COUNTRY',
'value' => $g_parameter->MY_PAYS);
345 $array[] = array(
'code' =>
'PHONE',
'value' => $g_parameter->MY_TEL);
346 $array[] = array(
'code' =>
'CEDEX',
'value' => $g_parameter->MY_CP);
347 $array[] = array(
'code' =>
'FAX',
'value' => $g_parameter->MY_FAX);
348 $array[] = array(
'code' =>
'NOTE',
'value' => $this->
d_description);
349 $array[] = array(
'code' =>
'TODAY',
'value' => date(
'd.m.Y'));
352 $ifile = fopen($p_dir .
'/' . $p_filename,
'r');
355 $temp_dir = $_SERVER[
"DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR .
'tmp';
356 if (is_dir($temp_dir) ==
false)
358 if (mkdir($temp_dir) ==
false)
360 echo
"Ne peut pas créer le répertoire " . $temp_dir;
365 $oname = tempnam($temp_dir,
"rapport_avance_");
366 $ofile = fopen($oname,
"w+");
373 foreach ($array as
$key => $value)
377 $replace =
'<<' . $value[
'code'] .
'>>';
378 $fmt_value = $value[
'value'];
379 $fmt_value = str_replace(
'&',
'&', $fmt_value);
380 $fmt_value = str_replace(
'<',
'<', $fmt_value);
381 $fmt_value = str_replace(
'>',
'>', $fmt_value);
382 $fmt_value = str_replace(
'"',
'"', $fmt_value);
383 $fmt_value = str_replace(
"'",
''', $fmt_value);
386 $replace =
'<<' . $value[
'code'] .
'>>';
387 $fmt_value = $value[
'value'];
389 $buffer = str_replace($replace, $fmt_value, $buffer);
392 fwrite($ofile, $buffer);
399 if ((
$ret = copy($oname, $p_dir .
'/' . $p_filename)) == FALSE)
401 echo _(
'Ne peut pas sauver ' . $oname .
' vers ' . $p_dir .
'/' . $p_filename .
' code d\'erreur =' .
$ret);
410 $this->d_lob = $cn->lo_import($p_file);
411 if ($this->d_lob ==
false)
413 echo
"ne peut pas importer [$p_file]";
416 $this->d_size = filesize($p_file);
417 $date = date(
'ymd-Hi');
418 $this->d_filename =
$date .
'-' . $this->d_filename;
431 function compute($p_id, $p_start, $p_end, $p_step)
439 $this->form->f_id = $p_id;
441 $this->d_title = $this->form->f_title;
442 $this->d_start = $p_start;
443 $this->d_end = $p_end;
444 $this->to_keep =
'N';
445 $this->d_lob = $this->form->f_lob;
446 $this->d_filename = $this->form->f_filename;
447 $this->d_mimetype = $this->form->f_mimetype;
448 $this->d_size = $this->form->f_size;
449 $this->d_step = $p_step;
454 $array = $cn->get_array(
"select p_id,p_code,p_libelle,p_type,p_order,f_id,t_id
455 from rapport_advanced.formulaire_param
458 order by p_order", array($p_id));
465 for ($i = 0; $i < count(
$array); $i++)
468 $row->d_id = $this->d_id;
469 $row->dr_id = $cn->get_next_seq(
'rapport_advanced.declaration_param_seq');
471 $row->dr_start = $p_start;
472 $row->dr_end = $p_end;
473 $row->dr_account=null;
474 if (
$array[$i][
'p_type'] == 3 )
476 $row->compute($p_start, $p_end);
479 } elseif (
$array[$i][
'p_type'] == 9)
492 $row->dr_start = $p_start;
493 $row->dr_end = $p_end;
503 for ($i = 0; $i < count(
$array); $i++)
506 $row->d_id = $this->d_id;
507 $row->dr_id = $cn->get_next_seq(
'rapport_advanced.declaration_param_seq');
509 $row->dr_account=null;
510 if (
$array[$i][
'p_type'] == 3)
512 $row->compute($this->start, $this->end);
513 $row->dr_start = $this->start;
514 $row->dr_end = $this->end;
517 elseif (
$array[$i][
'p_type'] == 9)
537 if ($a_depending==
false)
540 $row->dr_start=$p_start;
546 $nb_depending=count($a_depending);
547 for (
$j=0;
$j<$nb_depending;
$j++)
550 $row->d_id=$this->d_id;
551 $row->dr_id=$cn->get_next_seq(
'rapport_advanced.declaration_param_seq');
553 $row->dr_start=$p_start;
556 $row->dr_account=$a_depending[
$j][
'pcm_val'];
557 $row->param->p_libelle=$a_depending[
$j][
'pcm_lib'];
558 $row->param->p_order=$row->param->p_order+$j/1000;
567 static $s_start =
"";
576 $date_start = DateTime::createFromFormat(
'd.m.Y', $s_start);
577 $date_end = DateTime::createFromFormat(
'd.m.Y', $s_start);
578 $date_finish = DateTime::createFromFormat(
'd.m.Y', $p_end);
596 $s_start = $this->start;
602 $array_interval = array(
"",
"P7D",
"P14D",
"P1M",
"P2M",
"P3M",
'P6M',
'P1Y');
603 return new DateInterval($array_interval[$p_step]);
608 $url = HtmlInput::request_to_string(array(
'gDossier',
'ac',
'plugin_code'));
609 $url =
'extension.raw.php' .
$url .
'&act=export_decla_document&id=' . $this->d_id;
610 return HtmlInput::anchor($this->d_filename,
$url);
616 $array = $cn->get_array(
'select * from rapport_advanced.declaration_row where d_id=$1 order by dr_order,dr_start', array($this->
d_id));
617 require_once
'template/declaration_display.php';
626 $this->to_keep =
'Y';
628 $code = $_POST[
'code'];
630 for ($i = 0; $i < count($code); $i++)
632 $cn->exec_sql(
'update rapport_advanced.declaration_row set dr_amount=$2 where dr_id=$1', array($code[$i],
$amount[$i]));
635 }
catch (Exception $e)
637 alert($e->getTraceAsString());
656 $data->dr_code = $this->param->p_code;
657 $data->dr_libelle = $this->param->p_libelle;
658 $data->dr_order = $this->param->p_order;
660 $data->d_id = $this->d_id;
661 $data->dr_id = $this->dr_id;
662 $data->dr_type = $this->param->p_type;
663 $data->dr_start = $this->dr_start;
664 $data->dr_end = $this->dr_end;
665 $data->dr_account=$this->dr_account;
684 foreach (array(
'p_id',
'p_code',
'p_libelle',
'p_type',
'p_order',
'f_id',
't_id') as $e)
686 $this->param->$e = $p_array[$e];
688 $this->param->load();
706 switch ($this->param->t_id)
709 $this->start = $p_start;
714 list($this->start, $this->end) = $g_user->get_limit_current_exercice();
730 list($this->start, $this->end) = $g_user->get_limit_current_exercice();
735 throw new Exception(
'compute_date : t_id est incorrect');
742 $exist_exercice = $cn->get_value(
'select count(p_id) from parm_periode where p_exercice=$1', array(
$exercice));
743 if ($exist_exercice == 0)
745 $this->start =
'01.01.1900';
746 $this->end =
'01.01.1900';
752 $this->start = $per_start->first_day();
753 $this->end = $per_end->last_day();
770 $array = $cn->get_array(
"select fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,
771 with_tmp_val,type_sum_account,operation_pcm_val,jrn_def_id,date_paid
772 from rapport_advanced.formulaire_param_detail where p_id=$1", array($this->param->p_id));
774 for ($e = 0; $e < count(
$array); $e++)
777 $row_detail->form->tmp_val=$p_pcm_val;
778 $row_detail->dr_id = $this->dr_id;
779 $row_detail->d_id = $this->d_id;
780 $tmp_amount = $row_detail->compute($this->start, $this->end);
781 $this->amount = bcadd(
"$tmp_amount",
"$this->amount");
782 $row_detail->insert();
799 $array = $cn->get_array(
"select fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,
800 with_tmp_val,type_sum_account,operation_pcm_val,jrn_def_id,date_paid
801 from rapport_advanced.formulaire_param_detail where p_id=$1", array($this->param->p_id));
803 for ($e = 0; $e < count(
$array); $e++)
806 $row_detail->dr_id = $this->dr_id;
807 $row_detail->d_id = $this->d_id;
808 $tmp_amount = $row_detail->compute($this->start, $this->end);
809 $this->amount = bcadd(
"$tmp_amount",
"$this->amount");
810 $row_detail->insert();
819 $accounting = $cn->get_value(
" select tmp_val
820 from rapport_advanced.formulaire_param_detail
821 where p_id=$1", array($this->param->p_id));
823 $array=$cn->get_array(
"select pcm_val,pcm_lib from tmp_pcmn where
824 pcm_val like $1||'%' order by pcm_val::text",array($accounting));
845 switch ($p_array[
'type_detail'])
867 throw new Exception(
"Type inconnu");
870 $ret->from_array($p_array);
871 $ret->ddr_amount = 0;
883 $attribute = explode(
',',
'fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,with_tmp_val,type_sum_account,operation_pcm_val,jrn_def_id,date_paid');
884 foreach ($attribute as $e)
886 $this->form->$e = $p_array[$e];
911 if ($this->form->jrn_def_id != null)
913 $sql =
' and j_jrn_def =' . $this->form->jrn_def_id;
915 if ($this->form->date_paid == 1)
917 $sql.=sprintf(
" and j_id in ( select j_id from jrnx join jrn on (j_grpt=jr_grpt_id) where jr_date_paid >= to_date('%s','DD.MM.YYYY') and jr_date_paid <= to_date ('%s','DD.MM.YYYY'))", $p_start, $p_end);
918 $p_start =
'01.01.1900';
919 $p_end =
'01.01.2100';
921 if ($this->form->date_paid == 2)
923 $sql.=sprintf(
" and j_id in ( select j_id from jrnx join jrn on (j_grpt=jr_grpt_id) where jr_ech >= to_date('%s','DD.MM.YYYY') and jr_ech <= to_date ('%s','DD.MM.YYYY'))", $p_start, $p_end);
924 $p_start =
'01.01.1900';
925 $p_end =
'01.01.2100';
927 $amount = Impress::parse_formula($cn,
"", $this->form->fp_formula, $p_start, $p_end,
true, 1,
$sql);
956 $formula = $this->form->fp_formula;
959 preg_match_all(
"/\[([A-Z]*[0-9]*)*_*([0-9]*[A-Z]*)\]/i", $formula, $e);
962 foreach ($tmp as $piece)
965 $search = str_replace(
'[',
'', $piece);
966 $search = str_replace(
']',
'', $search);
967 $value = $cn->get_value(
'select coalesce(sum(dr_amount),0) as value
968 from rapport_advanced.declaration_row where d_id=$1 and dr_code=$2', array($this->
d_id, $search));
969 $formula = str_replace($piece, $value, $formula);
972 eval(
'$amount = ' . $formula .
';');
1002 $filter_ledger =
"";
1003 if ($this->form->jrn_def_id !=
"")
1005 $filter_ledger =
" and j_jrn_def = " . sql_string($this->form->jrn_def_id);
1009 if ($this->form->jrn_def_type ==
'ACH')
1012 $sql =
"select coalesce(sum(qp_vat),0) as amount
1013 from quant_purchase join jrnx as jrn1 using (j_id)
1014 where qp_vat_code=$1
1016 and j_poste::text like ($4) $filter_ledger";
1017 $amount = $this->cn->get_value(
$sql, array($this->form->tva_id,
1020 $this->form->tmp_val));
1023 if ($this->form->jrn_def_type ==
'VEN')
1025 $sql =
"select coalesce(sum(qs_vat),0) as amount
1026 from quant_sold join jrnx as jrn1 using (j_id)
1027 where qs_vat_code=$1
1029 and j_poste::text like ($4) $filter_ledger";
1031 $amount = $this->cn->get_value(
$sql, array($this->form->tva_id,
1034 $this->form->tmp_val));
1037 $this->errcode =
'Erreur dans le journal';
1054 $filter_ledger =
"";
1055 if ($this->form->jrn_def_id !=
"")
1057 $filter_ledger =
" and j_jrn_def = " . sql_string($this->form->jrn_def_id);
1061 if ($this->form->jrn_def_type ==
'ACH')
1063 $sql =
"select coalesce(sum(qp_price),0) as amount from quant_purchase join jrnx as jrn1 using (j_id)
1064 where qp_vat_code=$1 $sql_date
1065 and j_poste::text like ($4) $filter_ledger";
1067 $amount = $this->cn->get_value(
$sql, array($this->form->tva_id,
1070 $this->form->tmp_val));
1073 if ($this->form->jrn_def_type ==
'VEN')
1075 $sql =
"select coalesce(sum(qs_price),0) as amount from quant_sold
1076 join jrnx as jrn1 using (j_id)
1077 where qs_vat_code=$1 $sql_date
1078 and j_poste::text like ($4) $filter_ledger";
1079 $amount = $this->cn->get_value(
$sql, array($this->form->tva_id,
1082 $this->form->tmp_val));
1085 $this->errcode =
'Erreur dans le journal';
1106 switch ($this->form->tt_id)
1110 $t2_amount = $this->
compute_tva($p_start, $p_end);
1111 $amount = bcadd($t1_amount, $t2_amount);
1124 throw new Exception(
'Type de total invalide');
1148 $filter_ledger =
"";
1149 if ($this->form->jrn_def_id !=
"")
1151 $filter_ledger =
" and jrn1.j_jrn_def = " . sql_string($this->form->jrn_def_id);
1157 switch ($this->form->type_sum_account)
1165 select sum(jrnx_amount)
1167 select distinct jrn1.j_id,case when jrn1.j_debit = 't' then jrn1.j_montant else jrn1.j_montant*(-1) end as jrnx_amount
1169 join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1171 jrn1.j_poste like $1
1174 jrn2.j_poste like $4
1179 $this->form->tmp_val,
1182 $this->form->with_tmp_val
1185 if ($this->form->type_sum_account == 2)
1192 select sum(jrnx_amount)
1194 select distinct jrn1.j_id,jrn1.j_montant as jrnx_amount
1196 join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1198 jrn1.j_poste like $1
1201 jrn2.j_poste like $4
1208 $this->form->tmp_val,
1211 $this->form->with_tmp_val
1218 select sum(jrnx_amount)
1220 select distinct jrn1.j_id,jrn1.j_montant as jrnx_amount
1222 join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1224 jrn1.j_poste like $1
1227 jrn2.j_poste like $4
1234 $this->form->tmp_val,
1237 $this->form->with_tmp_val,
1244 die(__FILE__ .
":" . __LINE__ .
" UNKNOW SUM TYPE");
1272 $filter_ledger =
"";
1273 if ($this->form->jrn_def_id !=
"")
1275 $filter_ledger =
" and jrn1.j_jrn_def = " . sql_string($this->form->jrn_def_id);
1277 switch ($this->form->type_sum_account)
1284 select sum(tv_amount.jrnx_amount)
1286 select distinct jrn1.j_id,j1.jr_id,
1287 case when jrn1.j_debit = 't' then jrn1.j_montant else jrn1.j_montant*(-1) end as jrnx_amount
1289 join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1290 join jrn as j1 on (jrn1.j_grpt=j1.jr_grpt_id)
1292 jrn1.j_poste like $1
1293 and jrn2.j_poste like $2
1296 join jrn_rapt as rap1 on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
1297 join (select distinct jrn3.j_id,j2.jr_id
1299 join jrn as j2 on (j2.jr_grpt_id=jrn3.j_grpt)
1301 (jrn3.j_date >= to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
1302 jrn3.j_poste like $5) as reconc on (rap1.jr_id=reconc.jr_id or rap1.jra_concerned=reconc.jr_id)
1306 $this->form->tmp_val,
1307 $this->form->with_tmp_val,
1310 $this->form->operation_pcm_val
1313 if ($this->form->type_sum_account == 2)
1319 select sum(tv_amount.jrnx_amount)
1321 select distinct jrn1.j_id,j1.jr_id,
1322 jrn1.j_montant as jrnx_amount
1324 join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1325 join jrn as j1 on (jrn1.j_grpt=j1.jr_grpt_id)
1327 jrn1.j_poste like $1
1328 and jrn2.j_poste like $2
1329 and jrn1.j_debit='t'
1332 join jrn_rapt as rap1 on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
1333 join (select distinct jrn3.j_id,j2.jr_id
1335 join jrn as j2 on (j2.jr_grpt_id=jrn3.j_grpt)
1337 (jrn3.j_date >= to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
1338 jrn3.j_poste like $5) as reconc on (rap1.jr_id=reconc.jr_id or rap1.jra_concerned=reconc.jr_id)
1342 $this->form->tmp_val,
1343 $this->form->with_tmp_val,
1346 $this->form->operation_pcm_val
1352 select sum(tv_amount.jrnx_amount)
1354 select distinct jrn1.j_id,j1.jr_id,
1355 jrn1.j_montant as jrnx_amount
1357 join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1358 join jrn as j1 on (jrn1.j_grpt=j1.jr_grpt_id)
1360 jrn1.j_poste like $1
1361 and jrn2.j_poste like $2
1362 and jrn1.j_debit='f'
1365 join jrn_rapt as rap1 on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
1366 join (select distinct jrn3.j_id,j2.jr_id
1368 join jrn as j2 on (j2.jr_grpt_id=jrn3.j_grpt)
1370 (jrn3.j_date >= to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
1371 jrn3.j_poste like $5) as reconc on (rap1.jr_id=reconc.jr_id or rap1.jra_concerned=reconc.jr_id)
1375 $this->form->tmp_val,
1376 $this->form->with_tmp_val,
1379 $this->form->operation_pcm_val
1386 die(__FILE__ .
":" . __LINE__ .
" UNKNOW SUM TYPE");
compute_tva($p_start, $p_end)
compute the amount of tva using the given account in either the ledger ACH or VEN following the $this...
compute($p_start, $p_end)
compute the amount for one detail rapport_advanced.formulaire_param_detail the attribute d_id and dr_...
parse_document($p_dir, $p_filename, $p_type)
for($i=0;$i< Database::num_row($ret);$i++) $row
$type
Retrouve le type de row si == 3.
handle the param_detail type Compute
add_child_account(Rapav_Declaration_Param $row, $p_array, $p_start, $p_end)
compute, save and display a declaration
compute($p_start, $p_end)
Compute the amount of TVA or Account, call internally private functions.
insert()
insert into rapport_advanced.formulaire_param
compute_interval($p_start, $p_end, $p_step)
handle the param_detail type Account The type_sum_account gives the type of total ...
compute($p_id, $p_start, $p_end, $p_step)
$cn $cn
if(isset($_POST['remove'])) $array
compute($p_start, $p_end)
Match each row of a form, this row can have several details.
compute_amount($p_start, $p_end)
compute the amount of account using the given tva_id in either the ledger ACH or VEN following the $t...
compute($p_start, $p_end)
from_array($p_array)
the p_array contains a row from formulaire_param_detail it will be copied into this->form.
compute_child($p_pcm_val, $p_start, $p_end)
compute($p_start, $p_end)
compute_date($p_start, $p_end)
compute the date following the attribute t_id (match rapport_advanced.periode_type and store the resu...
get_depending()
find depending accounting
static to_csv($p_id, $p_orient="list")
export a declaration to CSV $cn database conx
static factory($p_array)
create an object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute following the idx type_de...
static get_sql_date($p_date, $p_prefix="")
Compute the SQL for the date.
handle the param_detail type Account The type_sum_account gives the type of total ...
handle the param_detail type Account_Tva The t_id gives the type of total
if(isset($_POST['save'])) if(isset($_GET['compute'])) $date_start
special_tag($p_dir, $p_filename, $p_type)
from_array($p_array)
set the attribute param with the content of the array.