This commit is contained in:
Kayn Ty 2018-04-19 16:26:48 +02:00
parent 2f16a34aa4
commit af4c5415dd
5 changed files with 42 additions and 10 deletions

View File

@ -8,7 +8,9 @@
Votre caisse mobile dynamique en ligne
</div>
<div class="try">
<a class="btn btn-primary" href="{{ path('dashboard') }}" class="btn btn-primary">Essayez dès maintenant</a>
<a class="btn btn-primary" href="{{ path('fos_user_security_login') }}" class="btn btn-primary">Essayez dès
maintenant
</a>
</div>
</div>
{% include 'default/description-app.html.twig' %}
@ -26,7 +28,6 @@
</p>
</div>
<div class="col-xs-6">
<a class="btn btn-primary" href="{{ path('fos_user_registration_register') }}">
<i class="fa fa-user"></i>
Créer un compte

View File

@ -1,10 +1,13 @@
{% verbatim %}
<div class="current-selling">
<form action="#">
<form action="#container">
<h2>
Festival:</h2>
Festival:
<span class="badge badge-success">{{ activeFestival.chiffreAffaire }} €</span>
</h2>
<input type="text" ng-model="activeFestival.name" placeholder="nom du festival">
<input type="text" ng-model="activeFestival.commentaire" placeholder="commentaire">
<hr>
@ -13,7 +16,8 @@
<i class="fa fa-user"></i> Client actuel:
</h2>
{{ activeSelling.length }} produit<span ng-if="activeSelling.length>1">s</span>
<input class="input input-lg" type="text" ng-model="sellingComment" placeholder="nom ou commentaire">
<input id="sellingComment" name="sellingComment" class="input input-lg" type="text" ng-model="sellingComment" placeholder="nom ou commentaire">
{{ sellingComment }}
<hr>
<ul>
<li ng-repeat="p in activeSelling track by $index">

View File

@ -5,7 +5,7 @@ angular
.controller('CaisseCtrl', ['$scope', '$http', function ($scope, $http, stuff) {
$scope.productsFromDB = []; // loaded products
$scope.categories = []; // product categories
$scope.sellingComment = ""; // 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.recentSellings = [];
$scope.lesParams = {};
@ -14,10 +14,11 @@ angular
$scope.activeItemsSold = []; // list of products ID to sell
$scope.activeSelling = []; // list of products to sell
$scope.activeFestival = { // an event where selling take place
id : null,
name : "le festival",
dateCreation: new Date(),
commentaire : ""
id : null,
name : "le festival",
dateCreation : new Date(),
chiffreAffaire: 0,
commentaire : ""
};
/**
* get the sum of products prices
@ -42,9 +43,11 @@ angular
$scope.regenActiveSellingIds = function () {
$scope.activeItemsSold = [];
$scope.paidAmount = 0;
for (let obj in $scope.activeSelling) {
$scope.activeItemsSold.push(obj.id);
}
$scope.paidAmount += $scope.sumOfList($scope.activeSelling);
};
$scope.stuff = stuff;
$scope.setActiveSelling = function (selling) {
@ -56,6 +59,9 @@ angular
$scope.addProduct = function (product) {
$scope.activeSelling.push(product);
$scope.activeItemsSold.push(product.id);
$scope.regenActiveSellingIds();
document.querySelector('#sellingComment').focus()
};
$scope.pauseSelling = function () {
$scope.pausedSelling.push(angular.copy($scope.activeSelling));
@ -85,6 +91,7 @@ angular
$scope.activeFestival.name = rep.data.lastFestival.name;
$scope.activeFestival.dateCreation = rep.data.lastFestival.dateCreation;
$scope.activeFestival.commentaire = rep.data.lastFestival.commentaire;
$scope.activeFestival.chiffreAffaire = rep.data.lastFestival.chiffreAffaire;
//done
$scope.initLoadDone = true;
}, (err) => {
@ -117,6 +124,7 @@ angular
} else {
// if successful, bind success message to message
$scope.successMessage = rep.data.message;
$scope.activeFestival.chiffreAffaire = rep.data.new_ca_festival;
// changer le type de bout de phrase demandé
$scope.formData["tykayn_portfoliobundle_cadexqphrasepart[type]"]["$viewValue"] = 'nouveauType';
}

View File

@ -54,6 +54,7 @@ class DefaultController extends Controller {
0,
1 );
}
$lastFestival->recalculateChiffreAffaire();
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$categories = $categRepo->findAll();
@ -153,6 +154,7 @@ class DefaultController extends Controller {
'name' => $activeFestival->getName(),
'commentaire' => $activeFestival->getComment(),
'dateCreation' => $activeFestival->getDateCreation(),
'chiffreAffaire' => $activeFestival->getChiffreAffaire(),
'fondDeCaisseAvant' => $activeFestival->getFondDeCaisseAvant(),
'fondDeCaisseApres' => $activeFestival->getFondDeCaisseApres(),
],
@ -210,10 +212,13 @@ class DefaultController extends Controller {
$newSellRecord->setPaidByClient( $json[ 'paidByClient' ] );
$newSellRecord->setComment( $json[ 'sellingComment' ] );
$festivalFound->recalculateChiffreAffaire();
$currentUser->addSellRecords( $newSellRecord );
$m->persist( $newSellRecord );
$m->persist( $currentUser );
$m->persist( $festivalFound );
$m->flush();
// setup dates
@ -224,6 +229,7 @@ class DefaultController extends Controller {
return new JsonResponse( [
"message" => "ok",
"new_ca_festival" => $festivalFound->getChiffreAffaire(),
"recent_sellings" => json_encode( $lastSellings ),
"dump" => $json,
], 200 );

View File

@ -66,6 +66,19 @@ class Festival {
*/
private $chiffreAffaire;
public function recalculateChiffreAffaire() {
$sellings = $this->getSellRecords();
$newChiffreAffaire = 0;
foreach ( $sellings as $selling ) {
$newChiffreAffaire += $selling->getAmount();
}
$this->setChiffreAffaire( $newChiffreAffaire );
return $this;
}
/**
* Get id
*