modif pompiers pas finis

This commit is contained in:
pierre renaudot 2023-10-05 11:53:36 +02:00
parent 438ab2f077
commit ea3ea7cb5f
7 changed files with 201 additions and 154 deletions

View File

@ -0,0 +1,3 @@
<?php
$pdo

View File

@ -9,132 +9,114 @@
// Auteur : pascal.blain@ac-dijon.fr '
//*****************************************'
$action = $_REQUEST['action'];
switch($action) {
case 'voir':
{
$formulaire = "choixP"; //Donne le focus dans le form
$champ = "lstPompiers";
include("vues/v_entete.php");
switch ($action) {
case 'voir': {
$formulaire = "choixP"; //Donne le focus dans le form
$champ = "lstPompiers";
include("vues/v_entete.php");
$lesLignes = $pdo->getLesPompiers($_SESSION['cis']);
include("vues/v_choixPompier.php"); // Formulaire de choix des pompiers
$lesLignes = $pdo->getLesPompiers($_SESSION['cis']);
include("vues/v_choixPompier.php"); // Formulaire de choix des pompiers
$lesInfosPompier = $pdo->getInfosPompier("*",$choix);
$lesTranches = $pdo->getParametre("tranche");
$lesGardes = $pdo->getInfosGardes($choix);
$lesInfosPompier = $pdo->getInfosPompier("*", $choix);
$lesTranches = $pdo->getParametre("tranche");
$lesGardes = $pdo->getInfosGardes($choix);
if(!isset($_REQUEST['zSemaine'])) {
$_REQUEST['zSemaine'] = date('W');
}
$semaine = $_REQUEST['zSemaine'];
if(!isset($_REQUEST['zAnnee'])) {
$_REQUEST['zAnnee'] = date('Y');
}
$annee = $_REQUEST['zAnnee'];
$lesDispos = $pdo->getDisposHebdo($choix, $semaine, $annee);
//echo "annee:".$annee."pompier: ".$choix."semaine : ".$semaine;
$premierJour = strtotime("+$semaine weeks", mktime(0,0,0,1,1,$annee));
if (date('w',$premierJour) != 1){
$premierJour = strtotime("last monday", $premierJour);
}
$lesTypesDispos = $pdo->getParametre("dispo");
include("vues/v_fichePompier.php");
break;
}
//----------------------------------------- FORMULAIRE DE SAISIE
case 'ajouter':
case 'modifier':
case 'supprimer':
{
$formulaire = "frmA";
$champ = "ztNom";
include("vues/v_entete.php");
$choix = $_REQUEST['lstPompiers'];
$lesInfosPompier = $pdo->getInfosPompier("*",$choix);
$lesTypes = $pdo->getParametre("typePer");
$lesGrades = $pdo->getParametre("grade");
$lesStatuts = $pdo->getParametre("statAgt");
include("vues/v_unPompier.php");
break;
}
//----------------------------------------- VALIDATION
case 'validerAjouter':
case 'validerModifier':
case 'validerSupprimer':
{
$valeur = $_REQUEST['agent'];
if ($_REQUEST['zOk'] == "OK")
{
if ($action === "validerSupprimer") {
$pdo->supprimePompier($valeur);
if (!isset($_REQUEST['zSemaine'])) {
$_REQUEST['zSemaine'] = date('W');
}
else {
$nom = addslashes ($_REQUEST['ztNom']);
$prenom = addslashes ($_REQUEST['ztPrenom']);
$type = $_REQUEST['lstType'];
$grade = $_REQUEST['lstGrade'];
$statut = $_REQUEST['lstStatut'];
$cis = $_REQUEST['zCis'];
$mail = $_REQUEST['ztMail'];
$login = $_REQUEST['ztLogin'];
$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";
}
$ville = addslashes($_REQUEST['ztVille']);
$semaine = $_REQUEST['zSemaine'];
if (strlen($_REQUEST['ztTel'])>1) {
$tel = str_replace(" ", "", $_REQUEST['ztTel']);
$tel=str_replace(".", "", $tel);
$tel=str_replace("/", "", $tel);
} else {
$tel="Null";
}
$commentaire = addslashes ($_REQUEST['ztObs']);
if (!isset($_REQUEST['zAnnee'])) {
$_REQUEST['zAnnee'] = date('Y');
}
$annee = $_REQUEST['zAnnee'];
$lesDispos = $pdo->getDisposHebdo($choix, $semaine, $annee);
//echo "annee:".$annee."pompier: ".$choix."semaine : ".$semaine;
$premierJour = strtotime("+$semaine weeks", mktime(0, 0, 0, 1, 1, $annee));
if ($action === "validerAjouter") {
$pdo->ajoutPompier($cis, $valeur,$nom,$prenom,$statut,$mail,$login,$mdp,$grade,$type,$adresse,$cp,$ville,$tel,$commentaire);
$sujet = "nouveau compte";
$msg = "Bonjour " . $prenom . " " . $nom . ", \r\nLe Castel vient de créer un compte pour vous ...\r\n";
} else {
$pdo->majPompier($cis, $valeur,$nom,$prenom,$statut,$mail,$login,$mdp,$grade,$type,$adresse,$cp,$ville,$tel,$commentaire);
$sujet = "nouveau mot de passe";
$msg = "Bonjour " . $prenom . " " . $nom . ", \r\nLe Castel vient de modifier votre mot de passe ...\r\n";
}
$entete = "From: Pascal Blain <pascal-blain@wanadoo.fr>\r\n";
$entete .= "Mime-Version: 1.0\r\n";
$entete .= "Content-type: text/html; charset=utf-8\r\n";
$entete .= "\r\n";
$msg .= "Statut : " . $statut."\r\n";
$msg .= "Identifiant : " . $login."\r\n";
$msg .= "Mot de passe : " . $_REQUEST['ztMdp'] . "\r\n";
//$pdo->envoyerMail($mail, $sujet, $msg, $entete);
}
if (date('w', $premierJour) != 1) {
$premierJour = strtotime("last monday", $premierJour);
}
$lesTypesDispos = $pdo->getParametre("dispo");
include("vues/v_fichePompier.php");
break;
}
header ('location: index.php?choixTraitement=pompiers&action=voir&lstPompiers=' . $valeur);
//----------------------------------------- FORMULAIRE DE SAISIE
case 'ajouter':
case 'modifier':
case 'supprimer': {
$formulaire = "frmA";
$champ = "ztNom";
include("vues/v_entete.php");
$choix = $_REQUEST['lstPompiers'];
$lesInfosPompier = $pdo->getInfosPompier("*", $choix);
$lesTypes = $pdo->getParametre("typePer");
$lesGrades = $pdo->getParametre("grade");
$lesStatuts = $pdo->getParametre("statAgt");
include("vues/v_unPompier.php");
break;
}
//----------------------------------------- VALIDATION
case 'validerSupprimer':
$valeur = $_REQUEST['pId'];
$pdo->supprimePompier($valeur);
break;
}
case 'validerAjouter':
case 'validerModifier': {
var_dump($_REQUEST);
$valeur = $_REQUEST['pId'];
$nom = addslashes($_REQUEST['ztNom']);
$prenom = addslashes($_REQUEST['ztPrenom']);
$type = $_REQUEST['lstType'];
$grade = $_REQUEST['lstGrade'];
$statut = $_REQUEST['lstStatut'];
$cis = $_REQUEST['zCis'];
$mail = $_REQUEST['ztMail'];
$login = $_REQUEST['ztLogin'];
$mdp = md5($_REQUEST['ztMdp']);
if ($_REQUEST['brMdp'] == 0 and $action === "validerModifier") {
$mdp = "*";
}
$adresse = addslashes($_REQUEST['ztAdresse']);
//-----------------------------------------
case 'majActivite':
{
$pdo->majActivite($_REQUEST["ztLaDate"], $_REQUEST["ztLaTranche"], $_REQUEST["ztExDispo"],$_REQUEST["brDispo"] );
header ('location: index.php?choixTraitement=pompiers&action=voir&zSemaine='.$_REQUEST["zSemaine"].'&zAnnee='.$_REQUEST["zAnnee"]);
break;
}
//-----------------------------------------
default :
{
echo 'erreur d\'aiguillage !'.$action;
break;
}
if (strlen($_REQUEST['ztCodePostal']) > 1) {
$cp = $_REQUEST['ztCodePostal'];
} else {
$cp = "Null";
}
$ville = addslashes($_REQUEST['ztVille']);
if (strlen($_REQUEST['ztTel']) > 1) {
$tel = str_replace(" ", "", $_REQUEST['ztTel']);
$tel = str_replace(".", "", $tel);
$tel = str_replace("/", "", $tel);
} else {
$tel = "Null";
}
$commentaire = addslashes($_REQUEST['ztObservation']);
if ($action === "validerAjouter") {
$pdo->ajoutPompier($cis, $valeur, $nom, $prenom, $statut, $mail, $login, $mdp, $grade, $type, $adresse, $cp, $ville, $tel, $commentaire);
} elseif ($action === "validerModifier") {
$pdo->majPompier($cis, $valeur, $nom, $prenom, $statut, $mail, $login, $mdp, $grade, $type, $adresse, $cp, $ville, $tel, $commentaire);
}
//header('location: index.php?choixTraitement=pompiers&action=voir&lstPompiers=' . $valeur);
break;
}
//-----------------------------------------
case 'majActivite': {
$pdo->majActivite($_REQUEST["ztLaDate"], $_REQUEST["ztLaTranche"], $_REQUEST["ztExDispo"], $_REQUEST["brDispo"]);
header('location: index.php?choixTraitement=pompiers&action=voir&zSemaine=' . $_REQUEST["zSemaine"] . '&zAnnee=' . $_REQUEST["zAnnee"]);
break;
}
//-----------------------------------------
default: {
echo 'erreur d\'aiguillage !' . $action;
break;
}
}
?>
?>

View File

@ -78,9 +78,31 @@ class PdoBD
*/
public function getInfosPompier($login, $mdp)
{
/*
$req = "SELECT pCis, pId as id, pNom as nom, pPrenom as prenom, pStatut, pMail, pLogin, pMdp, pGrade, pAdresse, pCp, pVille, pBip, pCommentaire,
'la caserne' as cNom, 'adresse' as cAdresse, 'telephone' as cTel, 'le groupement' as cGroupement, 'le grade' as wGrade, 'le statut' as wStatut, 'le type' as wType
FROM pompier";
'la caserne' as cNom, 'adresse' as cAdresse, 'telephone' as cTel, 'le groupement' as cGroupement, 'le grade' as wGrade, 'le statut' as wStatut, 'le type' as wType
FROM pompier";
*/
$req = "SELECT
pCis,
pId as id,
pNom as nom,
pPrenom as prenom,
pStatut, pMail,
pLogin, pMdp,
pAdresse,
pCp, pVille,
pBip, pCommentaire,
a.pLibelle AS wType,
b.pLibelle AS wGrade,
c.pLibelle AS wStatut,
cNom, cAdresse,
cTel, cGroupement
FROM pompier
INNER JOIN caserne ON pompier.pCis = caserne.cId
INNER JOIN parametre AS a ON a.pType = 'typePer' AND pompier.pType = a.pIndice
INNER JOIN parametre AS b ON b.pType = 'grade' AND pompier.pGrade = b.pIndice
INNER JOIN parametre AS c ON c.pType = 'statAgt' AND pompier.pStatut = c.pIndice;";
if ($login === "*") {
$req .= " WHERE pCis=" . $_SESSION['cis'] . " AND pId = $mdp";
} else {
@ -233,8 +255,8 @@ class PdoBD
$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
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'];

View File

@ -350,4 +350,34 @@ $(document).on('click', '.click-garde', function () {
}
});
}
})
})
/**
* Modifier
*/
$(document).on('click', '.btn-modif', function (e) {
e.preventDefault();
$('.infoPompier').attr('disabled', false);
$('.btn-valid-modif').css('display', 'block');
})
$(document).on('click', '.btn-valid-modif', function (e) {
e.preventDefault();
data = $('.dataPompier').serialize()
$.ajax({
url: "/controleurs/c_pompiers.php?action=validerModifier", // URL de l'API ou de la ressource
method: "POST", // Méthode HTTP (GET, POST, etc.)
dataType: "json", // Type de données attendu
data : data,
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);
}
});
})

View File

@ -12,7 +12,7 @@ if ($_SESSION['statut'] == 1) {
$choix = $_SESSION['idUtilisateur'];
} else {
echo '
<select name="lstPompiers" STYLE="width:350px;" onchange="submit();">';
<select name="lstPompiers" STYLE="width:auto;" onchange="submit();">';
if (!isset($_REQUEST['lstPompiers'])) {
$choix = $_SESSION['idUtilisateur'];
@ -44,7 +44,7 @@ echo ('
if ($_SESSION['statut'] == 2) {?>
<input type="image" id="zNouveau" title="Ajouter" src="images/ajout.gif" onclick="faire('choixP', 'ajouter')">
<input type="image" id="zModif" title="Modifier" src="images/modif.gif" onclick="faire('choixP', 'modifier')">
<input type="image" class="btn-modif" id="zModif" title="Modifier" src="images/modif.gif">
<input type="image" id="zSupprime" title="Supprimer" src="images/supprimer.gif" onclick="faire('choixP', 'supprimer')">&nbsp;&nbsp;
<input type="image" id="zPremier" title="premier" src="images/goPremier.gif" onclick="premier('choixP','lstPompiers')">
<input type="image" id="zPrecedent" title="précédent" src="images/goPrecedent.gif" onclick="precedent('choixP','lstPompiers')">
@ -56,7 +56,7 @@ if ($_SESSION['statut'] == 2) {?>
<?php
} else {
echo '
<input type="image" id="zModif" title="Modifier" src="images/modif.gif" onclick="faire(\'choixP\', \'modifier\')">';
<input type="image" class="btn-modif" id="zModif" title="Modifier" src="images/modif.gif">';
}?>
</div>

View File

@ -78,9 +78,9 @@ $titre3 = ($_SESSION['statut'] == 1) ? "Mon profil" : "Profil";
echo ('
<div id="fiche">
<ul class="lesOnglets">
<li class="actif onglet" id="onglet1" onclick="javascript:Affiche(\'1\',3);">'.$titre1.'</li>
<li class="inactif onglet" id="onglet2" onclick="javascript:Affiche(\'2\',3);">'.$titre2.'</li>
<li class="inactif onglet" id="onglet3" onclick="javascript:Affiche(\'3\',3);">'.$titre3.'</li>
<li class="actif onglet" id="onglet1" onclick="javascript:Affiche(\'1\',3);">' . $titre1 . '</li>
<li class="inactif onglet" id="onglet2" onclick="javascript:Affiche(\'2\',3);">' . $titre2 . '</li>
<li class="inactif onglet" id="onglet3" onclick="javascript:Affiche(\'3\',3);">' . $titre3 . '</li>
</ul>');
/*================================================================================================== DISPONIBILITEES (1) */
echo ("
@ -179,7 +179,7 @@ echo ("
echo ("
</fieldset>
</div>");
/*================================================================================================== GARDES (2)*/
/*================================================================================================== GARDES (2)*/
echo ("
<div style='display: none;' class='unOnglet' id='contenuOnglet2'>
<fieldset><legend>Gardes r&eacute;alis&eacute;es ");
@ -192,13 +192,17 @@ echo ("
$dateGarde="premiere";
$colonne=1;
echo "</tr>";
foreach ($lesGardes as $uneLigne)
{
if ($dateGarde != $uneLigne['wDate'])
{
if ($dateGarde != "premiere")
{
while ($colonne<=count($lesTranches)) {echo "<td class='controle' style='text-align : center;'>&nbsp;</td>"; $colonne++;}
while ($colonne <= count($lesTranches)) {
echo "<td class='controle' style='text-align : center;'>&nbsp;</td>";
$colonne++;
}
echo "</tr>
";
}
@ -220,39 +224,42 @@ echo ("
/*================================================================================================== COORDONNEES (3) */
echo ("
<div style='display: none;' class='unOnglet' id='contenuOnglet3'>
<form class='dataPompier' method='post'>
<table style='border: 0px solid white;'>
<tr>
<td style='border :0px;'>
<fieldset><legend>Coordonn&eacute;es</legend>
<table>
<tr><th style='width:130px;'>Nom</th> <td style='width:130px;'>".$lesInfosPompier['nom']."</td> </tr>
<tr><th>Pr&eacute;nom</th> <td>".$lesInfosPompier['prenom']."</td> </tr>
<tr><th>Adresse</th> <td>".$lesInfosPompier['pAdresse']."</td> </tr>
<tr><th>Code postal</th> <td>".$lesInfosPompier['pCp']."</td> </tr>
<tr><th>Ville</th> <td>".$lesInfosPompier['pVille']."</td> </tr>
<tr><th>T&eacute;l&eacute;phone</th> <td>".$lesInfosPompier['pBip']."</td> </tr>
<tr><th>Adresse &eacute;lectronique</th> <td>".$lesInfosPompier['pMail']."</td> </tr>
<tr><th>Nom de compte</th> <td>".$lesInfosPompier['pLogin']."</td></tr>
<tr><th>&nbsp;</th> <td>&nbsp;</td> </tr>
<tr><th style='width:130px;'>Nom</th> <td style='width:130px;'><input name='ztNom' type='text' class='infoPompier' value='".$lesInfosPompier['nom']."' disabled></td> </tr>
<tr><th>Pr&eacute;nom</th> <td> <input name='ztPrenom' type='text' class='infoPompier infoPompier-chef' value='" . $lesInfosPompier['prenom']."' disabled></td> </tr>
<tr><th>Adresse</th> <td> <input name='adress' type='text' class='infoPompier infoPompier-chef' value='" . $lesInfosPompier['pAdresse']."' disabled></td> </tr>
<tr><th>Code postal</th> <td> <input name='ztCodePostal' type='text' class='infoPompier infoPompier-chef' value='" . $lesInfosPompier['pCp']."' disabled></td> </tr>
<tr><th>Ville</th> <td> <input name='ztVille' type='text' class='infoPompier infoPompier-chef' value='" . $lesInfosPompier['pVille']."' disabled></td> </tr>
<tr><th>T&eacute;l&eacute;phone</th> <td> <input name='ztTel' type='text' class='infoPompier-chef' value='" . $lesInfosPompier['pBip']."' disabled></td> </tr>
<tr><th>Adresse &eacute;lectronique</th> <td> <input name='ztMail' type='text' class='infoPompier infoPompier-chef' value='" . $lesInfosPompier['pMail']."' disabled></td> </tr>
<tr><th>Nom de compte</th> <td>" . $lesInfosPompier['pLogin'] . "</td></tr>
<input name='pId' type='hidden' class='infoPompier' value='" . $lesInfosPompier['id']."' disabled>
<br />");
echo (" </table>
echo ("
</table>
</fieldset>
</td>
<td style='border :0px;'>
<fieldset><legend>Centre d'Incendie et de Secours</legend>
<table>
<tr><th style='width:130px;'>Code</th> <td>".$lesInfosPompier['pCis']."</td> </tr>
<tr><th>Nom</th> <td>".$lesInfosPompier['cNom']."</td> </tr>
<tr><th>Adresse</th> <td>".$lesInfosPompier['cAdresse']."</td> </tr>
<tr><th>T&eacute;l&eacute;phone</th> <td>".$lesInfosPompier['cTel']."</td> </tr>
<tr><th>Groupement</th> <td>".$lesInfosPompier['cGroupement']."</td> </tr>
<tr><th style='width:130px;'>Code</th> <td><input name='zCis' type='text' class='infoPompier-chef' value='" . $lesInfosPompier['pCis'] . "' disabled></td> </tr>
<tr><th>Nom</th> <td>" . $lesInfosPompier['cNom'] . "</td> </tr>
<tr><th>Adresse</th> <td>" . $lesInfosPompier['cAdresse'] . "</td> </tr>
<tr><th>T&eacute;l&eacute;phone</th> <td>" . $lesInfosPompier['cTel'] . "</td> </tr>
<tr><th>Groupement</th> <td>" . $lesInfosPompier['cGroupement'] . "</td> </tr>
</table>
</fieldset>
<fieldset><legend>Fonction</legend>
<table>
<tr><th>Type</th> <td>".$lesInfosPompier['wType']."</td> </tr>
<tr><th>Grade</th> <td>".$lesInfosPompier['wGrade']."</td> </tr>
<tr><th>Statut</th> <td>".$lesInfosPompier['wStatut']."</td> </tr> </table>
<tr><th>Type</th> <td> <input name='lstType' type='text' class='infoPompier-chef' value='" . $lesInfosPompier['wType'] . "' disabled></td> </tr>
<tr><th>Grade</th> <td> <input name='lstGrade' type='text' class='infoPompier-chef' value='" . $lesInfosPompier['wGrade'] . "' disabled></td> </tr>
<tr><th>Statut</th> <td> <input name='lstStatut' type='text' class='infoPompier-chef' value='" . $lesInfosPompier['wStatut'] . "' disabled></td> </tr>
</table>
</fieldset></td>
</tr>
</table>
@ -264,7 +271,10 @@ echo (" </table>
</tr>
</table>
</fieldset>
</div>");
</form>
</div>
<input type='image' class='btn-valid-modif' id='validModif' title='Modifier' src='images/valider.jpg' style='display:none; margin: 0 auto;'>
");
/*================================================================================================== Onglet X */
echo ("

View File

@ -23,7 +23,7 @@
);
echo ('
<form name="frmA" action="index.php?choixTraitement=pompiers&action=validerModifier&type='
. $lesInfosPompier['pType'] . '&agent='
. $lesInfosPompier['wType'] . '&agent='
. $lesInfosPompier['id']
. '&caserne=' . $lesInfosPompier['pCis']
. '" method="post">'
@ -32,7 +32,7 @@
if ($_REQUEST['action'] == "ajouter") {
echo "<h2>AJOUT D'UN NOUVEAU POMPIER</h2>";
echo '
<form name="frmA" action="index.php?choixTraitement=pompiers&action=validerAjouter&type='
<form name="frmA" action="index.php?choixTraitement=pompiers&action=validerAjouter&type='
. $lesInfosPompier['pType'].'" method="post" onsubmit="return valider(this)">';
}
echo ("
@ -61,7 +61,7 @@ if ($_REQUEST['action'] == "modifier") {
");
}
if ($_REQUEST['action'] == "ajouter") {
echo (" <tr><th style='width:130px;'>Nom</th> <td style='width:130px;'><input id='ztNom' type='text' name='ztNom'></td> </tr>
echo (" <tr><th style='width:130px;'>Nom</th> <td style='width:130px;'><input id='ztNom' type='text' name='ztNom'></td> </tr>
<br />");
}