compute, save and display a declaration
More...
|
| __construct () |
|
| load_formulaire () |
|
| get_file_to_parse () |
|
| generate_document () |
|
| parse_document ($p_dir, $p_filename, $p_type) |
|
| special_tag ($p_dir, $p_filename, $p_type) |
|
| load_document ($p_file) |
|
| compute ($p_id, $p_start, $p_end, $p_step) |
| $cn $cn More...
|
|
| add_child_account (Rapav_Declaration_Param $row, $p_array, $p_start, $p_end) |
|
| compute_interval ($p_start, $p_end, $p_step) |
|
| get_interval ($p_step) |
|
| anchor_document () |
|
| display () |
|
| save () |
|
|
static | to_csv ($p_id, $p_orient="list") |
| export a declaration to CSV $cn database conx More...
|
|
compute, save and display a declaration
Definition at line 37 of file class_rapav_declaration.php.
Rapav_Declaration::__construct |
( |
| ) |
|
Rapav_Declaration::anchor_document |
( |
| ) |
|
Definition at line 606 of file class_rapav_declaration.php.
References $url.
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);
Rapav_Declaration::compute |
( |
|
$p_id, |
|
|
|
$p_start, |
|
|
|
$p_end, |
|
|
|
$p_step |
|
) |
| |
$cn $cn
- Parameters
-
type | $p_id | |
type | $p_start | |
type | $p_end | |
type | $p_step | |
if step != 0, recompute the date
children must be inserted into DECLARATION_ROW and DECLARARION_ROW_DETAIL for each depending accounting impact also order(use of decimal)
children must be inserted into DECLARATION_ROW and DECLARARION_ROW_DETAIL for each depending accounting impact also order(use of decimal)
Definition at line 431 of file class_rapav_declaration.php.
References $array, $cn, $row, add_child_account(), and compute_interval().
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)
for($i=0;$i< Database::num_row($ret);$i++) $row
add_child_account(Rapav_Declaration_Param $row, $p_array, $p_start, $p_end)
compute_interval($p_start, $p_end, $p_step)
if(isset($_POST['remove'])) $array
Match each row of a form, this row can have several details.
Rapav_Declaration::compute_interval |
( |
|
$p_start, |
|
|
|
$p_end, |
|
|
|
$p_step |
|
) |
| |
Rapav_Declaration::display |
( |
| ) |
|
Definition at line 613 of file class_rapav_declaration.php.
References $array, $cn, and d_id.
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';
if(isset($_POST['remove'])) $array
Rapav_Declaration::generate_document |
( |
| ) |
|
Definition at line 174 of file class_rapav_declaration.php.
References $cn, $res, $type, get_file_to_parse(), load_document(), parse_document(), and special_tag().
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);
parse_document($p_dir, $p_filename, $p_type)
$type
Retrouve le type de row si == 3.
special_tag($p_dir, $p_filename, $p_type)
Rapav_Declaration::get_file_to_parse |
( |
| ) |
|
Definition at line 126 of file class_rapav_declaration.php.
References $cn, and $type.
Referenced by generate_document().
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);
$type
Retrouve le type de row si == 3.
Rapav_Declaration::get_interval |
( |
|
$p_step | ) |
|
Rapav_Declaration::load_document |
( |
|
$p_file | ) |
|
Definition at line 406 of file class_rapav_declaration.php.
References $cn, and $date.
Referenced by generate_document().
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;
Rapav_Declaration::load_formulaire |
( |
| ) |
|
Rapav_Declaration::parse_document |
( |
|
$p_dir, |
|
|
|
$p_filename, |
|
|
|
$p_type |
|
) |
| |
Definition at line 213 of file class_rapav_declaration.php.
References $array, $cn, $ifile, $key, $p_type, $ret, and d_id.
Referenced by generate_document().
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);
if(isset($_POST['remove'])) $array
Rapav_Declaration::save |
( |
| ) |
|
Definition at line 620 of file class_rapav_declaration.php.
References $amount, and $cn.
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());
Rapav_Declaration::special_tag |
( |
|
$p_dir, |
|
|
|
$p_filename, |
|
|
|
$p_type |
|
) |
| |
Definition at line 333 of file class_rapav_declaration.php.
References $_REQUEST, $array, $cn, $g_parameter, $ifile, $key, $p_type, $ret, and d_description.
Referenced by generate_document().
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);
if(isset($_POST['remove'])) $array
static Rapav_Declaration::to_csv |
( |
|
$p_id, |
|
|
|
$p_orient = "list" |
|
) |
| |
|
static |
export a declaration to CSV $cn database conx
- Parameters
-
$p_id | pk of rapav_declaration |
$p_orient | value :
- list : for a list
- table : to have a table (if using step)
|
Definition at line 57 of file class_rapav_declaration.php.
References $cn, and $title.
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']));
The documentation for this class was generated from the following file: