btn nvl inter + gestion des pompiers dans le form

This commit is contained in:
pierre renaudot 2023-11-24 11:36:16 +01:00
parent 591b6a0d41
commit 062e417a9c
8 changed files with 404 additions and 58 deletions

View File

@ -9,44 +9,67 @@
// Auteur : pascal-blain@wanadoo.fr '
//*****************************************'
$action = $_REQUEST['action'];
switch($action)
{
case 'voir':
{
include("vues/v_entete.php");
if(!isset($_REQUEST['zSemaine'])){$_REQUEST['zSemaine'] = date('W');}
$semaine = $_REQUEST['zSemaine'];
if(!isset($_REQUEST['zAnnee'])){$_REQUEST['zAnnee'] = date('Y');}
$annee = $_REQUEST['zAnnee'];
$premierJour = strtotime("+$semaine weeks",mktime(0,0,0,1,1,$annee));
if (date('w',$premierJour) != 1){$premierJour = strtotime("last monday",$premierJour);}
$lesTranches = $pdo->getParametre("tranche");
$lesTypesDispos = $pdo->getParametre("dispo");
$titre="CIS"; //Centre d'incendie et de secours :";
$lesCasernes = $pdo->getLesCasernes($_SESSION["adr1"]);
include("vues/v_choixCaserne.php");
$lesPompiers = $pdo->getLesPompiers($choix);
$lesInterventions=$pdo->getLesInterventions($choix);
$intervention=1;
$lesParticipants= $pdo->getLesParticipants($choix, $intervention);
include("vues/v_Intervention.php");
break;
}
switch ($action) {
case 'voir': {
include("vues/v_entete.php");
//-----------------------------------------
case 'majGarde':
{
$pdo->majGarde($_REQUEST["ztLaDate"], $_REQUEST["ztLaTranche"], $_REQUEST["ztExGarde"], $_REQUEST["ztPompier"]);
header ('location: index.php?choixTraitement=gardes&action=voir&zSemaine='.$_REQUEST["zSemaine"].'&zAnnee='.$_REQUEST["zAnnee"]);
break;
}
if (!isset($_REQUEST['zSemaine'])) {
$_REQUEST['zSemaine'] = date('W');
}
$semaine = $_REQUEST['zSemaine'];
if (!isset($_REQUEST['zAnnee'])) {
$_REQUEST['zAnnee'] = date('Y');
}
$annee = $_REQUEST['zAnnee'];
$premierJour = strtotime("+$semaine weeks", mktime(0, 0, 0, 1, 1, $annee));
if (date('w', $premierJour) != 1) {
$premierJour = strtotime("last monday", $premierJour);
}
$lesTranches = $pdo->getParametre("tranche");
$lesTypesDispos = $pdo->getParametre("dispo");
$titre = "CIS"; //Centre d'incendie et de secours :";
//include("vues/v_choixCaserne.php");
//$lesPompiers = $pdo->getLesPompiers($choix);
//$lesInterventions = $pdo->getLesInterventions($choix);
//$intervention = 1;
//$lesParticipants = $pdo->getLesParticipants($choix, $intervention);
include("vues/v_Intervention.php");
break;
}
case 'nouvelle': {
include("vues/v_entete.php");
$lesCasernes = $pdo->getLesCasernes($_SESSION["adr1"]);
$lesMotifs = $pdo->motifIntervention();
$lesPompiers = $pdo->getPompiersDispo('2023-09-23', 2, 2924);
include("vues/v_nouvelleIntervention.php");
break;
}
case 'listePompier':
require_once ("../include/class.pdo.php");
$pdo = PdoBD::getPdoBD();
$lesPompiers = $pdo->getPompiersDispo('2023-09-23', 2, $_GET['cis']);
echo(json_encode($lesPompiers));
//-----------------------------------------
default :
{
echo 'erreur d\'aiguillage !'.$action;
break;
}
//-----------------------------------------
case 'majGarde': {
$pdo->majGarde($_REQUEST["ztLaDate"], $_REQUEST["ztLaTranche"], $_REQUEST["ztExGarde"], $_REQUEST["ztPompier"]);
header('location: index.php?choixTraitement=gardes&action=voir&zSemaine=' . $_REQUEST["zSemaine"] . '&zAnnee=' . $_REQUEST["zAnnee"]);
break;
}
//-----------------------------------------
default: {
echo 'erreur d\'aiguillage !' . $action;
break;
}
}
/*
table equipe:
@ -64,4 +87,4 @@ iTranche tinyint(3)
iHeureDebut datetime
iHeureFin datetime
*/
?>
?>

View File

@ -63,7 +63,7 @@ class PdoBD
{
$req = "SELECT pCis, pId, pNom, pPrenom, pStatut
FROM pompier
WHERE pCis=" . $cis . "
WHERE pCis = " . $cis . "
ORDER BY pNom;";
$rs = PdoBD::$monPdo->query($req);
if ($rs === false) {
@ -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,
@ -358,8 +358,8 @@ class PdoBD
$lesDispos[$pompier][$laDate][$couleur] = $uneLigne['dCouleur'];
}
/* echo "<PRE>";
print_r($lesDispos);
echo "</PRE>";*/
print_r($lesDispos);
echo "</PRE>";*/
return $lesDispos;
}
@ -543,7 +543,7 @@ class PdoBD
return $lesLignes;
}
public function getLastId($pCis) : int
public function getLastId($pCis): int
{
$req = "SELECT MAX(pId) + 1 as id FROM pompier WHERE pCis =" . $pCis . ";";
$rs = PdoBD::$monPdo->query($req);
@ -556,11 +556,11 @@ class PdoBD
public function verifDataAjoutPompier(
string $nom,
string $prenom,
string $tel,
string $mail,
string $prenom,
string $tel,
string $mail,
string $login
) : bool {
): bool {
if (empty($nom) || empty($prenom) || empty($tel) || empty($mail) || empty($login)) {
return false;
@ -569,6 +569,111 @@ class PdoBD
}
}
/**
* PARTIE INTERVENTION
*/
public function motifIntervention()
{
$req = "SELECT pIndice, pLibelle
FROM `parametre`
WHERE pType = 'cateInt'
ORDER BY pLibelle;";
$cat = PdoBD::$monPdo->query($req);
$cat = $cat->fetchAll();
//Valeur : nbUtil
//Plancher : Time
//Plafond: nbPompier estimé
$reqType = "SELECT pIndice, pLibelle, pValeur, pPlancher, pPlafond
FROM parametre
WHERE pType = 'typeInt'
ORDER BY pLibelle;";
$type = PdoBD::$monPdo->query($reqType);
$type = $type->fetchAll();
$response = [];
foreach ($cat as $uneCat) {
$table = [];
foreach ($type as $row) {
if (substr($row['pIndice'], -3, 1) === $uneCat['pIndice']) {
array_push($table, $row);
}
}
$response[$uneCat['pLibelle']] = $table;
}
return $response;
}
public function getPompiersDispo(string $date, int $tranche, int $caserne)
{
$req = "SELECT pompier.pId, pompier.pNom, pompier.pPrenom, g.pLibelle AS statut, 0 AS enIntervention, p.pLibelle, p.pValeur
FROM `pompier`
INNER JOIN activite ON pompier.pId = activite.aPompier
AND activite.aCis = pompier.pCis
INNER JOIN parametre p ON p.pType = 'dispo' AND p.pIndice = activite.aDisponibilite
INNER JOIN parametre g ON g.pType = 'grade' AND g.pIndice = pompier.pGrade
WHERE activite.aGarde = 1
AND pCis = :caserne
AND activite.aDateGarde = :date
AND activite.aTranche = :tranche
AND pompier.pId NOT IN(SELECT ePompier
FROM equipe
INNER JOIN intervention on intervention.iId = equipe.eIntervention AND intervention.iCis = equipe.eCis
WHERE intervention.iHeureFin is null
AND intervention.iDate = :date
AND intervention.iTranche = :tranche
AND intervention.iCis = :caserne
)
UNION
SELECT pompier.pId, pompier.pNom, pompier.pPrenom, g.pLibelle AS statut, 1 AS enIntervention, p.pLibelle, 'grey'
FROM equipe
INNER JOIN pompier on equipe.ePompier = pompier.pId
AND equipe.eCis = pompier.pCis
INNER JOIN intervention on intervention.iId = equipe.eIntervention
AND intervention.iCis = equipe.eCis
INNER JOIN activite on pompier.pId = activite.aPompier
AND activite.aCis = pompier.pCis
AND activite.aDateGarde = intervention.iDate
AND activite.aTranche = intervention.iTranche
INNER JOIN parametre p ON p.pType = 'dispo' AND p.pIndice = activite.aDisponibilite
INNER JOIN parametre g ON g.pType = 'grade' AND g.pIndice = pompier.pGrade
WHERE intervention.iHeureFin is null
AND intervention.iTranche = :tranche
AND intervention.iDate = :date
AND equipe.eCis = :caserne;";
$result = PdoBD::$monPdo->prepare($req);
$result->bindParam(':date', $date); // 2023-09-23
$result->bindParam(':tranche', $tranche); //2
$result->bindParam(':caserne', $caserne); //2924
$result->execute();
return $result->fetchAll();
}
}
/**
SELECT pompier.*, 0 AS enIntervention, activite.aDisponibilite
FROM `pompier`
INNER JOIN activite ON pompier.pId = activite.aPompier AND activite.aCis = pompier.pCis
WHERE pCis = 2924 AND activite.aDateGarde = '2023-09-23' AND activite.aTranche = 2 AND activite.aGarde = 1
AND pompier.pId NOT IN(SELECT ePompier
FROM equipe
INNER JOIN intervention on intervention.iId = equipe.eIntervention AND intervention.iCis = equipe.eCis
WHERE intervention.iDate = '2023-09-23' AND intervention.iTranche = 2 AND intervention.iHeureFin is null)
UNION
SELECT pompier.*, 1 AS enIntervention, activite.aDisponibilite
FROM equipe
INNER JOIN pompier on equipe.ePompier = pompier.pId AND equipe.eCis = pompier.pCis
INNER JOIN activite on pompier.pId = activite.aPompier AND activite.aCis = pompier.pCis
INNER JOIN intervention on intervention.iId = equipe.eIntervention AND intervention.iCis = equipe.eCis
WHERE intervention.iDate = '2023-09-23' AND intervention.iTranche = 2 AND intervention.iHeureFin is null;
*/
?>

View File

@ -0,0 +1,73 @@
formulaire = $('.formulaire')
date = Date.now()
$(document).ready(function () {
// $.ajax({
// url: "/controleurs/c_interventions.php?action=infoFormulaire",
// method: "POST", // Méthode HTTP (GET, POST, etc.)
// dataType: "json", // Type de données attendu
// error: function(status, error) {
// // Gérer les erreurs de la requête AJAX
// console.error("Erreur lors de la requête AJAX :", status, error);
// },
// success: function(result) {
// }
// });
$('#caserneInter').change(function () {
console.log($(this).val());
caserne = $(this).val()
//cis
$.ajax({
url: "./../controleurs/c_interventions.php?action=listePompier&cis=" + caserne,
method: "POST", // Méthode HTTP (GET, POST, etc.)
dataType: "json", // Type de données attendu
error: function (status, error) {
// Gérer les erreurs de la requête AJAX
console.error("Erreur lors de la requête AJAX :", status, error);
},
success: function (result) {
$('#pompierDispo').html(' ');
result.forEach(element => {
var ligne = '<div id='
+ element['pId']
+ ' class="' + element['pLibelle']
+ '" style = "background-color: ' + element['pValeur'] + ';" draggable = "true" ondragstart = "dragstartHandler(event)" >'
+ element['pPrenom'] + ' ' + element['pNom']
+ ' (' + element['statut'] + ')'
+ '</div> ';
$('#pompierDispo').append(ligne)
});
}
});
});
});
function dragstartHandler(ev) {
// Add the target element's id to the data transfer object
ev.dataTransfer.setData("application/my-app", ev.target.id);
ev.dataTransfer.effectAllowed = "move";
}
function dragoverHandler(ev) {
ev.preventDefault();
ev.dataTransfer.dropEffect = "move";
}
function dropHandler(ev) {
ev.preventDefault();
// Get the id of the target and add the moved element to the target's DOM
const data = ev.dataTransfer.getData("application/my-app");
if (ev.target.id === "target" || ev.target.parentNode.id === "target") {
trgt = document.getElementById('target');
} else if (ev.target.id === "pompierDispo" || ev.target.parentNode.id === "pompierDispo") {
trgt = document.getElementById('pompierDispo');
}
trgt.appendChild(document.getElementById(data));
}

View File

@ -17,7 +17,9 @@ $pdo = PdoBD::getPdoBD();
$estConnecte = estConnecte();
// on vérifie que le pompier est authentifié
if(!isset($_REQUEST['choixTraitement']) || !$estConnecte){$_REQUEST['choixTraitement'] = 'connexion';}
if(!isset($_REQUEST['choixTraitement']) || !$estConnecte){
$_REQUEST['choixTraitement'] = 'connexion';
}
// on analyse le cas d'utilisation en cours ...
$choixTraitement= $_REQUEST['choixTraitement'];
@ -33,4 +35,5 @@ switch($choixTraitement)
break;
}
}
include("vues/v_pied.php") ;

View File

@ -640,3 +640,60 @@ table.listeLegere td {
cursor: pointer;
}
/*
PARTIE DES INTERVENTIONS
*/
.nouvelleInter{
margin: 0 20px;
overflow:auto;
width: 100%;
}
.formulaire{
width: 50%;
border-right: solid 1px black;
float: left;
}
.nouvelleInter .formulaire{
/* float: right; */
}
.selectionPompier{
margin: 0 30px;
overflow:auto;
display: flex;
justify-content: space-between;
}
.pompierDispo{
background-color: #8B93A7;
width: 40%;
height: 80%;
margin: 0 20px;
padding: 5px;
text-align: center;
display: inline-block;
}
.pompierDispo div,
.pompierIntervenant div{
text-decoration: none;
background-color: #FFFFFF;
padding: 3px;
margin: 5px;
cursor: pointer;
}
.pompierDispo .1{
}
.pompierIntervenant{
background-color: red;
width: 40%;
height: 200px;
margin: 0 20px;
padding: 5px;
display: block;
text-align: center;
}
#sendInter{
width: auto;
text-align: center;
margin: 10px;
}

View File

@ -1,8 +1,8 @@
<!-- affichage d'une intervention / Derniere modification le 23 mai 2019 par Pascal Blain -->
<?php
$nbi=count($lesInterventions);
//$nbi = count($lesInterventions);
/*
$titre="Ajout";
echo ('
<div id="fiche">
@ -13,6 +13,7 @@ echo ('
</ul>');
/*================================================================================================== nouvelle intervention (1) */
/*
echo("
<div style='display: block;' class='unOnglet' id='contenuOnglet1'>
<fieldset><legend>Nouvelle intervention</legend>
@ -71,7 +72,7 @@ echo(" </table>
</fieldset>
</div>");
/*================================================================================================== Onglet (2) */
/*
echo ("
<div style='display: none;' class='unOnglet' id='contenuOnglet2'>
<fieldset><legend>XXXX</legend>
@ -83,6 +84,7 @@ echo ("
</div>");
/*================================================================================================== Onglet 3 */
/*
echo ("
<div style='display: none;' class='unOnglet' id='contenuOnglet3'>
<fieldset><legend>XXXX</legend>
@ -94,5 +96,11 @@ echo ("
</div>
</div>
</div>");
?>
</div>");
*/
?>
<div class="lesInterventions" style="height: 200px;">
<!-- Liste des interventions -->
</div>

View File

@ -0,0 +1,70 @@
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
crossorigin="anonymous"></script>
<div class="nouvelleInter">
<h1>Nouvelle intervention</h1>
<div class="formulaire">
<form action="">
<label for="motif">Motif de l'intervention : </label>
<select name="motif" id="motifInter">
<?php
foreach ($lesMotifs as $key => $type) {
echo '<optgroup label="' . $key . '">';
foreach ($type as $motif) {
echo ' <option value="' . $motif['pIndice'] . '">' . $motif['pLibelle'] . '</option>';
}
}
?>
</select>
<br>
<br>
<label for="adresse">Adresse de l'intervention : </label>
<input type="text" id="adresse" name="adresse">
<br>
<br>
<label for="caserne">Caserne la plus proche : </label>
<select name="caserne" id="caserneInter">
<?php
foreach ($lesCasernes as $uneCaserne) {
echo '<option value="' . $uneCaserne['cId'] . '">' . $uneCaserne['cNom'] . ' - ' . $uneCaserne['cAdresse'] . '</option>\n';
}
?>
</select>
<br>
<br>
<label for="commentaire">Commentaire sur l'intervention : </label>
<textarea name="commentaire" id="" cols="auto" rows="5"></textarea>
</form>
</div>
<div class="selectionPompier">
<div id="pompierDispo" class="pompierDispo" ondrop="dropHandler(event)" ondragover="dragoverHandler(event)">
<!-- Liste des pompiers appelable -->
<?php
$pCis = isset($_GET['caserne']) ? $_GET['caserne'] : 2904;
foreach ($lesPompiers as $key => $pompier):
?>
<div id="<?= $pompier['pId'] ?>" class="<?= $pompier['pLibelle'] ?>"
style="background-color: <?= $pompier['pValeur'] ?>" draggable="true"
ondragstart="dragstartHandler(event)">
<?= $pompier['pPrenom'] ?>
<?= $pompier['pNom'] ?>
(<?= $pompier['statut'] ?>)
</div>
<?php endforeach ?>
</div>
<div id="target" ondrop="dropHandler(event)" ondragover="dragoverHandler(event)"
ondragstart="dragstartHandler(event)" class="pompierIntervenant">
<p>Nombre de pompiers conseillé: 4</p>
</div>
</div>
</div>
<center><button type="submit" id="sendInter">Envoyer l'intervention</button></center>
<script src="include/gestionInterventions.js" type="text/javascript"></script>

View File

@ -1,9 +1,16 @@
<!-- Derniere modification le 18/09/2023 par Pascal Blain -->
<!-- Division pour le pied de page -->
<a href="index.php?choixTraitement=interventions&action=nouvelle">
<button type="button" style="margin: 0 auto; display: block; width: auto; background-color: green;"> Nouvelle
intervention</button>
</a>
<div>
<hr /><p style="text-align:center;">
<img src="images/castel.png" style="vertical-align: middle;">
<?php echo "Lyc&eacute;e Le Castel &agrave; Dijon - BTS SIO - <img src='images/copyleft.png' style='text-align: center; vertical-align: middle;'> 2023 Pierre Renaudot";?></p>
<hr />
<p style="text-align:center;">
<img src="images/castel.png" style="vertical-align: middle;">
<?php echo "Lyc&eacute;e Le Castel &agrave; Dijon - BTS SIO - <img src='images/copyleft.png' style='text-align: center; vertical-align: middle;'> 2023 Pierre Renaudot"; ?>
</p>
</div>
</body>
</body>
</html>