<h2>Matchs du Ladder</h2>
<?php
if ( sizeof((array)v('Matchs')) == 0 ){
	$html = 'Aucun match prévu';
} else {
	$html = '<table class="listeMatchs blocListeMatchs pageLesMatchs table-css" style="width: 60% !important" id="ListeMatchsLadder" border="0" cellspacing="0" cellpadding="0" align="center">
	<thead>
		<tr>
			<th>#</th>
			<th>Date</th>
			<th>Equipe 1</th>
			<th colspan="2">Score</th>
			<th>Equipe 2</th>
		</tr>
	</thead>
	';


	$cpt = 0;
	foreach((array)v('Matchs') as $MAT_CLE=>$UN_MAT){
		$intervention_admin = $UN_MAT['MAT_FLAG']==41||$UN_MAT['MAT_FLAG']==42||$UN_MAT['MAT_FLAG']==81||$UN_MAT['MAT_FLAG']==82?'intervention':'';
		$etat = $UN_MAT['MAT_ETAT'];
		$c1 = null;
		$c2 = null;

		$eq1 = array('EQI_CLE'=>$UN_MAT['EQI_CLE1'],'EQI_TAG'=>$UN_MAT['EQI_TAG1'],'EQI_NOM'=>$UN_MAT['EQI_NOM1']);
		$eq2 = array('EQI_CLE'=>$UN_MAT['EQI_CLE2'],'EQI_TAG'=>$UN_MAT['EQI_TAG2'],'EQI_NOM'=>$UN_MAT['EQI_NOM2']);

		if ( $etat == 0 ){
			$UN_MAT['EQI_S1'] = '&nbsp;';
			$UN_MAT['EQI_S2'] = '&nbsp;';
		} else {
			$c1 = $UN_MAT['EQI_S1']!=''&&$UN_MAT['EQI_S2']!=''?($UN_MAT['EQI_S1']==$UN_MAT['EQI_S2']?'egalite':($UN_MAT['EQI_S1']>$UN_MAT['EQI_S2']?'gagnant':'perdant')):'';
			$c2 = $UN_MAT['EQI_S1']!=''&&$UN_MAT['EQI_S2']!=''?($UN_MAT['EQI_S1']==$UN_MAT['EQI_S2']?'egalite':($UN_MAT['EQI_S1']<$UN_MAT['EQI_S2']?'gagnant':'perdant')):'';
		}
		$pair_impair = $cpt++%2==0?'pair':'impair';
		$html .= '
			<tr class="un-match '.$intervention_admin.' '.$pair_impair.'">
				<td>'.href(img('icons/calendar.png'),array('controleur'=>'Tournoi','action'=>'Rencontre','params'=>$UN_MAT['TNS_CLE'].'-'.$UN_MAT['MAT_CLE'].'-'.$UN_MAT['EQI_CLE1'].'-'.$UN_MAT['EQI_CLE2'],'class'=>'ajax','rel'=>$UN_MAT['TNS_CLE'].'-'.$UN_MAT['MAT_CLE'].'-'.$UN_MAT['EQI_CLE1'].'-'.$UN_MAT['EQI_CLE2']),false,false,false).'</td>';
		$html .= '
				<td class="date_m">'.date_et_time_fr($UN_MAT['MAT_DATE'],false).'</td>
				<td class="eq">'.zk_eq_tn($eq1).'</td>';
		if ( OPT_CACHER_SCORE_BLOC_MATCHS === false ){
			$html .= $etat>=1?'
				<td class="s '.$c1.'">'.$UN_MAT['EQI_S1'].'</td>
				<td class="s '.$c2.'">'.$UN_MAT['EQI_S2'].'</td>':'<td class="vs" colspan="2">vs</td>';
		} else {
			$html .= $etat>=1?'
				<td class="ss '.$c1.'">&nbsp;</td>
				<td class="ss '.$c2.'">&nbsp;</td>':'<td class="vs" colspan="2">vs</td>';
		}
		$html .= '
				<td class="eq">'.zk_eq_tn($eq2).'</td>
			</tr>';	

		$cpt++;
	}

	$html .= '</table>';

}
echo $html;

?>