<?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>

        <!-- Començament del cos -->
        <?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";
              }

              $link=Conectar();
              $tid=addslashes($_POST["tid"]);
              $result=mysql_query("SELECT * FROM $taula WHERE tid = $tid",$link);
              $row = mysql_fetch_array($result);
              $id1 = nom($row["id1"]);
              $id2 = nom($row["id2"]);
              $id3 = nom($row["id3"]);
              $resum = $row["resum"];
              $categoria = categoria($row["categoria"]);
              mysql_free_result($result);
        ?>
        <h2>Administració Tesis: Modificar</h2>
        <form action="preview-mod.php" method="post">
          <b>Títol:</b><br>
          <?php
            printf ("<input name=\"tid\" type=hidden value=\"%s\">",
            htmlspecialchars($_POST["tid"]));
            printf ("<input name=\"lang\" type=hidden value=\"%s\">", $lang);
            printf ("<input name=\"titol\" size=\"75\" maxlength=\"100\" type=\"text\" value=\"%s\">",
            htmlspecialchars($row["titol"]));
          ?>  
          <br><br>
          <b>Paraules clau:</b><br>
          <?php
           printf ("<input name=\"keywords\" size=\"75\" maxlength=\"100\" type=\"text\"
           value=\"%s\">", htmlspecialchars($row["keywords"]));
          ?>
          <br><br>
          <b>Assignatures relacionades:</b><br>
          <?php
            printf ("<input name=\"assignatures_rel\" size=\"75\" maxlength=\"100\" type=\"text\"
            value=\"%s\">", htmlspecialchars($row["assignatures_rel"]));
          ?>
          <br><br>
          <b>Director 1:</b><br>
          <?php
            $link=Conectar();
            $result=mysql_query("SELECT nom FROM personal ORDER BY nom");
            echo "<select name=\"id1\">";
            // Si nomes pot modificar les seves tesis, al modificar una tesis no pot
            //canviar el seu nom per un altre.
            if (permis($_COOKIE["login"], "tesis_total")=="false") {
              echo "<option>" . login2nom($_COOKIE["login"]) . "</option>";
            } else {
              while($row = mysql_fetch_array($result)){
                echo "<option ";
                if ($row["nom"] == "$id1") {
                  echo "selected";
                }
                echo ">" . htmlspecialchars($row["nom"]) . "</option>";
              }
            }
            echo "</select>";
          ?>
          <br><br>
          <b>Director 2:</b><br>
          <?php
            mysql_data_seek($result, 0);
            echo "<select name=\"id2\">";
            if ($id2 == "0"){
              echo "<option selected>Cap</option>";
            } else {
              echo "<option>Cap</option>";
            }
            while($row = mysql_fetch_array($result)){
              echo "<option ";
              if ($row["nom"] == "$id2") {
                echo "selected";
              }
              echo ">" . htmlspecialchars($row["nom"]) . "</option>";
            }
            echo "</select>";
          ?>
          <br><br>
          <b>Director 3:</b><br>
          <?php
            mysql_data_seek($result, 0);
            echo "<select name=\"id3\">";
            if ($id3 == "0"){
              echo "<option selected>Cap</option>";
            } else {
              echo "<option>Cap</option>";
            }
            while($row = mysql_fetch_array($result)){
              echo "<option ";
              if ($row["nom"] == "$id3") {
                 echo "selected";
              }
              echo ">" . htmlspecialchars($row["nom"]) . "</option>";
            }
            echo "</select>";
            mysql_free_result($result);
          ?>
          <br><br>
          <b>Categoria:</b><br>
          <select name="categoria">
          <?php
            $link=Conectar();
            $result=mysql_query("SELECT titol FROM categories");
            while($row = mysql_fetch_array($result)){
              echo "<option ";
              if ($categoria == $row["titol"]) {
                echo "selected";
              }
              echo ">" . $row["titol"] . "</option>";
            }
            mysql_free_result($result);
          ?>
          </select>
          <br><br>
          <b>Resum:</b> <i>Insertar en format <a href="../ajuda/html.php"
          >HTML</a></i><br>
          <textarea name="resum" cols="65" rows="15"><?php echo
          htmlspecialchars($resum); ?></textarea><br><br>
          <b>Idioma:</b><br>
          <select name="idioma">
            <option <?php if ($lang=="cat") { echo "SELECTED"; } ?>>Català</option>
            <option <?php if ($lang=="es") { echo "SELECTED"; } ?>>Castellano</option>
            <option <?php if ($lang=="en") { echo "SELECTED"; } ?>>English</option>
          </select>
          <br><br>
          &nbsp;&nbsp;<input type="image" src="images/vistaprevia.jpg">
        </form>
        <input type="image" onClick="history.go(-1)" src="images/tornar.jpg">
        </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>

