summaryrefslogtreecommitdiff
path: root/test/test-tab_v1.php
blob: 79d13b15a3ae4125d1ae98cf97c214f959f9dbcc (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
<?php
$mysql_host='localhost';
$mysql_user='lud_restricted';
$mysql_pass='maille_ess_ku_elle';
$mysql_base='awor';
$link = mysql_connect($mysql_host,$mysql_user,$mysql_pass)
	    or die('Erreur MySql : Impossible de se connecter : ' . mysql_error());
mysql_select_db($mysql_base) or die('Erreur Mysql : Impossible de s�lectionner la database');

// Variables r�cup�r�es par les $_POST ou dans les sessions (�vite les modifications c�t� client)

$id_reunion=1;
$id_personne=2;

echo '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n"
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
	<head>
		<title>Tests BD</title>
		<link rel="stylesheet" type="text/css" href="style1.css" />
	</head>
	<body>
<table class="details" cellspacing="0">
<thead>
<tr>
<th>Personnes/Creneaux</th>
<?php
	$query="SELECT idC, UNIX_TIMESTAMP(dateHeure), duree FROM Creneau WHERE idR='$id_reunion';";
	$creneaux=array();
	if ( $result = mysql_query($query) )
	{
		while ( $c = mysql_fetch_row($result) )
		{
			$date_deb =$c[1];
			//echo $date_deb . "\n";
			$date_fin = $date_deb + 60 * $c[2];
			echo '<th>' . date('d/m/y', $date_deb) . '<br />' . date('H:i', $date_deb)  . ' - ' . date('H:i', $date_fin) . "</th>\n";
			$creneaux[] = $c[0];
		}
	}
	//print_r($creneaux);
?>
</tr>
</thead>
<tbody>
<?php
	// Requette �crivant les disponibilit�s dans un tableau associatif en une seule fois
	$query='SELECT ch.idC, ch.idP, ch.estDispo FROM Choisir ch, Creneau c, Personne p, Appartenir a, Reunion r WHERE '
		."c.idR=$id_reunion AND r.idR=$id_reunion AND a.idL=r.idL AND p.idP=a.idP AND ch.idC = c.idC AND ch.idP = p.idP;";
	//echo $query . "\n";
	$dispos=array();
	if ( $result = mysql_query($query) )
	{	
		while ( list($idC, $idP, $estDispo) = mysql_fetch_row($result) )
		{
			$dispos[$idC][$idP]=$estDispo;
		}
	}
	//print_r($dispos);
	
	$query='SELECT p.idP, p.prenomP, p.nomP FROM Personne p, Appartenir a, Reunion r WHERE '
		. "r.idR='$id_reunion' AND a.idL=r.idL AND p.idP=a.idP;";
	if ( $result = mysql_query($query) ) 
	{
		while ( $p = mysql_fetch_array($result) )
		{
			// Boucle sur chaque personne
			// TODO : v�rif car changement de la boucle
			echo "<tr>\n<td>$p[1] $p[2]</td>\n";
			// Pour chaque cr�neau
			foreach ( $creneaux as $c_id )
			{
				// TODO : voir si l'on est la personne concern�e !!!
				
				// Cas g�n�ral, on n'est pas la personne concern�e
				if ( ! isset($dispos[$c_id][$p[0]]) )
				{
					// Dispo Inconnue (icone ?)
					echo '<td><img src="./images/question.gif" alt="Inconnu" height="15" width="15"></td>' . "\n";
				}
				else
				{
					if ( $dispos[$c_id][$p[0]] == 'oui' )
					{
						// Disponible
						echo '<td><img src="./images/ok.gif" alt="Disponible" height="16" width="16"></td>' . "\n";
					}else
					{
						// Non Disponible
						echo '<td><img src="./images/del.gif" alt="Non disponible" height="15" width="15"></td>' . "\n";
					}
				}
			}
			echo "</tr>\n";	
		}
	}
?>
</tbody>
</table>
</body>
</html>