{*
  Template for the club detailview
  $Id: show_stadiums.tpl,v 1.00 2006/10/25 20:14:18
*}

<!-- {$smarty.template} -->
{assign var="namenextyear" value="`$nameseason.season+1`"}
<div>
<br>

<table id="tableshow" border="0" cellspacing="0" cellpadding="2" width="100%">
	<tr>
		<td id="toppage"><a href="show_competitions.php?id={$competition}&season={$season}">{$competdata.longname}  - {$lang.season} {if $competdata.oneyear}{$nameseason.season}{else}{$nameseason.season} / {$namenextyear}{/if}</a></td>
	</tr>
	<tr>
		<td align="right"><b>{$lang.seasons} :</b> 
			<select id="season" name="season" onchange="if(this.options[this.selectedIndex].value) window.location.href='edit_matchs.php?competition={$competition}&season='+this.options[this.selectedIndex].value;">
			{foreach item=myseason from=$seasons}
			{assign var=nextyear value="`$myseason.season+1`"}
				{if $competdata.oneyear}
				<option value='{$myseason.id_season}'{if $season==$myseason.id_season}selected{/if}>{$myseason.season}</option>
				{else}
				<option value='{$myseason.id_season}'{if $season==$myseason.id_season}selected{/if}>{$myseason.season} / {$nextyear}</option>
				{/if}
			{/foreach}
			</select>
		</td>
	</tr>
{if $editable || $administrable}
	<tr>
		<td>
		{if $administrable}
			<form action="edit_competitions.php" name="editform">
				<span class="onglet-admin">
				<input type="submit" value="{$lang.newdata}" />
				</span>
			</form>
			<form action="edit_competitions.php" name="editform">
					<input type="hidden" name="id" value="{$competition}"/>
					<span class="onglet-admin">
					<input type="submit" value="{$lang.edit}" />
					</span>
			</form>
			<form action="delete.php" name="deleteform">
					<input type="hidden" name="id" value="{$competition}"/>
					<input type="hidden" name="cat" value="3"/>
					<span class="onglet-admin">
					<input type="submit" value="{$lang.del}" onclick="return(confirm('{$competition.lastname|escape:javascript}: {$lang.really_del}?'))" />
					</span>
			</form>
		{/if}
		{if $editable || $administrable}
			<form action="edit_candidates.php" name="candidateform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>				
					<span class="onglet-admin">
					<input type="submit" value="{$lang.editseason}" />
					</span>
			</form>
			{if $competdata.type != 1}
			<form action="edit_penalitys.php" name="penalityform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>				
					<span class="onglet-admin">
					<input type="submit" value="{$lang.editpenality}" />
					</span>
			</form>
			{/if}
			<form action="edit_days.php" name="dayform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>				
					<span class="onglet-admin">
					<input type="submit" value="{$lang.editday}" />
					</span>
			</form>
			<form action="edit_matchs.php" name="matchsform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>				
					<span class="onglet-admin">
					<input type="submit" value="{$lang.editmatchs}" />
					</span>
			</form>
			<form action="edit_goals.php" name="matchsform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>				
					<span class="onglet-admin">
					<input type="submit" value="{$lang.editgoals}" />
					</span>
			</form>
		{/if}
		</td>
	</tr>
{/if}
	<tr>
		<td>
			<form action="show_competitions.php" name="editform">
					<input type="hidden" name="id" value="{$competition}"/>
					<input type="hidden" name="action" value="card"/>
					<span class="onglet">
					<input type="submit" value="{$lang.card}" />
					</span>
			</form>
			<form action="prizelist.php" name="tableform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<span class="onglet">
					<input type="submit"  value="{$lang.prizelist}" {if !$competition.id}disabled="disabled"{/if} />
					</span>
			</form>
			{if $season}
				<form action="show_matchs.php" name="calendarform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>
					<span class="onglet">
					<input type="submit"  value="{$lang.calendar}" {if !$competition}disabled="disabled"{/if} />
					</span>
				</form>
				{if $statsactive}
				<form action="stats_competitions.php" name="statsform">
						<input type="hidden" name="id" value="{$competition}"/>
						<input type="hidden" name="season" value="{$season}"/>
						<span class="onglet">
						<input type="submit" value="{$lang.stats}" {if !$competition} disabled="disabled"{/if} />
						</span>
				</form>
				{/if}
				{if $competdata.type != 1}
				<form action="show_tables.php" name="tableform">
					<input type="hidden" name="competition" value="{$competition}"/>
					<input type="hidden" name="season" value="{$season}"/>
					<span class="onglet">
					<input type="submit"  value="{$lang.classement}" {if !$competition}disabled="disabled"{/if} />
					</span>
				</form>
				{/if}
			{/if}
			{if $seegallery}
				<form action="gallery.php" name="galleryform">
					<input type="hidden" name="subcat" value="{$competition}"/>
					<input type="hidden" name="cat" value="2" />
					<span class="onglet">
					<input type="submit" value="{$lang.gallery}" />
					</span>
				</form>
			{/if}
			{if $commentable}
					<form action="comments.php" name="mkcommentform">
						<input type="hidden" name="subcat" value="{$competition}"/>
						<input type="hidden" name="cat" value="2" />
						<span class="onglet">
						<input type="submit" value="{$lang.comments}" />
						</span>
					</form>
			{/if}
			{if $prev_id || $next_id}
					<form action="show_competitions.php" name="prevform">
						<input type="hidden" name="id" value="{$prev_id}"/>
						<span class="onglet">
						<input type="submit"  value="<" {if !$prev_id}disabled="disabled"{/if} accesskey="," />
						</span>
					</form>
					<form action="show_competitions.php" name="nextform">
						<input type="hidden" name="id" value="{$next_id}"/>
						<span class="onglet">
						<input type="submit"  value=">" {if !next_id}disabled="disabled"{/if} accesskey="." />
						</span>
					</form>			
			{/if}
	
    	</td>
	</tr>

	<tr><td id="bottompage">&nbsp;</td></tr>
</table>
</div>


<script language="JavaScript" type="text/javascript" src="javascript/look.js"></script>



<div id="pagecontent">
<table id="tableshow" width="100%" border="0" cellspacing="0" cellpadding="5">
<form action="edit_matchs.php" id="day" name="day" method="get">
<input type="hidden" name="competition" id="compet" value="{$competition}" />
<input type="hidden" name="season" id="season" value="{$season}" />
  	<tr>
  		<td id="toppage"><a href="#">{$dateday}</a></td>
	</tr>
	<tr>
		<td align="right">
		{if $administrable}
			{if $matchvalidation == 0}
				<b>{$lang.matchvalidation0} :</b>
			{elseif $matchvalidation == 1}
				<b>{$lang.matchvalidation1} :</b>
			{elseif $matchvalidation == 2}
				<b>{$lang.matchvalidation2} :</b>
			{/if}
		{/if}
		<select name="day" onchange="submit();">
				{if $numdays is odd}
				{math equation="$numdays/2" assign=startnumday}
				{counter start=$startnumday direction=down print=false name=arcount assign=arcount}
				{else}
				{math equation="($numdays+1)/2" assign=startnumday}
				{counter start=$startnumday direction=down print=false name=arcount assign=arcount}
				{/if}
				{counter start=0 print=false name=daycount}
				
				{section name="loopday" start=0 loop=$numdays}
				{counter assign=counterday name=counterday}
				{if $competdata.type == 1}
					{if $counterday == $numdays and $competdata.ar == 0}		
						<option value="{$counterday}"{if $counterday == $day} selected{/if}>{$lang.final_game}</option>
					{elseif $arcount == 0 and $numdays is odd}
						<option value="{$counterday}"{if $counterday == $day} selected{/if}>{$lang.final_game}</option>
					{elseif $arcount == 0 and $numdays is even}
						{if $counterday is odd}
						<option value="{$counterday}"{if $counterday == $day} selected{/if}>{$lang.final_game} {$lang.firstleg}</option>
						{else}
						<option value="{$counterday}"{if $counterday == $day} selected{/if}>{$lang.final_game} {$lang.secondleg}</option>
						{/if}
					{else}
						{if !$competdata.ar}
						<option value="{$counterday}"{if $counterday == $day} selected{/if}>1/{math equation="pow(2, ($numdays-$counterday+1))/2"} {$lang.final_game}</option>
						{else}
						
							{if $counterday is odd}
							<option value="{$counterday}"{if $counterday == $day} selected{/if}>1/{math equation="pow(2, ($numdays-$counterday-$arcount+1))/2"} {$lang.final_game} {$lang.firstleg}</option>
							{else}
							<option value="{$counterday}"{if $counterday == $day} selected{/if}>1/{math equation="pow(2, ($numdays-$counterday-$arcount+2))/2"} {$lang.final_game} {$lang.secondleg}</option>
							{counter name=arcount direction=down}
							
							{/if}
						{/if}
					{/if}
				{else}
				<option value="{$counterday}"{if $counterday == $day} selected{/if}>{$lang.matchday} {$counterday}</option>
				{/if}
				{/section}		
		</select>
		</td>
  </tr>

</form>

<!-- content begin -->
<form action="edit_matchs.php" id="edi" name="edi" method="post">
  <input type="hidden" name="mycompet" id="compet" value="{$competition}" />
  <input type="hidden" name="myseason" id="season" value="{$season}" />
  <input type="hidden" name="day" id="myday" value="{$day}" />
  <input type="hidden" name="save" id="save" value="1" />
  <tr>
      <td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="30%" align="center"><b>{$lang.dom}</b></td>
				<td width="30%" align="center" colspan="2" align="center"><b>{$lang.score}</b></td>
				<td width="30%" align="center"><b>{$lang.ext}</b></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5">
				  {counter start=0 print=false name=matchcount}
				  {foreach item=match from=$matchs}
				  {cycle values="listeven,listodd" assign=CLASS print=false}
				  <table width="100%" border="0" cellspacing="0" cellpadding="2">
					  <tr>
						<td class="lineeven" width="30%">
							{if !$administrable and ($matchvalidation == 2 or $matchvalidation == 0)}
							<input type="hidden" name="dom{$match.id}" id="dom{$match.id}" value="{$match.id_candidate_dom}" />
							{/if}
							<select name="dom{$match.id}" style="width:100%;"{if !$administrable and ($matchvalidation == 2 or $matchvalidation == 0)} disabled="disabled"{/if}>
							<option value="">---------------</option>
							{foreach item=club from=$allcandidates}
							<option value="{$club.id}" {if $club.id == $match.id_candidate_dom}Selected{/if}>{$club.shortname}</option>
							{/foreach}
							</select>
						</td>
					   <td class="lineeven" width="15%" align="center">
					   {if !$administrable and ($matchvalidation == 2 or $matchvalidation == 0)}
						<input type="hidden" name="butsdom{$match.id}" id="butsdom{$match.id}" value="{if !$match.buts_dom}0{else}{$match.buts_dom}{/if}" />
					   {/if}
					   <input type="text" value="{if !$match.buts_dom}0{else}{$match.buts_dom}{/if}" name="butsdom{$match.id}" size="3" maxlenght="3"{if !$administrable and  (!$match.dom_validable or ($match.validation == 2 or $match.validation == 1))} disabled="disabled"{/if}></td>
					   <td class="lineeven" width="15%" align="center">
					   {if !$administrable and ($matchvalidation == 2 or $matchvalidation == 0)}
						<input type="hidden" name="butsext{$match.id}" id="butsext{$match.id}" value="{if !$match.buts_ext}0{else}{$match.buts_ext}{/if}" />
					   {/if}
					   <input type="text" value="{if !$match.buts_ext}0{else}{$match.buts_ext}{/if}" name="butsext{$match.id}" size="3" maxlenght="3"{if !$administrable and (!$match.dom_validable or ($match.validation == 2 or $match.validation == 1))} disabled="disabled"{/if}></td>
					   <td class="lineeven" width="30%">
					   		{if !$administrable and ($matchvalidation == 2 or $matchvalidation == 0)}
							<input type="hidden" name="ext{$match.id}" id="ext{$match.id}" value="{$match.id_candidate_ext}" />
							{/if}
							<select name="ext{$match.id}" style="width:100%;"{if !$administrable and ($matchvalidation == 2 or $matchvalidation == 0)} disabled="disabled"{/if}>
							<option value="">---------------</option>
							{foreach item=club from=$allcandidates}
							<option value="{$club.id}" {if $club.id == $match.id_candidate_ext}Selected{/if}>{$club.shortname}</option>
							{/foreach}
							</select>					
						</td>					
						<td class="lineeven" width="10%" NOWRAP>
							<a href="edit_lineup.php?match={$match.id}"><h3>{$lang.lineup}</h3></a>
						</td>
				   </tr>
				   <tr>
				   		<td colspan="4" class="lineeven" valign="middle">
						{* if amin loggued *}
						{if $administrable}
							<h3>{$lang.validation} :<input type="checkbox" name="valid{$match.id}" value="1"{if $matchvalidation == 1 && $match.timediff<0} checked{else}{if $match.validation == 1} checked{/if}{/if}></h3>
						
						{* if match not validated and home candidate logged *}
						{elseif (!$match.validation or $match.validation == 4 or $match.validation == 5) and $match.dom_validable}
							<h3>{$lang.validation_home} :<input type="checkbox" name="valid{$match.id}" value="2"{if $match.validation == 2 or $match.validation == 4} checked{/if}></h3>
						
						{* if match validated by candidates or admin and home candidate logged  *}
						{elseif ($match.validation == 1 or $match.validation == 2)  and $match.dom_validable}
							<h3>{$lang.alsovalidated} -
							{$lang.protestation} :<input type="checkbox" name="valid{$match.id}" value="4"{if $match.validation == 4} checked{/if}></h3>
						
						{* if match validated by home candidate and away candidate logged  *}
						{elseif $match.validation == 2 and $match.ext_validable}
							<h3>{$lang.validation_away} :<input type="checkbox" name="valid{$match.id}" value="1"{if $match.validation == 1} checked{/if}></h3>
							<h3>{$lang.protestation} :<input type="checkbox" name="valid{$match.id}" value="5"{if $match.validation == 1} checked{/if}></h3>
						
						{* if match not validated by home candidate and away candidate logged  *}
						{elseif (!$match.validation or $match.validation == 4 or $match.validation == 5) and $match.ext_validable}
							<h3>{$lang.inwaiting} {$lang.validation_home}<input type="hidden" name="valid{$match.id}" id="valid{$match.id}" value="{$match.validation}" /></h3>
						{* if match validated by candidates or admin and away candidate logged  *}
						{elseif $match.validation == 1  and $match.ext_validable}
							<h3>{$lang.alsovalidated} -
							{$lang.protestation} :<input type="checkbox" name="valid{$match.id}" value="5"{if $match.validation == 5} checked{/if}></h3>
								
						{else}
							<input type="hidden" name="valid{$match.id}" id="valid{$match.id}" value="{$match.validation}" />
						{/if}
						</td>
						<td class="lineeven" width="10%">
							{if $administrable}
							<a href="javascript:" onclick="blocking('bloc{$count+1}','yes', 'block'); return false;"><h3>{$lang.details}:</h3>
							{elseif (!$match.validation or $match.validation == 4 or $match.validation == 5) and $match.dom_validable}
							<a href="javascript:" onclick="blocking('bloc{$count+1}','yes', 'block'); return false;"><h3>{$lang.details}:</h3>
							{elseif (!$match.validation or $match.validation == 4) and $match.ext_validable}
							<a href="javascript:" onclick="blocking('bloc{$count+1}','yes', 'block'); return false;"><h3>{$lang.details}:</h3>
							{/if}
						</td>
				   </tr>
				   <tr>
						<td class="lineodd" colspan="5">
						   <div id="bloc{$count+1}" style="display:none; padding-top:0px;">
							   <table width="100%" border="0" cellspacing="0" cellpadding="2">
									<tr><td><b>{$lang.extendtime} :</b><input type="checkbox" name="extendtime{$match.id}" value="1"{if $match.extendtime} checked{/if}></td>
										<td><b>{$lang.penalty}</b></td>
										<td>
										<input type="text" value="{if !$match.pen_dom}0{else}{$match.pen_dom}{/if}" name="pendom{$match.id}" size="2" maxlenght="2"> -
										<input type="text" value="{if !$match.pen_ext}0{else}{$match.pen_ext}{/if}" name="penext{$match.id}" size="2" maxlenght="2">
										</td>
									</tr>
								</table>
								<hr>
							   <table width="100%" cellspacing="0" cellpadding="2" border="0">
							   <tr>
									<td align="center"><b>{$lang.matchdate}</b></td>
									<td align="center"><b>{$lang.matchhour}</b></td>
									<td align="center"><b>{$lang.spectators}</b></td>
									<td align="center"><b>{$lang.temperature}</b></td>
									<td align="center"><b>{$lang.weather}</b></td>
								</tr>	
								<tr>
									<td align="center"><input type="text" id="date{$match.id}" name="date{$match.id}" value="{$match.matchdate}" size="8" maxlength="8"><a title="{$lang.calendar}" href="javascript:void(lookupCalendar(document.edi.date{$match.id}.value,'date{$match.id}'))"><img alt="{$lang.calendar}" src="templates/portal/images/calendar.png" width="16" height="16" border="0"></a></td>
									<td align="center"><input type="text" name="hour{$match.id}" value="{$match.matchhour}" size="5" maxlength="5"></td>
									<td align="center"><input type="text" name="spect{$match.id}" value="{$match.spectators}" size="7" maxlength="7"></td>
									<td align="center"><input type="text" name="temp{$match.id}" value="{$match.temperature}" size="2" maxlength="2"></td>
									<td align="center"><select name="weather{$match.id}">
									<option value="0">---{$lang.weather}---</option>
									{foreach item=weather from=$weatherselect}
									<option value="{$weather.id}" {if $weather.id == $match.id_weather}Selected{/if}>{$weather.val}</option>
									{/foreach}
									</select></td>
							   </tr>
							   <tr>
									<td colspan="5"><b>{$lang.referee} :</b>
									<select name="ref{$match.id}">
									<option value="0">---{$lang.referee}---</option>
									{foreach item=referee from=$refereeselect}
									<option value="{$referee.id}" {if $referee.id == $match.id_referee}Selected{/if}>{$referee.lastname} - {$referee.firstname}</option>
									{/foreach}
									</select>
									</td>
								</tr>
								<tr>
									<td colspan="5"><b>{$lang.stadium} :</b>
									<select name="stadium{$match.id}">
									<option value="0">---{$lang.stadium}---</option>
									{foreach item=stadium from=$stadiumselect}
									<option value="{$stadium.id}" {if $stadium.id == $match.id_stadium}Selected{/if}>{$stadium.longname}</option>
									{/foreach}
									</select>
									</td>
							   </tr>
							   <tr><td colspan="5"><b>{$lang.comments}</b></td></tr>
							   <tr><td colspan="5"><textarea name="plot{$match.id}" style="width:95%; height:150px;">{$match.plot}</textarea></td></tr>
							   </table>
						   </div>
			   			</td>
					</tr>
			   </table>
			  {counter assign=count name=matchcount}		
			  {/foreach}
			  </td>
			</tr>
			<tr>
			<td>
				<span class="onglet">  
				<input style="width:100%;" type="submit" value="{$lang.save}" id="savebutton" accesskey="s" />
				</span>	
			</td>
			</tr>  
		</table>
	  </td>
  </tr>
  {if $administrable}
  <tr>
      <td><b><{$lang.matchday} {$lang.mirror}</b></td>
	</tr>
	<tr>
		<td align="left">{$lang.helpmirrorday}
		<select name="mirror" onchange="submit();">
				<option value="" selected>--------------------</option>
				{if $numdays is odd}
				{math equation="$numdays/2" assign=startnumday}
				{counter start=$startnumday direction=down print=false name=arcount assign=arcount}
				{else}
				{math equation="($numdays+1)/2" assign=startnumday}
				{counter start=$startnumday direction=down print=false name=arcount assign=arcount}
				{/if}
				{counter start=0 print=false name=daycount}
				{counter start=0 print=false assign=counterday name=counterday}
				
				{section name="loopday" start=0 loop=$numdays}
				{counter assign=counterday name=counterday}
				{if $competdata.type == 1}
					{if $counterday == $numdays and $competdata.ar == 0}		
						<option value="{$counterday}">{$lang.final_game}</option>
					{elseif $arcount == 0 and $numdays is odd}
						<option value="{$counterday}">{$lang.final_game}</option>
					{elseif $arcount == 0 and $numdays is even}
						{if $counterday is odd}
						<option value="{$counterday}">{$lang.final_game} {$lang.firstleg}</option>
						{else}
						<option value="{$counterday}">{$lang.final_game} {$lang.secondleg}</option>
						{/if}
					{else}
						{if !$competdata.ar}
						<option value="{$counterday}">1/{math equation="pow(2, ($numdays-$counterday+1))/2"} {$lang.final_game}</option>
						{else}
						
							{if $counterday is odd}
							<option value="{$counterday}">1/{math equation="pow(2, ($numdays-$counterday-$arcount+1))/2"} {$lang.final_game} {$lang.firstleg}</option>
							{else}
							<option value="{$counterday}">1/{math equation="pow(2, ($numdays-$counterday-$arcount+2))/2"} {$lang.final_game} {$lang.secondleg}</option>
							{counter name=arcount direction=down}
							
							{/if}
						{/if}
					{/if}
				{else}
				<option value="{$counterday}">{$lang.matchday} {$counterday}</option>
				{/if}
				{/section}		
		</select>
		</td>
  </tr>
  {/if}
  <tr><td id="bottompage">&nbsp;</td></tr>
</form>
</table>


</div>
<!-- /showheader -->


</div>
<!-- /content -->
