From bb6deffd964a171d6e0f0857f17edc2b60084d38 Mon Sep 17 00:00:00 2001 From: Kayn Ty Date: Thu, 24 May 2018 16:56:19 +0200 Subject: [PATCH] timeout for success and count of objects sold --- .../views/logged/angular/current.html.twig | 17 ++++++------- .../logged/angular/listing-products.html.twig | 9 ++++--- .../logged/angular/loaded-caisse.html.twig | 2 +- .../views/logged/dashboard.html.twig | 24 ++++++++++++++++++- assets/css/pages/_dashboard.scss | 8 +++++++ assets/css/split/custom_vars.scss | 2 +- assets/css/split/formulaires.scss | 8 ++----- assets/js/parts/main.js | 24 ++++++++++++++++++- .../Controller/DefaultController.php | 1 + src/AppBundle/Entity/Festival.php | 12 ++++++++++ 10 files changed, 86 insertions(+), 21 deletions(-) diff --git a/app/Resources/views/logged/angular/current.html.twig b/app/Resources/views/logged/angular/current.html.twig index 6c666b50..20eed8a7 100755 --- a/app/Resources/views/logged/angular/current.html.twig +++ b/app/Resources/views/logged/angular/current.html.twig @@ -1,5 +1,5 @@ {% verbatim %} -
+
@@ -10,10 +10,13 @@ {{ activeFestival.fondDeCaisseAvant + activeFestival.chiffreAffaire}} € - CA {{ activeFestival.chiffreAffaire }} € + CA {{ activeFestival.chiffreAffaire }} € + + + + {{ activeFestival.clientsCount }} -
@@ -31,13 +34,12 @@

- +
diff --git a/app/Resources/views/logged/angular/listing-products.html.twig b/app/Resources/views/logged/angular/listing-products.html.twig index 4eacaaab..f99e57cc 100755 --- a/app/Resources/views/logged/angular/listing-products.html.twig +++ b/app/Resources/views/logged/angular/listing-products.html.twig @@ -1,7 +1,6 @@ {% verbatim %}
- -
+

{{ c.name }} @@ -18,9 +17,13 @@ {{ p.price }} € - + {{ p.stockCount }} + + + {{ countProductsSoldForActiveFestival[p.id] }} +

-
+
{% include 'logged/angular/validate-button.html.twig' %} {% if app.user.products |length %} diff --git a/app/Resources/views/logged/dashboard.html.twig b/app/Resources/views/logged/dashboard.html.twig index 7247b16d..19e233c9 100755 --- a/app/Resources/views/logged/dashboard.html.twig +++ b/app/Resources/views/logged/dashboard.html.twig @@ -17,7 +17,29 @@ ng-click="expressSelling = !expressSelling"> mode vente express - activé + + + + +
diff --git a/assets/css/pages/_dashboard.scss b/assets/css/pages/_dashboard.scss index a5f5daa9..1c2a171c 100755 --- a/assets/css/pages/_dashboard.scss +++ b/assets/css/pages/_dashboard.scss @@ -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; } diff --git a/assets/css/split/custom_vars.scss b/assets/css/split/custom_vars.scss index 1391f426..29095ace 100755 --- a/assets/css/split/custom_vars.scss +++ b/assets/css/split/custom_vars.scss @@ -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); diff --git a/assets/css/split/formulaires.scss b/assets/css/split/formulaires.scss index 25a5570b..ddfdd1f8 100755 --- a/assets/css/split/formulaires.scss +++ b/assets/css/split/formulaires.scss @@ -24,10 +24,6 @@ table { margin-right: 0.5em; margin-bottom: 0.5em; } - -label[required] { - &:after { - content: "*"; - color: red; - } +.remove-item{ + margin-left: -1rem; } diff --git a/assets/js/parts/main.js b/assets/js/parts/main.js index 7f8e9913..e01a9ac2 100755 --- a/assets/js/parts/main.js +++ b/assets/js/parts/main.js @@ -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(); })(); diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php index 5d356379..a6ad2758 100755 --- a/src/AppBundle/Controller/DefaultController.php +++ b/src/AppBundle/Controller/DefaultController.php @@ -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), diff --git a/src/AppBundle/Entity/Festival.php b/src/AppBundle/Entity/Festival.php index e694c66d..8cc1b404 100644 --- a/src/AppBundle/Entity/Festival.php +++ b/src/AppBundle/Entity/Festival.php @@ -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, ]; }