{include file="$gentemplates/_header.tpl"}

<script type="text/javascript">
var err_no_start = "{$temp_err_no_start}";
var err_no_end = "{$temp_err_no_end}";
var err_end_before = "{$temp_err_end_before}";
var err_no_person = "{$temp_err_no_person}";

var err_thema_long = "{$temp_err_thema_long}";
var err_external_long = "{$temp_err_external_long}";
//var appt_start_default_id = "{$appt_start_default_id}";


var err_no_week = "{$temp_err_no_week}"
var err_no_participant = "{$temp_err_no_participant}";


{literal}

function keep_weeks_coherence(){
if (document.nd.serial_week.length==53) //there are 52 weeks in list + item ' '
	{
		document.nd.serial_week.options[53] = new Option('53','53');
	}

var sel_value = document.nd.serial_year.options[document.nd.serial_year.selectedIndex].value;
if (
{/literal}
{section name=y53 loop=$year53_list}
	sel_value!={$year53_list[y53]} &&
{/section}
{literal}
    1 ) document.nd.serial_week.options[53] = null;
	
}

function update_week_sel(w){
	if (w!="") {
		//alert("update : "+w);
		keep_weeks_coherence();
		document.nd.serial_week.selectedIndex=w;
		
	 }
}
function selectItems() {
    var to_form = eval('document.nd.elements[\"participants[]\"]');
    for(i=0; i < to_form.length; i++) {
	to_form.options[i].selected = true;
    }
    return true;
}

function check_form() {
   
   
   // if (document.nd.day.checked == false) {
	
	if (document.nd.serial_week.selectedIndex == 0) {
	    alert (err_no_week);
	    document.nd.serial_week.focus();
	    return false;
	} else if (document.nd.elements["participants[]"].length == 0) {
	    alert (err_no_participant);
	    document.nd.elements["participants[]"].focus();
	    return false;
	}
	
	
	/* else if (!document.nd.appointment_attribute[0].checked && (document.nd.appointment_end.value < document.nd.appointment_start.value)) {
	    alert (err_end_before);
	    document.nd.appointment_end.focus();
	    return false;
	}
    }
*/
  
    return selectItems();
}
</script>
{/literal}

<form name="nd" action="{$phpself}?action=view" method="POST">
<input type="hidden" name="{$SESSIONNAME}" value="{$SESSIONID}">
<!-- <input type="hidden" name="date" value="{$date}"> -->
<input type="hidden" name="chosen_week" >



{include file="$gentemplates/_navi.tpl" submenu="$submenu"}
{include file="$gentemplates/_contentheader.tpl" title=$gentemp_view_avail}

<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr><td class="lines" height="1" width="1" colspan="3"><img src="{$imgpathgeneral}/space.gif" alt="" width="1" height="1" /></td></tr>
  <tr align="left">
    <td class="category" height="20" width="10">&nbsp;</td>
    <td class="category" width="130">{$gentemp_period},&nbsp;{$duration}</td>
    <td class="category" width="70%">&nbsp;</td>
  </tr>
  
  <tr><td class="lines" height="1" width="1" colspan="3"><img src="{$imgpathgeneral}/space.gif" alt="" width="1" height="1" /></td></tr>
  <tr class="tab" align="left">
    <td class="tab" height="40"><img src="{$imgpathgeneral}/space.gif" alt="" width="60" height="1" /></td>
    <td class="formhead">{$gentemp_period}</td>
    <td class="formhead">
	<!-- <INPUT TYPE="text" NAME="week" VALUE="{$week}" SIZE="2"  />  -->
	{$gentemp_week}&nbsp;&nbsp;
	<select name="serial_week" size="1" onFocus="update_week_sel(document.nd.chosen_week.value); document.nd.chosen_week.value='';">
	<option value="0">&nbsp;</option>	
	  <OPTION VALUE="01">01</OPTION> 
	  <OPTION VALUE="02">02</OPTION>
	  <OPTION VALUE="03">03</OPTION>
	  <OPTION VALUE="04">04</OPTION>
	  <OPTION VALUE="05">05</OPTION>
	  <OPTION VALUE="06">06</OPTION>
	  <OPTION VALUE="07">07</OPTION>
	  <OPTION VALUE="08">08</OPTION>
	  <OPTION VALUE="09">09</OPTION>
	  <OPTION VALUE="10">10</OPTION>
	  <OPTION VALUE="11">11</OPTION> 
	  <OPTION VALUE="12">12</OPTION>
	  <OPTION VALUE="13">13</OPTION>
	  <OPTION VALUE="14">14</OPTION>
	  <OPTION VALUE="15">15</OPTION>
	  <OPTION VALUE="16">16</OPTION>
	  <OPTION VALUE="17">17</OPTION>
	  <OPTION VALUE="18">18</OPTION>
	  <OPTION VALUE="19">19</OPTION>
	  <OPTION VALUE="20">20</OPTION>
	  <OPTION VALUE="21">21</OPTION> 
	  <OPTION VALUE="22">22</OPTION>
	  <OPTION VALUE="23">23</OPTION>
	  <OPTION VALUE="24">24</OPTION>
	  <OPTION VALUE="25">25</OPTION>
	  <OPTION VALUE="26">26</OPTION>
	  <OPTION VALUE="27">27</OPTION>
	  <OPTION VALUE="28">28</OPTION>
	  <OPTION VALUE="29">29</OPTION>
	  <OPTION VALUE="30">30</OPTION>
	  <OPTION VALUE="31">31</OPTION> 
	  <OPTION VALUE="32">32</OPTION>
	  <OPTION VALUE="33">33</OPTION>
	  <OPTION VALUE="34">34</OPTION>
	  <OPTION VALUE="35">35</OPTION>
	  <OPTION VALUE="36">36</OPTION>
	  <OPTION VALUE="37">37</OPTION>
	  <OPTION VALUE="38">38</OPTION>
	  <OPTION VALUE="39">39</OPTION>
	  <OPTION VALUE="40">40</OPTION>
	  <OPTION VALUE="41">41</OPTION> 
	  <OPTION VALUE="42">42</OPTION>
	  <OPTION VALUE="43">43</OPTION>
	  <OPTION VALUE="44">44</OPTION>
	  <OPTION VALUE="45">45</OPTION>
	  <OPTION VALUE="46">46</OPTION>
	  <OPTION VALUE="47">47</OPTION>
	  <OPTION VALUE="48">48</OPTION>
	  <OPTION VALUE="49">49</OPTION>
	  <OPTION VALUE="50">50</OPTION>
	  <OPTION VALUE="51">51</OPTION>
	  <OPTION VALUE="52">52</OPTION>
	  <OPTION VALUE="53">53</OPTION>
   	</select>
	
	<!-- <img src="{$imgpathgeneral}/space.gif" alt="" width="10" height="1" /> -->
	{literal}
	<SCRIPT language="javascript">
	    function OuvrirPopup(page,nom,option) {
	       F=window.open(page,nom,option);
		   F.focus();
	    }
	</SCRIPT>
	{/literal}
		
	&nbsp;
	{$gentemp_year}&nbsp;{$serial_year|smarty:nodefaults}
	
	<img src="{$imgpathgeneral}/space.gif" alt="" width="5" height="1" />
	<!-- 'resizable=no, location=no, width=220, height=170, menubar=no, status=no, scrollbars=no, menubar=no' -->
	<a href="javascript:void(0);" ONCLICK="javascript:OuvrirPopup('choose_week.php?target={$target}&{$SESSION}', 'choose_week', 'resizable=no, location=no, width=210, height=185, menubar=no, status=no, scrollbars=no, menubar=no')"><img src="{$imgpath}/cal_mini.gif" alt="{$gentemp_choose_date}" border="0" ></a>

	<SCRIPT language="javascript">
		{if $week_sel != ""}
		update_week_sel({$week_sel});
		{/if}
		keep_weeks_coherence();		
	</SCRIPT>
	</td>
  </tr>
  <tr>
  <td class="lines" height="1" width="1" colspan="3"><img src="{$imgpathgeneral}/space.gif" alt="" width="1" height="1" /></td></tr>
  <tr class="tab" align="left">
    <td class="tab" height="40"><img src="{$imgpathgeneral}/space.gif" alt="" width="60" height="1" /></td>
    <td class="formhead">{$gentemp_duration}</td>
    <td class="tab">
      <select name="appointment_duration" size="1">
	<!-- value 31532400 is 1st jan 1971 at 00:00 -->
	<option value="31532400">&nbsp;</option>	
	  {section name=hour loop=$appointment_duration_list}
	<option value="{$appointment_duration_list[hour].timestamp}"{$appointment_duration_list[hour].sel}>{$appointment_duration_list[hour].time_label}</option>	
	  {/section}	    
      </select>	  	  
    </td>
  </tr>
  
  {* participants *}
  <tr><td class="lines" height="1" width="1" colspan="3"><img src="{$imgpathgeneral}/space.gif" alt="" width="1" height="1" /></td></tr>						
  <tr align="left">
    <td class="category" height="20"><img src="{$imgpathgeneral}/space.gif" alt="" width="10" height="1" /></td>
    <td class="category" width="130">{$temp_participants}</td>
    <td class="category">&nbsp;</td>
  </tr>
  <tr class="tab" align="left">
    <td class="tab" height="80"><img src="{$imgpathgeneral}/space.gif" alt="" width="60" height="1" /></td>
    <td class="formhead">{$temp_participants}</td>
    <td class="formhead" >
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
	  <td class="formhead" valign="top" width="270">{$gentemp_people_list}<br>
	    <select class="available" name="tn[]" multiple size="4">
	      {section name=pt loop=$partie}
	      <option value="{$partie[pt].userid}">{$partie[pt].name}</option>
		{/section}	    
	    </select>
	    <br>
	    <input class="submit" onclick="MoveOption('tn','participants');" type="button" value="{$addbutton}" name="Add">			    
	    <img src="{$imgpathgeneral}/space.gif" alt="" width="60" height="1" />
	  </td>
	  <td class="formhead" valign="top">
	    {$temp_selparticipants}
	    <br>
	    <select class="select" multiple  name="participants[]">
	      {section name=spt loop=$spartie}
	      <option value="{$spartie[spt].userid}">{$spartie[spt].name}</option>
		{/section}	
	    </select>
	    <br>
	    <input class="submit" onclick="MoveOption('participants','tn');" type="button" value="{$removebutton}" name="Remove">
	  </td>
	  <td class="formhead" align="left" width="200">&nbsp;</td>
	</tr>
	<tr>
	  <td class="formhead" colspan=3>&nbsp;</td>
	</tr>
	<!--
	<tr>
	  <td class="formhead" align="left">&nbsp;</td>
	  <td class="formhead" align="left" colspan="2">
	    <input class="submit" onclick="testAvail('{$sname}');" type="button" value="{$temp_avail_text}" name="AvailTest"><br /><br />
	  </td>
	</tr>
	-->
      </table>
    </td>
  </tr>
  
  <tr><td class="lines2" height="1" width="1" colspan="3"><img src="{$imgpathgeneral}/space.gif" alt="" width="1" height="1" /></td></tr>
  <tr class="tab" align="left">
    <td class="tab" height="40"><img src="{$imgpathgeneral}/space.gif" alt="" width="60" height="1" /></td>
    <td class="formhead"><a class="edit" href="{$back}">{$gentemp_abort}</a>&nbsp;</td>
    <td class="formhead"><input class="submit" type="submit" name="{$sname}" value="{$suvalue}" onclick="return check_form();"></td>
  </tr>
  <tr><td class="lines" height="1" width="1" colspan="3"><img src="{$imgpathgeneral}/space.gif" alt="" width="1" height="1" /></td></tr>
</table>
<input type="hidden" name="id" value="{$id}">
</form>


{include file="$gentemplates/_footer.tpl" aktUser=$username}
