1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <?php
if (isset($_POST['Enregistrer']))
{
include("connection_BICF_bd.php");
// On récupère tout le numero maximum de la table agents
$requete = $bdd->query('SELECT ifnull(max(substr( num_pros,7,10))+1,0) as num FROM activites');
$donnees = $requete->fetch();
$numero_prosp =$donnees['num'];
$num = "BICFAC".$numero_prosp;
$verifi = true;
while($verifi==true)
{
$num = "BICFAC".$numero_prosp;
$jour = date('d');
$mois = date('m');
$annee = date('Y');
$heure = date('H');
$minute = date('i');
$date_saisie=$jour.'/'.$mois.'/'.$annee.' '.$heure.':'.$minute;
$login = $_SESSION['login'];
try
{
$req=$bdd->prepare('INSERT INTO activites
(
num_pros,
nom_activité,
date_debut,
heure_debut,
date_fin,
heure_fin,
agt_responsable,
besoin_materiel,
besoin_financier,
besoin_humain,
info_af_activités,
User_saisie,
Date_saisie
)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?)');
$req->execute(array
(
htmlspecialchars("$num"),
htmlspecialchars($_POST['Nom']),
htmlspecialchars($_POST['Date_debut']),
htmlspecialchars($_POST['Heure_debut']),
htmlspecialchars($_POST['Date_fin']),
htmlspecialchars($_POST['Heure_fin']),
htmlspecialchars($_POST['Responsable']),
htmlspecialchars($_POST['Besoins_M']),
htmlspecialchars($_POST['Besoins_F']),
htmlspecialchars($_POST['Besoins_H']),
htmlspecialchars($_POST['Info_afferente']),
htmlspecialchars("$login"),
htmlspecialchars("$date_saisie")
));
// Insertion du numero de l'activités et le numero de l'agent dans la table intermediaire
$req=$bdd->prepare('INSERT INTO activites_agent
(
num_pros,
num_agt
)
VALUES
(?,?)');
$req->execute(array
(
htmlspecialchars("$num"),
htmlspecialchars($_POST['Responsable'])
));
echo "<script langage='javascript'>alert('Enregistrement terminé avec succès ...');</script>";
$verifi=false;
redirect('accueil.php');
}
catch(Exception $e)
{
$numero_prosp=$numero_prosp+1;
$verifi=true;
}
}
}
?> |