Location: PHPKode > scripts > TAF > taf/html/index.php
<!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&acirc;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&egrave;s &agrave; 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&eacute;vu pour <b>$REMOTE_USER</b>.\n";
    echo "Mais vous pouvez toujours <a href='insert.php'>ajouter un &eacute;l&eacute;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 &agrave; faire, tri&eacute;es par priorit&eacute; et date de d&eacute;but.<br><br>\n";
    echo "<table border=0><tr bgcolor=green>";
    echo "<td></td><td></td>";
    echo "<td><font color=white>Date d&eacute;but</font></td>";
    echo "<td><font color=white>Priorit&eacute;</font></td>";
    echo "<td><font color=white>Cat&eacute;gorie</font></td>";
    echo "<td><font color=white>Perso</font></td>";
    echo "<td><font color=white>D&eacute;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&acirc;che n'est &agrave; la recherche d'un\n";
    echo "gentil utilisateur pouvant la mener &agrave; terme.\n";
    echo "Mais vous pouvez toujours <a href='insert.php'>ajouter un &eacute;l&eacute;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 &agrave; 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&eacute;but</font></td>";
    echo "<td><font color=white>Priorit&eacute;</font></td>";
    echo "<td><font color=white>Cat&eacute;gorie</font></td>";
    echo "<td><font color=white>D&eacute;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&eacute;s</h2>
<p>Vous pouvez <a href='insert.php'>ins&eacute;rer</a> une nouvelle
t&acirc;che, voir la liste des <a href='list.php?closed=t'>t&acirc;ches termin&eacute;es</a>, voir la
liste de 
<?
  echo "<a href='list.php?closed=t&owner=$REMOTE_USER'><b>vos</b> t&acirc;ches termin&eacute;es</a>.";
?>

<? include "$DOCUMENT_ROOT/section-footer.shtml" ?>
<? include "$DOCUMENT_ROOT/page-footer.shtml" ?>
</BODY></HTML>
Return current item: TAF