<!DOCTYPE HTML PUBLIC "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN">
<HTML>
<HEAD>
<TITLE>Taches</TITLE></HEAD>
<BODY LEFTMARGIN="0" TOPMARGIN="0" BACKGROUND="/13a.jpg">
<?
include "$DOCUMENT_ROOT/page-header.shtml";
include "$DOCUMENT_ROOT/section-header.shtml";
echo "<H1 ALIGN=center>Tâches pour $REMOTE_USER</H1>";
/*
* On se connecte à la base, et on ne joue que si ça marche
*/
$conn = pg_connect("dbname=tafdb");
if (!$conn)
{
echo "<h2>Une erreur est survenue</h2>";
echo "<p>Accès à la base impossible.</p>";
echo "<HR WIDTH='50%'>\n";
include "$DOCUMENT_ROOT/section-footer.shtml";
include "$DOCUMENT_ROOT/page-footer.shtml";
echo "</BODY></HTML>";
exit;
}
/*
* Les requêtes SQL qui vont bien ...
*/
$sql="SET DateStyle TO 'European';";
pg_Exec($sql);
/*
* On récupère d'abord ce qui concerne le chtit gars...
*/
$sql="select *, pr.value as prvalue, ca.value as cavalue
from item,priority pr,category ca
where owner='$REMOTE_USER' and closed='f' and pr.id=priority_id and ca.id=category_id
order by priority_id, startdate desc;";
$sql_res = pg_Exec($conn, $sql);
$sql_count = pg_NumRows($sql_res);
if ((!$sql_res) || ($sql_count < 1))
{
echo "<h2>Petit veinard...</h2>";
echo "<p>Rien n'est prévu pour <b>$REMOTE_USER</b>.\n";
echo "Mais vous pouvez toujours <a href='insert.php'>ajouter un élément</a>.\n";
}
else
{
/*
* Et là, on, va afficher le résultat pour le chtit gars ...
*/
echo "<h2>Voici votre menu</h2>";
echo "<p>Liste des choses à faire, triées par priorité et date de début.<br><br>\n";
echo "<table border=0><tr bgcolor=green>";
echo "<td></td><td></td>";
echo "<td><font color=white>Date début</font></td>";
echo "<td><font color=white>Priorité</font></td>";
echo "<td><font color=white>Catégorie</font></td>";
echo "<td><font color=white>Perso</font></td>";
echo "<td><font color=white>Détail</font></td>";
echo "</tr>\n";
for ($i=0; $i < $sql_count; $i++)
{
if (($i % 2) == 0)
echo "<tr>";
else
echo "<tr bgcolor=lightblue>";
$item_id=pg_result($sql_res, $i, "id");
echo "<td>";
echo "<a href='done.php?id=$item_id";
echo "'><img border=0 src='alert.black.gif' alt='Marquer comme fini'></a>";
echo "<a href='insert.php?id=$item_id";
echo "'><img border=0 src='quill.gif' alt='Modifier'></a>";
echo "<td></td>";
echo "<td>";
echo pg_result($sql_res, $i, "startdate");
echo "</td><td>";
echo pg_result($sql_res, $i, "prvalue");
echo "</td><td>";
echo pg_result($sql_res, $i, "cavalue");
echo "</td><td>";
$perso=pg_result($sql_res, $i, "private");
if ($perso == 't')
{
echo "Oui";
}
else
{
echo "Non";
}
echo "</td><td><pre>";
echo pg_result($sql_res, $i, "detail");
echo "</pre></td></tr>\n";
}
echo "</table>";
}
/*
* Et là, on va voir si il y a des tâches non assignées...
*/
$sql="select *, ca.value as cavalue, pr.value as prvalue from item,priority pr, category ca where owner='' and closed='f' and pr.id=priority_id and ca.id=category_id order by priority_id, startdate;";
$sql_res = pg_Exec($conn, $sql);
$sql_count = pg_NumRows($sql_res);
if ((!$sql_res) || ($sql_count < 1))
{
echo "<h2>Tout baigne...</h2>";
echo "<p>Aucune tâche n'est à la recherche d'un\n";
echo "gentil utilisateur pouvant la mener à terme.\n";
echo "Mais vous pouvez toujours <a href='insert.php'>ajouter un élément</a>.\n";
}
else
{
/*
* Et là, on, va afficher le résultat pour le chtit gars ...
*/
echo "<h2>Choisissez donc</h2>";
echo "<p>Liste des choses à faire, n'ayant pas encore de preneur.<br><br>\n";
echo "<table border=0><tr bgcolor=green>";
echo "<td></td><td></td>";
echo "<td><font color=white>Date début</font></td>";
echo "<td><font color=white>Priorité</font></td>";
echo "<td><font color=white>Catégorie</font></td>";
echo "<td><font color=white>Détail</font></td>";
echo "</tr>\n";
for ($i=0; $i < $sql_count; $i++)
{
if (($i % 2) == 0)
echo "<tr>";
else
echo "<tr bgcolor=lightblue>";
$item_id=pg_result($sql_res, $i, "id");
echo "<td>";
echo "<a href='take.php?id=$item_id";
echo "'><img border=0 src='hand.right.gif' alt='Prendre en charge'></a>";
echo "<td></td>";
echo "<td>";
echo pg_result($sql_res, $i, "startdate");
echo "</td><td>";
echo pg_result($sql_res, $i, "prvalue");
echo "</td><td>";
echo pg_result($sql_res, $i, "cavalue");
echo "</td><td><pre>";
echo pg_result($sql_res, $i, "detail");
echo "</pre></td></tr>\n";
}
echo "</table>";
}
?>
<h2>Autres possibilités</h2>
<p>Vous pouvez <a href='insert.php'>insérer</a> une nouvelle
tâche, voir la liste des <a href='list.php?closed=t'>tâches terminées</a>, voir la
liste de
<?
echo "<a href='list.php?closed=t&owner=$REMOTE_USER'><b>vos</b> tâches terminées</a>.";
?>
<? include "$DOCUMENT_ROOT/section-footer.shtml" ?>
<? include "$DOCUMENT_ROOT/page-footer.shtml" ?>
</BODY></HTML>