diff --git a/LICENSE b/LICENSE
old mode 100644
new mode 100755
diff --git a/app/Resources/views/logged/angular/current.html.twig b/app/Resources/views/logged/angular/current.html.twig
index f44d632d..253e864f 100755
--- a/app/Resources/views/logged/angular/current.html.twig
+++ b/app/Resources/views/logged/angular/current.html.twig
@@ -32,8 +32,49 @@
+
+
diff --git a/assets/js/parts/dashboard.js b/assets/js/parts/dashboard.js
new file mode 100755
index 00000000..4a4b1518
--- /dev/null
+++ b/assets/js/parts/dashboard.js
@@ -0,0 +1,11 @@
+/**
+ * test to import things
+ */
+export class DashboardStuff{
+ sayHi(){
+ console.log('hiiiiiiii! from dashboard stuff');
+ }
+ sayHo(){
+ console.log('hoooo');
+ }
+};
\ No newline at end of file
diff --git a/assets/js/parts/main.js b/assets/js/parts/main.js
index 52667ab6..2dd83a54 100755
--- a/assets/js/parts/main.js
+++ b/assets/js/parts/main.js
@@ -15,6 +15,8 @@ $(document).ready(function () {
console.log('hello console for main.js');
var stuff = ['initialstuff'];
+
+// TODO split controllers in other files
angular
.module('caisse', [])
.controller('CaisseCtrl', ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
@@ -34,6 +36,7 @@ angular
};
$scope.activeItemsSold = []; // list of products ID to sell
$scope.activeSelling = []; // list of products to sell
+ $scope.activeSellingFiltered = []; // list of products to sell
$scope.activeFestival = { // an event where selling take place
id: null,
name: "le festival",
@@ -42,6 +45,43 @@ angular
clientsCount: 0,
commentaire: ""
};
+ /**
+ * deduplicate the active selling items in the view,
+ * show a count for each of them when there are more than one
+ */
+ $scope.refreshDeduplicateSellings = () => {
+ let soldObjectsIdsCount = {}
+ $scope.activeSellingFiltered = {};
+ console.log("$scope.activeSelling", $scope.activeSelling);
+ console.log("#####refreshDeduplicateSellings $scope.activeSelling", $scope.activeSelling);
+
+ $scope.activeSelling.forEach(elem => {
+ let groupId = elem.id;
+ let group = soldObjectsIdsCount[groupId];
+ console.log("elem.price", elem.price);
+ if (group) { // sort elements by the product id corresponding
+ console.log("add to total", group.totalPrice);
+ group.count++;
+ group.totalPrice += (elem.price * 1);
+ group.sellings.push(elem);
+ console.log("total is now", group.totalPrice);
+ } else {
+
+ soldObjectsIdsCount[groupId] = {
+ groupId: groupId,
+ count: 1,
+ name: elem.name,
+ unitPrice: elem.price * 1,
+ totalPrice: elem.price * 1,
+ sellings: [elem],
+ }
+ }
+ });
+ console.log("#####refreshDeduplicateSellings soldObjectsIdsCount", soldObjectsIdsCount);
+ $scope.activeSellingFiltered = soldObjectsIdsCount;
+
+ }
+
/**
* get the sum of products prices
* @param list
@@ -70,6 +110,7 @@ angular
$scope.activeItemsSold.push(obj.id);
}
$scope.paidAmount += $scope.sumOfList($scope.activeSelling);
+
};
$scope.stuff = stuff;
$scope.setActiveSelling = function (selling) {
@@ -87,6 +128,7 @@ angular
$scope.activeSelling.push(product);
$scope.activeItemsSold.push(product.id);
$scope.regenActiveSellingIds();
+ $scope.refreshDeduplicateSellings();
};
/**
* remove from current sell list
@@ -95,6 +137,12 @@ angular
$scope.removeProduct = function (product, index) {
product.stockCount++;
$scope.activeSelling.splice($index, 1);
+ $scope.regenActiveSellingIds();
+ $scope.refreshDeduplicateSellings();
+ };
+ $scope.removeAll = function () {
+
+ $scope.activeSelling = [];
$scope.regenActiveSellingIds()
};
$scope.pauseSelling = function () {
@@ -189,6 +237,7 @@ angular
},
data: lesParams // pass in data as strings
}).then(function (rep) {
+ activeSelling
$scope.clearCurrentSelling();
// if successful, bind success message to message
$scope.successMessage = rep.data.message;