fix sending all
This commit is contained in:
parent
bd483ac877
commit
2eac04c1e1
|
@ -35,24 +35,27 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="new-display">
|
<div class="new-display">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-sm-6">
|
||||||
<h2>new display without duplicates:</h2>
|
<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
|
<i class="fa fa-trash"></i> enlever Tout
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-repeat="group in activeSellingFiltered track by $index">
|
<div ng-repeat="group in activeSellingFiltered track by $index">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-4">
|
<div class="col-xs-12 col-sm-4">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" ng-model="group.name">
|
<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>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-4 text-right">
|
<div class="col-xs-12 col-sm-4 text-right">
|
||||||
<strong>
|
<strong>
|
||||||
<!--<input type="number" ng-model="p.price">-->
|
|
||||||
{{group.unitPrice}}
|
{{group.unitPrice}}
|
||||||
€ </strong>
|
€ </strong>
|
||||||
<span class="badge badge-default" ng-if="group.count">
|
<span class="badge badge-default" ng-if="group.count">
|
||||||
|
@ -60,53 +63,32 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-4 text-right">
|
<div class="col-xs-12 col-sm-4 text-right">
|
||||||
|
|
||||||
|
|
||||||
<strong>
|
<strong>
|
||||||
<!--<input type="number" ng-model="p.price">-->
|
<!--<input type="number" ng-model="p.price">-->
|
||||||
{{group.totalPrice}}
|
{{group.totalPrice}}
|
||||||
€ </strong>
|
€ </strong>
|
||||||
|
<span class="btn btn-warning remove-item"
|
||||||
|
ng-click="removeGroupeProducts(group.groupId)">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<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="text-right">
|
||||||
<div class="row">
|
<div class="row clickable" >
|
||||||
<div class="col-xs-12 col-sm-6">
|
<div class="col-xs-12 col-sm-6">
|
||||||
<h3>Total: </h3>
|
<h3 ng-click="setRightAmountPaid()">Total: </h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-6">
|
<div class="col-xs-12 col-sm-6">
|
||||||
<h3>
|
<h3 ng-click="setRightAmountPaid()">
|
||||||
<strong>
|
<strong>
|
||||||
|
{{ CurrentSellingTotal() }}
|
||||||
{{ CurrentSellingTotal() }} </strong>€
|
</strong>€
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-6">
|
<div class="col-xs-12 col-sm-6">
|
||||||
|
@ -136,6 +118,30 @@
|
||||||
<!--</button>-->
|
<!--</button>-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
</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>
|
</form>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -45,6 +45,15 @@ angular
|
||||||
clientsCount: 0,
|
clientsCount: 0,
|
||||||
commentaire: ""
|
commentaire: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the right paid amount
|
||||||
|
*/
|
||||||
|
$scope.setRightAmountPaid = function () {
|
||||||
|
// debugger;
|
||||||
|
$scope.paidAmount += $scope.sumOfList($scope.activeSelling);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* deduplicate the active selling items in the view,
|
* deduplicate the active selling items in the view,
|
||||||
* show a count for each of them when there are more than one
|
* show a count for each of them when there are more than one
|
||||||
|
@ -52,19 +61,14 @@ angular
|
||||||
$scope.refreshDeduplicateSellings = () => {
|
$scope.refreshDeduplicateSellings = () => {
|
||||||
let soldObjectsIdsCount = {}
|
let soldObjectsIdsCount = {}
|
||||||
$scope.activeSellingFiltered = {};
|
$scope.activeSellingFiltered = {};
|
||||||
console.log("$scope.activeSelling", $scope.activeSelling);
|
|
||||||
console.log("#####refreshDeduplicateSellings $scope.activeSelling", $scope.activeSelling);
|
|
||||||
|
|
||||||
$scope.activeSelling.forEach(elem => {
|
$scope.activeSelling.forEach(elem => {
|
||||||
let groupId = elem.id;
|
let groupId = elem.id;
|
||||||
let group = soldObjectsIdsCount[groupId];
|
let group = soldObjectsIdsCount[groupId];
|
||||||
console.log("elem.price", elem.price);
|
|
||||||
if (group) { // sort elements by the product id corresponding
|
if (group) { // sort elements by the product id corresponding
|
||||||
console.log("add to total", group.totalPrice);
|
|
||||||
group.count++;
|
group.count++;
|
||||||
group.totalPrice += (elem.price * 1);
|
group.totalPrice += (elem.price * 1);
|
||||||
group.sellings.push(elem);
|
group.sellings.push(elem);
|
||||||
console.log("total is now", group.totalPrice);
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
soldObjectsIdsCount[groupId] = {
|
soldObjectsIdsCount[groupId] = {
|
||||||
|
@ -77,7 +81,6 @@ angular
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("#####refreshDeduplicateSellings soldObjectsIdsCount", soldObjectsIdsCount);
|
|
||||||
$scope.activeSellingFiltered = soldObjectsIdsCount;
|
$scope.activeSellingFiltered = soldObjectsIdsCount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,6 +132,7 @@ angular
|
||||||
$scope.activeItemsSold.push(product.id);
|
$scope.activeItemsSold.push(product.id);
|
||||||
$scope.regenActiveSellingIds();
|
$scope.regenActiveSellingIds();
|
||||||
$scope.refreshDeduplicateSellings();
|
$scope.refreshDeduplicateSellings();
|
||||||
|
$scope.setRightAmountPaid();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* remove from current sell list
|
* remove from current sell list
|
||||||
|
@ -140,10 +144,24 @@ angular
|
||||||
$scope.regenActiveSellingIds();
|
$scope.regenActiveSellingIds();
|
||||||
$scope.refreshDeduplicateSellings();
|
$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.removeAll = function () {
|
||||||
|
|
||||||
$scope.activeSelling = [];
|
$scope.activeSelling = [];
|
||||||
$scope.regenActiveSellingIds()
|
$scope.regenActiveSellingIds();
|
||||||
|
$scope.refreshDeduplicateSellings();
|
||||||
};
|
};
|
||||||
$scope.pauseSelling = function () {
|
$scope.pauseSelling = function () {
|
||||||
$scope.pausedSelling.push(angular.copy($scope.activeSelling));
|
$scope.pausedSelling.push(angular.copy($scope.activeSelling));
|
||||||
|
@ -156,12 +174,13 @@ angular
|
||||||
|
|
||||||
$scope.clearSellingComment = function () {
|
$scope.clearSellingComment = function () {
|
||||||
$scope.sellingComment = '';
|
$scope.sellingComment = '';
|
||||||
document.querySelector('#sellingCommentInput').focus();
|
document.querySelector('.client-now input').focus();
|
||||||
};
|
};
|
||||||
$scope.clearCurrentSelling = function () {
|
$scope.clearCurrentSelling = function () {
|
||||||
$scope.paidAmount = 0;
|
$scope.paidAmount = 0;
|
||||||
// $scope.sellingComment = "";
|
$scope.clearSellingComment();
|
||||||
$scope.activeSelling = [];
|
$scope.activeSelling = [];
|
||||||
|
$scope.removeAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
// http related calls
|
// http related calls
|
||||||
|
@ -212,22 +231,23 @@ angular
|
||||||
console.log('logger', stuff);
|
console.log('logger', stuff);
|
||||||
};
|
};
|
||||||
$scope.sendForm = function () {
|
$scope.sendForm = function () {
|
||||||
console.log('$scope.sellingComment', this.sellingComment);
|
console.log('$scope.sellingComment', $scope.sellingComment);
|
||||||
|
console.log("$scope.activeSelling", $scope.activeSelling);
|
||||||
let lesParams = {
|
let lesParams = {
|
||||||
paidByClient: this.paidAmount,
|
paidByClient: $scope.paidAmount,
|
||||||
sellingComment: this.sellingComment,
|
sellingComment: $scope.sellingComment,
|
||||||
activeSelling: this.activeSelling,
|
activeSelling: $scope.activeSelling,
|
||||||
activeFestival: this.activeFestival
|
activeFestival: $scope.activeFestival
|
||||||
};
|
};
|
||||||
$scope.recentSellings.push({
|
$scope.recentSellings.push({
|
||||||
id: this.recentId++,
|
id: $scope.recentId++,
|
||||||
amount: this.CurrentSellingTotal(),
|
amount: $scope.CurrentSellingTotal(),
|
||||||
paidAmount: this.paidAmount,
|
paidAmount: $scope.paidAmount,
|
||||||
products:
|
products:
|
||||||
angular
|
angular
|
||||||
.copy(this.activeSelling)
|
.copy($scope.activeSelling)
|
||||||
});
|
});
|
||||||
console.log('$scope.recentSellings', this.recentSellings);
|
console.log('$scope.recentSellings', $scope.recentSellings);
|
||||||
$scope.lesParams = lesParams;
|
$scope.lesParams = lesParams;
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -237,7 +257,7 @@ angular
|
||||||
},
|
},
|
||||||
data: lesParams // pass in data as strings
|
data: lesParams // pass in data as strings
|
||||||
}).then(function (rep) {
|
}).then(function (rep) {
|
||||||
activeSelling
|
|
||||||
$scope.clearCurrentSelling();
|
$scope.clearCurrentSelling();
|
||||||
// if successful, bind success message to message
|
// if successful, bind success message to message
|
||||||
$scope.successMessage = rep.data.message;
|
$scope.successMessage = rep.data.message;
|
||||||
|
@ -383,9 +403,7 @@ angular
|
||||||
},
|
},
|
||||||
$scope.manageError)
|
$scope.manageError)
|
||||||
};
|
};
|
||||||
// save TODO
|
$scope.save = function () {
|
||||||
|
|
||||||
$scope.save = () => {
|
|
||||||
if ($scope.config.loading) {
|
if ($scope.config.loading) {
|
||||||
console.log('already saving');
|
console.log('already saving');
|
||||||
return;
|
return;
|
||||||
|
@ -402,7 +420,7 @@ angular
|
||||||
},
|
},
|
||||||
$scope.manageError)
|
$scope.manageError)
|
||||||
};
|
};
|
||||||
$scope.addExpense = () => {
|
$scope.addExpense = function () {
|
||||||
$scope.expenses.push({
|
$scope.expenses.push({
|
||||||
name: "",
|
name: "",
|
||||||
repeat: 0,
|
repeat: 0,
|
||||||
|
@ -410,7 +428,7 @@ angular
|
||||||
amount: 0,
|
amount: 0,
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
$scope.init = () => {
|
$scope.init = function () {
|
||||||
$scope.fetchExpenses();
|
$scope.fetchExpenses();
|
||||||
};
|
};
|
||||||
$scope.manageError = (error) => {
|
$scope.manageError = (error) => {
|
||||||
|
@ -418,7 +436,7 @@ angular
|
||||||
$scope.config.loading = false;
|
$scope.config.loading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
$scope.updateCanevas = () => {
|
$scope.updateCanevas = function () {
|
||||||
var dataPoints = $scope.graphPointsPrevision;
|
var dataPoints = $scope.graphPointsPrevision;
|
||||||
var chartContainer = new CanvasJS.Chart("simulationPrevision", {
|
var chartContainer = new CanvasJS.Chart("simulationPrevision", {
|
||||||
title: {
|
title: {
|
||||||
|
|
Loading…
Reference in New Issue