timeout for success and count of objects sold

This commit is contained in:
Kayn Ty 2018-05-24 16:56:19 +02:00
parent 9a97f7312d
commit bb6deffd96
No known key found for this signature in database
GPG Key ID: 55B09AA0ED327CD3
10 changed files with 86 additions and 21 deletions

View File

@ -1,5 +1,5 @@
{% verbatim %} {% verbatim %}
<div class="current-selling"> <div class="current-selling" >
<form > <form >
@ -10,10 +10,13 @@
<i class="fa fa-archive"></i> <i class="fa fa-archive"></i>
{{ activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire}} € {{ activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire}} €
</span> </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> <span class="badge badge-success">{{ activeFestival.clientsCount }} <i class="fa fa-user"></i></span>
</h2> </h2>
<input type="text" ng-model="activeFestival.name" placeholder="nom du festival"> <input type="text" ng-model="activeFestival.name" placeholder="nom du festival">
<input type="text" ng-model="activeFestival.commentaire" placeholder="commentaire"> <input type="text" ng-model="activeFestival.commentaire" placeholder="commentaire">
<hr> <hr>
@ -31,13 +34,12 @@
</div> </div>
<hr> <hr>
<ul> <div 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">
<div class="input-group"> <div class="input-group">
<input type="text" ng-model="p.name"> <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)"> ng-click="removeProduct(p,$index)">
<i class="fa fa-trash"></i> <i class="fa fa-trash"></i>
</span> </span>
@ -49,8 +51,7 @@
€ </strong> € </strong>
</div> </div>
</div> </div>
</li> </div>
</ul>
<div class="text-right"> <div class="text-right">
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">

View File

@ -1,7 +1,6 @@
{% verbatim %} {% verbatim %}
<div class="row"> <div class="row">
<div class="category-listing" ng-repeat="c in categories">
<div class="category-listing col-md-6 col-xs-12" ng-repeat="c in categories">
<h2> <h2>
{{ c.name }} {{ c.name }}
@ -18,9 +17,13 @@
<span class="badge"> <span class="badge">
{{ p.price }} {{ p.price }}
</span> </span>
<span class="badge badge-default"> <span class="badge badge-default" ng-if="show_config.stock_count">
{{ p.stockCount }} {{ p.stockCount }}
</span> </span>
<span class="badge badge-success" ng-if="show_config.sold">
<i class="fa fa-tick"></i>
{{ countProductsSoldForActiveFestival[p.id] }}
</span>
</button> </button>
<button class="express-button" ng-if="expressSelling" ng-click="expressSell(p)" title="achat express sans compléter les infos du client"> <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> <i class="fa fa-shopping-cart"></i>

View File

@ -12,7 +12,7 @@
</div> </div>
<div class="sellings col-xs-5"> <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' %} {% include 'logged/angular/validate-button.html.twig' %}
{% if app.user.products |length %} {% if app.user.products |length %}

View File

@ -17,7 +17,29 @@
ng-click="expressSelling = !expressSelling"> ng-click="expressSelling = !expressSelling">
<i class="fa fa-shopping-cart"></i> <i class="fa fa-shopping-cart"></i>
mode vente express 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> </button>
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">

View File

@ -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 { .validate_selling {
margin: 0.25rem; margin: 0.25rem;
} }

View File

@ -2,6 +2,6 @@ $dark: #222;
$light: #dedede; $light: #dedede;
$deepblue: #1b6d85; $deepblue: #1b6d85;
$lightblue: lightblue; $lightblue: lightblue;
$grey: #e3e3e3;
$logo-color: mix($deepblue, $light); $logo-color: mix($deepblue, $light);
$all-text-color: mix($deepblue, $light); $all-text-color: mix($deepblue, $light);

View File

@ -24,10 +24,6 @@ table {
margin-right: 0.5em; margin-right: 0.5em;
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.remove-item{
label[required] { margin-left: -1rem;
&:after {
content: "*";
color: red;
}
} }

View File

@ -17,16 +17,21 @@ var stuff = ['initialstuff'];
angular angular
.module('caisse', []) .module('caisse', [])
.controller('CaisseCtrl', ['$scope', '$http', function ($scope, $http, stuff) { .controller('CaisseCtrl', ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
$scope.productsFromDB = []; // loaded products $scope.productsFromDB = []; // loaded products
$scope.categories = []; // product categories $scope.categories = []; // product categories
$scope.sellingComment = "un gens"; // comment about the client or the current selling $scope.sellingComment = "un gens"; // comment about the client or the current selling
$scope.initLoadDone = false; // becames true after first init of product loading $scope.initLoadDone = false; // becames true after first init of product loading
$scope.recentSellings = []; $scope.recentSellings = [];
$scope.lesParams = {}; $scope.lesParams = {};
$scope.countProductsSoldForActiveFestival = {};
$scope.paidAmount = 0; $scope.paidAmount = 0;
$scope.expressSelling = true; $scope.expressSelling = true;
$scope.pausedSelling = []; $scope.pausedSelling = [];
$scope.show_config = {
stock_count: false,
sold: true,
};
$scope.activeItemsSold = []; // list of products ID to sell $scope.activeItemsSold = []; // list of products ID to sell
$scope.activeSelling = []; // list of products to sell $scope.activeSelling = []; // list of products to sell
$scope.activeFestival = { // an event where selling take place $scope.activeFestival = { // an event where selling take place
@ -129,6 +134,9 @@ angular
$scope.activeFestival.fondDeCaisseAvant = rep.data.lastFestival.fondDeCaisseAvant; $scope.activeFestival.fondDeCaisseAvant = rep.data.lastFestival.fondDeCaisseAvant;
$scope.activeFestival.fondDeCaisseApres = rep.data.lastFestival.fondDeCaisseApres; $scope.activeFestival.fondDeCaisseApres = rep.data.lastFestival.fondDeCaisseApres;
$scope.activeFestival.clientsCount = rep.data.lastFestival.clientsCount; $scope.activeFestival.clientsCount = rep.data.lastFestival.clientsCount;
// stat count for items
$scope.countProductsSoldForActiveFestival = rep.data.lastFestival.sold;
console.log(' $scope.countProductsSoldForActiveFestival', $scope.countProductsSoldForActiveFestival)
//done //done
$scope.initLoadDone = true; $scope.initLoadDone = true;
}, (err) => { }, (err) => {
@ -180,6 +188,8 @@ angular
$scope.successMessage = rep.data.message; $scope.successMessage = rep.data.message;
$scope.activeFestival.chiffreAffaire = rep.data.newChiffreAffaire; $scope.activeFestival.chiffreAffaire = rep.data.newChiffreAffaire;
$scope.activeFestival.clientsCount = rep.data.clientsCount; $scope.activeFestival.clientsCount = rep.data.clientsCount;
$scope.countProductsSoldForActiveFestival = rep.data.activeFestival.sold;
$scope.showTemporaryMessage();
console.log(rep); console.log(rep);
if (!rep.success) { if (!rep.success) {
// if not successful, bind errors to error variables // 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.init = (function () {
$scope.fetchProductsFromDB(); $scope.fetchProductsFromDB();
})(); })();

View File

@ -215,6 +215,7 @@ class DefaultController extends Controller
return new JsonResponse([ return new JsonResponse([
"message" => "ok", "message" => "ok",
"activeFestival" => $festivalFound->makeArray(),
"newChiffreAffaire" => $festivalFound->getChiffreAffaire(), "newChiffreAffaire" => $festivalFound->getChiffreAffaire(),
"clientsCount" => count($festivalFound->getSellRecords()), "clientsCount" => count($festivalFound->getSellRecords()),
"recent_sellings" => json_encode($lastSellings), "recent_sellings" => json_encode($lastSellings),

View File

@ -88,6 +88,17 @@ class Festival {
* @return array * @return array
*/ */
public function makeArray(){ 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 [ return [
'id' => $this->getId(), 'id' => $this->getId(),
'name' => $this->getName(), 'name' => $this->getName(),
@ -97,6 +108,7 @@ class Festival {
'clientsCount' => count($this->getSellRecords()), 'clientsCount' => count($this->getSellRecords()),
'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(), 'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(),
'fondDeCaisseApres' => $this->getFondDeCaisseApres(), 'fondDeCaisseApres' => $this->getFondDeCaisseApres(),
'sold' => $soldItems,
]; ];
} }