<?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 personal</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");
              ident();
      	      autoritzar($_COOKIE["login"], "personal_propi");
              $id=addslashes($_GET["id"]);
              // Comprovem que realment modifica la seva fitxa
              es_el_seu_id($id);
              $link=Conectar();
              $result=mysql_query("SELECT * FROM personal WHERE 
              id = $id",$link);
              $row = mysql_fetch_array($result);
              $consultes=$row["consultes"];
              mysql_free_result($result);
        ?>
        <h2>Administració Personal: Modificar</h2>

        <form action="preview-mod.php" method="post">
          <?php printf ("<input name=\"id\" value=\"%s\" type=\"hidden\">", $id); ?>
          <b>Nom:</b> 
          <?php printf ("<input name=\"nom\" size=\"65\" maxlength=\"50\" type=\"hidden\"
            value=\"%s\">", htmlspecialchars($row["nom"]));
            echo htmlspecialchars($row["nom"]);
          ?>
          
          <br><br>
          <b>Despatx:</b> 
          <?php printf ("<input name=\"despatx\" size=\"15\" maxlength=\"15\" type=\"text\" value=\"%s\">",
          htmlspecialchars($row["despatx"])); ?>&nbsp;
          <b>Telf:</b> 
          <?php printf ("<input name=\"telf\" size=\"9\" maxlength=\"9\" type=\"int\"
          value=\"%s\">", htmlspecialchars($row["telf"])); ?><br><br>
          <b>E-Mail:</b> 
          <?php printf ("<input name=\"email\" size=\"30\" maxlength=\"30\" type=\"text\"
          value=\"%s\">", htmlspecialchars($row["email"])); ?>&nbsp;
          <br><br>
          <b>Web:</b>
          <?php printf ("<input name=\"web\" size=\"30\" maxlength=\"60\" type=\"text\"
          value=\"%s\">", htmlspecialchars($row["web"])); ?>
          <br><br>
          <select name="area">
          <?php
            $link=Conectar();
            $result=mysql_query("SELECT * FROM arees ORDER BY aid");
            while($row2 = mysql_fetch_array($result)){
              if ($row2["aid"] == $row["area"]) {
                echo "<option selected>";
              } else {
                echo "<option>";
              }
              echo $row2["area"] . "</option>";
            }
          ?>
          </select><br><br>
          <?php
            $checked=false;
            $result=mysql_query("SELECT * FROM becaris WHERE id=$id", $link);
            $row = mysql_fetch_array($result);
            if ($row["id"] == $id){
              printf ("<input type=\"radio\" name=\"extra\" value=\"Becari\" CHECKED>");
              $checked=true;
            } else {
              printf ("<input type=\"radio\" name=\"extra\" value=\"Becari\">");
            }
            mysql_free_result($result);
            echo "Becari<br>";

            $result=mysql_query("SELECT * FROM profes_associats WHERE id=$id");
            $row = mysql_fetch_array($result);
            if ($row["id"] == $id){
              printf ("<input type=\"radio\" name=\"extra\" value=\"Professor Associat\"
              CHECKED>");
              $checked=true;
            } else {
              printf ("<input type=\"radio\" name=\"extra\" value=\"Professor Associat\">");
            }
            echo "Professor Associat<br>";
            mysql_free_result($result);
            
            if ($checked) {
              printf("<input type=\"radio\" name=\"extra\" value=\"Cap\">");
            } else {
              printf ("<input type=\"radio\" name=\"extra\" value=\"Cap\" CHECKED>");
            }
            echo "Cap del anteriors";
          ?>
          <br><br>
          <b>Horari de consultes:</b><br><input type="text" name="consultes"
             size="65" value="<?php echo htmlspecialchars($consultes); ?>">
          <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>

