<?php
if(isset($_POST['prolonger'])) {			
	$dday = date("Y-m-d");
	$datef = new DateTime($dday);
	for($i=0;$i<366;$i++) {
		$cal = mysqli_query($bdd,"SELECT * FROM ".$prefix."_calendrier WHERE date = '".date_format($datef, 'Y-m-d')."'");
		$cal_nb = mysqli_num_rows($cal);
		if($cal_nb==0) {
			mysqli_query($bdd,"INSERT INTO ".$prefix."_calendrier (date, statut) VALUES ('".date_format($datef, 'Y-m-d')."', 1)");
		}
		$datef->modify('+1 day');
	}
}
$lastdate = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT * FROM ".$prefix."_calendrier ORDER BY date DESC LIMIT 1"));
$lastdateTimestamp = strtotime($lastdate['date']); // Convertit la date en timestamp
$formattedDate = date("d/m/Y", strtotime($lastdate['date']));
$now = time(); // Timestamp actuel
$difference = ($lastdateTimestamp - $now) / (60 * 60 * 24); // Différence en jours
if ($difference > 0 && $difference <= 30) {
    echo '<p class="signal">'.PARAC_CAL25.$formattedDate.').<form method="POST" action=""><input class="bouton boutparam paddvalid1" type="submit" name="prolonger" value="'.PARAC_CAL23.'"></form></p>';
} elseif ($difference <= 0) {
    echo '<p class="signal">'.PARAC_CAL26.'.<form method="POST" action=""><input class="bouton boutparam paddvalid1" type="submit" name="prolonger" value="'.PARAC_CAL23.'"></form></p>';
}
?>