Vous êtes sur la page 1sur 4

TP Facturation

Index.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Facture</title>
</head>
<body>
<h1>FACTURE</h1>
<hr>

<form method="post" action="save.php">


<table align="center">

<tr>
<td></td>
<td>
<input type="date" name="df">
</td>
</tr>
<tr>
<td><h2>Client : </h2></td>
<td><textarea name="cl" placeholder="Nom et Prénom, Adresse,
Tél."></textarea></td>
</tr>
</table>

<hr>
<h1>Commande</h1>
<hr>
<center>

<table align="center">
<tr>
<td>N°</td>
<td><input type="text" name="np"> </td>
</tr>
<tr>
<td>Libellés</td>
<td><input type="text" name="lib"> </td>
</tr>
<tr>
<td>P.U</td>
<td><input type="text" name="pu"> </td>
</tr>
<tr>
<td>Qtè</td>
<td><input type="text" name="qte"> </td>
</tr>

<tr>
<td>TVA</td>
<td><input type="" name="tva" placeholder="19%"> </td>
</tr>

<tr>
<td></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Confirmer la commande"></td>
</tr>
</table>
</form>
<hr>
<form method="post" action="print.php">
<table align="center">
<tr>
<td><h2>Facture N°</h2> </td>
<td><input type="text" name="nf"></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="" value="Imprimer"></td>
</tr>
</table>

</body>
</html>

print.php

<?php

mysql_connect("localhost","root","");
mysql_select_db("ecole");
$nf=$_POST['nf'];
$req=mysql_query("select * from facture where NumF='$nf'");
$lig=mysql_fetch_row($req);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
<table width="300" align="center">
<tr style="font-size: 22px; font-weight: bold;">
<td >Facture N°:</td>
<td><?php echo $lig[0];?></td>
</tr>
<tr style="font-size: 14px; font-weight: bold;">
<td>Date de Facturation:</td>
<td><?php echo $lig[1];?></td>
</tr>
<tr style="font-size: 14px; font-weight: bold;">
<td>Client:</td>
<td><?php echo $lig[2];?></td>
</tr>
</table>
<br>
<table width="800" align="center">
<tr style="font-size: 14px; font-weight: bold; background: #666;">
<td>Num Prod</td>
<td>Libellé</td>
<td>Prix Unitaire</td>
<td>Qunatité</td>
<td>Total HT</td>
</tr>
<tr>
<td><?php echo $lig[3];?></td>
<td><?php echo $lig[4];?></td>
<td><?php echo $lig[5];?></td>
<td><?php echo $lig[6];?></td>
<td><?php echo $lig[7];?></td>
</tr>

</table>
<br>
<table width="300" align="center" style="font-size: 14px; font-weight: bold; ">
<tr>
<td>Total HT : </td>
<td><?php echo $lig[7];?> DNT</td>
</tr>
<tr>
<td>TVA (19%) :</td>
<td><?php echo $lig[8];?> DNT</td>
</tr>
<tr>
<td>Net à payer :</td>
<td><?php echo $lig[9];?> DNT</td>
</tr>
</table>

</body>
</html>
save.php

<?php

mysql_connect("localhost","root","");
mysql_select_db("ecole");

$df=$_POST['df'];
$cl=$_POST['cl'];
$np=$_POST['np'];
$lib=$_POST['lib'];
$pu=$_POST['pu'];
$qte=$_POST['qte'];
$tva=$_POST['tva'];
$mt=$pu*$qte;
$mtva=($mt/100)*$tva;
$net=$mt+$mtva;
$req=mysql_query("insert into facture
values('','$df','$cl','$np','$lib','$pu','$qte','$mt','$mtva','$net')");
header('location:index.php');
?>

Vous aimerez peut-être aussi