Commit 912501b3 authored by MOREAU Ulysse's avatar MOREAU Ulysse
Browse files

Add dirty table to display more properly

parent 460fa25d
...@@ -26,10 +26,13 @@ window.addEventListener("load", function (e) { ...@@ -26,10 +26,13 @@ window.addEventListener("load", function (e) {
button.addEventListener("click", function() { button.addEventListener("click", function() {
let cb = function(data){ let cb = function(data){
let popup = new Popup("Commandes de " + button.closest("article").querySelector("h2").innerText); let popup = new Popup("Commandes de " + button.closest("article").querySelector("h2").innerText);
let ul = document.createElement('ul');
let orders = data["data"]; let orders = data["data"];
let table = document.createElement('table');
table.insertAdjacentHTML("beforeend", "<tr><th>Utilisateur</th><th>Personnalisation</th><th>Opt 1</th><th>Opt 2</th><th>Payé</th><th>Quantité</th></tr>");
for (let i = orders.length - 1; i >= 0; i--) { for (let i = orders.length - 1; i >= 0; i--) {
let order = orders[i]; let order = orders[i];
let line = document.createElement("tr")
let li = document.createElement('li'); let li = document.createElement('li');
let content = order.user + " : " + order.quantity; let content = order.user + " : " + order.quantity;
console.log(orders) console.log(orders)
...@@ -38,11 +41,35 @@ window.addEventListener("load", function (e) { ...@@ -38,11 +41,35 @@ window.addEventListener("load", function (e) {
content = (order.second_option === '') ? content : content + ' ; ' + order.customization; content = (order.second_option === '') ? content : content + ' ; ' + order.customization;
content = order.paid ? content : content + " ; Impayé"; content = order.paid ? content : content + " ; Impayé";
content = (order.quantity_delivered === 0) ? content : content + " ; " + order.quantity_delivered + " livré(s)" content = (order.quantity_delivered === 0) ? content : content + " ; " + order.quantity_delivered + " livré(s)"
li.appendChild(document.createTextNode(content));
ul.appendChild(li);
let c1 = document.createElement("td")
let c2 = document.createElement("td")
let c3 = document.createElement("td")
let c4 = document.createElement("td")
let c5 = document.createElement("td")
let c6 = document.createElement("td")
c1.appendChild(document.createTextNode(order.user))
c2.appendChild(document.createTextNode(order.customization))
c3.appendChild(document.createTextNode(order.option))
c4.appendChild(document.createTextNode(order.second_option))
c5.appendChild(document.createTextNode(order.paid))
c6.appendChild(document.createTextNode(order.quantity))
line.appendChild(c1)
line.appendChild(c2)
line.appendChild(c3)
line.appendChild(c4)
line.appendChild(c5)
line.appendChild(c6)
table.appendChild(line);
} }
popup.main.appendChild(ul); popup.main.appendChild(table);
popup.pop(); popup.pop();
}; };
queryJson(document.location, { queryJson(document.location, {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment