bug historique ok

thierry
Tmadkaud 7 years ago
parent 44b75971d3
commit a203ba8dea

@ -26,7 +26,7 @@
<div class="card-block row no-margin">
<div class="col-md-8" id="subCard2Part1">
<div class="md-form">
<input mdbActive type="number" id="form1" class="form-control" step="any">
<input mdbActive type="number" id="form1" class="form-control" step="any" [(ngModel)]="tarifXJCParr" name="tarifXJCPar" #tarifXJCPar="ngModel">
<label for="form1" class="">Tarif XJC</label>
</div>
<div id="opTitle">
@ -39,8 +39,8 @@
</div>
</div>
<div class="col-md-2" id="subCard2Part2">
<button type="button" class="btn btn-success btn-rounded waves-light" mdbRippleRadius (click)="valider(op.uid)">Valider</button>
<button type="button" class="btn btn-danger btn-rounded waves-light" mdbRippleRadius (click)="rejeter(op.uid)">Rejeter</button>
<button type="button" class="btn btn-success btn-rounded waves-light" mdbRippleRadius [disabled]="tarifXJCParr <= 0" (click)="valider(op)">Valider</button>
<button type="button" class="btn btn-danger btn-rounded waves-light" mdbRippleRadius (click)="rejeter(op)">Rejeter</button>
</div>
</div>
</div>
@ -84,6 +84,10 @@
<div class="col-md-6 card subCard2">
<div class="card-block row no-margin">
<div class="col-md-8" id="subCard2Part1">
<div class="md-form">
<input mdbActive type="number" id="form1" class="form-control" step="any" [(ngModel)]="tarifXJCParr" name="tarifXJCPar" #tarifXJCPar="ngModel">
<label for="form1" class="">Tarif XJC</label>
</div>
<div id="opTitle">
<label>Operation Commerciale: {{op.name}}</label>
</div>
@ -98,7 +102,7 @@
</div>
</div>
<div class="col-md-2" id="subCard2Part2">
<button class="btn btn-success btn-rounded waves-light" (click)="valider(op.uid)">Valider</button>
<button class="btn btn-success btn-rounded waves-light" [disabled]="tarifXJCParr <= 0" (click)="valider(op)">Valider</button>
</div>
</div>
</div>

@ -25,6 +25,7 @@ export class DemandeOpCommercialComponent implements OnInit, OnDestroy {
profileData: FirebaseListObservable<any[]>;
commercant: Commercant;
databaseRef: any;
tarifXJCParr: number;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
@ -32,6 +33,7 @@ export class DemandeOpCommercialComponent implements OnInit, OnDestroy {
this.databaseRef = firebase.database().ref();
this.user = afAuth.authState;
this.commercant = new Commercant();
this.tarifXJCParr = 0;
this.user.subscribe(
(auth) => {
// console.log("afAuth.authState : " + auth.toJSON());
@ -54,14 +56,27 @@ export class DemandeOpCommercialComponent implements OnInit, OnDestroy {
}
);
}
rejeter(uidRejeter: string){
const opEnvRef = this.databaseRef.child('OperationCommercial').child(uidRejeter).child('validationXJC');
rejeter(opRejeter: OperationCommerciale) {
const opTarifPRef = this.databaseRef.child('OperationCommercial').child(opRejeter.uid).child('tarifXJCParrain');
opTarifPRef.set('');
const opTarifFRef = this.databaseRef.child('OperationCommercial').child(opRejeter.uid).child('tarifXJCFilleul');
opTarifFRef.set('');
const opEnvRef = this.databaseRef.child('OperationCommercial').child(opRejeter.uid).child('validationXJC');
opEnvRef.set('rejeté');
this.tarifXJCParr = 0;
}
valider(uidValider: string){
const opEnvRef = this.databaseRef.child('OperationCommercial').child(uidValider).child('validationXJC');
valider(opValider: OperationCommerciale) {
const opTarifRef = this.databaseRef.child('OperationCommercial').child(opValider.uid).child('tarifXJCParrain');
opTarifRef.set(this.tarifXJCParr.toString());
const opTarifFRef = this.databaseRef.child('OperationCommercial').child(opValider.uid).child('tarifXJCFilleul');
opTarifFRef.set(this.tarifXJCParr.toString());
const opEnvRef = this.databaseRef.child('OperationCommercial').child(opValider.uid).child('validationXJC');
opEnvRef.set('validé');
this.tarifXJCParr = 0;
}
ngOnInit() {

@ -68,7 +68,7 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
this.parrain = new Parrain();
this.commercant = new Commercant();
this.cartePar = new CarteParrainage();
this.cartePar.historique = [];
this.parrainAffList = null;
this.user = afAuth.authState;
@ -107,6 +107,9 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
console.log('succes code secret parrain carte est: ' + this.filteredCartesTest[i].parrainCarte.secretCode);
this.cartePar = this.filteredCartesTest[i];
if (this.cartePar.historique === undefined){
this.cartePar.historique = new Array();
}
}else{
console.log('echec de la carte ! ');
}

@ -76,6 +76,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.commercant = new Commercant();
this.cartePar = new CarteParrainage();
this.cartePar.uid = firebase.database().ref().child('CarteParrainage').push().key;
this.cartePar.historique = new Array();
this.parrainAffList = null;
this.minDateTimeTest = new Date('1917-01-01');
this.maxDateTimeTest = new Date('2117-01-01');

@ -41,10 +41,12 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
carteIDTemp: string;
avAdmin: string;
commList: FirebaseListObservable<any[]>;
opCommList: FirebaseListObservable<any[]>;
scanList: FirebaseListObservable<any[]>;
adminAvantage: FirebaseListObservable<any[]>;
filleulExistList: FirebaseListObservable<any[]>;
databaseRef: any;
@ -64,6 +66,7 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
this.radioFilleul = '';
this.filleulSelect = '';
this.avAdmin = '';
this.filleul = new Filleul();
this.scan = new Scan();
this.parrain = new Parrain();
@ -146,6 +149,9 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
console.log('succes id carte est: ' + this.filteredCartesTest[i].uid);
console.log('succes le parrain de la carte est: ' + this.filteredCartesTest[i].parrainCarte.firstname);
this.cartePar = this.filteredCartesTest[i];
if (this.cartePar.historique === undefined){
this.cartePar.historique = new Array();
}
this.parrain = this.filteredCartesTest[i].parrainCarte;
}else{
console.log('echec de la carte ! ');
@ -207,6 +213,29 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
const opEnvRef = this.databaseRef.child('OperationCommercial').child(this.opComm.uid.toString()).child('nbScan');
opEnvRef.set(this.opComm.nbScan);
// Admin
this.adminAvantage = this.afDb.list('/Admin/', {
query: {
orderByChild: 'avantageCumule'
}
}
);
this.adminAvantage.forEach(avantage => {
avantage.forEach(elementavantage => {
console.log('elementavantage: ' + elementavantage);
this.avAdmin = elementavantage;
console.log('this.avAdmin : ' + this.avAdmin);
});
});
console.log('this.avAdmin : ' + this.avAdmin);
console.log('this.opComm.avantageParrain : ' + this.opComm.avantageParrain);
this.avAdmin = ((+this.avAdmin) + (+this.opComm.avantageParrain)).toString();
const adminAvantageRef = this.databaseRef.child('Admin').child('avantageCumule');
adminAvantageRef.set(this.avAdmin);
console.log('this.avAdmin : ' + this.avAdmin);
//Fin Admin
//Historique carte
@ -217,6 +246,7 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
+ ') a credité cette carte de ' + this.opComm.avantageParrain + '€, à valoir lors d un prochain achat.';
console.log(elementCarteHist);
// this.cartePar.historique = [];
this.cartePar.historique.push(elementCarteHist);
const crtHistoriqueRef = this.databaseRef.child('CarteParrainage').child(this.cartePar.uid.toString()).child('historique');
crtHistoriqueRef.set(this.cartePar.historique);

Loading…
Cancel
Save