diff --git a/app/Resources/views/logged/angular/current.html.twig b/app/Resources/views/logged/angular/current.html.twig index 253e864f..495bd65d 100755 --- a/app/Resources/views/logged/angular/current.html.twig +++ b/app/Resources/views/logged/angular/current.html.twig @@ -35,24 +35,27 @@
+
+

new display without duplicates:

-
+
+ +
+
+ +
- - - -
- {{group.unitPrice}} € @@ -60,53 +63,32 @@
- - {{group.totalPrice}} € + + +

-
-

old display:

- -
-
-
-
- - - - -
-
-
- - - € -
-
-
- -
-
+
-

Total:

+

Total:

-

- - - {{ CurrentSellingTotal() }} € -

-
+

+ + {{ CurrentSellingTotal() }} + € +

+
@@ -136,6 +118,30 @@
+
+ + + + + + + + + + + + + + + + + + + + + + +

diff --git a/assets/js/parts/main.js b/assets/js/parts/main.js index 2dd83a54..576ad307 100755 --- a/assets/js/parts/main.js +++ b/assets/js/parts/main.js @@ -45,6 +45,15 @@ angular clientsCount: 0, commentaire: "" }; + + + /** + * set the right paid amount + */ + $scope.setRightAmountPaid = function () { + // debugger; + $scope.paidAmount += $scope.sumOfList($scope.activeSelling); + } /** * deduplicate the active selling items in the view, * show a count for each of them when there are more than one @@ -52,19 +61,14 @@ angular $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] = { @@ -77,7 +81,6 @@ angular } } }); - console.log("#####refreshDeduplicateSellings soldObjectsIdsCount", soldObjectsIdsCount); $scope.activeSellingFiltered = soldObjectsIdsCount; } @@ -129,6 +132,7 @@ angular $scope.activeItemsSold.push(product.id); $scope.regenActiveSellingIds(); $scope.refreshDeduplicateSellings(); + $scope.setRightAmountPaid(); }; /** * remove from current sell list @@ -140,10 +144,24 @@ angular $scope.regenActiveSellingIds(); $scope.refreshDeduplicateSellings(); }; + /** + * remove all products of a certain group id in the active Selling + * @param productId + * @returns {*} + */ + $scope.removeGroupeProducts = function (productId) { + console.log("##### removeGroupeProducts", productId); + console.log("$scope.activeSelling", $scope.activeSelling); + $scope.activeSelling = $scope.activeSelling.filter(elem => elem.id != productId) + console.log("$scope.activeSelling", $scope.activeSelling); + $scope.regenActiveSellingIds(); + $scope.refreshDeduplicateSellings(); + } $scope.removeAll = function () { $scope.activeSelling = []; - $scope.regenActiveSellingIds() + $scope.regenActiveSellingIds(); + $scope.refreshDeduplicateSellings(); }; $scope.pauseSelling = function () { $scope.pausedSelling.push(angular.copy($scope.activeSelling)); @@ -156,12 +174,13 @@ angular $scope.clearSellingComment = function () { $scope.sellingComment = ''; - document.querySelector('#sellingCommentInput').focus(); + document.querySelector('.client-now input').focus(); }; $scope.clearCurrentSelling = function () { $scope.paidAmount = 0; - // $scope.sellingComment = ""; + $scope.clearSellingComment(); $scope.activeSelling = []; + $scope.removeAll(); }; // http related calls @@ -212,22 +231,23 @@ angular console.log('logger', stuff); }; $scope.sendForm = function () { - console.log('$scope.sellingComment', this.sellingComment); + console.log('$scope.sellingComment', $scope.sellingComment); + console.log("$scope.activeSelling", $scope.activeSelling); let lesParams = { - paidByClient: this.paidAmount, - sellingComment: this.sellingComment, - activeSelling: this.activeSelling, - activeFestival: this.activeFestival + paidByClient: $scope.paidAmount, + sellingComment: $scope.sellingComment, + activeSelling: $scope.activeSelling, + activeFestival: $scope.activeFestival }; $scope.recentSellings.push({ - id: this.recentId++, - amount: this.CurrentSellingTotal(), - paidAmount: this.paidAmount, + id: $scope.recentId++, + amount: $scope.CurrentSellingTotal(), + paidAmount: $scope.paidAmount, products: angular - .copy(this.activeSelling) + .copy($scope.activeSelling) }); - console.log('$scope.recentSellings', this.recentSellings); + console.log('$scope.recentSellings', $scope.recentSellings); $scope.lesParams = lesParams; $http({ method: 'POST', @@ -237,7 +257,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; @@ -383,9 +403,7 @@ angular }, $scope.manageError) }; - // save TODO - - $scope.save = () => { + $scope.save = function () { if ($scope.config.loading) { console.log('already saving'); return; @@ -402,7 +420,7 @@ angular }, $scope.manageError) }; - $scope.addExpense = () => { + $scope.addExpense = function () { $scope.expenses.push({ name: "", repeat: 0, @@ -410,7 +428,7 @@ angular amount: 0, }) }; - $scope.init = () => { + $scope.init = function () { $scope.fetchExpenses(); }; $scope.manageError = (error) => { @@ -418,7 +436,7 @@ angular $scope.config.loading = false; } - $scope.updateCanevas = () => { + $scope.updateCanevas = function () { var dataPoints = $scope.graphPointsPrevision; var chartContainer = new CanvasJS.Chart("simulationPrevision", { title: {