timeout for success and count of objects sold
This commit is contained in:
parent
9a97f7312d
commit
bb6deffd96
@ -10,10 +10,13 @@
|
||||
<i class="fa fa-archive"></i>
|
||||
{{ activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire}} €
|
||||
</span>
|
||||
<span class="badge badge-success">CA {{ activeFestival.chiffreAffaire }} €</span>
|
||||
<span class="badge badge-success">CA {{ activeFestival.chiffreAffaire }} €
|
||||
<span ng-if="sellingOk">
|
||||
<i class="fa fa-check-circle-o"></i>
|
||||
</span>
|
||||
</span>
|
||||
<span class="badge badge-success">{{ activeFestival.clientsCount }} <i class="fa fa-user"></i></span>
|
||||
</h2>
|
||||
|
||||
<input type="text" ng-model="activeFestival.name" placeholder="nom du festival">
|
||||
<input type="text" ng-model="activeFestival.commentaire" placeholder="commentaire">
|
||||
<hr>
|
||||
@ -31,13 +34,12 @@
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<ul>
|
||||
<li ng-repeat="p in activeSelling track by $index">
|
||||
<div ng-repeat="p in activeSelling track by $index">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<input type="text" ng-model="p.name">
|
||||
<span class="btn btn-warning input-group-addon remove-itm"
|
||||
<span class="btn btn-warning input-group-addon remove-item"
|
||||
ng-click="removeProduct(p,$index)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
@ -49,8 +51,7 @@
|
||||
€ </strong>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% verbatim %}
|
||||
<div class="row">
|
||||
|
||||
<div class="category-listing col-md-6 col-xs-12" ng-repeat="c in categories">
|
||||
<div class="category-listing" ng-repeat="c in categories">
|
||||
|
||||
<h2>
|
||||
{{ c.name }}
|
||||
@ -18,9 +17,13 @@
|
||||
<span class="badge">
|
||||
{{ p.price }} €
|
||||
</span>
|
||||
<span class="badge badge-default">
|
||||
<span class="badge badge-default" ng-if="show_config.stock_count">
|
||||
{{ p.stockCount }}
|
||||
</span>
|
||||
<span class="badge badge-success" ng-if="show_config.sold">
|
||||
<i class="fa fa-tick"></i>
|
||||
{{ countProductsSoldForActiveFestival[p.id] }}
|
||||
</span>
|
||||
</button>
|
||||
<button class="express-button" ng-if="expressSelling" ng-click="expressSell(p)" title="achat express sans compléter les infos du client">
|
||||
<i class="fa fa-shopping-cart"></i>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
</div>
|
||||
<div class="sellings col-xs-5">
|
||||
<div class="well">
|
||||
<div class="well" ng-class="{'bg-success text-success': sellingOk }">
|
||||
|
||||
{% include 'logged/angular/validate-button.html.twig' %}
|
||||
{% if app.user.products |length %}
|
||||
|
@ -17,7 +17,29 @@
|
||||
ng-click="expressSelling = !expressSelling">
|
||||
<i class="fa fa-shopping-cart"></i>
|
||||
mode vente express
|
||||
<span ng-if=expressSelling>activé</span>
|
||||
<span ng-if=expressSelling>
|
||||
<i class="fa fa-check-circle"></i></span>
|
||||
</button>
|
||||
<button
|
||||
title="montrer le nombre d'objets restants dans les stocks"
|
||||
class="btn"
|
||||
ng-class="{'btn-success': show_config.stock_count, 'btn-disabled':!show_config.stock_count}"
|
||||
ng-click="show_config.stock_count = !show_config.stock_count">
|
||||
<i class="fa fa-shopping-cart"></i>
|
||||
stocks
|
||||
<span ng-if=show_config.stock_count>
|
||||
<i class="fa fa-check-circle"></i></span>
|
||||
</button>
|
||||
<button
|
||||
title="montrer le nombre d'objets restants dans les stocks"
|
||||
class="btn"
|
||||
ng-class="{'btn-success': show_config.sold, 'btn-disabled':!show_config.sold}"
|
||||
ng-click="show_config.sold = !show_config.sold">
|
||||
<i class="fa fa-shopping-cart"></i>
|
||||
vendus
|
||||
<span ng-if=show_config.sold>
|
||||
<i class="fa fa-check-circle"></i>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
|
@ -37,6 +37,14 @@
|
||||
|
||||
}
|
||||
|
||||
.category-listing{
|
||||
border: solid 1px $grey;
|
||||
padding: 1rem;
|
||||
margin: 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
width: calc(50% - 2rem);
|
||||
float: left;
|
||||
}
|
||||
.validate_selling {
|
||||
margin: 0.25rem;
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ $dark: #222;
|
||||
$light: #dedede;
|
||||
$deepblue: #1b6d85;
|
||||
$lightblue: lightblue;
|
||||
|
||||
$grey: #e3e3e3;
|
||||
$logo-color: mix($deepblue, $light);
|
||||
$all-text-color: mix($deepblue, $light);
|
||||
|
@ -24,10 +24,6 @@ table {
|
||||
margin-right: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
label[required] {
|
||||
&:after {
|
||||
content: "*";
|
||||
color: red;
|
||||
}
|
||||
.remove-item{
|
||||
margin-left: -1rem;
|
||||
}
|
||||
|
@ -17,16 +17,21 @@ var stuff = ['initialstuff'];
|
||||
|
||||
angular
|
||||
.module('caisse', [])
|
||||
.controller('CaisseCtrl', ['$scope', '$http', function ($scope, $http, stuff) {
|
||||
.controller('CaisseCtrl', ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
|
||||
$scope.productsFromDB = []; // loaded products
|
||||
$scope.categories = []; // product categories
|
||||
$scope.sellingComment = "un gens"; // comment about the client or the current selling
|
||||
$scope.initLoadDone = false; // becames true after first init of product loading
|
||||
$scope.recentSellings = [];
|
||||
$scope.lesParams = {};
|
||||
$scope.countProductsSoldForActiveFestival = {};
|
||||
$scope.paidAmount = 0;
|
||||
$scope.expressSelling = true;
|
||||
$scope.pausedSelling = [];
|
||||
$scope.show_config = {
|
||||
stock_count: false,
|
||||
sold: true,
|
||||
};
|
||||
$scope.activeItemsSold = []; // list of products ID to sell
|
||||
$scope.activeSelling = []; // list of products to sell
|
||||
$scope.activeFestival = { // an event where selling take place
|
||||
@ -129,6 +134,9 @@ angular
|
||||
$scope.activeFestival.fondDeCaisseAvant = rep.data.lastFestival.fondDeCaisseAvant;
|
||||
$scope.activeFestival.fondDeCaisseApres = rep.data.lastFestival.fondDeCaisseApres;
|
||||
$scope.activeFestival.clientsCount = rep.data.lastFestival.clientsCount;
|
||||
// stat count for items
|
||||
$scope.countProductsSoldForActiveFestival = rep.data.lastFestival.sold;
|
||||
console.log(' $scope.countProductsSoldForActiveFestival', $scope.countProductsSoldForActiveFestival)
|
||||
//done
|
||||
$scope.initLoadDone = true;
|
||||
}, (err) => {
|
||||
@ -180,6 +188,8 @@ angular
|
||||
$scope.successMessage = rep.data.message;
|
||||
$scope.activeFestival.chiffreAffaire = rep.data.newChiffreAffaire;
|
||||
$scope.activeFestival.clientsCount = rep.data.clientsCount;
|
||||
$scope.countProductsSoldForActiveFestival = rep.data.activeFestival.sold;
|
||||
$scope.showTemporaryMessage();
|
||||
console.log(rep);
|
||||
if (!rep.success) {
|
||||
// if not successful, bind errors to error variables
|
||||
@ -191,6 +201,18 @@ angular
|
||||
;
|
||||
};
|
||||
|
||||
$scope.sellingOk = false;
|
||||
$scope.tempMessage = {};
|
||||
$scope.showTemporaryMessage = function(){
|
||||
if($scope.sellingOk ){
|
||||
return;
|
||||
}
|
||||
$scope.sellingOk = true;
|
||||
$timeout.cancel($scope.tempMessage );
|
||||
$scope.tempMessage = $timeout(function(){
|
||||
$scope.sellingOk=false;
|
||||
},2000)
|
||||
};
|
||||
$scope.init = (function () {
|
||||
$scope.fetchProductsFromDB();
|
||||
})();
|
||||
|
@ -215,6 +215,7 @@ class DefaultController extends Controller
|
||||
|
||||
return new JsonResponse([
|
||||
"message" => "ok",
|
||||
"activeFestival" => $festivalFound->makeArray(),
|
||||
"newChiffreAffaire" => $festivalFound->getChiffreAffaire(),
|
||||
"clientsCount" => count($festivalFound->getSellRecords()),
|
||||
"recent_sellings" => json_encode($lastSellings),
|
||||
|
@ -88,6 +88,17 @@ class Festival {
|
||||
* @return array
|
||||
*/
|
||||
public function makeArray(){
|
||||
$sellRecords = $this->getSellRecords();
|
||||
$soldItems = [];
|
||||
foreach ( $sellRecords as $sell_record ) {
|
||||
foreach ( $sell_record->getProductsSold() as $sold ) {
|
||||
if(!isset($soldItems[$sold->getProduct()->getId()])){
|
||||
$soldItems[$sold->getProduct()->getId()] = 0;
|
||||
}
|
||||
$soldItems[$sold->getProduct()->getId()]++;
|
||||
}
|
||||
|
||||
}
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'name' => $this->getName(),
|
||||
@ -97,6 +108,7 @@ class Festival {
|
||||
'clientsCount' => count($this->getSellRecords()),
|
||||
'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(),
|
||||
'fondDeCaisseApres' => $this->getFondDeCaisseApres(),
|
||||
'sold' => $soldItems,
|
||||
];
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user