<?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>Deiminari Mail</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/text.inc");
          require ("../private/func-deiminaris.inc");
          
          ident();
      	  autoritzar($_COOKIE["login"], "deiminaris");
          $did=addslashes($_POST["did"]);
          $link=Conectar();

          $result=mysql_query("SELECT * FROM deiminaris_mail", $link);
          while ($row = mysql_fetch_array($result)){
            if ($mails == "") {
              $mails = $row["email"];
            } else {
              $mails= $mails . ", " . $row["email"];
            }
          }

          $result=mysql_query("SELECT * FROM deiminaris WHERE did=$did", $link);
          $row = mysql_fetch_array($result);

          mysql_free_result($result);
        ?>
        <h2>Administració Deiminaris: Enviar notificació</h2>
        <?php
              $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);

              $subjectpre = "Pre-Anunci DEIMinari";
              $bodypre="El dia ". $dd . " " . $mes . " " . $yy . " hi haurà un nou seminari, al"
              . " qual esteu tots convidats.\n";
              $subject = "Anunci DEIMinari";
              $body="Avui hi haurà un nou seminari, al qual esteu tots convidats.\n";

              $bodyStandard = "\nTrobareu l'anunci a http://deim.etse.urv.es/deiminaris/deiminaris.php\n" . "i les seguents línies:\n\n" .
              "---------------------------------------------------------------------\n\n" .
              htmlspecialchars($row["titol"]) . "\n\n" .
              htmlspecialchars($row["encarregat"]) . "\n\n" .
              htmlspecialchars($row["institucio"]) . "\n\n" .
              htmlspecialchars($row["departament"]) . "\n\n" .
              unformat_all($row["resum"]) . "\n\n" .
              "Dia: " . $dd . " " . $mes . " " . $yy . "\n" .
              "Hora: " . htmlspecialchars($row["hora"]) . "\n" .
              "Lloc: " . htmlspecialchars($row["lloc"]) . "\n" .
              "Obert a: " . htmlspecialchars($row["obert_a"]) . "\n" .
              "Idioma: " . htmlspecialchars($row["idioma"]) . "\n";
             

              echo "<form action=\"sendmail.php\" method=\"post\">
                      <br><h2>PRE-ANUNCI</h2>
                      <br><b>Asunte:</b><br>
                      <input type=\"text\" name=\"subject\" size=\"80\" value=\"$subjectpre\"><br>
                      <br><b>Destinataris:</b><br>
                      <input type=\"text\" name=\"mails\" size=\"80\" value=\"$mails\"><br>
                      <br><b>Missatge:</b><br>
                      <textarea name=\"body\" cols=\"80\" rows=\"20\">$bodypre $bodyStandard</textarea><br>
                      <input type=\"hidden\" name=\"did\" value=\"" .
                      htmlspecialchars($did) . "\">
                      <br>&nbsp;&nbsp;<input type=\"image\" border=0
                      src=\"images/enviar.jpg\"></form>";

              echo "<form action=\"sendmail.php\" method=\"post\">
                      <br><h2>ANUNCI</h2>
                      <br><b>Asunte:</b><br>
                      <input type=\"text\" name=\"subject\" size=\"80\" value=\"$subject\"><br>
                      <br><b>Destinataris:</b><br>
                      <input type=\"text\" name=\"mails\" size=\"80\" value=\"$mails\"><br>
                      <br><b>Missatge:</b><br>
                      <textarea name=\"body\" cols=\"80\" rows=\"20\">$body $bodyStandard</textarea><br>
                      <input type=\"hidden\" name=\"did\" value=\"" .
                      htmlspecialchars($did) . "\">
                      <br>&nbsp;&nbsp;<input type=\"image\" border=0
                      src=\"images/enviar.jpg\"></form>";


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

