fix sending all
This commit is contained in:
parent
bd483ac877
commit
2eac04c1e1
@ -35,24 +35,27 @@
|
||||
</div>
|
||||
<div class="new-display">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<h2>new display without duplicates:</h2>
|
||||
<button class="btn btn-warning" ng-click="removeAll()">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<button class="btn btn-warning" ng-click="removeAll()" ng-disable="!CurrentSellingTotal()">
|
||||
<i class="fa fa-trash"></i> enlever Tout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-repeat="group in activeSellingFiltered track by $index">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="text" ng-model="group.name">
|
||||
<!--<span class="btn btn-warning input-group-addon remove-item"-->
|
||||
<!--ng-click="removeProductGroup(group.id)">-->
|
||||
<!--<i class="fa fa-trash"></i>-->
|
||||
<!--</span>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-4 text-right">
|
||||
<strong>
|
||||
<!--<input type="number" ng-model="p.price">-->
|
||||
{{group.unitPrice}}
|
||||
€ </strong>
|
||||
<span class="badge badge-default" ng-if="group.count">
|
||||
@ -60,51 +63,30 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-4 text-right">
|
||||
|
||||
|
||||
<strong>
|
||||
<!--<input type="number" ng-model="p.price">-->
|
||||
{{group.totalPrice}}
|
||||
€ </strong>
|
||||
<span class="btn btn-warning remove-item"
|
||||
ng-click="removeGroupeProducts(group.groupId)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="old-display">
|
||||
|
||||
<h2>old display:</h2>
|
||||
|
||||
<div ng-repeat="p in activeSelling track by $index">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="input-group">
|
||||
<input type="text" ng-model="p.name">
|
||||
<span class="btn btn-warning input-group-addon remove-item"
|
||||
ng-click="removeProduct(p,$index)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 text-right">
|
||||
<strong>
|
||||
<input type="number" ng-model="p.price">
|
||||
€ </strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<div class="row">
|
||||
<div class="row clickable" >
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<h3>Total: </h3>
|
||||
<h3 ng-click="setRightAmountPaid()">Total: </h3>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<h3>
|
||||
<h3 ng-click="setRightAmountPaid()">
|
||||
<strong>
|
||||
|
||||
{{ CurrentSellingTotal() }} </strong>€
|
||||
{{ CurrentSellingTotal() }}
|
||||
</strong>€
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
@ -136,6 +118,30 @@
|
||||
<!--</button>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
<div class="old-display well">
|
||||
|
||||
<!--<h2>old display:</h2>-->
|
||||
|
||||
<!--<div ng-repeat="p in activeSelling track by $index">-->
|
||||
<!--<div class="row">-->
|
||||
<!--<div class="col-xs-12 col-sm-6">-->
|
||||
<!--<div class="input-group">-->
|
||||
<!--<input type="text" ng-model="p.name">-->
|
||||
<!--<span class="btn btn-warning input-group-addon remove-item"-->
|
||||
<!--ng-click="removeProduct(p,$index)">-->
|
||||
<!--<i class="fa fa-trash"></i>-->
|
||||
<!--</span>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="col-xs-12 col-sm-6 text-right">-->
|
||||
<!--<strong>-->
|
||||
<!--<input type="number" ng-model="p.price">-->
|
||||
<!--€ </strong>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<hr>
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user