{*
  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`"}
<div id="title">{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}</div>
<div id="actions">
    <div id="barre-onglet">
{if $mycompetition}
	{if $mycompetition}
		<form action="show_competitions.php" method="get" name="show">
			<input type="hidden" name="id" value="{$mycompetition}" />
			<input type="submit" class="onglet" value="{$lang.card}" />
		</form>
		<form action="prizelist.php" name="tableform">
			<input type="hidden" name="competition" value="{$mycompetition}"/>
			<input type="submit" class="onglet" value="{$lang.prizelist}" {if !$mycompetition}disabled="disabled"{/if} />
		</form>
		{if $statsactive}
			<form action="stats_competitions.php" name="statsform">
				<input type="hidden" name="id" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>
				<input class="onglet" type="submit" value="{$lang.statistics}" {if !$mycompetition} disabled="disabled"{/if} />
			</form>
		{/if}
	{/if}
	{if $myseason}
	<form action="show_matchs.php" name="calendarform">
				<input type="hidden" name="competition" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>
				<input type="submit" class="onglet" value="{$lang.calendar}" {if !$mycompetition}disabled="disabled"{/if} />
	</form>
	<form action="show_tables.php" name="tableform">
				<input type="hidden" name="competition" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>
				<input type="submit" class="onglet" value="{$lang.classement}" {if !$mycompetition}disabled="disabled"{/if} />
	</form>
	{/if}
	{if $seegallery}
        <form action="gallery.php" name="galleryform">
            <input type="hidden" name="subcat" value="{$mycompetition}"/>
            <input type="hidden" name="cat" value="2" />
            <input type="submit" value="{$lang.gallery}" class="onglet"/>
        </form>
	{/if}
	{if $commentable}
			<form action="comments.php" name="mkcommentform">
				<input type="hidden" name="subcat" value="{$mycompetition}"/>
				<input type="hidden" name="cat" value="2" />
				<input type="submit" value="{$lang.comments}" class="onglet"/>
			</form>
	{/if}
	{if $prev_id || $next_id}
			<form action="show_competitions.php" name="prevform">
				<input type="hidden" name="id" value="{$prev_id}"/>
				<input type="submit" class="onglet" value="<" {if !$prev_id}disabled="disabled"{/if} accesskey="," />
			</form>
			<form action="show_competitions.php" name="nextform">
				<input type="hidden" name="id" value="{$next_id}"/>
				<input type="submit" class="onglet" value=">" {if !$next_id}disabled="disabled"{/if} accesskey="." />
			</form>
	{/if}
	
	</div>
	<!-- /actions -->
	{if $editable || $administrable}
	<div id="barre-season">
		{if $administrable}
		<form action="edit_competitions.php" name="editform">
				<input type="hidden" name="id" value="{$mycompetition}"/>
				<input type="submit" value="{$lang.edit}" class="onglet"/>
		</form>
		<form action="edit_competitions.php" name="editform">
				<input type="hidden" name="id" value="{$mycompetition}"/>
				<input class="onglet" type="submit" value="{$lang.edit}" />
		</form>
		<form action="delete.php" name="deleteform">
			<input type="hidden" name="id" value="{$mycompetition}"/>
			<input type="hidden" name="cat" value="3"/>
			<input class="onglet" type="submit" value="{$lang.del}" onclick="return(confirm('{$competition.lastname|escape:javascript}: {$lang.really_del}?'))" />
		</form>
		{/if}
		{if $editable || $administrable}
		<form action="edit_candidates.php" name="candidateform">
				<input type="hidden" name="competition" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>				
				<input type="submit" value="{$lang.editseason}" class="onglet"/>
		</form>
			{if !$competdata.type}
			<form action="edit_penalitys.php" name="penalityform">
					<input type="hidden" name="competition" value="{$mycompetition}"/>
					<input type="hidden" name="season" value="{$myseason}"/>				
					<input type="submit" value="{$lang.editpenality}" class="onglet"/>
			</form>
			{/if}
		<form action="edit_days.php" name="dayform">
				<input type="hidden" name="competition" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>				
				<input type="submit" value="{$lang.editday}" class="onglet"/>
		</form>
		<form action="edit_matchs.php" name="matchsform">
				<input type="hidden" name="competition" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>				
				<input type="submit" value="{$lang.editmatchs}" class="onglet"/>
		</form>
		<form action="edit_goals.php" name="matchsform">
				<input type="hidden" name="competition" value="{$mycompetition}"/>
				<input type="hidden" name="season" value="{$myseason}"/>				
				<input type="submit" value="{$lang.editgoals}" class="onglet"/>
		</form>
		{/if}
	</div>
	{/if}
{/if}
</div>

<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" />
<div id="edit" align="center">

{counter start=0 print=false name=counterday}  
<table border="0" style="border:1px solid #000000;" cellspacing="0" cellpadding="2" width="100%">
  <tr>
  	  <td class="title-classement" style="border-bottom:1px solid #000000;" colspan="2">{$lang.definedate}</td>
  </tr>
  <tr id="barre-classement">
  	  <td 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="td-value">
		<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 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}'))">Calendar</a>
		   <a href="delete.php?cat=4&id={if $count == 0}{$days[0].id}{else}{$days.$count.id}{/if}">{$lang.del}</a>
		   </td></tr>
		  {counter assign=count name=daycount}		
		  {/section}
		</table>
	  </td>

   </tr>
   <tr>
   	<td class="td-value" colspan="2"><INPUT TYPE="submit" CLASS="button" STYLE="width:100%" VALUE="{$lang.save}"></td>
	</tr> 
</table>
</div>
<!-- /edit -->
</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" />
<div>
<table border="0" style="border:1px solid #000000;" cellspacing="0" cellpadding="2">
  <tr>
  	  <td class="title-classement">{$lang.add_day} :</td>
	  <td class="td-value" ><input size="1" maxlength="2" type="text" name="num_add_day" value="00"></td>
	  <td class="td-value"><INPUT TYPE="submit" CLASS="button" STYLE="width:100%" VALUE="{$lang.save}"></td>
  </tr>
</table>

</div>
</form>
{else}
	<table border="0" id="tableshow" cellspacing="0" cellpadding="2" width="100%">
	  <tr>
		  <td class="title-classement" colspan="2"><a href="#">{$lang.editday}</a></td>
	  </tr>
	  <tr>
		  <td class="lineeven">{$lang.definecandidatebefore}</td>
	  </tr>
	</table>
{/if}
</div>
<!-- /content -->
