<h1><?php echo __('em.ma.titre'); ?></h1>
<?php
if ( v('erreur') == 1 ){
	?><p><?php echo __('em.ma.no_eq'); ?></p><?php
} else {
	$html = '';
	$Tournois = v('PM_liste');

	foreach((array)$Tournois as $RencontresEtat){
		$caption = '';
		$html .= '
	<table class="table listeMatchs blocListeMatchs pageLesMatchs" border="0" cellspacing="0" cellpadding="0" align="center">
	';

		foreach((array)$RencontresEtat as $Rencontres){
			$cpt = 0;
			foreach((array)$Rencontres as $k=>$UN_MAT){
				if ( $cpt >= OPT_LISTE_MATCHS_LIMIT){
					//http://zkup.dev/tournoi/voir/6.html#tabs-matchs
					$html .= '<tr><td colspan="6" style="text-align:right">'.href(__('em.match.autres'),array('controleur'=>'tournoi','action'=>'voir','params'=>$UN_MAT['TNS_CLE']),false,false,true,true,'tabs-matchs').'</td></tr>';
					break;
				}
				if ( $caption == '' ){
					if ( isset($UN_MAT['TNS_NOM']) ){
						$caption = $UN_MAT['TNS_NOM'];
					} else {
						$caption = 'Comp&eacute;tition #'.$UN_MAT['TNS_CLE'];
					}
					$html .= '<caption class="lead">'.zk_jeu($UN_MAT['TNS_JEU'],false).' '.href($caption,array('controleur'=>'tournoi','action'=>'voir','params'=>$UN_MAT['TNS_CLE']),false,false,true,true,'tabs-matchs').'</caption>';
				}

				$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'],'EQI_LOGO'=>$UN_MAT['EQI_LOGO1']);
				$eq2 = array('EQI_CLE'=>$UN_MAT['EQI_CLE2'],'EQI_TAG'=>$UN_MAT['EQI_TAG2'],'EQI_NOM'=>$UN_MAT['EQI_NOM2'],'EQI_LOGO'=>$UN_MAT['EQI_LOGO2']);

				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')):'';
				}
				$html .= '
			<tr>
				<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'=>'equipe ajax'),false,false,false).'</td>';
				$html .=$UN_MAT['MAT_TOUR']==0? '<td>&nbsp;</td>':'<td>'.__('com.txt.jour').' '.$UN_MAT['MAT_TOUR'].'</td>';
				$html .= '
				<td class="date_m">'.date_et_time_fr($UN_MAT['MAT_DATE'],false).'</td>
				<td class="eq d">'.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 g">'.zk_eq_tn($eq2).'</td>
			</tr>';	

				$cpt++;
			}
		}
		$html .= '</table>';
	}

	echo $html;
}
?>