Modification du pompier

This commit is contained in:
pierre renaudot 2023-10-12 09:01:55 +02:00
parent ea3ea7cb5f
commit 5fdb28c44e
5 changed files with 61 additions and 31 deletions

View File

@ -65,8 +65,14 @@ switch ($action) {
break;
case 'validerAjouter':
case 'validerModifier': {
var_dump($_REQUEST);
$valeur = $_REQUEST['pId'];
var_dump($_REQUEST);
if (!isset($pdo)) {
require_once ("../include/class.pdo.php");
$pdo = PdoBD::getPdoBD();
}
$pId = $_REQUEST['pId'];
$nom = addslashes($_REQUEST['ztNom']);
$prenom = addslashes($_REQUEST['ztPrenom']);
$type = $_REQUEST['lstType'];
@ -74,11 +80,12 @@ switch ($action) {
$statut = $_REQUEST['lstStatut'];
$cis = $_REQUEST['zCis'];
$mail = $_REQUEST['ztMail'];
$login = $_REQUEST['ztLogin'];
$mdp = md5($_REQUEST['ztMdp']);
if ($_REQUEST['brMdp'] == 0 and $action === "validerModifier") {
$mdp = "*";
}
$login = strtolower($_REQUEST['ztPrenom'][0]) . strtoupper($_REQUEST['ztNom']);
$mdp = md5($login);
//$mdp = md5($_REQUEST['ztMdp']);
// if ($_REQUEST['brMdp'] == 0 and $action === "validerModifier") {
// $mdp = "*";
// }
$adresse = addslashes($_REQUEST['ztAdresse']);
if (strlen($_REQUEST['ztCodePostal']) > 1) {
@ -88,7 +95,7 @@ switch ($action) {
}
$ville = addslashes($_REQUEST['ztVille']);
if (strlen($_REQUEST['ztTel']) > 1) {
if (strlen($_REQUEST['ztTel']) > 0) {
$tel = str_replace(" ", "", $_REQUEST['ztTel']);
$tel = str_replace(".", "", $tel);
$tel = str_replace("/", "", $tel);
@ -98,9 +105,9 @@ switch ($action) {
$commentaire = addslashes($_REQUEST['ztObservation']);
if ($action === "validerAjouter") {
$pdo->ajoutPompier($cis, $valeur, $nom, $prenom, $statut, $mail, $login, $mdp, $grade, $type, $adresse, $cp, $ville, $tel, $commentaire);
$pdo->ajoutPompier($cis, $pId, $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);
$pdo->majPompier($cis, $pId, $nom, $prenom, $statut, $mail, $login, $mdp, $grade, $type, $adresse, $cp, $ville, $tel, $commentaire);
}
//header('location: index.php?choixTraitement=pompiers&action=voir&lstPompiers=' . $valeur);
break;

View File

@ -79,10 +79,10 @@ 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";
*/
$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";
*/
$req = "SELECT
pCis,
pId as id,
@ -122,7 +122,7 @@ class PdoBD
*/
public function majActivite($cis, $idUser, $jour, $tranche, $newDispo)
{
$existedTranche = 'SELECT aDisponibilite FROM `activite`
$existedTranche = 'SELECT aDisponibilite FROM activite
WHERE aCis = ' . $cis . ' AND aDateGarde = "' . $jour . '" AND aTranche = ' . $tranche . ' AND aPompier = ' . $idUser . ';';
$rs = PdoBD::$monPdo->query($existedTranche);
var_dump($rs);
@ -174,14 +174,29 @@ class PdoBD
/**
* Met à jour une ligne de la table pompier
*/
public function majPompier($cis, $valeur, $nom, $prenom, $statut, $mail, $login, $mdp, $grade, $type, $adresse, $cp, $ville, $tel, $commentaire)
public function majPompier($cis, $pId, $nom, $prenom, $statut, $mail, $login, $mdp, $grade, $type, $adresse, $cp, $ville, $tel, $commentaire)
{
$grade = 7;
$type = 2;
$statut = 2;
date_default_timezone_set('Europe/Paris');
$dateUpdate = date('y-m-d h:i:s');
$req = "
UPDATE pompier
SET pCis ='$cis', pId ='$pId',
pNom ='$nom', pPrenom ='$prenom',
pStatut ='$statut', pType ='$type',
pMail ='$mail', pLogin ='$login',
pMdp ='$mdp', pAdresse ='$adresse',
pCp ='$cp', pVille ='$ville',
pBip ='$tel', pGrade ='$grade',
pCommentaire ='$commentaire', pDateModif ='$dateUpdate'
WHERE pCis='$cis' AND pId = '$pId'
;";
var_dump($req);
die;
$rs = PdoBD::$monPdo->exec($req);
if ($rs === false) {
afficherErreurSQL("Probleme lors de la mise à jour du pompier dans la base de données.", $req, PdoBD::$monPdo->errorInfo());
@ -340,8 +355,8 @@ class PdoBD
$lesDispos[$pompier][$laDate][$couleur] = $uneLigne['dCouleur'];
}
/* echo "<PRE>";
print_r($lesDispos);
echo "</PRE>";*/
print_r($lesDispos);
echo "</PRE>";*/
return $lesDispos;
}

View File

@ -195,7 +195,7 @@ function format_euro(valeur) {
// ========================= affiche l'onglet choisi
function Affiche(ongletChoisi, nb)
{
for(i=1;i<nb+1;i++)
for(i = 1; i < nb+1; i++)
{
document.getElementById('onglet'+i).className = 'inactif onglet';
document.getElementById('contenuOnglet'+i).style.display = 'none';
@ -203,9 +203,9 @@ function format_euro(valeur) {
document.getElementById('onglet'+ongletChoisi).className = 'actif onglet';
document.getElementById('contenuOnglet'+ongletChoisi).style.display = 'block';
document.getElementById('zOnglet').value=ongletChoisi;
document.getElementById('zOnglet').value = ongletChoisi;
document.getElementById('zNbOnglets').value=nb;
ongletActif=ongletChoisi;
ongletActif = ongletChoisi;
}
// ========================= transfert des données d'une liste à une autre
function deplacer_elements(frm, origine, destination) {
@ -358,14 +358,22 @@ $(document).on('click', '.click-garde', function () {
$(document).on('click', '.btn-modif', function (e) {
e.preventDefault();
$('.infoPompier').attr('disabled', false);
$('.btn-valid-modif').css('display', 'block');
if ($('.infoPompier').attr('disabled') == 'disabled') {
$('.infoPompier').attr('disabled', false);
$('.btn-valid-modif').css('display', 'block');
} else {
$('.infoPompier').attr('disabled', true);
$('.btn-valid-modif').css('display', 'none');
}
})
$(document).on('click', '.btn-valid-modif', function (e) {
e.preventDefault();
$('.infoPompier-chef').attr('disabled', false);
data = $('.dataPompier').serialize()
$('.infoPompier-chef').attr('disabled', true);
$('.infoPompier').attr('disabled', true);
$('.btn-valid-modif').css('display', 'none');
$.ajax({
url: "/controleurs/c_pompiers.php?action=validerModifier", // URL de l'API ou de la ressource

View File

@ -20,7 +20,7 @@
$champ = $_REQUEST['zChamp'];
}
?>
<body onload="donner_focus('<?= $formulaire . ',' . $champ;?>');">
<body >
<div id="page">
<div id="entete">
<img src="./images/logo.png" id="logo" alt="SDIS29" title="SDIS 29" />

View File

@ -232,7 +232,7 @@ echo ("
<table>
<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>Adresse</th> <td> <input name='ztAdresse' 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>
@ -267,7 +267,7 @@ echo ("
<fieldset><legend>Observations</legend>
<table style='border: 0px solid white;'>
<tr>
<td>.".$lesInfosPompier['pCommentaire']."</td>
<td> <input name='ztObservation' type='text' class='infoPompier' value='" . $lesInfosPompier['pCommentaire'] . "' disabled></td></td>
</tr>
</table>
</fieldset>