Révision 3d5328c4

b/index.php
69 69

  
70 70
	$str_date = $_POST['str_date'];
71 71
	$nom = $_POST['nom'];
72
	$demi_jour = $_POST['demi_jour'];
73 72
	getConges("datas", $employes, $conges);
74 73
	if ($_POST['action'] == 'add') {
75 74
		if (!$conges[$nom] || !in_array($str_date, $conges[$nom])) {
......
80 79
				$key = array_search("$str_date PM", $conges[$nom]);
81 80
				if ($key !== FALSE) unset($conges[$nom][$key]);
82 81
			}
83
			$conges[$nom][] = $str_date.($demi_jour ? " $demi_jour" : "");
82
			$conges[$nom][] = $str_date;
84 83
			setConges('datas', $nom, $conges);
85 84
		}
86 85
	} elseif ($_POST['action'] == 'del') {
......
132 131
	<meta http-equiv="Content-language" content="fr" />
133 132
	<meta name="copyright" content="Tous droits réservés - All Rights Reserved" />
134 133
	<meta name="author" content="Romuald DELAVERGNE">
134
	<style type="text/css">
135
		td a {
136
			display: block;
137
			width: 100%;
138
			background-color: white;
139
			color: black;
140
			text-decoration: none;
141
			text-align: center;
142
			font-family: Arial, Helvetica, sans-serif;
143
			font-weight: bold;
144
			cursor: pointer;
145
		}
146
		td a:hover {
147
			background-color: gray;
148
			color: white;
149
		}
150
	</style>
135 151
	<script language=JavaScript>
136
		function updateConges(jour, nom, str_date, action) {
152
		var ie = document.all;
153
		var ns6 = document.getElementById&&!document.all;
154
		var isMenu = false;
155
		var overpopupmenu = false;
156
		var selectNom = '';
157
		var selectDate = '';
158

  
159
		function $(id) {
160
			return document.getElementById(id);
161
		}
162

  
163
		function updateConges(nom, str_date, action) {
137 164
			document.forms["update"].action.value = action;
138 165
			document.forms["update"].nom.value = nom;
139 166
			document.forms["update"].str_date.value = str_date;
140 167
			document.forms["update"].submit();
141 168
		}
169

  
170
		function mouseSelect(e) {
171
			var obj = ns6 ? e.target.parentNode : e.srcElement.parentElement;
172
			//var obj = ns6 ? e.target : e.srcElement;
173
			if (isMenu) {
174
				if (overpopupmenu == false) {
175
					isMenu = false;
176
					overpopupmenu = false;
177
					$('popupMenu').style.display = "none";
178
					if (obj.id == 'AM' || obj.id == 'PM' ) {
179
						updateConges(selectNom, selectDate+' '+obj.id, 'add');
180
					}
181
					selectNom = '';
182
					selectDate = '';
183
					return true;
184
				}
185
				return true;
186
			}
187
			return false;
188
		}
189

  
190
		function ItemSelMenu(e, nom, strDate) {
191
			if (e.target.className != 'menu') return false;
192
			if (ns6) {
193
				$('popupMenu').style.left = e.clientX+document.body.scrollLeft;
194
				$('popupMenu').style.top = e.clientY+document.body.scrollTop;
195
			} else {
196
				$('popupMenu').style.pixelLeft = event.clientX + document.body.scrollLeft;
197
				$('popupMenu').style.pixelTop = event.clientY + document.body.scrollTop;
198
			}
199
			$('popupMenu').style.display = "";
200
			$('AM').style.backgroundColor = 'white';
201
			$('PM').style.backgroundColor = 'white';
202
			$('annuler').style.backgroundColor = 'white';
203
			isMenu = true;
204
			selectNom = nom;
205
			selectDate = strDate;
206
			return false;
207
		}
208

  
209
		document.onmousedown = mouseSelect;
142 210
	</script>
143 211
</head>
144 212
<html>
......
147 215
		<input type="hidden" name="nom" value="" />
148 216
		<input type="hidden" name="str_date" value="" />
149 217
		<input type="hidden" name="action" value="" />
150
		<select name="demi_jour">
151
			<option value=""></option>
152
			<option value="AM">AM</option>
153
			<option value="PM">PM</option>
154
		</select>
155 218
	</form>
156 219
	<form method="get">
157 220
		<input type="hidden" name="date" value="<?=$date?>" />
......
194 257
				$jour_semaine = date("w", $ts3);
195 258
				$libOnClick = "";
196 259
				$libTitle = "";
260
				$menu = "";
197 261
				if (($libFerie = jourFeries($ts3))) {
198 262
					$color = "gray";
199 263
					$libTitle = " title=\"$libFerie\"";
......
201 265
					$color = "lightgray";
202 266
				} else if (isset($conges[$nom]) && in_array($str_date, $conges[$nom])) {
203 267
					$color = "blue";
204
					$libOnClick = " onClick=\"updateConges(this, '$nom', '$str_date', 'del')\"";
268
					$libOnClick = " onClick=\"updateConges('$nom', '$str_date', 'del')\"";
205 269
				} else if (isset($conges[$nom]) && in_array("$str_date AM", $conges[$nom])) {
206 270
					$colorAM = "blue";
207 271
					$colorPM = "white";
208
					$libOnClickAM = " onClick=\"updateConges(this, '$nom', '$str_date AM', 'del')\"";
209
					$libOnClickPM = " onClick=\"updateConges(this, '$nom', '$str_date', 'add')\"";
272
					$libOnClickAM = " onClick=\"updateConges('$nom', '$str_date AM', 'del')\"";
273
					$libOnClickPM = " onClick=\"updateConges('$nom', '$str_date', 'add')\"";
210 274
				} else if (isset($conges[$nom]) && in_array("$str_date PM", $conges[$nom])) {
211 275
					$colorAM = "white";
212 276
					$colorPM = "blue";
213
					$libOnClickAM = " onClick=\"updateConges(this, '$nom', '$str_date', 'add')\"";
214
					$libOnClickPM = " onClick=\"updateConges(this, '$nom', '$str_date PM', 'del')\"";
277
					$libOnClickAM = " onClick=\"updateConges('$nom', '$str_date', 'add')\"";
278
					$libOnClickPM = " onClick=\"updateConges('$nom', '$str_date PM', 'del')\"";
215 279
				} else {
216 280
					$color = "white";
217
					$libOnClick = " onClick=\"updateConges(this, '$nom', '$str_date', 'add')\"";
281
					$libOnClick = " onClick=\"updateConges('$nom', '$str_date', 'add')\"";
282
					$menu = " class=\"menu\" onContextMenu=\"ItemSelMenu(event, '$nom', '$str_date'); return false;\"";
218 283
				}
219 284
?>
220 285
<?php
......
223 288
			<td style="cursor: pointer; background-color: <?=$colorAM?>"<?=$libOnClickAM?><?=$libTitle?>>&nbsp;</td>
224 289
			<td style="cursor: pointer; background-color: <?=$colorPM?>"<?=$libOnClickPM?><?=$libTitle?>>&nbsp;</td>
225 290
<?php 	} else {?>
226
			<td colspan="2" style="cursor: pointer; background-color: <?=$color?>"<?=$libOnClick?><?=$libTitle?>>&nbsp;</td>
291
			<td colspan="2" style="cursor: pointer; background-color: <?=$color?>"<?=$libOnClick?><?=$menu?><?=$libTitle?>>&nbsp;</td>
227 292
<?php 	} ?>
228 293
<?php } ?>
229 294
		</tr>
......
237 302
?>
238 303
	</table>
239 304
	</form>
305
	<div id="popupMenu" style="position: absolute; display: none; top: 0px; left: 0px; z-index: 10000;" onMouseOver="javascript:overPopupMenu=true;" onMouseOut="javascript:overPopupMenu=false;">
306
		<table border="0" bgcolor="lightgray">
307
			<tr><td id="AM"><a href="#">Matin</a></td></tr>
308
			<tr><td id="PM"><a href="#">Apr&egrave;s-midi</a></td></tr>
309
			<tr><td id="annuler"><a href="#">Annuler</a></td></tr>
310
		</table>
311
	</div>
240 312
</body>
241 313
</html>

Formats disponibles : Unified diff