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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <?php
header( 'content-type: text/html; charset=utf-8' );
header("Content-type: application/vnd.ms-excel; charset=utf-8");
//header("Content-Disposition: attachment; filename=stat.xls");
header("Content-Disposition: attachment; filename=Rapport.xls; charset=utf-8");
include_once('connexion_bd.php');
include_once('libphp/fonctions.php');
if(!empty($_POST['statdu']))
{
$statau = '';
$statdu = dateFrToTimeStamp($_POST['statdu']);
if(!empty($_POST['statau'])){
$statau = dateFrToTimeStamp($_POST['statau']);
}
$query_Recordset1="";
if(!empty($statau) && $statdu<$statau)
{
$mysqldu = timestampToDateMysqlGMT($statdu);
$mysqlau = timestampToDateMysqlGMT($statau);
$query_Recordset1 = "SELECT id, nom, genre, age, adulte, nationalite, lieu_appel, lieu_habit, date_appel, date_enreg, resum_appel, impress_conseil, numref, conseil, duree, langue, zone, nom_conseil, categorie, sous_categorie FROM appelant, langue, zone, conseiller, appelantcategorie, categorie, sous_categorie WHERE appelant.id_langue=langue.id_langue AND appelant.id_zone=zone.id_zone AND appelant.id_conseil=conseiller.id_conseil AND appelant.id=appelantcategorie.id_appelant AND categorie.id_categ=appelantcategorie.id_categ AND sous_categorie.id_sous_categ=appelantcategorie.id_sous_categ AND date_appel BETWEEN '$mysqldu' AND '$mysqlau' ";
}
else if(empty($statau) || $statdu==$statau)
{
$mysqldu = timestampToDateMysqlGMT($statdu);
$query_Recordset1 = "SELECT id, nom, genre, age, adulte, nationalite, lieu_appel, lieu_habit, date_appel, date_enreg, resum_appel, impress_conseil, numref, conseil, duree, langue, zone, nom_conseil, categorie, sous_categorie FROM appelant, langue, zone, conseiller, appelantcategorie, categorie, sous_categorie WHERE appelant.id_langue=langue.id_langue AND appelant.id_zone=zone.id_zone AND appelant.id_conseil=conseiller.id_conseil AND appelant.id=appelantcategorie.id_appelant AND categorie.id_categ=appelantcategorie.id_categ AND sous_categorie.id_sous_categ=appelantcategorie.id_sous_categ AND date_appel='$mysqldu'";
}
if(!empty($query_Recordset1))
{
$Recordset1 = mysql_query($query_Recordset1) ;
//$Recordset1 = mysql_query($query_Recordset1) or die ("pb requette ".mysql_error()); tu as deja selectionne la base donc mysql_query suffit
$totalrow_Recordset1 = mysql_num_rows($Recordset1);
$tbl = "";
if($totalrow_Recordset1>0)
{
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1))
{
$tbl .= "<tr>\r\n";
$tbl .= " <td>" . $row_Recordset1['id'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['nom'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['genre'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['age'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['adulte'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['nationalite'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['lieu_appel'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['lieu_habit'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['date_appel'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['date_enreg'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['resum_appel'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['impress_conseil'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['numref'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['conseil'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['duree'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['langue'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['zone'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['nom_conseil'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['categorie'] . "</td>\r\n";
$tbl .= " <td>" . $row_Recordset1['sous_categorie'] . "</td>\r\n";
$tbl .= "</tr> \r\n";
}
$tableau= " <table border='1' cellpadding='0' cellspacing='0'>
<tr bgcolor='#CCCCCC' height='40px'>
<td>Identifiant</td>
<td>Nom</td>
<td>Genre</td>
<td>Age</td>
<td>Adulte</td>
<td>Nationalite</td>
<td>Lieu Appel</td>
<td>Lieu Habitation</td>
<td>Date d'Appel</td>
<td>Date d'Enregistrement</td>
<td>Resume Appel</td>
<td>Impression Conseiller</td>
<td>Numeros Reference</td>
<td>Conseil</td>
<td>Duree</td>
<td>Langue</td>
<td>Zone</td>
<td>Conseiller</td>
<td>Categorie</td>
<td>Sous Categorie</td>
</tr>
".$tbl."\r\n</table>" ;
print $tableau ;
}
}
} |