<?php
// Démarrage de la session
session_start();
// Connexion à la base de données
$pdo = new PDO('mysql:host=localhost;dbname=nom_de_la_base', 'utilisateur', 'mot_de_passe');
// Fonction pour ajouter un nouvel appel
function addCall($data) {
global $pdo;
$stmt = $pdo->prepare("INSERT INTO calls (date_time, origin, city, contact, type, species, action, remarks, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute($data);
}
// Fonction pour récupérer tous les appels
function getCalls() {
global $pdo;
$stmt = $pdo->query("SELECT * FROM calls ORDER BY date_time DESC");
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Traitement du formulaire
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = [
$_POST['date_time'],
$_POST['origin'],
$_POST['city'],
$_POST['contact'],
$_POST['type'],
$_POST['species'],
$_POST['action'],
$_POST['remarks'],
$_POST['status']
];
addCall($data);
}
// Récupération des appels pour affichage
$calls = getCalls();
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Main Courante - Sauvegarde Hérault Littoral</title>
<style>
body { font-family: Arial, sans-serif; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; text-align: left; border-bottom: 1px solid #ddd; }
.status { font-weight: bold; }
.status.en-cours { color: orange; }
.status.intervention { color: red; }
.status.conseils { color: blue; }
.status.judiciaire { color: purple; }
.status.terminer { color: green; }
</style>
</head>
<body>
<h1>Main Courante</h1>
<form method="post">
<label for="date_time">Date et Heure:</label>
<input type="datetime-local" id="date_time" name="date_time" required><br>
<label for="origin">Origine:</label>
<select id="origin" name="origin" required>
<option value="Grand Public">Grand Public</option>
<option value="Pompier">Pompier</option>
<option value="Police/Gendarmerie">Police/Gendarmerie</option>
<option value="Ville">Ville</option>
<option value="Entreprise">Entreprise</option>
<option value="Camping">Camping</option>
<option value="Autre">Autre</option>
</select><br>
<label for="city">Ville:</label>
<input type="text" id="city" name="city" required><br>
<label for="contact">N° de téléphone / Mail:</label>
<input type="text" id="contact" name="contact" required><br>
<label for="type">Type d'appel:</label>
<select id="type" name="type" required>
<option value="Faune en détresse">Faune en détresse</option>
<option value="Tortue">Tortue</option>
<option value="Signalement dégradation">Signalement dégradation</option>
<option value="Pollution">Pollution</option>
<option value="Autre">Autre</option>
</select><br>
<label for="species">Si faune sauvage : Espèce:</label>
<input type="text" id="species" name="species"><br>
<label for="action">Action:</label>
<select id="action" name="action" required>
<option value="Conseil de transport au centre de soin">Conseil de transport au centre de soin</option>
<option value="Intervention de l'association">Intervention de l'association</option>
<option value="Appel OFB">Appel OFB</option>
<option value="Appel Police/Gendarmerie">Appel Police/Gendarmerie</option>
<option value="Médiation">Médiation</option>
</select><br>
<label for="remarks">Remarques:</label>
<textarea id="remarks" name="remarks"></textarea><br>
<label for="status">Statut:</label>
<select id="status" name="status" required>
<option value="En cours">En cours</option>
<option value="Intervention">Intervention</option>
<option value="Conseils téléphonique">Conseils téléphonique</option>
<option value="Procédure judiciaire">Procédure judiciaire</option>
<option value="Terminer">Terminer</option>
</select><br>
<button type="submit">Ajouter l'appel</button>
</form>
<h2>Historique des appels</h2>
<table>
<thead>
<tr>
<th>Date et Heure</th>
<th>Origine</th>
<th>Ville</th>
<th>Contact</th>
<th>Type</th>
<th>Espèce</th>
<th>Action</th>
<th>Remarques</th>
<th>Statut</th>
</tr>
</thead>
<tbody>
<?php foreach ($calls as $call): ?>
<tr>
<td><?= htmlspecialchars($call['date_time']) ?></td>
<td><?= htmlspecialchars($call['origin']) ?></td>
<td><?= htmlspecialchars($call['city']) ?></td>
<td><?= htmlspecialchars($call['contact']) ?></td>
<td><?= htmlspecialchars($call['type']) ?></td>
<td><?= htmlspecialchars($call['species']) ?></td>
<td><?= htmlspecialchars($call['action']) ?></td>
<td><?= htmlspecialchars($call['remarks']) ?></td>
<td class="status <?= strtolower(str_replace(' ', '-', $call['status'])) ?>"><?= htmlspecialchars($call['status']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
J’aime ça :
J’aime chargement…