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
| <?php
function convertionDate($dateEur){
$rsl = explode ('/',$dateEur);
$rsl = array_reverse($rsl);
return implode($rsl,'-');
}
$link = mysql_connect('localhost', 'myuser', 'mypassword');
mysql_select_db('ma_db', $link);
$list_service = mysql_query('SELECT distinct service FROM servcart order by service', $link);
$service='';
$form_correct=(isset($_POST['date_debut']) and isset($_POST['date_fin']) and isset($_POST['service']));
if ($form_correct) {
$service=$_POST['service'];
$date_debut=convertionDate($_POST['date_debut']);
$date_fin=convertionDate($_POST['date_fin']);
$resultat= mysql_query("SELECT uf,service,cartouche,sortie_stock,date_sortie FROM servcart WHERE service='$service' and date_sortie BETWEEN '$date_debut' and '$date_fin' order by date_sortie", $link);
}
?>
<html>
<head>
</head>
<body>
<script language="JavaScript">
function verifSelection() {
if (document.rechercher.service.value == "") {
alert("Merci de renseigner le service")
return false
}
if (document.rechercher.date_debut.value == "") {
alert("Merci de renseigner la date de début")
return false
}
if (document.rechercher.date_fin.value == "") {
alert("Merci de renseigner la date de fin")
return false
}
}
</script>
<table width="580" height="209" border="3">
<form name="rechercher" method="post" action="index.php?idpage=3" onSubmit="return verifSelection()">
<tr>
<td height="35" colspan="5" align="center" style="font-size:24px" >Statistiques de consommation </td>
</tr>
<tr>
<td height="32" colspan="5" align="left">
<select name="service" >
<option selected> Choisissez un service</option>
<?php while ($row = mysql_fetch_assoc($list_service)): ?>
<option value="<?php echo $row['service']; ?>" <?php if ($row['service']==$service) {echo " selected";} ?> ><?php echo $row['service']; ?></option>
<?php endwhile; ?>
</select>
</td>
</tr>
<tr>
<td height="30" colspan="5" align="center">
<label>Entre : </label>
<input type="text" id="datepicker" name="date_debut"/>
<label>Et : </label>
<input type="text" id="datepicker1" name="date_fin" />
</td>
</tr>
<tr>
<th height="28" colspan="5" scope="row" align="center">
<input type="submit" value="Rechercher" />
</th>
</tr>
<?php if ($form_correct) :?>
<tr>
<th width="52" height="36" bgcolor="#5ab9d8" scope="col">UF</th>
<th width="159" bgcolor="#5ab9d8" scope="col">SERVICE</th>
<th width="191" bgcolor="#5ab9d8" scope="col">CARTOUCHE</th>
<th width="77" bgcolor="#5ab9d8" scope="col">DATE</th>
<th width="63" bgcolor="#5ab9d8" scope="col">SORTIE STOCK</th>
</tr>
<?php while ($row = mysql_fetch_assoc($result)): ?>
<tr>
<td height="22"><?php echo $row['uf']; ?></td>
<td><?php echo $row['service']; ?></td>
<td><?php echo $row['cartouche']; ?></td>
<td><?php echo $row['date_sortie']; ?></td>
<td><?php echo $row['sortie_stock']; ?></td>
</tr>
<?php endwhile; ?>
<?php endif; ?>
</form>
</table>
</body>
</html>
<?php
mysql_close($link);
?> |