<?php 
	loadClass ( 'CompManager' );
	$Logs = CompManager::getLastResults(25);//Limite de nombre de matchs joués
?>

<div class="block">
	<div class="title title_3"><?php echo __('adm.bloc.match'); ?></div>
	<div class="content">
		<?php if ( sizeof((array)$Logs) == 0 ){ 
			echo __('adm.bloc.match.no');
		} else { 
			foreach ($Logs as $etat=>$renc){
			if ( sizeof($renc) == 0 ){continue; }
			?>
				<table class="resultats">
				<tr>
					<th>&nbsp;</th>
					<th><?php echo __('com.table.date'); ?></th>
					<th><?php echo __('com.table.equipe1'); ?></th>
					<?php
					if ( $etat >= 1 ){
						?>
						<th colspan="2"><?php echo __('com.score'); ?></th>
						<?php
					} else {
						?><th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><?php
					}
					?>
					<th><?php echo __('com.table.equipe2'); ?></th>
				</tr>
						
			<?php
			$ancien_etat = null;
			$alterne = false;
			foreach ($renc as $UN_MAT){
				
				if ( $etat == 1 ){
					$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')):'';
				} else {
					$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']);
				
				?>
				<tr class="tac">
					<td><?php echo 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>
					<td class="date"><?php echo $UN_MAT['MAT_DATE']==''?'--':date_et_time_fr($UN_MAT['MAT_DATE']);?></td>
					<td><?php echo zk_eq_tn($eq1);?></td>
					<?php
					if ( $etat >= 1 ){
						?>
						<td class="score <?php echo $c1; ?>"><?php echo $UN_MAT['EQI_S1'];?></td>
						<td class="score <?php echo $c2; ?>"><?php echo $UN_MAT['EQI_S2'];?></td>
						<?php
					} else { 
						?>
						<td colspan="2" align="center"><?php echo __('com.table.vs'); ?></td>
						<?php
					}
					?>
					<td><?php echo zk_eq_tn($eq2);?></td>
				</tr>
				<?php

			}
			
		} ?>
		</table>
		<script type="text/javascript">
			$(window).load(function(){
				$("#box_ui").hide();
				$('.blockOverlay').attr('title','Fermer').click($.unblockUI);



				$('a.equipe').click(function(e) {
					e.preventDefault();
					
					$("#box_ui").html("<?php echo zk_loading(); ?>");

					$.ajax({
						url: this.href,
						cache: false,
						success: function(html){
							$("#box_ui").html(html);
						}
					});

					$.blockUI({
						message: $('#box_ui'),
						css: { top: '10%', width: '' }
					});




					return false;
				});
			});

	    		</script>
		<!--<a href="#" title="tout afficher" class="more">Tout afficher</a>  -->
		<?php 
	} ?>
	</div>
</div>
