<?php setcookie("login", $_COOKIE["login"] , time()+3600, "/", "deim.etse.urv.es", 1 ); ?>
<?php setcookie("sessio", $_COOKIE["sessio"] , time()+3600, "/", "deim.etse.urv.es", 1 ); ?>
<html>
  <head>
    <link rel="stylesheet" href="../estils/hoja.css" type="text/css" />
    <title>Deiminaris</title>
  </head>

  <body leftmargin="0" topmargin="0" bgcolor="#8F0000">
    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
      <tr>
        <!-- Menú dret -->

        <td align="left" valign="top" width="100" bgcolor="#4F0000">
          <?php include("../menu.inc") ?>
        </td>
        <!-- Capçalera -->

        <td align="left" valign="top" width="100%" class="centered">
          <h2>Departament d'Enginyeria Informàtica i Matemàtiques</h2>
          <img src="images/separador.gif"><br>
          <br>

          <div align="left">
            <blockquote>
            <h2>Administració Deiminaris: Extra</h2>
              <!-- Començament del cos -->
        <?php require("../private/connect.inc");
              require("../private/ident.inc");
              require ("../private/func-deiminaris.inc");
              
              ident();
              autoritzar($_COOKIE["login"], "deiminaris");

              $link=Conectar();
              $result=mysql_query("SELECT did,titol,data,hora,encarregat FROM deiminaris WHERE
                data>=curdate() ORDER BY data DESC", $link);
              $row = mysql_fetch_array($result);
              // Només visualitzar si n'hi ha nous
              if ($row["did"]!=null) {
                echo("<table border=\"0\" width=\"90%\" >");
                echo("<tr bgcolor=black><td><b>Data</b></td> <td><b>Hora</b></td>
                      <td><b>Titol</b></td> <td><b>Autor</b></td></tr>");
                do{
                  $dd = substr($row["data"], 8, 2);
                  $mm = substr($row["data"], 5, 2);
                  $yy = substr($row["data"], 0, 4);

                  // Guardem en $mes el nom corresponent
                  $mes = num2mes($mm);


                  $did = $row["did"];
                  if (($dd!=31)||($mm!=12)||($yy!=9999)){
                    echo("<tr><td align=\"left\"> <div align=\"left\">" . $dd . " " . $mes . " "
                    . $yy . "</td>");
                    echo("<td align=\"left\"> <div align=\"left\">" . $row["hora"] .
                    "</td>");
                  } else {
                    echo("<tr><td align=\"left\"> <div align=\"left\">Sense
                    determinar</td><td></td>");
                  }
                  printf("<td><b>&nbsp; %s</b></td>", 
                      htmlspecialchars($row["titol"]));
                  printf("<td>%s</td>",
                      htmlspecialchars($row["encarregat"]));
                  echo("<td><form action=\"print.php\" method=\"get\"><input
                        type=\"hidden\" name=\"did\" value=\"$did\">");
                  echo("<input type=\"image\" border=0 
                    src=\"images/imprimir.jpg\"></form></td>");
                  if (($dd!=31)||($mm!=12)||($yy!=9999)){
                    echo("<td><form action=\"email.php\" method=\"post\"><input
                          type=\"hidden\" name=\"did\" value=\"$did\">");
                    echo("<input type=\"image\" border=0
                      src=\"images/email.jpg\"></form></td></tr>");
                  } else {
                    echo "</tr>";
                  }
                }while($row = mysql_fetch_array($result));
                echo "</table>";
              } else {
                echo "<i>No hi ha cap seminari nou programat.</i>";
              }
              mysql_free_result($result);
        ?>
              <br><br><h2>Llista E-Mails</h2>
              <b>Afegir</b><br><br>
              <form action="afegir-maildb.php" method="POST">
                <input type="text" size="30" maxlength="50" name="email">
                <input type="image" border=0 src="images/afegir.jpg">
              </form>
              <br>
              <b>Esborrar</b><br><br>
              <form action="esborrar-maildb.php" method="POST">
                <select name="email">
                <?php
                  $link=Conectar();
                  $result=mysql_query("SELECT email FROM deiminaris_mail");
                  while($row = mysql_fetch_array($result)){
                    echo "<option>" . $row["email"] . "</option>";
                  }
                  mysql_free_result($result);
                ?>
                </select>
                <input type="image" border=0 src="images/esborrar.jpg">
              </form>
              <br><h2>Enviar Mails no predefinits</h2>
              <li><a href="blankmail.php">Composició de nou Mail</a></li>

              <br><br>
              <a href="../login.php"><img src="images/tornar.jpg" border="0"></a>
            </blockquote>
          </div>
        </td>
        <td align="left" valign="top" width="100">
          <br />
          <br />
          <br />
          <br />
          <a href="../desconectar.php" class="link2"><img src="images/tancar.jpg" border="0"></a>
        </td>

      </tr>
    </table>
  </body>
</html>

