btn nvl inter + gestion des pompiers dans le form
This commit is contained in:
@@ -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;
|
||||
*/
|
||||
?>
|
Reference in New Issue
Block a user