-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodificationAttributions.php
More file actions
171 lines (148 loc) · 5.88 KB
/
modificationAttributions.php
File metadata and controls
171 lines (148 loc) · 5.88 KB
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
<?php
include("_debut.inc.php");
include("_gestionBase.inc.php");
include("_controlesEtGestionErreurs.inc.php");
// CONNEXION AU SERVEUR MYSQL PUIS SÉLECTION DE LA BASE DE DONNÉES festival
$connexion=connect();
if (!$connexion)
{
ajouterErreur("Echec de la connexion au serveur MySql");
afficherErreurs();
exit();
}
if (!selectBase($connexion))
{
ajouterErreur("La base de données festival est inexistante ou non accessible");
afficherErreurs();
exit();
}
// EFFECTUER OU MODIFIER LES ATTRIBUTIONS POUR L'ENSEMBLE DES ÉTABLISSEMENTS
// CETTE PAGE CONTIENT UN TABLEAU CONSTITUÉ DE 2 LIGNES D'EN-TÊTE (LIGNE TITRE ET
// LIGNE ÉTABLISSEMENTS) ET DU DÉTAIL DES ATTRIBUTIONS
// UNE LÉGENDE FIGURE SOUS LE TABLEAU
// Recherche du nombre d'établissements offrant des chambres pour le
// dimensionnement des colonnes
$nbEtabOffrantChambres=obtenirNbEtabOffrantChambres($connexion);
$nb=$nbEtabOffrantChambres+1;
// Détermination du pourcentage de largeur des colonnes "établissements"
$pourcCol=50/$nbEtabOffrantChambres;
$action=$_REQUEST['action'];
// Si l'action est validerModifAttrib (cas où l'on vient de la page
// donnerNbChambres.php) alors on effectue la mise à jour des attributions dans
// la base
if ($action=='validerModifAttrib')
{
$idEtab=$_REQUEST['idEtab'];
$idGroupe=$_REQUEST['idGroupe'];
$nbChambres=$_REQUEST['nbChambres'];
modifierAttribChamb($connexion, $idEtab, $idGroupe, $nbChambres);
}
echo "
<table width='80%' cellspacing='0' cellpadding='0' align='center'
class='tabQuadrille'>";
// AFFICHAGE DE LA 1ÈRE LIGNE D'EN-TÊTE
echo "
<tr class='enTeteTabQuad'>
<td colspan=$nb><strong>Attributions</strong></td>
</tr>";
// AFFICHAGE DE LA 2ÈME LIGNE D'EN-TÊTE (ÉTABLISSEMENTS)
echo "
<tr class='ligneTabQuad'>
<td> </td>";
$req=obtenirReqEtablissementsOffrantChambres();
$rsEtab=mysql_query($req, $connexion);
$lgEtab=mysql_fetch_array($rsEtab);
// Boucle sur les établissements (pour afficher le nom de l'établissement et
// le nombre de chambres encore disponibles)
while ($lgEtab!=FALSE)
{
$idEtab=$lgEtab["id"];
$nom=$lgEtab["nom"];
$nbOffre=$lgEtab["nombreChambresOffertes"];
$nbOccup=obtenirNbOccup($connexion, $idEtab);
// Calcul du nombre de chambres libres
$nbChLib = $nbOffre - $nbOccup;
echo "
<td valign='top' width='$pourcCol%'><i>Disponibilités : $nbChLib </i> <br>
$nom </td>";
$lgEtab=mysql_fetch_array($rsEtab);
}
echo "
</tr>";
// CORPS DU TABLEAU : CONSTITUTION D'UNE LIGNE PAR GROUPE À HÉBERGER AVEC LES
// CHAMBRES ATTRIBUÉES ET LES LIENS POUR EFFECTUER OU MODIFIER LES ATTRIBUTIONS
$req=obtenirReqIdNomGroupesAHeberger();
$rsGroupe=mysql_query($req, $connexion);
$lgGroupe=mysql_fetch_array($rsGroupe);
// BOUCLE SUR LES GROUPES À HÉBERGER
while ($lgGroupe!=FALSE)
{
$idGroupe=$lgGroupe['id'];
$nom=$lgGroupe['nom'];
echo "
<tr class='ligneTabQuad'>
<td width='25%'>$nom</td>";
$req=obtenirReqEtablissementsOffrantChambres();
$rsEtab=mysql_query($req, $connexion);
$lgEtab=mysql_fetch_array($rsEtab);
// BOUCLE SUR LES ÉTABLISSEMENTS
while ($lgEtab!=FALSE)
{
$idEtab=$lgEtab["id"];
$nbOffre=$lgEtab["nombreChambresOffertes"];
$nbOccup=obtenirNbOccup($connexion, $idEtab);
// Calcul du nombre de chambres libres
$nbChLib = $nbOffre - $nbOccup;
// On recherche si des chambres ont déjà été attribuées à ce groupe
// dans cet établissement
$nbOccupGroupe=obtenirNbOccupGroupe($connexion, $idEtab, $idGroupe);
// Cas où des chambres ont déjà été attribuées à ce groupe dans cet
// établissement
if ($nbOccupGroupe!=0)
{
// Le nombre de chambres maximum pouvant être demandées est la somme
// du nombre de chambres libres et du nombre de chambres actuellement
// attribuées au groupe (ce nombre $nbmax sera transmis si on
// choisit de modifier le nombre de chambres)
$nbMax = $nbChLib + $nbOccupGroupe;
echo "
<td class='reserve'>
<a href='donnerNbChambres.php?idEtab=$idEtab&idGroupe=$idGroupe&nbChambres=$nbMax'>
$nbOccupGroupe</a></td>";
}
else
{
// Cas où il n'y a pas de chambres attribuées à ce groupe dans cet
// établissement : on affiche un lien vers donnerNbChambres s'il y a
// des chambres libres sinon rien n'est affiché
if ($nbChLib != 0)
{
echo "
<td class='reserveSiLien'>
<a href='donnerNbChambres.php?idEtab=$idEtab&idGroupe=$idGroupe&nbChambres=$nbChLib'>
__</a></td>";
}
else
{
echo "<td class='reserveSiLien'> </td>";
}
}
$lgEtab=mysql_fetch_array($rsEtab);
} // Fin de la boucle sur les établissements
$lgGroupe=mysql_fetch_array($rsGroupe);
} // Fin de la boucle sur les groupes à héberger
echo "
</table>"; // Fin du tableau principal
// AFFICHAGE DE LA LÉGENDE
echo "
<table align='center' width='80%'>
<tr>
<td width='34%' align='left'><a href='consultationAttributions.php'>Retour</a>
</td>
<td class='reserveSiLien'> </td>
<td width='30%' align='left'>Réservation possible si lien</td>
<td class='reserve'> </td>
<td width='30%' align='left'>Chambres réservées</td>
</tr>
</table>";
?>