<%
/******************************************************************************
 * Copyright (c) 2000-2008 e-Deal
 *
 * e-Deal S.A.
 * 55 rue Brillat Savarin
 * 75013 Paris
 * France
 *
 * T: +33 (0)1 53 80 80 30
 * F: +33 (0)1 73 01 69 77
 * http://www.e-deal.com
 * 
 * La diffusion de ce code source sous quelque forme que ce soit sans
 * l'autorisation de E-DEAL est interdite.
 *
 * Vous êtes autorisés à modifier ce code source uniquement pour votre usage
 * propre et sous réserve que les mentions de copyright demeurent intactes.
 *
 * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou
 * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour
 * responsable des dommages pouvant résulter de l'utilisation de ce code
 * source.
 ******************************************************************************/
%><%@page session="true" import="com.edeal.frontline.*,java.util.*,com.edeal.frontline.navigation.*"%>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>

<%
	final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());
	FlRequest flRequest = new FlRequest(request);
	FlContext context = flRequest.getContext();
	DataDictionary dico = context.getDataDictionary();
	
	Vector vectRefList = dico.getRefList(session, "SolDomID");
	String sfwID = flRequest.getParameter("SfwID");
%>
<style type="text/css">
.dataValueX {
	width: 30%;
	overflow: hidden;
	margin: 0px;
	padding: 0px;
	padding-left: 10px;
	font-size: small;
	font-size: expression("x-small");
	color: rgb(0, 0, 0);
	font-family: Arial, Verdana, sans-serif;
	vertical-align: top;
	padding: 4px;
}
.borderLineOne {
	border-right: 1px dashed #9EC6D0;
	border-bottom: 1px dashed #9EC6D0;
}
.borderLineTwo {
	border-right: 1px dashed #9EC6D0;
}
</style>
<script language="javascript" type="text/javascript" src="<fl:webapp/>/js/smalltabs.jsp"></script>
<script language="javascript" src="<fl:webapp/>/js/calendar.jsp"></script>
<script language="javascript" src="<fl:webapp/>/js/checkFields.jsp"></script>
<script type="text/javascript">
var actID ='';
function doSearch(){
	
	var f = document.forms[0];
	var domLst = "";
	for(var i = 0; i < f.DomID.length; i++) {
		if(f.DomID[i].checked) {
			domLst += (domLst.length > 0 ? ';' : '') + f.DomID[i].value;
		}
	}
	if(domLst == '') {
		window.alert('<fl:getMessage code="M1000" alt="Veuillez sélectionner une ou plusieurs compétences." js="true"/>');
		return;
	}else{
		var url = '<fl:webapp/>/ressources_list.fl?cpoID='+domLst;
		hideCal();
		doAjax(url, showActList);
	}
}

function showActList(arrIndex) {	
	hideWaiting();
		
	if (eDealXmlhttpArr[arrIndex].readyState == 4){
		var title = document.getElementById('ActTitle');
		title.style.display = 'block';
			
		var actList = document.getElementById('ActList');		
		actList.innerHTML = eDealXmlhttpArr[arrIndex].responseText;			
	}
}

function doSelect(id){
	var url= '<fl:webapp/>/ressources_actor_cal.fl?SfwID=<%= sfwID %>&ActID='+id;
	actID = id;
	doAjax(url, showCal);
}

function showCal(arrIndex) {
	hideWaiting();
	
	if (eDealXmlhttpArr[arrIndex].readyState == 4) {	
		var cal = document.getElementById('ActCal');
		cal.innerHTML = eDealXmlhttpArr[arrIndex].responseText;		
	}
}

function hideCal(){
	var cal = document.getElementById('ActCal');
	cal.innerHTML = '';			
}

// Calendar Functions

function changeDate(newDate) {
	var url= '<fl:webapp/>/ressources_actor_cal.fl?SfwID=<%= sfwID %>&ActID='+actID+'&Date='+encodeURIComponent(newDate);
	doAjax(url, showCal);
}

function createInt(actID, date) {
	window.location = "<fl:webapp/>/create_interaction.fl?SfwID=<%= sfwID %>&initIntActID=" + encodeURIComponent(actID) + "&initIntDate=" + encodeURIComponent(date);
}

function openCalendar2() {
 var f = window.document.forms[0];
 	openCalendar(f.calDate);
}

function oncalDateChange(){
	window.setTimeout("changeDate(window.document.forms[0].calDate.value)", 1);
}

function viewCalendars(){
	var f = document.forms[0];
	var j = 0;
	
	var actCheckbox;
	var checkboxIdx = 0;
	try {
		eval('actCheckbox = f.pActID0;');
	} catch (error) {
	}

	var calActID = '';
	while (actCheckbox) {
		if (actCheckbox.checked) {
			if (calActID != '') {
				calActID += ';';
			}
			
			eval('calActID += f.pActID' + checkboxIdx + '.value;');
		}
	
		checkboxIdx += 1;
		eval('actCheckbox = f.pActID' + checkboxIdx + ';');
	}
	
	if (calActID == '') {
		alert('<fl:getMessage code="M60A5" alt="Veuillez choisir au moins un acteur" js="true"/>');
		return;
	}
	
	actID = calActID;
	var url= '<fl:webapp/>/ressources_actor_cal.fl?SfwID=<%= sfwID %>&ActID=' + calActID;
	doAjax(url, showCal);
}

</script>

<fl:bigTabs objectTitle="<%=Utils.getMessage(session, \"L60F2\", false, true, \"Ressources\")%>">
<form action="" onSubmit="javascript:doSearch();" method="post">
<table class="container" width="100%">
	<input name="$$presentFields" type="hidden" value="">
	
	<tr class="fieldline">
		<td class="titrePartie" colspan="2"><fl:getMessage code="F2069" alt="Compétences"/></td>
	</tr>
	<tr class="ligne_separation_couleur">
		<td colspan="3"></td>
	</tr>
	<tr class="ligne_separation">
		<td colspan="3">&nbsp;</td>
	</tr>
	<tr>
		<td>
<%
	for(int i = 0; i < vectRefList.size() ; i++) {
		Vector vectRef = (Vector)vectRefList.elementAt(i);
		String refID = (String)vectRef.elementAt(0);
		String refDisp = (String)vectRef.elementAt(1);
%>

		<span class="dataValue"><input name="DomID" type="checkbox" value="<%= refID %>"><%= Utils.formatToWeb(refDisp, false) %></input></span><br>
<% } %>	
		</td>
		<td class="separation"><div class="separation"></div></td>
		<td>
			<a href="javascript:doSearch();"><img src="<fl:webapp/>/icons/ico/valider.gif"></a>
		</td>
	</tr>	
	<input type="hidden" name="calDate" value="">
</table>
&nbsp;
<table class="container" width="100%">
	<tr>
		<td colspan="3">
			<div id="ActTitle" style="display: none;">
				<table width="100%">
					<tr class="fieldline">
						<td class="titrePartie" colspan="2"><fl:getMessage code="L2089" alt="Acteur"/></td>
					</tr>
					<tr class="ligne_separation_couleur">
						<td></td>
					</tr>
					<tr class="ligne_separation">
						<td></td>
					</tr>
					<tr>
						<td width="100%" >
						<span id="ActList"></span>
						</td>
					</tr>
				</table>
			</div>
		<td>
	</tr>
</table>
&nbsp;
<div id="ActCal">
</div>
</form>
</fl:bigTabs>
