<!-- affichage de la feuille de gardes / Derniere modification le 18/09/2023 à 16h50 par Pascal Blain -->
<div style='display: block;' class='unOnglet' id='contenuOnglet1'>
	<fieldset style='width:80%; margin: 0 auto;'>
		<legend>Feuille de gardes</legend>
		<form name="frmDispos" action="index.php?choixTraitement=gardes&action=voir" method="post">
			<input type="hidden" name="zSemaine" value='<?php echo $semaine; ?>'>
			<input type="hidden" name="zAnnee" value='<?php echo $annee; ?>'>
			<input type="hidden" name="ztLaDate" value="">
			<input type="hidden" name="ztLaTranche" value="">
			<input type="hidden" name="ztExGarde" value="">
			<input type="hidden" name="ztPompier" value="">
		</form>
		<table id="tableau" class="tableau">
			<tbody>
				<tr>
					<th><input id="sPrecedente" name="gauche" title="semaine précédente" src="images/gauche.gif"
							onclick="autreSemaine('<?= date('W', strtotime("-7 days", $premierJour)) . "', '" . date('Y', strtotime("-7 days", $premierJour)) ?>')"
							onmouseover="document.gauche.src='images/gauche_.gif'"
							onmouseout="document.gauche.src='images/gauche.gif'" type="image"></th>

					<th colspan="27"><b><big>Semaine
								<?= $semaine . " : du lundi " . date('d/m/Y', $premierJour) . " au dimanche " . date('d/m/Y', strtotime("6 days", $premierJour)) . "</big></b></th>"; ?>

					<th><input id="sSuivante" name="droite" title="semaine suivante" src="images/droite.gif"
							onclick="autreSemaine('<?= date('W', strtotime("+7 day", $premierJour)) . "', '" . date('Y', strtotime("+7 day", $premierJour)); ?>')"
							onmouseover="document.droite.src='images/droite_.gif'"
							onmouseout="document.droite.src='images/droite.gif'" type="image"></th>
				</tr>
				<tr>
					<th>&nbsp;</th>
					<?php
					$nomJour = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche');

					for ($jour = 0; $jour <= 6; $jour++) {
						echo ('<th colspan="4">' . $nomJour[$jour] . ' ' . date('d/m', strtotime('+' . $jour . ' day', $premierJour)) . '</th>');
					}

					echo "</tr>" . PHP_EOL . "		<tr><th width='100'>Volontaires</th>";

					for ($jour = 0; $jour <= 6; $jour++) {
						foreach ($lesTranches as $uneTranche) {
							echo '<th class="semaine" style="text-align : center;">' . $uneTranche["pIndice"] . '</th>';
						}
					}
					echo PHP_EOL . "		</tr>";

					foreach ($lesPompiers as $unPompier) {
						echo "
							<tr>
								<td><small><small>" . $unPompier['pNom'] . " " . $unPompier['pPrenom'] . "</small></small></td>";

						for ($jour = 0; $jour <= 6; $jour++) {
							$leJour = date('Y-m-d', strtotime('+' . $jour . ' day', $premierJour));
							$dateTab = date('d/m/Y', strtotime('+' . $jour . ' day', $premierJour));
							$dispos = $lesDispos[$unPompier['pId']][$dateTab];

							for ($tranche = 1; $tranche <= 4; $tranche++) {
								$couleur = 'c' . $tranche;
								$garde = 'g' . $tranche;
								$dispo = 'd' . $tranche;

								echo '<td style="border: 1px solid grey; cursor:pointer; 
												background-color: ' . $dispos[$couleur] . ';
												color: black;" 
											   class="click-garde" id="' . $leJour . '/' . $tranche . '/' . $unPompier['pId'] . '">'
									. (($dispos[$garde] == 1) ? 'X' : '')
									. '</td>';
							}
						}					
						echo ("</tr>" . PHP_EOL . "		");
					}
					?>
				</tr>
			</tbody>
		</table>
	</fieldset>
</div>