diff --git a/src/controller/Distribution.hx b/src/controller/Distribution.hx index 9c52481..6ba6784 100755 --- a/src/controller/Distribution.hx +++ b/src/controller/Distribution.hx @@ -86,6 +86,17 @@ class Distribution extends Controller } } + + function getUser(uid:Int):db.User { + return db.User.manager.get(uid, false); + } + + function getBasket(userId, placeId, date){ + var user = getUser(userId); + var place = db.Place.manager.get(placeId, false); + return db.Basket.getOrCreate(user, place, date); + } + /** * Attendance sheet to print ( mutidistrib ) @@ -174,18 +185,24 @@ class Distribution extends Controller var data = new Array(); for (o in orders3) { + + + var basket = getBasket(o.userId,view.place.id,view.date); + data.push( { - "name":o.userName, - "productName":o.productName, - "price":view.formatNum(o.productPrice), - "quantity":o.quantity, - "fees":view.formatNum(o.fees), - "total":view.formatNum(o.total), - "paid":o.paid + "NUM": basket.num, + "ADHERENT":o.userName, + "PRODUIT":o.productName, + "QTÉ":o.quantity, + "price":view.formatNum(o.productPrice), + "fees":view.formatNum(o.fees), + "total":view.formatNum(o.total), + "paid":o.paid }); } - sugoi.tools.Csv.printCsvDataFromObjects(data, ["name", "productName", "price", "quantity","fees","total", "paid"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette"); + sugoi.tools.Csv.printCsvDataFromObjects(data, ["NUM","ADHERENT", "PRODUIT", "QTÉ","price","fees","total","paid"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette"); + //sugoi.tools.Csv.printCsvDataFromObjects(data, ["NUM","ADHERENT", "PRODUIT", "price", "quantity","fees","total", "paid"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette"); return; } }