sum of products ok

This commit is contained in:
Kayn Ty 2018-04-05 17:01:36 +02:00
parent 6543115387
commit 0b49351588
4 changed files with 79 additions and 24 deletions

View File

@ -32,14 +32,21 @@
<div class="sellings col-xs-5"> <div class="sellings col-xs-5">
<div class="current-selling"> <div class="current-selling">
<form action="#"> <form action="#">
Festival: {{activeFestival.name}}
<input type="text" ng-model="activeFestival.commentaire"> <input type="text" ng-model="activeFestival.commentaire">
<hr>
{{activeSelling.length}} produits
<ul> <ul>
<li ng-repeat="p in activeSelling track by $index"> <li ng-repeat="p in activeSelling track by $index">
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
{{p.name}} <div class="input-group">
<div class="btn btn-warning" ng-click="activeSelling.splice($index,1)"> <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> <i class="fa fa-trash"></i>
</div>
</div> </div>
</div> </div>
<div class="col-xs-6 text-right"> <div class="col-xs-6 text-right">
@ -52,22 +59,25 @@
</li> </li>
</ul> </ul>
<h3>Total: {{CurrentSellingTotal}}€</h3> <div class="text-right">
<h3 >Total: <strong>{{CurrentSellingTotal()}}€</strong></h3>
<input type="number" id="paid_amount" ng-model="paidAmount"> <input type="number" id="paid_amount" ng-model="paidAmount">
<h3>Rendu: {{ abs(CurrentSellingTotal - paidAmount) }}€</h3> <h3>Rendu: {{ CurrentSellingTotal() - paidAmount }}€</h3>
</div>
{% endverbatim %} {% endverbatim %}
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<button class="btn btn-default" id="pause_selling"> <button class="btn btn-primary btn-block" id="validate_selling" ng-click="sendForm()">
<i class="fa fa-clock"></i> <i class="fa fa-check"></i>
Pause Valider
</button> </button>
</div> </div>
<div class="col"> <div class="col">
<button class="btn btn-primary btn-block" id="validate_selling"> <button class="btn btn-default" id="pause_selling" ng-click="pauseSelling()">
<i class="fa fa-check"></i> <i class="fa fa-clock"></i>
Valider Pause
</button> </button>
</div> </div>
</div> </div>
@ -80,10 +90,16 @@
<h4> <h4>
Ventes en pause Ventes en pause
</h4> </h4>
{% verbatim %}
<ul> <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> </ul>
{% endverbatim %}
<hr> <hr>
</div> </div>
<div class="selling-history"> <div class="selling-history">

View File

@ -0,0 +1,5 @@
.current-selling {
ul {
list-style-type: none;
}
}

View File

@ -18,9 +18,26 @@ angular
dateCreation: new Date(), dateCreation: new Date(),
commentaire : "" commentaire : ""
}; };
$scope.CurrentSellingTotal = $scope.activeSelling.reduce(function (a, b) { /**
return a + b.price; * get the sum of products prices
}, 0); * @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.stuff = stuff;
$scope.setActiveSelling = function (selling) { $scope.setActiveSelling = function (selling) {
@ -43,11 +60,13 @@ angular
console.log(err); console.log(err);
}); });
}; };
$scope.init = (function () { $scope.pauseSelling = function () {
$scope.fetchProductsFromDB(); $scope.pausedSelling.push(angular.copy($scope.activeSelling));
})(); $scope.activeSelling = [];
$scope.logtest = function () { };
console.log('log test ok'); $scope.setBackPausedSelling = function (sellingList, index) {
$scope.activeSelling = angular.copy(sellingList);
$scope.pausedSelling.splice(index, 1);
}; };
$scope.sendForm = function () { $scope.sendForm = function () {
let lesParams = { let lesParams = {
@ -74,5 +93,9 @@ angular
}) })
; ;
}; };
$scope.init = (function () {
$scope.fetchProductsFromDB();
})();
}]); }]);

View File

@ -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" ] ); return new JsonResponse( [ "message" => "ok" ] );
} }
} }