122 lines
4.0 KiB
PHP
122 lines
4.0 KiB
PHP
<?php
|
|
// ****************************************'
|
|
// Le CASTEL-BTS SIO/ PROJET SDIS29 '
|
|
// Programme: c_pompiers.php '
|
|
// Objet : gestion des pompiers '
|
|
// Client : Bts SIO2 '
|
|
// Version : 2023.0 '
|
|
// Date : 18/09/2023 à 16h50 '
|
|
// 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");
|
|
|
|
$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);
|
|
|
|
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 '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']);
|
|
|
|
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;
|
|
}
|
|
}
|
|
?>
|