summaryrefslogtreecommitdiff
path: root/maquette/script.js
blob: 2dd33e9d5c16f928e29616bbc003bb863b134baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
function addPers(form) 
{
	if(form.contactDispo.options.selectedIndex>=0)
	{
		var oValue = form.contactDispo.options[form.contactDispo.options.selectedIndex].value;   		
		
		var exist = false;
		var i = 0;
		while (i<form.participants.options.length && !exist) { if (form.participants.options[i].value == oValue) exist = true; i=i+1;}
		
		if (!exist)
		{
			var oText = form.contactDispo.options[form.contactDispo.options.selectedIndex].text;
			var o = new Option(oText,oValue);
			form.participants.options[form.participants.options.length]=o;
		}
	}
}

function removePers(form) 
{
	if (form.participants.options.selectedIndex>=0) 
	{
		var i = form.participants.options.selectedIndex; 
		form.participants.options[form.participants.options.selectedIndex]=null;
		if (parseInt(i) > 0) {form.participants.options.selectedIndex=parseInt(i)-1;} else {form.participants.options.selectedIndex=0;}
	}
	else
	{
		alert("Suppression impossible : aucune ligne s�lectionn�e");
	}
}

function loadid(url,id,isPop) {
	if (isPop) 
		document.getElementById(id).innerHTML = "<em>Chargement en cours ...<br/><a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a></em>";
	else
		document.getElementById(id).innerHTML = "<em>Chargement en cours ...</em>";
		

	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
        }

        if (!http_request) {
		alert('Abandon : Impossible de cr�er une instance XMLHTTP');
		return false;
	}

        http_request.onreadystatechange = function(){

	        if (http_request.readyState == 4) {
	        	if (http_request.status == 200) {
				document.getElementById(id).innerHTML = http_request.responseText;
			} else {
				if (isPop) 
					document.getElementById(id).innerHTML = "<em>Un probl&egrave;me est survenu ...<br/><a href=\"#\" onclick=\"loadid('"+url+"','"+id+"',true)\" >R&eacute;essayer</a> - <a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a></em>";
				else
					document.getElementById(id).innerHTML = "<em>Un probl&egrave;me est survenu ...<br/><a href=\"#\" onclick=\"loadid('"+url+"','"+id+"',false)\" >R&eacute;essayer</a></em>";
			}
		}
	};

        http_request.open('GET', url, true);
        http_request.send(null);
}

function popon (id)
{
	var thisPopup = document.getElementById(id);
	thisPopup.style.display='block';
	var thisMasque = document.getElementById('masque');
	thisMasque.style.display='block';
}

function popoff (id)
{
	var thisPopup = document.getElementById(id);
	thisPopup.style.display='none';
	var thisMasque = document.getElementById('masque');
	thisMasque.style.display='none';
}

function addcreneau(form)
{
	if(form.day.options.selectedIndex>=0 && form.month.options.selectedIndex>=0 && form.year.options.selectedIndex>=0 && form.hourStart.options.selectedIndex>=0 && form.minuteStart.options.selectedIndex>=0 && form.hourEnd.options.selectedIndex>=0 && form.minuteEnd.options.selectedIndex>=0)
	{
		if (verifDate(form.day.options[form.day.options.selectedIndex].value,form.month.options[form.month.options.selectedIndex].value,form.year.options[form.year.options.selectedIndex].value))
		{
			//Cr�ation de la valeur
			var oValue = form.hourStart.options[form.hourStart.options.selectedIndex].value + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + "." + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value;
			oValue = oValue + "." + form.day.options[form.day.options.selectedIndex].value +  "." + form.month.options[form.month.options.selectedIndex].value + "." + form.year.options[form.year.options.selectedIndex].value;
			
			//Test si la valeur est d�ja dans la liste
			var exist = false;
			var i = 0;
			while (i<form.creneaux.options.length && !exist) { if (form.creneaux.options[i].value == oValue) exist = true; i=i+1;}
			
			//Cr�ation du texte et de l'option et insertion de l'option si la valeur n'a pas �t� trouv�e
			if (!exist) 
			{
				var oText = form.hourStart.options[form.hourStart.options.selectedIndex].value + ":" + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + " -> " + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + ":" + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value;
				oText = oText + "  " + form.day.options[form.day.options.selectedIndex].value + "/" + form.month.options[form.month.options.selectedIndex].value + "/" + form.year.options[form.year.options.selectedIndex].value;
				var o = new Option(oText,oValue);
				form.creneaux.options[form.creneaux.options.length]=o;
			}
		}
	}
}

function removecreneau(form) 
{
	if (form.creneaux.options.selectedIndex>=0) 
	{
		var i = form.creneaux.options.selectedIndex; 
		form.creneaux.options[form.creneaux.options.selectedIndex]=null;
		if (parseInt(i) > 0) {form.creneaux.options.selectedIndex=parseInt(i)-1;} else {form.creneaux.options.selectedIndex=0;}
	}
	else
	{
		alert("Suppression impossible : aucune ligne s�lectionn�e");
	}
}

function dataListe(idSelect,idInput)
{
	var liste = document.getElementById(idSelect);
	if (liste)
	{
		for (var i=0;i<liste.options.length;i++)
		{
			var newInput = document.createElement("input");
/*			newInput.setAttribute("type", "hidden");
			newInput.setAttribute("name", (idInput+"["+i+"]"));
			newInput.setAttribute("value", liste.options[i].value);*/
			newInput.type = "hidden";
			newInput.name = idInput+"["+i+"]";
			newInput.value = liste.options[i].value;
			liste.form.appendChild(newInput); 
		}
		return (true);
	}
	else
	{
		return (false);
	}
	
}
function verifDate(day,month,year)
{
	var a= year;
	var m= month;
	var d= day;
	var ok=true;

	var date2=new Date(a,m-1,d);
	d2=date2.getDate();
	m2=date2.getMonth()+1;
	a2=date2.getFullYear();
	if (a2<=100) {a2=1900+a2} //Pour depasser 2000
	if ( (d!=d2)||(m!=m2)||(a!=a2) ) 
	{
		alert("Cette date n'existe pas !");
		ok=false;
	}
	return (ok);
}
function loadlist(url,id,idListe)
{

	if (document.getElementById(id))
	{
		loadid((url+document.getElementById(id).options[document.getElementById(id).options.selectedIndex].value),idListe,false);
	}
}