sum of products ok
This commit is contained in:
parent
6543115387
commit
0b49351588
@ -32,14 +32,21 @@
|
||||
<div class="sellings col-xs-5">
|
||||
<div class="current-selling">
|
||||
<form action="#">
|
||||
<input type="text" ng-model="activeFestival.commentaire">
|
||||
Festival: {{activeFestival.name}}
|
||||
<input type="text" ng-model="activeFestival.commentaire">
|
||||
<hr>
|
||||
{{activeSelling.length}} produits
|
||||
<ul>
|
||||
<li ng-repeat="p in activeSelling track by $index">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
{{p.name}}
|
||||
<div class="btn btn-warning" ng-click="activeSelling.splice($index,1)">
|
||||
<i class="fa fa-trash"></i>
|
||||
<div class="input-group">
|
||||
<input type="text" ng-model="p.name">
|
||||
<div class="btn btn-warning input-group-addon" ng-click="activeSelling.splice($index,1)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
@ -52,22 +59,25 @@
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Total: {{CurrentSellingTotal}}€</h3>
|
||||
<div class="text-right">
|
||||
<h3 >Total: <strong>{{CurrentSellingTotal()}}€</strong></h3>
|
||||
<input type="number" id="paid_amount" ng-model="paidAmount">
|
||||
<h3>Rendu: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||
</div>
|
||||
|
||||
<input type="number" id="paid_amount" ng-model="paidAmount">
|
||||
<h3>Rendu: {{ abs(CurrentSellingTotal - paidAmount) }}€</h3>
|
||||
{% endverbatim %}
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
<button class="btn btn-default" id="pause_selling">
|
||||
<i class="fa fa-clock"></i>
|
||||
Pause
|
||||
<button class="btn btn-primary btn-block" id="validate_selling" ng-click="sendForm()">
|
||||
<i class="fa fa-check"></i>
|
||||
Valider
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary btn-block" id="validate_selling">
|
||||
<i class="fa fa-check"></i>
|
||||
Valider
|
||||
<button class="btn btn-default" id="pause_selling" ng-click="pauseSelling()">
|
||||
<i class="fa fa-clock"></i>
|
||||
Pause
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -80,10 +90,16 @@
|
||||
<h4>
|
||||
Ventes en pause
|
||||
</h4>
|
||||
|
||||
{% verbatim %}
|
||||
<ul>
|
||||
<li>h:m:s xxxx€</li>
|
||||
<li ng-repeat="list in pausedSellings track by $index" ng-click="setBackPausedSelling(list, $index)">
|
||||
{{ $index }}) {{ list.products.length }} produits,
|
||||
<strong>
|
||||
{{ sumOfList(list) }}€
|
||||
</strong>
|
||||
</li>
|
||||
</ul>
|
||||
{% endverbatim %}
|
||||
<hr>
|
||||
</div>
|
||||
<div class="selling-history">
|
||||
|
@ -0,0 +1,5 @@
|
||||
.current-selling {
|
||||
ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
}
|
@ -18,9 +18,26 @@ angular
|
||||
dateCreation: new Date(),
|
||||
commentaire : ""
|
||||
};
|
||||
$scope.CurrentSellingTotal = $scope.activeSelling.reduce(function (a, b) {
|
||||
return a + b.price;
|
||||
}, 0);
|
||||
/**
|
||||
* get the sum of products prices
|
||||
* @param list
|
||||
* @returns {number}
|
||||
*/
|
||||
$scope.sumOfList = function (list) {
|
||||
let counter = 0;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
counter += list[i].price;
|
||||
}
|
||||
return counter;
|
||||
};
|
||||
/**
|
||||
* sum of current selling list prices
|
||||
* @returns {number}
|
||||
* @constructor
|
||||
*/
|
||||
$scope.CurrentSellingTotal = function () {
|
||||
return $scope.sumOfList($scope.activeSelling);
|
||||
};
|
||||
|
||||
$scope.stuff = stuff;
|
||||
$scope.setActiveSelling = function (selling) {
|
||||
@ -43,11 +60,13 @@ angular
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
$scope.init = (function () {
|
||||
$scope.fetchProductsFromDB();
|
||||
})();
|
||||
$scope.logtest = function () {
|
||||
console.log('log test ok');
|
||||
$scope.pauseSelling = function () {
|
||||
$scope.pausedSelling.push(angular.copy($scope.activeSelling));
|
||||
$scope.activeSelling = [];
|
||||
};
|
||||
$scope.setBackPausedSelling = function (sellingList, index) {
|
||||
$scope.activeSelling = angular.copy(sellingList);
|
||||
$scope.pausedSelling.splice(index, 1);
|
||||
};
|
||||
$scope.sendForm = function () {
|
||||
let lesParams = {
|
||||
@ -74,5 +93,9 @@ angular
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
$scope.init = (function () {
|
||||
$scope.fetchProductsFromDB();
|
||||
})();
|
||||
}]);
|
||||
|
||||
|
@ -111,7 +111,18 @@ class DefaultController extends Controller {
|
||||
] );
|
||||
}
|
||||
|
||||
public function addSellingAction() {
|
||||
/**
|
||||
* @param Request $request
|
||||
* add a selling record corresponding to one client
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function addSellingAction( Request $request ) {
|
||||
var_dump( $request->request );
|
||||
// link selling record with user, festival
|
||||
// setup dates
|
||||
// persist all
|
||||
// fetch back history of selling
|
||||
return new JsonResponse( [ "message" => "ok" ] );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user