<?	
include ('logue.php'); 
include ('entete2.php');
include ('ressource.php');
include ('entete.php');

$sql2 = "SELECT hangarfer_lvl,hangarfer_evolution,hangaror_lvl,hangaror_evolution,hangarada_lvl,hangarada_evolution,hangaror_lvl,hangarura_lvl,hangarura_evolution FROM matgraph_users WHERE id='$planete' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2);

echo"<style>
input {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
textarea {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
select, option {
background-color:#000000;
color:white;
}
</style>
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
</STYLE>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"_parent\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">
         <input name=\"page\" value=\"" . $PHP_SELF . "\" type=\"hidden\" id=\"page\">
         <select name=\"idcolo\" onchange=submit()>";
include ('colo2.php'); 
echo" Proposition de pacte : <br>";
$req = "SELECT * FROM matgraph_explorer WHERE receveur = $idlogin ORDER BY type,id DESC";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  While ( $row = mysql_fetch_array($res) ) {
$sql3 = "SELECT login,galaxi,system,position FROM matgraph_users WHERE id='$row[planete_envoyeur]' ";
$res3 = db_mysql_Query($sql3)or die('erreur sql<br>'.$sql3.'<br>'.mysql_error());
$row3 = mysql_fetch_array($res3);  
echo"<br><table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
  <tr style =\"background-color:#111111;\">
    <td width=\"97\">Envoyer Par : </td>
    <td colspan=\"2\">$row3[login] [$row3[galaxi]:$row3[system]:$row3[position]]</td>
    </tr>
  <tr>
    <td>Envoyer le : </td>
    <td colspan=\"2\">$row[date]</td>
  </tr>
  <tr style =\"background-color:#111111;\">
    <td width=\"97\">Type de pacte : </td>
    <td colspan=\"2\">$row[type]</td>
  </tr>
  <tr>
    <td rowspan=\"2\" valign=\"top\">Message : </td>
    <td colspan=\"2\" valign=\"top\">$row[message]</td>
  </tr>
  <tr style =\"background-color:#111111;\">
    <form name=\"ac\" method=\"post\" action=\"commerce_accepter.php\" target=\"_parent\"><td width=\"257\"><div align=\"center\">
      <input name=\"id\" type=\"hidden\" id=\"id\" value=\"$row[id]\">
	  <input name=\"planete\" type=\"hidden\" id=\"planete\" value=\"$row[planete_envoyeur]\">
	  <input name=\"type\" type=\"hidden\" id=\"type\" value=\"$row[type]\">
	  <input name=\"envoyeur\" type=\"hidden\" id=\"envoyeur\" value=\"$row[envoyeur]\">
      <input type=\"submit\" name=\"Submit\" value=\"Accepter\">
    </div></td></form>
    <form name=\"ref\" method=\"post\" action=\"commerce_refuser.php\" target=\"_parent\"><td width=\"256\"><div align=\"center\">
	<input name=\"id\" type=\"hidden\" id=\"id\" value=\"$row[id]\">
	<input name=\"envoyeur\" type=\"hidden\" id=\"envoyeur\" value=\"$row[envoyeur]\">
	<input name=\"type\" type=\"hidden\" id=\"type\" value=\"$row[type]\">
	<input name=\"planete\" type=\"hidden\" id=\"planete\" value=\"$row[planete_envoyeur]\">
      <input type=\"submit\" name=\"Submit2\" value=\"Refuser\">
    </div></td></form>
  </tr>
</table>"; 
if ($row[lu] =="non") {
$requete = "UPDATE matgraph_explorer SET lu='oui' WHERE id='$row[id]'";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error()); }
}}
 
echo" <br><br>Proposition de pacte en attente de réponse : <br>";
$req = "SELECT * FROM matgraph_explorer WHERE envoyeur = $idlogin ORDER BY id DESC";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  While ( $row = mysql_fetch_array($res) ) {
$sql3 = "SELECT login FROM matgraph_users WHERE id='$row[planete_envoyeur]' ";
$res3 = db_mysql_Query($sql3)or die('erreur sql<br>'.$sql3.'<br>'.mysql_error());
$row3 = mysql_fetch_array($res3);  
echo"<br><table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
  <tr style =\"background-color:#111111;\">
    <td width=\"85\">Envoyer le : </td>
    <td>$row[date]</td>
    <form name=\"suprimer\" method=\"post\" action=\"mp_del5.php\" target=\"_parent\"><td width=\"25\" colspan=\"-1\" align=\"right\">
           <input type=\"hidden\" name=\"id\" value=\"$row[id]\">
          <input type=\"image\" src=\"imgs/del.gif\" width=\"25\" Style=\"border:0px solid #7E7E7E;\">
                  </td></form>
  </tr>
  <tr>
    <td valign=\"top\">Pour : </td>
    <td colspan=\"2\" valign=\"top\">$row3[login]</td>
  </tr>
  <tr style =\"background-color:#111111;\">
    <td valign=\"top\">Type de pacte : </td>
    <td colspan=\"2\" valign=\"top\">".htmlentities ($row[type])."</td>
  </tr>
  <tr>
    <td valign=\"top\">Message : </td>
    <td colspan=\"2\" valign=\"top\">".htmlentities ($row[message])."</td>
  </tr>
 </table>"; 
}}  

echo" <br><br>Pacte en vigueur : <br>";
echo"<br><table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
  <tr style =\"background-color:#222222;\">
    <td>Type de Pacte : </td>
	<td>Pacte effectuer avec : </td>
	<td>Supprimer : </td>
  </tr>";
$req = "SELECT * FROM matgraph_commerce WHERE joueur1 = $idlogin ORDER BY id DESC";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  While ( $row = mysql_fetch_array($res) ) {
$sql3 = "SELECT login FROM matgraph_users WHERE id='$row[joueur2]' ";
$res3 = db_mysql_Query($sql3)or die('erreur sql<br>'.$sql3.'<br>'.mysql_error());
$row3 = mysql_fetch_array($res3);  
echo"<tr";
// gère le quadrillage du tableau
			if (($i/2) == ceil($i/2))
			{
				echo' style ="background-color:#111111;"' ;
			}
	echo">
	<td>$row[type]</td>
    <td>$row3[login]</td>
    <form name=\"suprimer\" method=\"post\" action=\"mp_del6.php\" target=\"_parent\"><input type=\"hidden\" name=\"id\" value=\"$row[joueur2]\">
	<td width=\"25\" align=\"center\">
    <input align=\"center\" type=\"image\" src=\"imgs/del.gif\" width=\"25\" Style=\"border:0px solid #7E7E7E;\">
                  </td></form>
  </tr>"; 
}} 
echo"</table>";
?>
