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
| <?php
ini_set('myssql.trace_mode', true);
error_reporting(-1);
$client = mysql_real_escape_string($client);
$nom = mysql_real_escape_string($nom);
$sql = "SELECT * FROM factures WHERE client='$client' AND nom='$nom' ORDER BY ordre DESC LIMIT 5";
$res = mysql_query($sql) or die ('Erreur : '.mysql_error());
$today = new DateTime();
$etat5 = 'fin de durée';
$etat6 = 'actif';
$data = array();
while($row = mysql_fetch_assoc($res)) {
$end = DateTime::createFromFormat("d/m/Y", $row['date_end']);
$etat = ($today->getTimestamp() > $end->getTimestamp()) ? $etat5 : $etat6;
$sql = "UPDATE factures SET etat='$etat' WHERE ordre={$row['ordre']}";
$exec = mysql_query($sql) or die ('Erreur : '.mysql_error());
$row['etat'] = $etat; // on conserve le dernier état connu
if ($row['produit'] === 'points recharge') {
$row['renouveler'] = '<font size="1" color="green"><b>Achat points</b></font>';
}
else
if ($row['etat'] === $etat5) {
$row['renouveler'] = '<font size="1" color="red"><b><blink>Renouveler</blink></b></font>';
}
else {
$row['renouveler'] = '<font size="1" color="green"><b>Renouveler</b></font>';
}
$row['tr_class'] = (++$i % 2) ? 'classe2' : 'classe1';
$data[] = $row;
}
?>
<table width="560" border="0">
<thead>
<tr>
<th class="td1" width="155">Produits</th>
<th class="td1" width="157">Date achat</th>
<th class="td1" width="137">Date de fin</th>
<th class="td1" width="100">Etat</th>
<th class="td1" width="137">Durée</th>
<th class="td1" width="137">Renouveler</th>
</tr>
</thead>
<tbody>
<?php foreach($data as $row): ?>
<tr class="prem <?php echo $row['tr_class']; ?>">
<td width="130"><font size="1"><?php echo $row['produit']; ?></font></td>
<td width="130"><font size="1"><?php echo $row['date']; ?></font></td>
<td width="137"><font size="1"><?php echo $row['date_fin']; ?></font></td>
<td width="100"><font size="1"><?php echo $row['etat']; ?></font></td>
<td width="137"><font size="1"><?php echo $row['duree']; ?></font></td>
<td width="137"><?php echo $row['renouveler']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table> |