<h2><?php echo __('adm.ta.titre'); ?></h2>
<style type="text/css">
.g { width: 250px; font-size: 11px; }
select { min-width: 100px; }
</style>
<?php
$TNS = v('TNS');
$etape = v('etape');

$tMontrer = array(
'TNS_NOM'=>1,
'TNS_TYPE'=>1,
'TNS_JEU'=>1,
'TNS_NB_J'=>1
);


if ( $etape > 1 ){
	$tMontrer['TNS_NOM'] = 0;
	$tMontrer['TNS_TYPE'] = 0;
	$tMontrer['TNS_JEU'] = 0;
	$tMontrer['TNS_NB_J'] = 0;
	$tMontrer['REG_CLE'] = 1;
	$tMontrer['TNS_DIR'] = 1;
	$tMontrer['TNS_NB_M'] = 1;
	$tMontrer['TNS_NB_T'] = 1;
	$tMontrer['TNS_MAT_FLAG'] = 1;

	if ( p('TNS_TYPE') == 2 || p('TNS_TYPE') == 3 || p('TNS_TYPE') == 4 || p('TNS_TYPE') == 6 ){
		$tMontrer['TNS_NB_POU'] = 1;
		$tMontrer['TNS_NB_EQ_TNS'] = 1;
	}

	if ( $etape > 2){
		if ( p('TNS_DIR') == ''){ $tMontrer['TNS_LB'] = 1; }
		if ( p('TNS_NB_EQ_TNS')==6 ){ unset($tMontrer['TNS_LB']); }
		$tMontrer['REG_CLE'] = 0;
		$tMontrer['TNS_DIR'] = 0;
		$tMontrer['TNS_NB_M'] = 0;
		$tMontrer['TNS_NB_T'] = 0;
		$tMontrer['TNS_MAT_FLAG'] = 0;


		if ( p('TNS_TYPE') == 2 || p('TNS_TYPE') == 3 || p('TNS_TYPE') == 4 || p('TNS_TYPE') ==6 ){
			//$tMontrer['TNS_NB_EQ_EVT'] = p('TNS_TYPE')==3?1:0;
			$tMontrer['TNS_NB_POU'] = 0;
			$tMontrer['TNS_NB_EQ_TNS'] = 0;
			
			$tMontrer['TNS_DIR'] = 0;
			//$tMontrer['TNS_NB_POU'] = 1;

			$tMontrer['TNS_G'] = 1;
			$tMontrer['TNS_N'] = 1;
			$tMontrer['TNS_D'] = 1;
unset($tMontrer['TNS_LB']);

			
			if ( p('TNS_TYPE') == 4 ){
				//unset($tMontrer['TNS_NB_POU']);
			}
		}

		if ( $etape > 3){
			//if ( isset($tMontrer['TNS_NB_POU'])) { $tMontrer['TNS_NB_POU'] = 0; }
			if ( isset($tMontrer['TNS_LB'])) { $tMontrer['TNS_LB'] = 0; }
			if ( isset($tMontrer['TNS_NB_EQ_TNS'])) { $tMontrer['TNS_NB_EQ_TNS'] = 0; }
			//if ( isset($tMontrer['TNS_NB_EQ_EVT'])){ $tMontrer['TNS_NB_EQ_EVT'] = 0; }
			if ( isset($tMontrer['TNS_G'])){ $tMontrer['TNS_G'] = 0; }
			if ( isset($tMontrer['TNS_N'])){ $tMontrer['TNS_N'] = 0; }
			if ( isset($tMontrer['TNS_D'])){ $tMontrer['TNS_D'] = 0; }

		} else {

		}
	} else {

	}

	
}

?>
<form action="<?php echo php_self();?>" method="post" name="ajouter_ligue" id="ajouter_ligue">

<input type="hidden" name="etape" value="<?php echo $etape; ?>" />
<table>
	<?php
	if ( v('erreur') ){ ?>
	<tr>
		<td colspan="2" class="erreurs"><?php echo display_erreurs(); ?></td>
	</tr>
	<?php } ?>

	<tr>
		<td colspan="2">
			<h2 align="right"><?php echo __('adm.ta.etape'); ?> : <?php echo $etape; ?> sur 4</h2>
		</td>
	</tr>
	<?php 	if ( isset($tMontrer['TNS_NOM'])){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.nom'); ?></td>
		<td class="d"><?php 
		if ( !$tMontrer['TNS_NOM'] ){
			echo form('input',array('type'=>'hidden','name'=>'TNS_NOM'));
			echo p('TNS_NOM');
		} else {
			echo form('input',array('type'=>'text','maxlength'=>30,'name'=>'TNS_NOM'));
		} ?>
		</td>
	</tr>
	<?php } ?>
	<tr>
		<td class="g"><?php echo __('com.txt.type'); ?></td>
		<td class="d">
			<?php
			$disabled = array();
			if ( !$tMontrer['TNS_TYPE'] ){
				$disabled = array('disabled'=>'disabled');
				echo form('input',array('type'=>'hidden','name'=>'TNS_TYPE'));
			}
			echo formSelect('TNS_TYPE',$disabled,v('tTypesTournoi'));
			?>
		</td>
	</tr>
	
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.nb_j'); ?></td>
		<td class="d">
		<?php
		if ( !$tMontrer['TNS_JEU'] ){
			echo form('input',array('type'=>'hidden','name'=>'TNS_NB_J'));
		}
		?>
		<select name="TNS_NB_J"  <?php echo !$tMontrer['TNS_NB_J']?'disabled="disabled"':''; ?>>
			<?php
			for($i=1;$i<=__TNS_NB_J_MAX;++$i){
				?><option value="<?php echo $i; ?>" <?php echo $i==$TNS['TNS_NB_J']?'selected="selected"':''; ?>><?php echo $i; ?></option><?php
			}
			?>
		</select>
		</td>
	</tr>
	
	<tr>
		<td class="g"><?php echo __('com.txt.jeu'); ?></td>
		<td class="d"><?php 
		$disabled = array();
		if ( !$tMontrer['TNS_JEU'] ){
			$disabled = array('disabled'=>'disabled');
			echo form('input',array('type'=>'hidden','name'=>'TNS_JEU'));
		}
		echo formSelect('TNS_JEU',$disabled,v('tJeux'),false,true);
		?></td>
	</tr>
	
	<?php if ( isset($tMontrer['TNS_MAT_FLAG']) ){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.gest_eq'); ?></td>
		<td class="d"><?php 
		$disabled = array();
		if ( !$tMontrer['TNS_MAT_FLAG'] )
		{
			$disabled = array('disabled'=>'disabled');
			echo form('input',array('type'=>'hidden','name'=>'TNS_MAT_FLAG'));
		}
		echo formSelect('TNS_MAT_FLAG',$disabled,v('tMatchFlagsSimplifies'));
		?></td>
	</tr>
	<?php } ?>
	
	<?php if ( isset($tMontrer['TNS_NB_T']) ){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.nb_t'); ?></td>
		<td class="d"><?php 
		$disabled = array();
		if ( !$tMontrer['TNS_NB_T'] )
		{
			$disabled = array('disabled'=>'disabled');
			echo form('input',array('type'=>'hidden','name'=>'TNS_NB_T'));
		}
		echo formSelect('TNS_NB_T',$disabled,getListeNombre(1,3));
		?></td>
	</tr>
	<?php } ?>
	
	<?php if ( isset($tMontrer['TNS_NB_M']) ){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.nb_m'); ?></td>
		<td class="d"><?php 
		$disabled = array();
		if ( !$tMontrer['TNS_NB_M'] )
		{
			$disabled = array('disabled'=>'disabled');
			echo form('input',array('type'=>'hidden','name'=>'TNS_NB_M'));
		}
		echo formSelect('TNS_NB_M',$disabled,getListeNombre(1,10));
		?></td>
	</tr>
	<?php } ?>
	
	
	<?php if ( isset($tMontrer['REG_CLE']) ){ ?>
	<tr>
		<td class="g"><?php echo __('com.txt.reglement'); ?></td>
		<td class="d"><?php 
		$disabled = array();
		if ( !$tMontrer['REG_CLE'] )
		{
			$disabled = array('disabled'=>'disabled');
			echo form('input',array('type'=>'hidden','name'=>'REG_CLE'));
		}
		echo formSelect('REG_CLE',$disabled,v('ttab_reglements'));
		?></td>
	</tr>
	<?php } ?>
	
	
	<?php if ( isset($tMontrer['TNS_NB_POU']) ){ ?>
	<tr>
		<td class="g">Nombre de ligues</td>
		<td class="d"><?php 
		//getTournoisSpeciaux
		$disabled = array();
		if ( !$tMontrer['TNS_NB_POU'] )
		{
			$disabled = array('disabled'=>'disabled');
			echo form('input',array('type'=>'hidden','name'=>'TNS_NB_POU'));
		}
		echo formSelect('TNS_NB_POU',$disabled,getNbLigues());
		?></td>
	</tr>
	<?php } ?>
	
	
	<?php if ( isset($tMontrer['TNS_NB_EQ_TNS'])){ ?>
	<tr>
		<td class="g">Nb de repechés</td>
		<td class="d">
			<?php
			$disabled = array();
			if ( !$tMontrer['TNS_NB_EQ_TNS'] ){
				$disabled = array('disabled'=>'disabled');
				echo form('input',array('type'=>'hidden','name'=>'TNS_NB_EQ_TNS'));
			}
			echo formSelect('TNS_NB_EQ_TNS',$disabled,getNbRepeche()); ?>
		</td>
	</tr>
	<?php } ?>
	
	<?php 	if ( isset($tMontrer['TNS_G'])){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.pts.g'); ?></td>
		<td class="d"><?php 
		if ( !$tMontrer['TNS_G'] ){
			echo form('input',array('type'=>'hidden','name'=>'TNS_G'));
			echo p('TNS_G');
		} else {
			echo form('input',array('type'=>'text','maxlength'=>3,'name'=>'TNS_G'));
		} ?>
		</td>
	</tr>
	<?php } ?>
	
	<?php 	if ( isset($tMontrer['TNS_N'])){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.pts.n'); ?></td>
		<td class="d"><?php 
		if ( !$tMontrer['TNS_N'] ){
			echo form('input',array('type'=>'hidden','name'=>'TNS_N'));
			echo p('TNS_N');
		} else {
			echo form('input',array('type'=>'text','maxlength'=>3,'name'=>'TNS_N'));
		} ?>
		</td>
	</tr>
	<?php } ?>
	
	
	<?php 	if ( isset($tMontrer['TNS_D'])){ ?>
	<tr>
		<td class="g"><?php echo __('adm.ta.comp.pts.d'); ?></td>
		<td class="d"><?php 
		if ( !$tMontrer['TNS_D'] ){
			echo form('input',array('type'=>'hidden','name'=>'TNS_D'));
			echo p('TNS_D');
		} else {
			echo form('input',array('type'=>'text','maxlength'=>3,'name'=>'TNS_D'));
		} ?>
		</td>
	</tr>
	<?php } ?>
	
	
	<?php if ( isset($tMontrer['TNS_LB']) ){ ?>
	<tr>
		<td class="g">Nb de repéchés</td>
		<td class="d">
			<?php
			$disabled = array();
			if ( !$tMontrer['TNS_LB'] ){
				$disabled = array('disabled'=>'disabled');
				echo form('input',array('type'=>'hidden','name'=>'TNS_LB'));
			}
			echo formSelect('TNS_LB',$disabled,getNbRepeche());
			?>
		</td>
	</tr>
	<?php } ?>
	
	<tr>
		<td colspan="2" align="center" style="padding: 15px 0px">
		<?php
		if ($etape>1){ ?>
			<input type="submit" name="submit" value="<?php echo __('com.action.retour'); ?>" class="btn" />
			<?php } ?>
			<input type="submit" name="submit" value="<?php echo $etape==4?__('com.action.aj'):__('com.action.val'); ?>" class="btn" />
		
		</td>
	</tr>
	
	
</table>
<p style="text-align: center"><?php echo __('adm.ta.txt'); ?></p>

<h2><?php echo __('adm.ta.comp.desc'); ?></h2>
<?php echo runFCKeditor('TNS_DESC',p('TNS_DESC',true),400); ?>

</form>

