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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
| <?php
include("./templates/header.tpl");
include('config.php');
if(isset($_SESSION['username']))
{
include("./templates/login.tpl");
include("./templates/menu.tpl");
?>
<table cellpadding="0" cellspacing="0">
<tr>
<td width="990" height="224" align="left" valign="top" colspan="3">
<table class="cadre" width="100%" bgcolor="#FFFFCC">
<tr>
<td width="986">
<p><b><span style="font-size:11pt;"> RESULTAT DE LA RECHERCHE: FIN DE CONTRAT VEHICULE DANS MOIN DE 60 JOURS</span></b></p>
</td>
</tr>
<tr>
<td width="986" height="290" align="left" valign="top">
<div style="width:986px; height:610px; background-color:rgb(255,255,255); overflow:auto; border:solid 1px black;">
<?php
$limite=$_GET['limite'];
$nombre = 20; // on va afficher 5 résultats par page.
if (!isset($limite)) $limite = 0; // si on arrive sur la page pour la première fois
// on met limite à 0.
$path_parts = pathinfo($_SERVER['PHP_SELF']);
$page = $path_parts['basename'];
$limitesuivante = $limite + $nombre;
$limiteprecedente = $limite - $nombre;
function displayNextPreviousButtons($limite,$total,$nombre,$page) {
$limitesuivante = $limite + $nombre;
$limiteprecedente = $limite - $nombre;
echo '<table><tr>'."\n";
if($limite != 0) {
echo '<td valign="top">'."\n";
echo '<form action="'.$page.'" method="post">'."\n";
echo '<input type="submit" value="précédents">'."\n";
echo '<input type="hidden" value="'.$limiteprecedente.'" name="limite">'."\n";
echo '</form>'."\n";
echo '</td>'."\n";
}
if($limiteSuivante < $total) {
echo '<td valign="top">'."\n";
echo '<form action="'.$page.'" method="post">'."\n";
echo '<input type="submit" value="suivants">'."\n";
echo '<input type="hidden" value="'.$limitesuivante.'" name="limite">'."\n";
echo '</form>'."\n";
echo '</td>'."\n";
}
echo '</tr></table>'."\n";
}
function affichePages($nombre,$page,$total) {
$nbpages=ceil($total/$nombre);
$numeroPages = 1;
$compteurPages = 1;
$limite = 0;
//echo '<table border = "0" ><tr>'."\n";
while($numeroPages <= $nbpages) {
// echo '<td ><a href = "'.$page.'?limite='.$limite.'">'.$numeroPages.'/'.$nbpages.'</a></td>'."\n";
$limite = $limite + $nombre;
$numeroPages = $numeroPages + 1;
$compteurPages = $compteurPages + 1;
if($compteurPages == 20) {
$compteurPages = 1;
echo ''."\n";
}
}
// echo '</tr></table>'."\n";
echo ''.$nbpages.'';
}
$select = "SELECT count(id) FROM gestion_assur_prevoyance WHERE valid_contrat='En cours' AND DATE_ADD(DATE_ADD(date_effet, INTERVAL 1 YEAR), INTERVAL 60 DAY)";
//$select = "SELECT count(id) FROM gestion_assur_prevoyance WHERE valid_contrat='En cours' AND NOW() BETWEEN DATE_ADD(date_effet, INTERVAL 305 DAY) AND DATE_ADD(date_effet, INTERVAL 368 DAY)";
$result = mysql_query($select,$db) or die ('Erreur : '.mysql_error() );
$row = mysql_fetch_row($result);
$total = $row[0];
//$select = "select * FROM gestion_assur_prevoyance WHERE valid_contrat='En cours' AND NOW() BETWEEN DATE_ADD(date_effet, INTERVAL 305 DAY) AND DATE_ADD(date_effet, INTERVAL 368 DAY) ORDER BY id ASC limit $limite,$nombre";
$select = "select * FROM gestion_assur_prevoyance WHERE valid_contrat='En cours' AND DATE_ADD(DATE_ADD(date_effet, INTERVAL 1 YEAR), INTERVAL 60 DAY) ORDER BY id ASC limit $limite,$nombre";
$result = mysql_query($select,$db) or die ('Erreur : '.mysql_error() );
function CompteReboursAvant($evenement)
{
$evenement = explode('-', $evenement);
// secondes entre le 1er janv. 1970 et la date de l'evenement
$evenement = (mktime(23,59,59,$evenement[1],$evenement[0],$evenement[2]));
// secondes entre le 1er janv. 1970 et aujourd'hui
$aujourdhui = time(void);
// secondes entre aujourd'hui et l'evenement
$secondes = $evenement - $aujourdhui;
// on divise pour avoir en jour(s)
$jours = $secondes / 86400;
// on arrondi à l'entier inferieur
$jours = floor($jours);
// valeur de retour de la fonction
return $jours;
}
if($total) {
// début du tableau
echo '<table bgcolor="#FFFFFF" border="1" width="986">'."\n";
// première ligne on affiche les titres prénom et surnom dans 2 colonnes
echo '<tr>';
echo '<td width="12"><p> </p></td>';
echo '<td width="190" bgcolor="#FFCC66"><b>N° de dossier client:</b></td>';
echo '<td width="100" bgcolor="#FFCC66"><p><b>Type</b></p></td>';
echo '<td width="340" bgcolor="#FFCC66"><p><b>Marque véhicule et modele</b></p></td>';
echo '<td bgcolor="#FFCC66"><p><b>Nbr de j restant</b></p></td>';
echo '<td align="right" bgcolor="#FFCC66"><p><b>Date de debut</b></p></td>';
echo '<td width="10"><p> </p></td>';
echo '</tr>'."\n";
// lecture et affichage des résultats sur 2 colonnes, 1 résultat par ligne.
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td width="12"><p> </p></td>';
echo '<td width="190"><a href="fiche_assur_vehicule.php?id='.$row['num_dos_client'].'&asa='.$row['id'].'"><b>N° dos assurance: '.$row['id'].'</b></a></td>';
echo '<td width="100"><p>'.$row['type_vehicule'].'</p></td>';
echo '<td width="340"><p>'.$row['marque_vehicule'].' '.$row['modele_vehicule'].'</p></td>';
$event_dates = date("d-m-Y", strtotime($row['date_effet']));
$event_datess = date("d-m-Y", strtotime($event_dates));
$event_date = date("d-m-Y", strtotime("+1 year", strtotime($event_datess."-01" )));
//echo $event_date; afiche la date a l'endroit
$nbre_de_jours = CompteReboursAvant($event_date);
echo '<td><p><i>Il reste '.$nbre_de_jours.' jour(s)</i></p></td>';
echo '<td align="right"><p>'.$row['date_effet'].'</p></td>';
echo '<td width="10"><p> </p></td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
if($total > $nombre) {
?><p align="center"><?php
if($limite != 0) {
echo '<a href="'.$page.'?limite='.$limiteprecedente.'">Page précédente</a> - ';
}
else
{
echo 'Page précédente - ';
}
// affichage des liens vers les pages
$resa = $limite + $nombre;
$resb = $resa / $nombre;
echo 'page '.$resb.' / ';
affichePages($nombre,$page,$total);
// affichage des boutons
if($limitesuivante < $total) {
echo ' - <a href="'.$page.'?limite='.$limitesuivante.'">Page Suivante</a>';
}
else
{
echo ' - Page Suivante';
}
?></p><?php
}
// fin du tableau.
}
else echo 'Pas d\'enregistrements dans cette table...';
// on libère le résultat
mysql_free_result($result);
?>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
else
{
include("./templates/login_out.tpl");
include("./templates/menu_out.tpl");
include("./templates/index_out.tpl");
//include_once("./templates/accueil_out.tpl");
}
include("./templates/footer.tpl");
mysql_close ();
?> |
Partager