diff --git a/controleurs/c_pompiers.php b/controleurs/c_pompiers.php index 70aa370..ccb753f 100644 --- a/controleurs/c_pompiers.php +++ b/controleurs/c_pompiers.php @@ -49,14 +49,14 @@ case 'ajouter': case 'modifier': case 'supprimer': { - $formulaire ="frmA"; - $champ ="ztNom"; + $formulaire = "frmA"; + $champ = "ztNom"; include("vues/v_entete.php"); - $choix= $_REQUEST['lstPompiers']; + $choix = $_REQUEST['lstPompiers']; $lesInfosPompier = $pdo->getInfosPompier("*",$choix); - $lesTypes = $pdo->getParametre("typePer"); - $lesGrades = $pdo->getParametre("grade"); - $lesStatuts = $pdo->getParametre("statAgt"); + $lesTypes = $pdo->getParametre("typePer"); + $lesGrades = $pdo->getParametre("grade"); + $lesStatuts = $pdo->getParametre("statAgt"); include("vues/v_unPompier.php"); break; } @@ -66,11 +66,12 @@ case 'validerModifier': case 'validerSupprimer': { $valeur = $_REQUEST['agent']; - if ($_REQUEST['zOk']=="OK") + if ($_REQUEST['zOk'] == "OK") { - if ($action==="validerSupprimer") {$pdo->supprimePompier($valeur);} - else - { + if ($action === "validerSupprimer") { + $pdo->supprimePompier($valeur); + } + else { $nom = addslashes ($_REQUEST['ztNom']); $prenom = addslashes ($_REQUEST['ztPrenom']); $type = $_REQUEST['lstType']; @@ -82,9 +83,11 @@ case 'validerSupprimer': $mdp = md5($_REQUEST['ztMdp']); if($_REQUEST['brMdp']==0 AND $action==="validerModifier") {$mdp="*";} $adresse = addslashes ($_REQUEST['ztAdresse']); - if (strlen($_REQUEST['ztCP'])>1){ - $cp = $_REQUEST['ztCP'];} else {$cp = "Null"; - } + if (strlen($_REQUEST['ztCP']) > 1) { + $cp = $_REQUEST['ztCP']; + } else { + $cp = "Null"; + } $ville = addslashes($_REQUEST['ztVille']); if (strlen($_REQUEST['ztTel'])>1) { @@ -95,6 +98,7 @@ case 'validerSupprimer': $tel="Null"; } $commentaire = addslashes ($_REQUEST['ztObs']); + if ($action === "validerAjouter") { $pdo->ajoutPompier($cis, $valeur,$nom,$prenom,$statut,$mail,$login,$mdp,$grade,$type,$adresse,$cp,$ville,$tel,$commentaire); $sujet = "nouveau compte"; diff --git a/include/class.pdo.php b/include/class.pdo.php index c128b8f..b7d3722 100644 --- a/include/class.pdo.php +++ b/include/class.pdo.php @@ -202,7 +202,7 @@ class PdoBD public function getInfosGardes($pompier) { $req = "SELECT aPompier, DATE_FORMAT(aDateGarde,'%d/%m/%Y') as wDate, aTranche, pLibelle as tLibelle - FROM activite INNER JOIN parametre ON pType='tranche' AND aTranche=pIndice + FROM activite INNER JOIN parametre ON pType = 'tranche' AND aTranche = pIndice WHERE aCis=" . $_SESSION['cis']; if ($pompier <> "*") { $req .= " AND aPompier=" . $pompier; @@ -232,9 +232,11 @@ class PdoBD $fin = date('Y/m/d', strtotime("6 days", $premierJour)); $req = "SELECT pId, pNom, pPrenom, DATE_FORMAT(aDateGarde,'%d/%m/%Y') as wDate, aTranche, aDisponibilite, aGarde, d.pValeur as dCouleur - FROM (activite INNER JOIN parametre t ON t.pType='tranche'AND aTranche=t.pIndice - INNER JOIN parametre d ON d.pType='dispo' AND aDisponibilite=d.pIndice) - RIGHT OUTER JOIN pompier ON aCis=pCis AND aPompier=pId + FROM (activite + INNER JOIN parametre t ON t.pType='tranche'AND aTranche=t.pIndice + INNER JOIN parametre d ON d.pType='dispo' AND aDisponibilite=d.pIndice + ) + RIGHT OUTER JOIN pompier ON aCis = pCis AND aPompier=pId WHERE aCis=" . $_SESSION['cis']; if ($pompier <> "*") { diff --git a/include/proceduresJava.js b/include/proceduresJava.js index 170ac49..5060539 100644 --- a/include/proceduresJava.js +++ b/include/proceduresJava.js @@ -321,31 +321,33 @@ $(document).on('click', '.click-garde', function () { 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, - 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); + if ($(this).css('background-color') != "rgb(255, 0, 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, + 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); + } + }); + } }) \ No newline at end of file diff --git a/index.php b/index.php index 2e28b58..02d2d3b 100644 --- a/index.php +++ b/index.php @@ -25,10 +25,13 @@ switch($choixTraitement) { case 'connexion': {include("controleurs/c_connexion.php");break;} //Connecte le pompier {DONE} case 'parametres': {include("controleurs/c_param.php");break;} //Page paramètre {TODO} 3 - case 'gardes' : {include("controleurs/c_gardes.php");break;} //Page garde {TODO} 2 + case 'gardes' : {include("controleurs/c_gardes.php");break;} //Page garde {DONE} case 'interventions': {include("controleurs/c_interventions.php");break;} //Page intervention {NOT TODAY} - case 'pompiers' : {include("controleurs/c_pompiers.php");break;} //Page pompiers {TODO} 1 - default :{echo 'erreur d\'aiguillage !'.$uc;break;} + case 'pompiers' : {include("controleurs/c_pompiers.php");break;} //Page pompiers {TODO} + default : { + echo 'erreur d\'aiguillage !'.$uc; + break; + } } include("vues/v_pied.php") ; diff --git a/vues/v_choixCaserne.php b/vues/v_choixCaserne.php index 4baae3b..ad0b113 100644 --- a/vues/v_choixCaserne.php +++ b/vues/v_choixCaserne.php @@ -1,6 +1,6 @@