Location: PHPKode > scripts > TAF > taf/html/list.php
<!DOCTYPE HTML PUBLIC "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN">
<HTML>
<HEAD>
<TITLE>Taches - liste</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</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 " retour &agrave; l'<a href='./'>accueil</a>";
     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 est demandé...
   */
  if (($closed != 't') || ($closed != 'f')) $closed='t';

  $sql="select *,pr.value as prvalue, ca.value as cavalue
	from item,priority pr,category ca
	where closed='$closed' and pr.id=priority_id and ca.id=category_id";
  if ($owner == "" || $owner != $REMOTE_USER) $sql = $sql . " and private = 'f'";
  if ($owner != "") $sql = $sql . " and owner = '$owner'";
  $sql=$sql . " order by enddate, priority_id;";
  $sql_res = pg_Exec($conn, $sql);
  $sql_count = pg_NumRows($sql_res);
  if ((!$sql_res) || ($sql_count < 1))
  {
    echo "<h2>Rien ne correspond</h2>";
    echo "<p>Aucune t&acirc;che ne correspond &agrave; vos crit&egrave;res ";
    echo "de s&eacute;lection. Reformulez votre demande.";
  }
  else
  {

    /*
     * Et là, on, va afficher le résultat
     */
    echo "<h2>T&acirc;ches termin&eacute;es</h2>";
    echo "<table border=0><tr bgcolor=green>";
    echo "<td></td>";
    echo "<td><font color=white>Date d&eacute;but</font></td>";
    echo "<td><font color=white>Date fin</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>Propri&eacute;taire</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>";

      $owner=pg_result($sql_res, $i, "owner");
      if ($owner == $REMOTE_USER)
      {
        echo "<td><a href='take.php?delete=1&id=";
        echo pg_result($sql_res, $i, "id");
        echo "'><img border=0 src='bomb.gif' alt='Effacer definitivement'></a></td>";
      }
      else
        echo "<td></td>";
      echo "<td>";
      echo pg_result($sql_res, $i, "startdate");
      echo "</td><td>";
      echo pg_result($sql_res, $i, "enddate");
      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>";
      echo pg_result($sql_res, $i, "owner");
      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, ou revenir &agrave; <a href='index.php'>la liste des t&acirc;ches</a>.

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