<?php

function dispAdminEdito () {

if ($_SESSION["user_right"] < $GLOBALS["EPTV"] )
{
	return("T'es ouf");
}


$result = getAllEdito();


$str = '

<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font class="titre_rubrique">
			&nbsp;e d i t o&nbsp;
			</font>
			</b> 
		</td>
		</tr>

		<tr>
		<td>
			<FORM name="new_edito" method="post" action="index.php?section=AdminHome&section_admin=AdminAddEdito">
			<INPUT class="button" TYPE="submit" NAME="action" VALUE="  NOUVEL EDITO  "><BR> </TD>
			</FORM>
		</td>
		</tr>
						
		<tr>
		<td bgcolor="#303030">
		<table cellpadding="2" cellspacing="2" width="100%">
			<tr>
			<td>
			<table width="100%" border="0" cellspacing="2" cellpadding="2">
				';

					while ($edito = mysql_fetch_array($result)) {

						$result_user = getOneUserById($edito["edito_id_user"]);
						$member = mysql_fetch_array($result_user);

						$edito_id = $edito["edito_id"];

	$str .=	'
							<tr><td>
								<font class="texte_date">
								'.$edito["edito_date"].'
								</font>
								par: '
								.$member["user_pseudo"].
							'</td></tr>
							
							<tr><td>
								<font class="texte_normal">
								<b>'
								.$edito["edito_title"].
								'</b>
							</td></tr>

							<td width=60%>
								<font class="texte_normal">
								<small>'
								.$edito["edito_comment"].
								'</small>
							</td>
	
							<TD width=10% align=right>
								<FORM name="update_edito" method="post" action="index.php?section=AdminHome&section_admin=AdminModifEdito&edito_id='.$edito_id.'">
								<INPUT class="button" TYPE="submit" NAME="action" VALUE="  MODIFIER  "> 
								</FORM>
						
								<FORM name="supp_edito" method="post" action="index.php?section=AdminHome&section_admin=AdminDelEdito&edito_id='.$edito_id.'">
								<INPUT class="button" TYPE="submit" NAME="action" VALUE="  SUPPRIMER  ">
								</FORM>	
							</TD>
							</tr>
	';
					
	$str .= '
							<tr>
							<TD> <hr width="90%"> </TD>
							</tr>
	';	
	
					}


	$str .= '
			</table>
			</td>
			</tr>
		</table>
		</td>
		</tr>
	</table>
	</td>
	</tr>
</table>
';


return $str;

}


function dispAdminAddEdito () {

 $date = get_date();

 $str = '		
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp a d d &nbsp e d i t o &nbsp t o &nbsp d a t a b a s e
			</font>
			</b> 
		</td>
		</tr>					
	<tr>
	<td bgcolor="#303030">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>	
		    <form name="saisie" method="post" action="index.php?section=AdminHome&section_admin=AddEdito&edito_id='.$edito_id.'">
		    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
   
			    <TR><TD> Titre: </TD>
			    <TD> <INPUT TYPE="text" NAME="edito_get_title" VALUE="" SIZE="50" MAXLENGTH="52"> </TD>
			    </TR>
   	 
			    <TR><TD> Date: </TD>
			    <TD> <INPUT TYPE="text" NAME="edito_get_date" VALUE="'.$date.'" SIZE="8" MAXLENGTH="10"> </TD>
			    </TR>

			    <TR><TD>Edito: </TD>
			    <TD>
			    <TEXTAREA rows="12" cols="38" name="edito_get_comment" ONFOCUS=""></textarea>
			    </TD>
			    </TR>
    
			    <TR>
				    <TD> </TD>
				    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  UPLOADER  "> </TD>
			    </TR>
			    <TR>
			 	   <TD> </TD>
				   <TD> <INPUT class="button" TYPE="reset" NAME="action" VALUE=" RESET "> </TD>
			    </TR>
		    </TABLE>
		</FORM>
		</TR>
	</TABLE>
	</TD>
	</TR>
</TABLE>
';

return $str;
}



function dispAdminModifEdito () {

  $edito_id =$_GET['edito_id'];

  $result = getOneEdito($edito_id);


$str = '		
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp m o d i f y &nbsp e d i t o
			</font>
			</b> 
		</td>
		</tr>					
	<tr>
	<td bgcolor="#303030">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>	
	';

	  if (mysql_num_rows($result)){
	    $edito = mysql_fetch_array($result);    
	  }

	  $str .= '
	    <form name="saisie" method="post" action="index.php?section=AdminHome&section_admin=ModifEdito&edito_id='.$edito_id.'">
	    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
		<TR>
		<TD> Titre: </TD>
		<TD> <INPUT TYPE="text" NAME="edito_get_uptitle" VALUE="'.$edito["edito_title"].'" SIZE="50" MAXLENGTH="52"> </TD>
		</TR>
        
		<TR>
		<TD> Date: </TD>
		<TD> <INPUT TYPE="text" NAME="edito_get_update" VALUE="'.$edito["edito_date"].'" SIZE="8" MAXLENGTH="10"> </TD>
		</TR>

		<TR>
		<TD> Edito: </TD>
		<TD> <TEXTAREA rows="12" cols="38" name="edito_get_upcomment" ONFOCUS="">'.$edito["edito_comment"].'</TEXTAREA> </TD>
		</TR>

		<TR><TD>Postée par: </TD>
		<TD>
		';

		$id_user = getOneUserById($edito["edito_id_user"]);

		if (mysql_num_rows($id_user)){
		    $id_user = mysql_fetch_array($id_user);    
		}

		$str .= $id_user["user_pseudo"].'</TD></TR>';

		$str .= '

		<TR>
		<TD> </TD>
		<TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  UPDATE  "> </TD>
		</TR>

		<TR>
		<TD> </TD>
		<TD> <INPUT class="button" TYPE="reset" NAME="action" VALUE=" RESET "> </TD>
		</TR>
    	</TABLE>
	</FORM>
	</TR>
   </TABLE>
   </TD>
   </TR>
</TABLE>

';

return $str;
}



function dispAdminDelEdito () {

  $edito_id =$_GET['edito_id'];

  $result = getOneEdito($edito_id);


$str = '		
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp d e l e t e &nbsp e d i t o
			</font>
			</b> 
		</td>
		</tr>					
	<tr>
	<td bgcolor="#303030">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>	
	';

	  if (mysql_num_rows($result)){
	    $edito = mysql_fetch_array($result);    
	  }

	  $str .= '
	    <form name="saisie" method="post" action="index.php?section=AdminHome&section_admin=DelEdito&edito_id='.$edito_id.'">
	    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
   
		    <TR><TD> Titre: </TD>
		    <TD>'.$edito["edito_title"].'</TD>
		    </TR>
        
		    <TR><TD> Date: </TD>
		    <TD> '.$edito["edito_date"].'</TD>
		    </TR>

		    <TR><TD>Commentaire: </TD>
		    <TD>
		    '.$edito["edito_comment"].'
		    </TD>
		    </TR>';
    
		    $str .= '    
		    <TR><TD>Postée par: </TD>
		    <TD>
		    ';

		    $id_user = getOneUserById($edito["edito_id_user"]);

		if (mysql_num_rows($id_user)){
		    $id_user = mysql_fetch_array($id_user);    
		}

		$str .= $id_user["user_pseudo"].'</TD></TR>';

		$str .= '
		    <TR>
		    <TD> </TD>
		    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  SUPPRIMER  "> </TD>
		    </TR>  
    	</TABLE>
	</FORM>
	</TR>
   </TABLE>
   </TD>
   </TR>
</TABLE>

';

return $str;
}



?>