29 $act = HtmlInput::default_value_get(
"act", null);
34 if (
$act ==
'export_operation')
37 $p_from = HtmlInput::default_value_get(
"p_from", null);
38 $p_to = HtmlInput::default_value_get(
"p_to", null);
41 if ( $p_from==null || isDate($p_from)==null || $p_to == null || isDate($p_to) == null) {
42 die (_(
'Date invalide'));
45 $ledger=$g_user->get_ledger_sql(
'ALL',3);
49 select to_char(j_date,'DD.MM.YYYY') as str_date,
55 case when coalesce(j_text,'')='' then pcm_lib else j_text end as text,
57 case when j_debit='t' then 'D' else 'C' end as dc,
58 comptaproc.get_letter_jnt(j_id) AS lettrage
61 join jrn on (j_grpt=jr_grpt_id)
62 join tmp_pcmn on j_poste=pcm_val
63 join jrn_def on jrn_def_id=jr_def_id
65 j_date between to_date($1,'DD.MM.YYYY') and to_date($2,'DD.MM.YYYY')
66 and $ledger order by j_date
70 $file_name=
'export_operation-'.date(
'ymd').
'.csv';
71 header(
'Pragma: public');
72 header(
'Content-type: application/csv');
73 header(
'Content-Disposition: attachment;filename="'.$file_name.
'"', FALSE);
74 $nb=Database::num_row(
$ret);
75 printf(
'"%s";',_(
"Date DMY"));
76 printf(
'"%s";',_(
"Journal"));
77 printf(
'"%s";',_(
"n° interne"));
78 printf(
'"%s";',_(
"piece"));
79 printf(
'"%s";',_(
"poste"));
80 printf(
'"%s";',_(
"Code"));
81 printf(
'"%s";',_(
"texte"));
82 printf(
'"%s";',_(
"montant"));
83 printf(
'"%s";',_(
"DC"));
84 printf(
'"%s"',_(
"lettrage"));
87 for ($i=0;$i < $nb;$i++)
90 printf(
'"%s";',
$row[
'str_date']);
91 printf(
'"%s";',
$row[
'jrn_def_code']);
92 printf(
'"%s";',
$row[
'jr_internal']);
93 printf(
'"%s";',
$row[
'jr_pj_number']);
94 printf(
'"%s";',
$row[
'j_poste']);
95 printf(
'"%s";',
$row[
'j_qcode']);
96 printf(
'"%s";',
$row[
'text']);
97 printf(
'%s;',nb(
$row[
'j_montant']));
98 printf(
'"%s";',
$row[
'dc']);
99 printf(
'"%s"',
$row[
'lettrage']);
106 if (
$act==
'download_receipt')
110 $zip_file=HtmlInput::default_value_request(
'file',
'null');
111 if ($zip_file==
'null')
113 die(
'No file asked');
116 $zip_file=$_ENV[
'TMP'].
"/".$zip_file;
118 header(
'Pragma: public');
119 header(
'Content-type: application/zip');
120 header(
'Content-Disposition: attachment; filename="'.
$file.
'"');
121 $h_file=fopen($zip_file,
"r");
124 die(
'cannot open file');
126 $buffer=fread($h_file, filesize($zip_file));
for($i=0;$i< Database::num_row($ret);$i++) $row