if ($_SESSION['credit'] < $_SESSION['cartPrice'] && count($_SESSION['cartTitles']) + count($_SESSION['cartDiscs']) != 0) { echo "<div class=\"col-sm-12\">"; echo "<p id=\"error-message\"> Échec de paiement : Votre compte n'est pas assez approvisionné.</p>"; echo "</div><br />"; } else { if ($_SESSION['cartPrice'] == 0) { header('Location: ../index.php'); } else { $_SESSION['credit'] = $_SESSION['credit'] - $_SESSION['cartPrice']; $stmt = $bdd->prepare("UPDATE Abonné SET Credit = ? WHERE Abonné.Code_Abonné = ?"); $stmt->execute(array($_SESSION['credit'], $_SESSION['uid'])); //Insert albums buyings //Foreach disc in cart foreach ($_SESSION['cartDiscs'] as $disc) { $code = getDiscCodeByName($bdd, $disc[0]); $discTracks = getDiscsRecordings($bdd, $code); foreach ($discTracks as $dt) { $stmt = $bdd->prepare("INSERT INTO Achat (Code_Enregistrement, Code_Abonné) VALUES (?,?)"); $stmt->execute(array($dt[0], $_SESSION['uid'])); } } //Foreach title in cart foreach ($_SESSION['cartTitles'] as $title) { $code = getTrackIDByName($bdd, $title[0]); $stmt = $bdd->prepare("INSERT INTO Achat (Code_Enregistrement, Code_Abonné) VALUES (?,?)"); $stmt->execute(array($code, $_SESSION['uid'])); } header('Location: emptyCart.php'); } } ?>
echo "<p class=\"resultFilter\">Disque n° <strong>" . $i . "</strong> :</p>"; echo "<p class=\"resultFilter\">Prix du disque : <strong>" . substr_replace(getDiscPrice($bdd, $discID), '', -2) . "€ </strong></p>"; echo "<a href=\"../administration/addToCart.php?discID=" . $discID . "\" class=\"btn btn-info\" role=\"button\">Ajouter le disque au panier</a>"; echo "<table class=\"table table-striped\">"; echo "<thead>"; echo "<tr>"; echo "<th>Identifiant</th>"; echo "<th>Titre</th>"; echo "<th>Durée</th>"; echo "<th>Prix</th>"; echo "<th>Extrait</th>"; echo "<th>Achat</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; $titres = getDiscsRecordings($bdd, $discID); foreach ($titres as $t) { echo "<tr>"; echo "<td>" . $t[0] . "</td>"; echo "<td>" . $t[1] . "</td>"; echo "<td>" . $t[2] . "</td>"; echo "<td>" . substr_replace($t[3], '', -2) . " € </td>"; $request = "../data/getDiscAudio.php?id=" . $t[0]; echo "<td> <audio controls> <source src=\"" . $request . " \"type=\"audio/mpeg\"> </audio></td>"; echo "<td><a href=\"../administration/addToCart.php?titleID=" . $t[0] . "\" class=\"btn btn-info\" role=\"button\">Ajouter le titre au panier</a></td>"; echo "</tr>"; } $i++; echo "</tbody>"; echo "</table>"; }