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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
| <?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>INTRANET Le Chevalon: Gestion du weekend</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="../design.css" />
<script type="text/javascript" src="menu.js"></script>
</head>
<body>
<?php
include("../connect_bdd.php");
if(isset($_POST['data'])) {
$Datearrmid=implode("-", $_POST['AbsMidi']);
$Jourtransmid[]=explode("-", $Datearrmid);
$Datearrsoi=implode("-", $_POST['AbsSoir']);
$Jourtranssoi[]=explode("-", $Datearrsoi);
$Datearrnui=implode("-", $_POST['AbsNuit']);
$Jourtransnui[]=explode("-", $Datearrnui);
for($boucletableau=0; $Jourtransmid[0][5*$boucletableau] !== NULL ; $boucletableau++){
set_time_limit(25);
$jourmid = $Jourtransmid[0][5*$boucletableau+2] . "-" . $Jourtransmid[0][5*$boucletableau+3] . "-" . $Jourtransmid[0][5*$boucletableau+4];
$jourmidel = $Jourtransmid[0][5*$boucletableau+1];
$jourmidval = $Jourtransmid[0][5*$boucletableau];
$joursoi = $Jourtranssoi[0][5*$boucletableau+2] . "-" . $Jourtranssoi[0][5*$boucletableau+3] . "-" . $Jourtranssoi[0][5*$boucletableau+4];
$joursoiel = $Jourtranssoi[0][5*$boucletableau+1];
$joursoival = $Jourtranssoi[0][5*$boucletableau];
$journui = $Jourtransnui[0][5*$boucletableau+2] . "-" . $Jourtransnui[0][5*$boucletableau+3] . "-" . $Jourtransnui[0][5*$boucletableau+4];
$journuiel = $Jourtransnui[0][5*$boucletableau+1];
$journuival = $Jourtransnui[0][5*$boucletableau];
//Insertion (vérification, création absence)
$chupdt = $bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $jourmidel . ' AND a.idDate ="' . $jourmid . '"');
$updt = $chupdt->fetch();
if ($updt[0] !== NULL) {
$req = $bdd->prepare('UPDATE absence SET AbsMidi = :AbsMidi WHERE idEleve = :idEleve AND idDate = :idDate');
$req->execute(array('AbsMidi' => $jourmidval, 'idEleve' => $jourmidel, 'idDate' => $jourmid));
}
else {
$req = $bdd->prepare('INSERT INTO absence(AbsMidi, idEleve, idDate) VALUES(:AbsMidi, :idEleve, :idDate)');
$req->execute(array('AbsMidi' => $jourmidval, 'idEleve' => $jourmidel, 'idDate' => $jourmid ));
}
$chupdt = $bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $joursoiel . ' AND a.idDate ="' . $joursoi . '"');
$updt = $chupdt->fetch();
if ($updt[0] !== NULL) {
$req = $bdd->prepare('UPDATE absence SET AbsSoir = :AbsSoir WHERE idEleve = :idEleve AND idDate = :idDate');
$req->execute(array('AbsSoir' => $joursoival, 'idEleve' => $joursoiel, 'idDate' => $joursoi));
}
else {
$req = $bdd->prepare('INSERT INTO absence(AbsSoir, idEleve, idDate) VALUES(:AbsSoir, :idEleve, :idDate)');
$req->execute(array('AbsSoir' => $joursoival, 'idEleve' => $joursoiel, 'idDate' => $joursoi ));
}
$chupdt = $bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $journuiel . ' AND a.idDate ="' . $journui . '"');
$updt = $chupdt->fetch();
if ($updt[0] !== NULL) {
$req = $bdd->prepare('UPDATE absence SET AbsNuit = :AbsNuit WHERE idEleve = :idEleve AND idDate = :idDate');
$req->execute(array('AbsNuit' => $journuival, 'idEleve' => $journuiel, 'idDate' => $journui));
}
else {
$req = $bdd->prepare('INSERT INTO absence(AbsNuit, idEleve, idDate) VALUES(:AbsNuit, :idEleve, :idDate)');
$req->execute(array('AbsNuit' => $journuival, 'idEleve' => $journuiel, 'idDate' => $journui ));
}
}
$req = $bdd->prepare('UPDATE weekendvac SET Ferme = :Ferme WHERE idWevac = :weekendvac');
$req->execute(array('Ferme' => $_POST['Wkdtype'], 'weekendvac' => $_POST['idWevac'] ));
}
if(isset($_POST['idWevac'])) {
echo '<form method="post" action="./gestweekend.php">';
$choixwkdt=$bdd->query('SELECT * FROM weekendvac WHERE idWevac = ' . $_POST['idWevac']) ;
$wkdt = $choixwkdt->fetch();
echo ' <select name="Wkdtype" id="Wkdtype">
<option value="0" '; if($wkdt['Ferme'] == '0' ) { echo 'selected="selected"'; } echo ' > Weekend ouvert</option>
<option value="1" '; if($wkdt['Ferme'] == '1' ) { echo'selected="selected"'; } echo ' > Weekend fermé </option>
</select>';
$choixdeb=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate ASC LIMIT 0, 1') ;
$wedeb = $choixdeb->fetch();
$choixfin=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate DESC LIMIT 0, 1') ;
$wefin = $choixfin->fetch();
$tab_jour = array(0 =>'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
$num_jourdeb = date("w", mktime(0, 0, 0, $wedeb['mois'], $wedeb['jour'], $wedeb['annee']));
$nom_jourdeb = $tab_jour[$num_jourdeb];
$num_jourfin = date("w", mktime(0, 0, 0, $wefin['mois'], $wefin['jour'], $wefin['annee']));
$nom_jourfin = $tab_jour[$num_jourfin];
echo '<table>
<caption> Gestion des absences du weekend du '. $nom_jourdeb . ' ' . $wedeb['jour'] . '/' . $wedeb['mois'] . '/' . $wedeb['annee'] . ' au '. $nom_jourfin . ' ' . $wefin['jour'] . '/' . $wefin['mois'] . '/' . $wefin['annee'] . '</caption>';
$tabjour=$bdd->query('SELECT *, DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate ASC') ;
echo '<thead>
<tr>
<th> Elève </th>';
while ($jourf = $tabjour->fetch()) {
$tab_jour = array(0 =>'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
$num_jourf = date("w", mktime(0, 0, 0, $jourf['mois'], $jourf['jour'], $jourf['annee']));
$nom_jourf = $tab_jour[$num_jourf];
echo '<th>' . $nom_jourf . ' ' . $jourf['jour'] . '/' . $jourf['mois'] . '/' . $jourf['annee'] . '</th>';
}
echo '<input type="hidden" name="data" value="data" />
<input type="hidden" name="idWevac" value="' . $_POST['idWevac'] . '" />
</tr>
</thead>';
$choixel=$bdd->query('SELECT idEl, NomEl, PrenomEl, StatutChevEl FROM eleve e WHERE (e.StructEl = "Ent" OR e.StructEl = "Int" OR e.StructEl = "Sorta" )GROUP BY e.idEl ORDER BY e.NomEl ');
while ($el = $choixel->fetch()){
echo '<tr>
<td>' . $el['NomEl'] . ' ' . $el['PrenomEl'] . '</td>';
$jourabs=$bdd->query('SELECT * FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate ASC') ;
while ($jrabs = $jourabs->fetch()) {
$choixabs=$bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $el['idEl'] . ' AND a.idDate ="' . $jrabs['idDate'] . '"');
$abs = $choixabs->fetch();
echo '<td>
Absence midi:
<select name="AbsMidi['. $el['idEl'] .'-' . $jrabs['idDate']. ']" id=AbsMidi['. $el['idEl']. $jrabs['idDate']. ']">
<option value="0-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == '0' ) { echo ' selected="selected" '; } echo ' ></option>
<option value="AbsHop-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'AbsHop') { echo'selected="selected"'; } echo ' > Absence hospitalière </option>
<option value="AbsPrevu-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'AbsPrevu' || $el['StatutChevEl'] == 'Appart'|| $el['StatutChevEl'] == 'Semi') { echo'selected="selected"'; } echo ' > Absence prévue </option>
<option value="RepasFroid-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasFroid') { echo'selected="selected"'; } echo ' > Repas froid </option>
<option value="RepasGarde-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasGarde') { echo'selected="selected"'; } echo ' > Repas gardé </option>
<option value="RepasExt-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasExt') { echo'selected="selected"'; } echo ' > Repas extérieur </option>
<option value="Abs-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'Abs') { echo'selected="selected"'; } echo ' > Absence injustifié </option>
</select><br />
Absence soir:
<select name="AbsSoir['. $el['idEl'] .'-' . $jrabs['idDate']. ']" id="AbsSoir['. $el['idEl']. $jrabs['idDate']. ']">
<option value="0-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == '0' ) { echo 'selected="selected"'; } echo ' > </option>
<option value="AbsHop-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'AbsHop') { echo'selected="selected"'; } echo ' > Absence hospitalière </option>
<option value="AbsPrevu-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'AbsPrevu' || $el['StatutChevEl'] == 'Appart'|| $el['StatutChevEl'] == 'Semi') { echo'selected="selected"'; } echo ' > Absence prévue </option>
<option value="RepasFroid-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'RepasFroid') { echo'selected="selected"'; } echo ' > Repas froid </option>
<option value="RepasGarde-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'RepasGarde') { echo'selected="selected"'; } echo ' > Repas gardé </option>
<option value="RepasExt-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasExt') { echo'selected="selected"'; } echo ' > Repas extérieur </option>
<option value="Abs-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'Abs') { echo'selected="selected"'; } echo ' > Absence injustifié </option>
</select><br />
Absence nuit:
<select name="AbsNuit['. $el['idEl'] .'-' . $jrabs['idDate']. ']" id="AbsNuit'. $el['idEl'] .'/'.$jrabs['idDate'] . '">
<option value="0-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == '0' ) { echo 'selected="selected"'; } echo ' ></option>
<option value="AbsHop-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == "AbsHop") { echo'selected="selected"'; } echo ' > Absence hospitalière </option>
<option value="AbsPrevu-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == "AbsPrevu") { echo'selected="selected"'; } echo ' > Absence prévue </option>
<option value="Abs-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == "Abs") { echo'selected="selected"'; } echo ' > Absence injustifié </option>
</select>
</td>';
}
echo'</tr>' ;
}
echo '</table>';
?>
<input type="submit" value="Valider" />
<!-- BOUTON DE RETOUR HAUT DE PAGE -->
<a href="#"><input type="button" name="Haut de page" id="Haut de page" value="Haut de page" /></a>
</form>
<?php
}
else {
?>
<p> <!-- Page de choix de départ -->
<form method="post" action="./gestweekend.php">
<label for="Choix We">Choix du weekend : </label><br />
<select name="idWevac" id="idWevac">
<?php
$choixwe=$bdd->query('SELECT * FROM weekendvac v INNER JOIN jour j ON v.idWevac = j.idWevac GROUP BY v.idWevac ORDER BY j.idDate DESC') ;
while ($we = $choixwe->fetch()){ //Boucle d'affichage des recherche
$choixdeb=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $we['idWevac'] . ' ORDER BY idDate ASC LIMIT 0, 1') ;
while ($wedeb = $choixdeb->fetch()){
$choixfin=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $we['idWevac'] . ' ORDER BY idDate DESC LIMIT 0, 1') ;
while ($wefin = $choixfin->fetch()){
$tab_jour = array(0 =>'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
$num_jourdeb = date("w", mktime(0, 0, 0, $wedeb['mois'], $wedeb['jour'], $wedeb['annee']));
$nom_jourdeb = $tab_jour[$num_jourdeb];
$num_jourfin = date("w", mktime(0, 0, 0, $wefin['mois'], $wefin['jour'], $wefin['annee']));
$nom_jourfin = $tab_jour[$num_jourfin];
echo '<option value="' . $we['idWevac'] . '">Weekend du '. $nom_jourdeb . ' ' . $wedeb['jour'] . '/' . $wedeb['mois'] . '/' . $wedeb['annee'] . ' au '. $nom_jourfin . ' ' . $wefin['jour'] . '/' . $wefin['mois'] . '/' . $wefin['annee'] . '</option>';
}
}
}
?>
</select><br />
<input type="submit" value="Valider" />
</form>
<a href="./gestcalendar.php" title="Gestion du calendrier">Si vous ne trouvez pas le weekend voulu, veuillez préalablement le créer. </a>
</p>
<?php // End
}
?>
</div>
</body>
</html> |
Partager