<?php
include ('logue.php'); 
include ('entete2.php');
include ('ressource.php');
include ('entete.php');
echo"
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
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>";
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'); 

$sql2 = "SELECT ally,statut FROM matgraph_users WHERE id='$idlogin'";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2);

$sql_options = "SELECT recrutement FROM matgraph_ally_statut WHERE id='$row2[statut]'";
$res_options = db_mysql_Query($sql_options)or die('erreur sql<br>'.$sql_options.'<br>'.mysql_error());
$row_options = mysql_fetch_array($res_options); 

if($row2[ally] == "no") {
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("ally_index.php");
	-->
	</script>';
	exit;
}

$req = "SELECT * FROM matgraph_ally_recrut WHERE idally = $row2[ally]";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);

if ( $num == 0) {
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("ally_index.php");
	-->
	</script>';
	exit;
}

if($row2[statut] !== "0" AND $row_options[recrutement] == "1" OR $row2[statut] == "-1") {

	$req = "SELECT * FROM matgraph_ally_recrut WHERE idally = $row2[ally] ORDER by id ASC";
	$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) ) {
			$sql2 = "SELECT login FROM matgraph_users WHERE id='$row[idjoueur]' ";
				$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
			$row2 = mysql_fetch_array($res2);   

			echo"<br><br><table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
			  <tr>
			    <td width=\"306\">Pseudo : </td>
			    <td width=\"306\">$row2[login]</td>
			  </tr>
			  <tr style =\"background-color:#222222;\">
			    <td>Message personnel : </td>
			    <td>$row[msg]</td>
			  </tr>
			  <tr>
			    <td colspan=\"2\">&nbsp;</td>
			  </tr>
			  <tr style =\"background-color:#222222;\">
			    <td><form action=\"ally_demmande_recrut_accepter.php\" method=\"post\" name=\"form1\" target=\"_parent\">
			      <div align=\"center\">
			        <p>
			          <input name=\"idally\" type=\"hidden\" id=\"idally\" value=\"$row[idally]\">
			          <input name=\"idjoueur\" type=\"hidden\" id=\"idjoueur\" value=\"$row[idjoueur]\">
			          Message de bienvenue(optionnel) :<br>
			          <textarea name=\"msg\" id=\"msg\"></textarea> 
			          </p>
			        <p>
			          <input type=\"submit\" name=\"Submit\" value=\"Accepter\">
			</p>
			      </div>
			    </form></td>
			    <td><form action=\"ally_demmande_recrut_refuser.php\" method=\"post\" name=\"form2\" target=\"_parent\">
			      <div align=\"center\">
		        	<p>
			          <input name=\"idally\" type=\"hidden\" id=\"idally3\" value=\"$row[idally]\">
			          <input name=\"idjoueur\" type=\"hidden\" id=\"idjoueur\" value=\"$row[idjoueur]\">
			          Motif de refus(optionnel) :
			          <textarea name=\"msg\" id=\"msg\"></textarea> 
			          </p>
			        <p>
			          <input type=\"submit\" name=\"Submit2\" value=\"Refuser\">    
			            </p>
			      </div>
			    </form></td>
			  </tr>
			</table>";
		}
	}
}
else {
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("ally_index.php");
	-->
	</script>';
	exit;
}
?>


