<?php
# ---------------------------------------
# Paperasse (c) 2006 Guillaume BETTAYEB
# mail and documents management web page
# hide@address.com
# ---------------------------------------
function AfficherContact($id){
$query = false;
$sql = "SELECT `id`,`nom` FROM `contacts` WHERE `id`=$id";
$query = mysql_query($sql) OR die(mysql_error());
$array = mysql_fetch_array($query,MYSQL_ASSOC);
extract($array);
$AfficherContact = "<a href=\"index.php?page=ajouter_contact&id=$id\">$nom</a>";
return $AfficherContact;
}
function AfficherUtilisateur($id){
$query = false;
$sql = "SELECT `id`,`nom` FROM `utilisateurs` WHERE `id`=$id";
$query = mysql_query($sql) OR die(mysql_error());
$array = mysql_fetch_array($query,MYSQL_ASSOC);
extract($array);
$AfficherUtilisateur = "<a href=\"index.php?page=ajouter_utilisateur&id=$id\">$nom</a>";
return $AfficherUtilisateur;
}
function AfficherCouleurs($dossier){
$query = mysql_query("SELECT `nom`,`couleur` FROM `dossiers` WHERE `id` = '$dossier'");
$res = mysql_fetch_array($query,MYSQL_ASSOC);
extract($res);
$AfficherCouleurs = "<font color=\"$couleur\">$nom</font>";
return $AfficherCouleurs;
}
function AfficherResultats(){
if(func_num_args()==0){
$sort = 'date';
}
else{
$sort = func_get_arg(0);
}
$query = mysql_query("SELECT * FROM `papiers` ORDER BY $sort");
while($array = mysql_fetch_array($query,MYSQL_ASSOC)){
$array['date'] = InverserDate(str_replace('-','/',$array['date']));
$array['datepapier'] = InverserDate(str_replace('-','/',$array['datepapier']));
$res = "<tr><td class=\"texte\">".$array['id']."</td>"."<td class=\"texte\">".$array['modalite']."</td>"."<td class=\"texte\">".AfficherCouleurs($array['dossier'])."</td>"."<td class=\"texte\">".AfficherUtilisateur($array['utilisateur'])."</td>"."<td class=\"texte\">".AfficherContact($array['contact'])."</td>"."<td class=\"texte\"><a href=\"index.php?page=ajouter_papier&id=".$array['id']."\" class=\"texte\" onmouseover=\"montre('Cliquez pour editer ce ".substr($array['objet'], 0, 8)."...');\" onmouseout=\"cache();\">".substr($array['objet'], 0, 40)."</a></td>"."<td class=\"texte\">".$array['date']."</td><td class=\"texte\">".$array['datepapier']."</td></tr>";
echo $res;
}
}
?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" class="tableau">
<tr>
<td width="1%"><strong><a href="index.php?page=liste_papiers&sort=id">Id</a></strong></td>
<td><a href="index.php?page=liste_papiers&sort=modalite"><strong>modalite</strong></a></td>
<td><a href="index.php?page=liste_papiers&sort=dossier"><strong>dossier</strong></a></td>
<td><a href="index.php?page=liste_papiers&sort=utilisateur"><strong>utilisateur :</strong></a></td>
<td><a href="index.php?page=liste_papiers&sort=contact"><strong>contact :</strong></a></td>
<td><a href="index.php?page=liste_papiers&sort=objet"><strong>objet</strong></a></td>
<td><a href="index.php?page=liste_papiers&sort=date"><strong>entré le</strong></a></td>
<td><a href="index.php?page=liste_papiers&sort=datepapier"><strong>en date du </strong></a></td>
</tr>
<?php
if(isset($HTTP_GET_VARS['sort'])){
AfficherResultats($HTTP_GET_VARS['sort']);
}
else{
AfficherResultats();
}
?>
</table>