forked from ATM-Consulting/dolibarr_module_abricot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownlist.php
74 lines (55 loc) · 1.67 KB
/
downlist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$s_name = $_POST['session_name'] or die('Pas de session trouvée');
session_name($s_name);
session_start();
if(empty($_SESSION['token_list_'.$_POST['token']])) die('token de session liste invalide');
$TData = unserialize( gzinflate( $_SESSION['token_list_'.$_POST['token']]) );
$mode = $_POST['mode'];
$title = $TData['title'];
$sql = $TData['sql'];
$TBind = $TData['TBind'];
$TEntete = $TData['TEntete'];
$TChamps = $TData['TChamps'];
if(empty($title)) $title = 'report';
if($mode == 'CSV') {
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename='. $title.'.csv');
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
$r='';
foreach($TEntete as &$entete) {
$r.='"'.addslashes($entete['libelle']).'";';
}
$r.=PHP_EOL;
foreach($TChamps as $row) {
foreach($row as $v) {
$r.='"'.addslashes(strip_tags( $v )).'";';
}
$r.=PHP_EOL;
}
echo $r;
exit();
}
else if($mode == 'TXT') {
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename='. $title.'.txt');
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
$r='';
foreach($TEntete as &$entete) {
$r.='"'.addslashes($entete['libelle']).'"'."\t";
}
$r.=PHP_EOL;
foreach($TChamps as $row) {
foreach($row as $v) {
$r.='"'.addslashes(strip_tags($v)).'"'."\t";
}
$r.=PHP_EOL;
}
echo $r;
exit();
}
else if ($mode == 'PDF') {
}