2 Commits

7 changed files with 160 additions and 94 deletions

View File

@ -7,13 +7,20 @@ var_dump($_POST);
$pdo = PdoBD::getPdoBD();
var_dump($_SESSION);
$pdo->majActivite(
$_SESSION['cis'],
$_SESSION['idUtilisateur'],
$_POST['date'],
$_POST['tranche'],
$_POST['dispo']
);
if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'garde') {
$pdo->majGarde(
$_SESSION['cis'],
$_POST['pompier'],
$_POST['date'],
$_POST['tranche'],
$_POST['garde']
);
} elseif (isset($_REQUEST['option']) && $_REQUEST['option'] == 'dispo') {
$pdo->majActivite(
$_SESSION['cis'],
$_SESSION['idUtilisateur'],
$_POST['date'],
$_POST['tranche'],
$_POST['dispo']
);
}

View File

@ -13,7 +13,7 @@ class PdoBD
private static $serveur = 'mysql:host=localhost';
private static $bdd = 'dbname=sdis29';
private static $user = 'root';
private static $mdp = '';
private static $mdp = 'root';
private static $monPdo;
private static $monPdoBD = null;
@ -96,7 +96,7 @@ class PdoBD
}
/**
* Met à jour l'activité d'un pompier sur une tranche
* Met à jour les disp d'un pompier sur une tranche
*/
public function majActivite($cis, $idUser, $jour, $tranche, $newDispo)
{
@ -109,11 +109,11 @@ class PdoBD
afficherErreurSQL("Probleme lors de la mise à jour de l'activité dans la base de données.", $existedTranche, PdoBD::$monPdo->errorInfo());
} else {
if (count($rs->fetch()) !== 2) {
if ($rs->fetch() === false) {
$req = 'INSERT INTO activite (aCis, aPompier, aDateGarde, aTranche, aDisponibilite, aGarde)
VALUES (' . $cis . ',
VALUES (' . $cis . ',
' . $idUser . ',
' . $jour . ',
"' . $jour . '",
' . $tranche . ',
' . $newDispo . ', 0);';
} else {
@ -136,10 +136,14 @@ class PdoBD
/**
* Met à jour la garde d'un pompier sur une tranche
*/
public function majGarde()
public function majGarde($cis, $idUser, $jour, $tranche, $newGarde)
{
$req = "
";
$req = 'UPDATE activite
SET aGarde = ' . $newGarde . '
WHERE aCis = ' . $cis . '
AND aPompier = ' . $idUser . '
AND aDateGarde = "' . $jour . '"
AND aTranche = ' . $tranche . ';';
$rs = PdoBD::$monPdo->exec($req);
if ($rs === false) {
afficherErreurSQL("Probleme lors de la mise à jour de la garde dans la base de données.", $req, PdoBD::$monPdo->errorInfo());
@ -261,10 +265,10 @@ class PdoBD
'g2' => 0,
'g3' => 0,
'g4' => 0,
'c1' => 'gray',
'c2' => 'gray',
'c3' => 'gray',
'c4' => 'gray'
'c1' => 'red',
'c2' => 'red',
'c3' => 'red',
'c4' => 'red'
);
}
} else {
@ -293,10 +297,10 @@ class PdoBD
'g2' => 0,
'g3' => 0,
'g4' => 0,
'c1' => 'gray',
'c2' => 'gray',
'c3' => 'gray',
'c4' => 'gray'
'c1' => 'red',
'c2' => 'red',
'c3' => 'red',
'c4' => 'red'
);
}
}

View File

@ -281,17 +281,17 @@ $(document).on('click', '.select-dispo', function () {
dateDispo = $(this).attr('id').split('/')[0]
tranche = $(this).attr('id').split('/')[1]
dispo = 1;
dispo = 0;
if ($(this).css('background-color') == "rgb(255, 0, 0)") { //rgb(255, 0, 0) = red
$(this).css('background-color', 'green');
dispo = 2;
dispo = 1;
} else if ($(this).css('background-color') == 'rgb(0, 128, 0)') { //rgb(0, 128, 0) = green
$(this).css('background-color', 'yellow');
dispo = 3;
dispo = 2;
} else {
$(this).css('background-color', 'red');
dispo = 1;
dispo = 0;
}
var tableauDeDonnees = {
@ -300,7 +300,46 @@ $(document).on('click', '.select-dispo', function () {
"dispo" : dispo
}
$.ajax({
url: "/controleurs/c_disponibilitée.php", // URL de l'API ou de la ressource
url: "/controleurs/c_disponibilitée.php?option=dispo", // URL de l'API ou de la ressource
method: "POST", // Méthode HTTP (GET, POST, etc.)
dataType: "json", // Type de données attendu
data : tableauDeDonnees,
error: function(xhr, status, error) {
// Gérer les erreurs de la requête AJAX
console.error("Erreur lors de la requête AJAX :", status, error);
}
});
})
/**
* Gere l'ajout des gardes
*/
$(document).on('click', '.click-garde', function () {
date = $(this).attr('id').split('/')[0]
tranche = $(this).attr('id').split('/')[1]
idPompier = $(this).attr('id').split('/')[2]
garde = 0;
if ($(this).text() == 'X') {
$(this).text('');
garde = 0;
} else if ($(this).text() == ""){
$(this).text('X');
garde = 1;
} else {
$(this).text( "X");
garde = 0;
}
var tableauDeDonnees = {
"date" : date,
"tranche" : tranche,
"pompier" : idPompier,
"garde" : garde
}
$.ajax({
url: "/controleurs/c_disponibilitée.php?option=garde", // URL de l'API ou de la ressource
method: "POST", // Méthode HTTP (GET, POST, etc.)
dataType: "json", // Type de données attendu
data : tableauDeDonnees,

3
requeteUtile.txt Normal file
View File

@ -0,0 +1,3 @@
Garde de michel Rouat a tel date
SELECT * FROM `activite` WHERE aCis = 2901 AND aPompier = 1 AND aDateGarde = "2023-09-22";

View File

@ -583,7 +583,7 @@ table.listeLegere td {
padding: 1px;
margin: 1px;
border-spacing: 2px;
border-color: gray;
border-color: black;
}
.tableau td.semaine {

View File

@ -11,14 +11,16 @@
</head>
<?php
//version du code : le 18 septembre 2023 -------------------------------------
$formulaire = '';
$champ = '';
if (isset($_REQUEST['zFormulaire'])) {
$formulaire=$_REQUEST['zFormulaire'];
$formulaire = $_REQUEST['zFormulaire'];
}
if (isset($_REQUEST['zChamp'])) {
$champ = $_REQUEST['zChamp'];
}
?>
<body onload="donner_focus('<?= $formulaire."','".$champ;?>');">
<body onload="donner_focus('<?= $formulaire . ',' . $champ;?>');">
<div id="page">
<div id="entete">
<img src="./images/logo.png" id="logo" alt="SDIS29" title="SDIS 29" />

View File

@ -1,66 +1,77 @@
<!-- 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><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('<?php echo 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>
<fieldset>
<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 <?php echo $semaine." : du lundi ".date('d/m/Y',$premierJour)." au dimanche ".date('d/m/Y',strtotime("6 days",$premierJour))."</big></b></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('<?php echo 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>";
echo "</tr>".PHP_EOL." ";
}
?>
</tr>
</tbody>
</table>
<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>