|
|
|
@ -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);
|
|
|
|
|