fix update after add selling
This commit is contained in:
parent
af4c5415dd
commit
f2ac806dc1
@ -1,11 +1,13 @@
|
||||
{% verbatim %}
|
||||
<div class="current-selling">
|
||||
|
||||
<form action="#container">
|
||||
<form >
|
||||
|
||||
<h2>
|
||||
|
||||
Festival:
|
||||
<span class="badge badge-success">{{ activeFestival.chiffreAffaire }} €</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">
|
||||
@ -80,7 +82,8 @@
|
||||
<!--</button>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</form>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<button class="btn btn-primary btn-block" id="validate_selling" ng-click="sendForm()"
|
||||
<button class="btn btn-primary btn-block" id="validate_selling" ng-click="sendForm(event)"
|
||||
ng-disabled="!paidAmount">
|
||||
<i class="fa fa-check"></i>
|
||||
|
||||
|
@ -18,6 +18,7 @@ angular
|
||||
name : "le festival",
|
||||
dateCreation : new Date(),
|
||||
chiffreAffaire: 0,
|
||||
clientsCount : 0,
|
||||
commentaire : ""
|
||||
};
|
||||
/**
|
||||
@ -92,6 +93,7 @@ angular
|
||||
$scope.activeFestival.dateCreation = rep.data.lastFestival.dateCreation;
|
||||
$scope.activeFestival.commentaire = rep.data.lastFestival.commentaire;
|
||||
$scope.activeFestival.chiffreAffaire = rep.data.lastFestival.chiffreAffaire;
|
||||
$scope.activeFestival.clientsCount = rep.data.lastFestival.clientsCount;
|
||||
//done
|
||||
$scope.initLoadDone = true;
|
||||
}, (err) => {
|
||||
@ -103,7 +105,7 @@ angular
|
||||
$scope.sendForm = function () {
|
||||
let lesParams = {
|
||||
paidByClient : $scope.paidAmount,
|
||||
sellingComment: $scope.sellingComment,
|
||||
sellingComment: angular.copy($scope.sellingComment),
|
||||
activeSelling : $scope.activeSelling,
|
||||
activeFestival: $scope.activeFestival
|
||||
};
|
||||
@ -117,16 +119,14 @@ angular
|
||||
data : lesParams // pass in data as strings
|
||||
}).then(function (rep) {
|
||||
$scope.clearCurrentSelling();
|
||||
// if successful, bind success message to message
|
||||
$scope.successMessage = rep.data.message;
|
||||
$scope.activeFestival.chiffreAffaire = rep.data.newChiffreAffaire;
|
||||
$scope.activeFestival.clientsCount = rep.data.clientsCount;
|
||||
console.log(rep);
|
||||
if (!rep.success) {
|
||||
// if not successful, bind errors to error variables
|
||||
$scope.errors = rep.errors;
|
||||
} 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';
|
||||
}
|
||||
}, function (rep) {
|
||||
console.log('nope! ', rep.data);
|
||||
|
@ -155,6 +155,7 @@ class DefaultController extends Controller {
|
||||
'commentaire' => $activeFestival->getComment(),
|
||||
'dateCreation' => $activeFestival->getDateCreation(),
|
||||
'chiffreAffaire' => $activeFestival->getChiffreAffaire(),
|
||||
'clientsCount' => count( $activeFestival->getSellRecords() ),
|
||||
'fondDeCaisseAvant' => $activeFestival->getFondDeCaisseAvant(),
|
||||
'fondDeCaisseApres' => $activeFestival->getFondDeCaisseApres(),
|
||||
],
|
||||
@ -212,8 +213,8 @@ class DefaultController extends Controller {
|
||||
$newSellRecord->setPaidByClient( $json[ 'paidByClient' ] );
|
||||
$newSellRecord->setComment( $json[ 'sellingComment' ] );
|
||||
|
||||
$festivalFound->recalculateChiffreAffaire();
|
||||
|
||||
$festivalFound->addSellRecord( $newSellRecord );
|
||||
$currentUser->addSellRecords( $newSellRecord );
|
||||
|
||||
$m->persist( $newSellRecord );
|
||||
@ -221,6 +222,10 @@ class DefaultController extends Controller {
|
||||
$m->persist( $festivalFound );
|
||||
$m->flush();
|
||||
|
||||
$festivalFound->recalculateChiffreAffaire();
|
||||
$m->persist( $festivalFound );
|
||||
$m->flush();
|
||||
|
||||
// setup dates
|
||||
|
||||
// fetch back history of selling
|
||||
@ -229,7 +234,8 @@ class DefaultController extends Controller {
|
||||
|
||||
return new JsonResponse( [
|
||||
"message" => "ok",
|
||||
"new_ca_festival" => $festivalFound->getChiffreAffaire(),
|
||||
"newChiffreAffaire" => $festivalFound->getChiffreAffaire(),
|
||||
"clientsCount" => count( $festivalFound->getSellRecords() ),
|
||||
"recent_sellings" => json_encode( $lastSellings ),
|
||||
"dump" => $json,
|
||||
], 200 );
|
||||
|
Loading…
Reference in New Issue
Block a user