<?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>Modificar tesi</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ó Tesis: Modificar</h2>
        <!-- Començament del cos -->
        <table border=0 width="190"><tr>
        <td align="center"><a href="modificar.php?lang=cat"><img src="images/catala.jpg" border=\"0\"></a></td>
        <td align="center"><a href="modificar.php?lang=en"><img src="images/english.jpg" border=\"0\"></a></td>
        <td align="center"><a href="modificar.php?lang=es"><img src="images/castellano.jpg" border=\"0\"></a></td>
        </tr></table>
        <br>

        <?php require("../private/connect.inc");
              require("../private/ident.inc");
              require("../private/func.inc");
              ident();
      	      autoritzar($_COOKIE["login"], "tesis");
              $lang = $_REQUEST["lang"];
              if ($lang == "es") {
                $taula = "tesis_es";
              } else if ($lang == "en") {
                $taula = "tesis_en";
              } else {
                $taula = "tesis";
              }
              // Comprovem si te permis per modificar totes les tesis o nomes les seves
              if (permis($_COOKIE["login"], "tesis_total")=="false") {
                $id = login2id($_COOKIE["login"]);
                $link=Conectar();
                $result=mysql_query("SELECT tid,titol,id1,id2,id3 FROM $taula WHERE id1 = $id
                OR id2 = $id OR id3 = $id", $link);
              } else {
                $link=Conectar();
                $result=mysql_query("SELECT tid,titol,id1,id2,id3 FROM $taula ");
              }
              echo("<table border=\"0\" width=\"90%\" align=\"left\">");
              echo("<tr bgcolor=\"#4f0000\"><td><b>Titol</b></td><td><b>Director</b></td></tr>");
              while($row = mysql_fetch_array($result)){
                $tid = $row["tid"];
                echo("<tr><td align=\"left\"> <div align=\"left\">" .
                htmlspecialchars($row["titol"]) . "</td>" );
                // Obtenim el directors, si algun es 0 vol dir que no te cap assignat
                $id1=htmlspecialchars(nom($row["id1"]));
                $id2=" <br> " . htmlspecialchars(nom($row["id2"]));
                if ($id2==" <br> 0") $id2="";
                $id3=" <br> " . htmlspecialchars(nom($row["id3"]));
                if ($id3==" <br> 0") $id3="";
                printf("<td><br>%s %s %s</b>&nbsp;&nbsp;&nbsp;</td>",
                $id1, $id2,$id3);
                echo("<td><form action=\"modificar-reg.php\" method=\"post\"><input
                      type=\"hidden\" name=\"tid\" value=\"" . htmlspecialchars($tid) . "\">
                      <input type=\"hidden\" name=\"lang\" value=\"" . $lang . "\">");
                echo("<input type=\"image\" src=\"images/modificar.jpg\"></form></td></tr>");
              }
              mysql_free_result($result);
        ?>
        <td><br><a href="../login.php"><input type="image" src="images/tornar.jpg" border="0"></a></td>
        </table>
        </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>

