<?php

if (isset($_GET['test'])) {
    $_SESSION['test'] = $_GET['test'];
}
include './membre/lib/php/classes/facture.class.php';
include './membre/lib/php/classes/facture_manager.class.php';
$mg = new facture_manager($db);
$liste = $mg->getDetailFacture($_SESSION['test']);
$nbr = count($liste);
$flag = true;
$i = 0;
while ($i < $nbr && $flag == true) {
    $id_prod = $liste[$i]->id_prod;
    $id_facture = $_SESSION['test'];
    $retour = $mg->DeleteDetailFacture($id_prod, $id_facture);
    $i++;
    if ($retour == 1) {
        $flag = true;
    } else {
        $flag = false;
    }
}
if ($flag == true) {
    $retour = $mg->DeleteFacture($id_facture);
    if ($retour == 1) {
        $flag = true;
        print "<h1>Commande annulée</h1>";
        $_SESSION['lignedf'] = 0;
        $_SESSION['test'] = null;
    } else {
<?php

if (isset($_GET['fac'])) {
    $_SESSION['fac'] = $_GET['fac'];
}
include './membre/lib/php/classes/facture.class.php';
include './membre/lib/php/classes/facture_manager.class.php';
$mg = new facture_manager($db);
$liste = $mg->getDetailFacture($_SESSION['fac']);
$nbr = count($liste);
?>
<h1><?php 
print "Facture n°" . $_SESSION['fac'];
?>
</h1>
<div id="table_facture_detail">
    <table width="100%">
        <tr>
            <th>
                Ligne
            </th>
            <th>
                Titre
            </th>
            <th>
                Prix
            </th>
            <th>
                Quantite
            </th>
        </tr>