47 lines
959 B
PHP
Executable File
47 lines
959 B
PHP
Executable File
<?php
|
|
|
|
include('auth.php');
|
|
|
|
if ( empty($_GET) )
|
|
die(EngineSystem::get('back')->load('pages/export.html')->run()->getData(''));
|
|
|
|
|
|
$a = Provider::get('etpa')->query(sprintf(
|
|
'SELECT * FROM contact WHERE "%1$s" <= date AND date <= "%2$s";',
|
|
$_GET['begin'],
|
|
$_GET['end']
|
|
));
|
|
|
|
if ( !$a[0] ) {
|
|
|
|
die(EngineSystem::get('back')->load('pages/error.html')->run(array(
|
|
'message' => "Aucun contact enregistré entre les dates selectionnées."
|
|
))->getData(''));
|
|
|
|
}
|
|
|
|
$schema = array_keys($a[0][0]);
|
|
|
|
header("Content-disposition: attachment; filename=export.xls");
|
|
header("Content-Type: application/force-download");
|
|
|
|
echo "<table>\n";
|
|
|
|
echo "\t<tr>\n";
|
|
foreach ( $schema as $field )
|
|
echo sprintf("\t\t" . '<th>%1$s</th>' . "\n", $field);
|
|
echo "\t</tr>\n";
|
|
|
|
foreach ( $a[0] as $row ) {
|
|
|
|
echo "\t<tr>\n";
|
|
|
|
foreach ( $row as $k => $v )
|
|
echo sprintf('<td>%1$s</td>', utf8_decode($v));
|
|
echo "\t</tr>\n";
|
|
|
|
}
|
|
|
|
echo '</table>';
|
|
|
|
?>
|