{*
  Template for the edit interface
  $Id: edit_candidates.tpl,v 1.00 2006/10/26 20:00:00
*}

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


<table id="tableshow" border="0" cellspacing="0" cellpadding="2" width="100%">
	<tr>
		<td id="toppage">
		{if $mycompetition}<a href="show_competitions.php?id={$mycompetition}">{$competdata.longname}  - {$lang.season} {if $competdata.oneyear}{$nameseason.season}{else}{$nameseason.season} / {$namenextyear}</a>{/if}{/if}
		</td>
	</tr>
{if $mycompetition}
{if $editable || $administrable}
	<tr>
			<td>
			<!-- /actions -->
			{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="{$mycompetition}"/>
						<span class="onglet-admin">
						<input type="submit" value="{$lang.edit}" />
						</span>
				</form>
				<form action="delete.php" name="deleteform">
					<input type="hidden" name="id" value="{$mycompetition}"/>
					<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_prizelist.php" name="candidateform">
					<input type="hidden" name="competition" value="{$mycompetition}"/>
					<span class="onglet-admin">
					<input type="submit" value="{$lang.prizelist}"/>
					</span>
				</form>
				<form action="edit_candidates.php" name="candidateform">
						<input type="hidden" name="competition" value="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>				
						<span class="onglet-admin">
						<input type="submit" value="{$lang.editseason}" />
						</span>
				</form>
				<form action="edit_penalitys.php" name="penalityform">
						<input type="hidden" name="competition" value="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>				
						<span class="onglet-admin">
						<input type="submit" value="{$lang.editpenality}" />
						</span>
				</form>
				<form action="edit_days.php" name="dayform">
						<input type="hidden" name="competition" value="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>				
						<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="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>				
						<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="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>				
						<span class="onglet-admin">
						<input type="submit" value="{$lang.editgoals}" />
						</span>
				</form>
				{/if}
			
			</td>
		</tr>
{/if}
		<tr>
			<td>
			{if $mycompetition}
				<form action="show_competitions.php" method="get" name="show">
					<input type="hidden" name="id" value="{$mycompetition}" />
					<span class="onglet">
					<input type="submit"  value="{$lang.card}" />
					</span>
				</form>
			{/if}
			{if $myseason}
			<form action="show_matchs.php" name="calendarform">
						<input type="hidden" name="competition" value="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>
						<span class="onglet">
						<input type="submit"  value="{$lang.calendar}" {if !$mycompetition}disabled="disabled"{/if} />
						</span>
			</form>
			{if $statsactive}
			<form action="stats_competitions.php" name="statsform">
				<input type="hidden" name="id" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>
				<span class="onglet">
				<input type="submit" value="{$lang.stats}" {if !$mycompetition} disabled="disabled"{/if} />
				</span>
			</form>
			{/if}
			<form action="show_tables.php" name="tableform">
						<input type="hidden" name="competition" value="{$mycompetition}"/>
						<input type="hidden" name="season" value="{$myseason}"/>
						<span class="onglet">
						<input type="submit"  value="{$lang.classement}" {if !$mycompetition}disabled="disabled"{/if} />
						</span>
			</form>
			{/if}
			{if $seegallery}
				<form action="gallery.php" name="galleryform">
					<input type="hidden" name="subcat" value="{$mycompetition}"/>
					<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="{$mycompetition}"/>
						<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>
{/if}
		<tr>
			<td id="bottompage">&nbsp;</td>
		</tr>
		
</table>



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


{if $http_error}<div class="center">{$http_error}</div>{/if}

<div id="pagecontent">
<br />
{if $numdays}
	<form action="edit_days.php" id="edi" name="edi" method="post">
	<input type="hidden" name="mycompet" id="mycompet" value="{$mycompetition}" />
	<input type="hidden" name="season" id="season" value="{$myseason}" />
	<input type="hidden" name="numdays" id="numdays" value="{$numdays}" />
	<input type="hidden" name="update" id="update" value="{$update}" />
	<input type="hidden" name="save" id="save" value="1" />
	
	
	{counter start=0 print=false name=counterday}  
	<table border="0" id="tableshow" cellspacing="0" cellpadding="2" width="100%">
	  <tr>
		  <td id="toppage" colspan="2"><a href="#">{$lang.definedate}</a></td>
	  </tr>
	  <tr>
		  <td class="lineeven" align="right" colspan="2">{$lang.matchshours} <input size="1" maxlength="2" type="text" name="myhour" value="20"> H : <input size="1" maxlength="2" type="text" name="mymin" value="00">M</td>
	  </tr>
	  <tr>
		  <td class="lineodd">
			<table width="100%" border="0" cellpadding="5" cellspacing="0">
			  {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}
			   <tr><td class="td-opt">
			   {if $competdata.type == 1}
	
					{if $counterday == $numdays and $competdata.ar == 0}		
						{$lang.final_game}
					{elseif $arcount == 0 and $numdays is odd}
						{$lang.final_game}
					{elseif $arcount == 0 and $numdays is even}
						{if $counterday is odd}
							{$lang.final_game} {$lang.firstleg}
						{else}
							{$lang.final_game} {$lang.secondleg}
						{/if}
					{else}
						{if !$competdata.ar}
							1/{math equation="pow(2, ($numdays-$counterday+1))/2"} {$lang.final_game}
						{else}
							{if $counterday is odd}
								1/{math equation="pow(2, ($numdays-$counterday-$arcount+1))/2"} {$lang.final_game} {$lang.firstleg}
							{else}
								1/{math equation="pow(2, ($numdays-$counterday-$arcount+2))/2"} {$lang.final_game} {$lang.secondleg}
								{counter name=arcount direction=down}
							{/if}
						{/if}
					{/if}
				   {else}
				   {$lang.matchday} {$count+1}
				   {/if}
			   </td>
			   
			   <td class="td-value"><input type="text" size="10" maxlength="8" id="date{if $count == 0}{$days[0].id}{else}{$days.$count.id}{/if}" name="date{if $count == 0}{$days[0].id}{else}{$days.$count.id}{/if}" value="{if $count == 0}{$days[0].date_day}{else}{$days.$count.date_day}{/if}">
			   <a title="{$lang.calendar}" href="javascript:void(lookupCalendar(document.edi.date{if $count == 0}{$days[0].id}{else}{$days.$count.id}{/if}.value,'date{if $count == 0}{$days[0].id}{else}{$days.$count.id}{/if}'))"><img alt="{$lang.calendar}" src="templates/portal/images/calendar.png" width="16" height="16" border="0"></a>
			   <a title="{$lang.del}" href="delete.php?cat=4&id={if $count == 0}{$days[0].id}{else}{$days.$count.id}{/if}"><img alt="{$lang.del}" src="templates/portal/images/erase.png" width="16" height="16" border="0"></a>
			   </td></tr>
			  {counter assign=count name=daycount}		
			  {/section}
			</table>
		  </td>
		  
	   </tr>
	   <tr>
		<td class="lineeven" colspan="2">
			<span class="onglet">
			<input type="submit" STYLE="width:100%" VALUE="{$lang.save}">
			</span>
		</td>
		</tr>
		<tr>
		<td id="bottompage">&nbsp;</td>
		</tr> 
	</table>
	</form>
	<br />
	<form action="edit_days.php" id="add" name="add" method="post">
		<input type="hidden" name="mycompet" id="mycompet" value="{$mycompetition}" />
		<input type="hidden" name="season" id="season" value="{$myseason}" />
		<input type="hidden" name="numdays" id="numdays" value="{$numdays}" />
		<input type="hidden" name="add_day" id="add_day" value="1" />
		<table border="0" id="tableshow" cellspacing="0" cellpadding="2">
		  <tr>
			  <td id="toppage"><a href="#">{$lang.add_day}</a></td>
		  </tr>
		  <tr>
			  <td class="lineeven" ><input size="1" maxlength="2" type="text" name="num_add_day" value="00"></td>
		  </tr>
		  <tr>
			  <td class="lineeven">
				<span class="onglet">
				<input type="submit" STYLE="width:100%" VALUE="{$lang.save}">
				</span>
			  </td>
		  </tr>
		</table>
	</form>
{else}
	<table border="0" id="tableshow" cellspacing="0" cellpadding="2" width="100%">
	  <tr>
		  <td id="toppage" colspan="2"><a href="#">{$lang.editday}</a></td>
	  </tr>
	  <tr>
		  <td class="lineeven">{$lang.definecandidatebefore}</td>
	  </tr>
	  <tr>
		<td id="bottompage">&nbsp;</td>
		</tr> 
	</table>
{/if}
</div>
<!-- /content -->
