<?php // $Id: iInsertAuthor.php,v 1.1 2005/10/21 14:09:56 geothms Exp geothms $
session_start();
$pTipoUtilizador = $_SESSION['tipoUtilizador'];
if ($pTipoUtilizador=="anonymous" || $pTipoUtilizador=="regular") { // separa por tipo de utilizador
  require('headersubUsers.inc');
  require('menusubUsers.inc');
  echo "<meta http-equiv='refresh' content='0; url=../users.php' />";
  exit;  // os anonimos não têem acesso a esta página
}
else {
  require('headersubAdmins.inc');
  require('menusubAdmins.inc');
}
?>



<hr/>



<?php
require('loginsub.php');
?>


<center>
<h3 class="maketitle">Geometric Drawer Update</h3>
</center>

<hr/>

<?php
$argumento = $_GET['argumento'];

// cria uma pesquisa
$sql = "SELECT drawerId,name,version,description,url,email,dateSubmission
          FROM drawers
         WHERE drawerId='$argumento'";

$resultado = mysql_query($sql,$ligacao);

$ncampos =mysql_num_fields($resultado);


$linha = mysql_fetch_assoc($resultado);

$pDrawerId       = $linha['drawerId'];
$pName           = $linha['name'];
$pVersion        = $linha['version'];
$pDescription    = $linha['description'];
$pURL            = $linha['url'];
$pEmail          = $linha['email'];
$pDateSubmission = $linha['dateSubmission'];


echo "<form enctype='multipart/form-data' action='uUpdateDrawer.php' method='post'>";
echo "<!-- ficha -->";
echo "<table width='100%' bgcolor='white' cellpadding='4' cellspacing='4'>";
echo "<tr>";
echo "<td width='100%' colspan='8' align='center'>Geometric Drawer Info</td>";
// O valor de DrawerId tem de ser passado para o processador do
// formulário, embora como hidden.
echo "<input type='hidden' name='DrawerId' value='$pDrawerId'>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' width='12.5%'><span class='ficha'>Name</span></td>";
echo "<td width='25%' colspan='3'><span class='entrada'><input type='text' name='Name' value='$pName' size='50'></span></td>";
echo "<td align='left' width='12.5%'><span class='ficha'>Version</span></td>";
echo "<td width='25%' colspan='3'><span class='entrada'><input type='text' name='Version' value='$pVersion' size='20'></span></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='25%' colspan='2'><span class='opcional'>Description</span></td>";
echo "<td width='75%' colspan='6'><TEXTAREA NAME='Description' ROWS='10' COLS='120'>$pDescription</TEXTAREA></td>";
echo "</tr>";
echo "<td width='25%' colspan='2'><span class='opcional'>URL</span></td>";
echo "<td width='75%' colspan='6'><input type='text' name='URL' value='$pURL' size='100'></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='25%' colspan='2'><span class='opcional'>Email</span></td>";
echo "<td width='75%' colspan='6'><input type='text' name='Email' value='$pEmail' size='100'></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='25%' colspan='2'>Date of Submission</td>";
echo "<td width='25%' colspan='2'><input type='text' name='DateSubmission' value='$pDateSubmission' size='25'></td>"; 
echo "<td width='50%' colspan='4'> &nbsp; </td>"; 
echo "</tr>";
// E agora a pesquisa para a informação referente aos autores
$sqlAuthorId = "SELECT authorId
                  FROM authordrawer
                 WHERE drawerId ='$pDrawerId'";
$resultadoAuthorId = mysql_query($sqlAuthorId,$ligacao);
echo "<tr>";
echo "<td width='100%' colspan='8' align='center'>Authors Info</td>";
echo "</tr>";
// E agora a informação referente aos autores
while ($linhaAuthorId = mysql_fetch_assoc($resultadoAuthorId)) { 
  //Vai-se buscar a informação do autor à tabela respectiva
  $pAuthorId = $linhaAuthorId['authorId'];
  $sqlAuthorInfo = "SELECT name,affiliation
                      FROM authors
                     WHERE authorId ='$pAuthorId'";
  $resultadoAuthorInfo = mysql_query($sqlAuthorInfo,$ligacao);
  $linhaAuthorInfo = mysql_fetch_assoc($resultadoAuthorInfo);
  $pAuthorName = $linhaAuthorInfo['name'];
  $pAuthorAffiliation = $linhaAuthorInfo['affiliation'];
  echo "<tr>";
  echo "<td width='25%'colspan='2' ><span class='ficha'>Author's Name</span> </td>";
  echo "<td width='75%' colspan='6'>$pAuthorName</td>";
  echo "</tr>";
  echo "<tr>"; 
  echo "<td width='25%'colspan='2' ><span class='ficha'>Author's Affiliation</span> </td>";
  echo "<td width='75%' colspan='6'>$pAuthorAffiliation</td>";
  echo "</tr>";
 }
echo "<tr>";
echo "<td width='100%' colspan='8' align='center'><input type='submit' value='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update info &nbsp; & &nbsp; Go to Add Authors &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'></td>";
echo "</tr>  ";
echo "</table>";
echo "</form>";
?>

<hr/>

<?php
  require('footer.inc');
?>