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
| <?php
try
{
// On se connecte à MySQL
$pdo = new PDO('mysql:host=localhost;dbname=bddbc;charset=utf8', 'root', 'root');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
// Si tout va bien, on peut continuer
$sth = $pdo->prepare('SELECT
SUM(Paiement) CA,
SUM( case when rendu = 1 then Paiement else 0 end) + SUM( case when rendu = 0 then acompte else 0 end) caisse,
SUM( case when rendu = 0 then Paiement else 0 end) - SUM( case when rendu = 0 then acompte else 0 end) encours,
SUM(Paiement) - SUM(prixpiece) marge,
SUM( case when rendu = 1 then Paiement else 0 end) - SUM( case when rendu = 1 then prixpiece else 0 end) marge_C,
SUM( case when rendu = 0 then Paiement else 0 end) - SUM( case when rendu = 0 then prixpiece else 0 end) marge_F
FROM reparation
WHERE Date BETWEEN :dd AND :da');
$sth->execute(array(':dd'=>$_POST['dd'], ':da'=>$_POST['da']));
?>
<body >
<div id="DivCalendar" style="z-index:2; display:none; width:200px;height:235px; overflow:hidden;position:absolute;Top:1px; left:1px;" ></div>
<form name="calendar" action="index.php" onsubmit="return comparedate()" method="post">
<input type='text' name='da' id='da' onfocus="show_calendar('da','jj,mm,aaaa')" style='text-align:right' readonly/><br/>
<input type='text' name='dd' id='dd' onfocus="show_calendar('dd')" readonly style='text-align:right' />
<input type='submit' value='envoyer'/>
</form>
</body>
</html> |
Partager