historique carte envoyé

thierry
Tmadkaud 7 years ago
parent 8a417a0bf3
commit 277040a8ea

@ -25,7 +25,6 @@
</div>
<div class="col-md-2" id="subCard2Part2">
<button class="btn btn-outline-primary btn-rounded" (click)="hideme[i] = !hideme[i]">{{show ? 'Cacher Détails' : 'Détails'}}</button>
<!--<button class="btn btn-outline-info btn-rounded" (click)="sectionToImage(op.carteTemplate.downloadURL, commercant.image.downloadURL)">screenShot</button>-->
</div>
</div>
@ -35,7 +34,14 @@
</div>
</div>
</div>
<div class="card" [hidden]="!hideme[i]" style="width: 101%; height:20rem;">TEXT TO SHOW</div>
<div class="card" [hidden]="!hideme[i]" style="width: 101%; height:20rem;">
<ul>
<li *ngFor="let hst of crt.historique">
{{hst}}
<hr/>
</li>
</ul>
</div>
</div>
</div>
</div>

@ -75,6 +75,20 @@ export class CarteEnvoyerComponent implements OnInit {
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
}

@ -86,6 +86,21 @@ export class CarteParrainageComponent implements OnInit, OnDestroy {
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
goToProfil(){
this.router.navigate(['/profil']);

@ -77,6 +77,21 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
goToOpComm() {
this.router.navigate(['/opCommercial']);

@ -133,6 +133,18 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
console.log(this.opComm.nbDebiter);
const opEnvRef = this.databaseRef.child('OperationCommercial').child(this.opComm.uid.toString()).child('nbDebiter');
opEnvRef.set(this.opComm.nbDebiter);
//Historique carte
var dateTemp = new Date (Date.now());
var elementCarteHist = 'Le ' + dateTemp.getDate() + '/' + dateTemp.getMonth() + '/' + dateTemp.getFullYear()
+ ' à ' + dateTemp.getHours() + ':' + dateTemp.getMinutes()
+ ', ' + this.valeurRecup + '€ ont été récupérés sur cette carte par '
+ this.cartePar.parrainCarte.familyname.toUpperCase() + ' ' + this.cartePar.parrainCarte.firstname.toUpperCase() + '.';
this.cartePar.historique.push(elementCarteHist);
const crtHistoriqueRef = this.databaseRef.child('CarteParrainage').child(this.cartePar.uid.toString()).child('historique');
crtHistoriqueRef.set(this.cartePar.historique);
}
filter(query: string) {
this.filteredParrainsTest = (query) ?
@ -149,6 +161,20 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
.subscribe(parrains => this.parrainsTest = parrains);
this.subscriptionCarte = this.opComService.getCartes()
.subscribe(cartes => this.carteTest = cartes);
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
//////
@ -166,7 +192,8 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
avantageCumule: '',
avantageRecuperer: '',
carteTemplate: new FireImg(),
status: ''
status: '',
historique: []
};
this.localUser = {
uid: '',

@ -55,7 +55,10 @@
</form>
<div class="md-form">
<i class="fa fa-birthday-cake prefix grey-text"></i>
<input type="date" id="orangeForm-Birthday" [(ngModel)]="parrain.birthday" placeholder="Birthday">
<input type="date" id="orangeForm-Birthday" [(ngModel)]="parrain.birthday" placeholder="Birthday" required min="1917-01-01" max="2117-01-01" name="birthday" #birthday="ngModel">
<div *ngIf="((parrain.birthday != '01/01/1917') || birthday.errors) && (email.dirty || email.touched)" class="alert alert-danger">
Votre date de naissance doit être comprise entre <strong><i>1917-01-01 et 2117-01-01</i></strong>.
</div>
</div>
<div class="md-form">
<i class="fa fa-envelope prefix grey-text"></i>
@ -69,6 +72,27 @@
et indiquez que vous aves lu notre Politique d'utilisation des
données, y compris notre Utilisation des cookies.
</label>
<div class="col-md-12 subCard1 card" id="subCard1">
<img src="{{cartePar.carteTemplate.downloadURL}}" id="image1" crossorigin="anonymous" class="mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
<div class="view">
<div class="row firstRow">
<div class="col-md-6 flex-center card-block cardPart1"><label>{{commercant.commercialName}}</label></div>
<div class="col-md-6 flex-center card-block card-image mb-1 cardPart2 image2" [ngStyle]="{ 'background-image': 'url(' + commercant.image.downloadURL + ')'}">
</div>
</div>
<div class="row secondRow">
<div class="col-md-6 flex-center cardPart3 flex-column">
<label>{{cartePar.name}}</label>
</div>
<div class="col-md-6 flex-center cardPart4"><label>{{cartePar.uid}}</label></div>
</div>
<div class="col-md-12 text-center" id="dateFin">
<label>Valable jusqu'au: {{cartePar.dateFin | date:'dd/MM/yyyy'}}</label>
</div>
</div>
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-light-green waves-light" [disabled]="email.errors" (click)="registerNewParrain()">Creer nouveau parrain & envoyer carte</button>
<button class="btn btn-cyan" (click)="goToOpComm()">Back</button>
@ -119,34 +143,35 @@
et indiquez que vous aves lu notre Politique d'utilisation des
données, y compris notre Utilisation des cookies.
</label>
<div class="col-md-12 subCard1 card" id="subCard1">
<img src="{{cartePar.carteTemplate.downloadURL}}" id="image1" crossorigin="anonymous" class="mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
<div class="view">
<div class="row firstRow">
<div class="col-md-6 flex-center card-block cardPart1"><label>{{commercant.commercialName}}</label></div>
<div class="col-md-6 flex-center card-block card-image mb-1 cardPart2 image2" [ngStyle]="{ 'background-image': 'url(' + commercant.image.downloadURL + ')'}">
</div>
</div>
<div class="row secondRow">
<div class="col-md-6 flex-center cardPart3 flex-column">
<label>{{cartePar.name}}</label>
</div>
<div class="col-md-6 flex-center cardPart4"><label>{{cartePar.uid}}</label></div>
</div>
<div class="col-md-12 text-center" id="dateFin">
<label>Valable jusqu'au: {{cartePar.dateFin | date:'dd/MM/yyyy'}}</label>
</div>
</div>
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-light-green waves-light" [disabled]="(parSelect === '') || (birthdayTemp !== parrain.birthday)" (click)="creerCartePar()">Envoyer Carte {{parSelect}}</button>
<button class="btn btn-light-green waves-light" [disabled]="(parSelect === '') || (birthdayTemp !== parrain.birthday)" (click)="creerCartePar()">Envoyer Carte à {{parSelect}}</button>
<button class="btn btn-cyan" (click)="goToOpComm()">Back</button>
</div>
</div>
<!-- Fin Si cest un parrain existant -->
<div class="col-md-12 subCard1 card" id="subCard1">
<img src="{{cartePar.carteTemplate.downloadURL}}" id="image1" crossorigin="anonymous" class="mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
<div class="view">
<div class="row firstRow">
<div class="col-md-6 flex-center card-block cardPart1"><label>{{commercant.commercialName}}</label></div>
<div class="col-md-6 flex-center card-block card-image mb-1 cardPart2 image2" [ngStyle]="{ 'background-image': 'url(' + commercant.image.downloadURL + ')'}">
</div>
</div>
<div class="row secondRow">
<div class="col-md-6 flex-center cardPart3 flex-column">
<label>{{cartePar.name}}</label>
</div>
<div class="col-md-6 flex-center cardPart4"><label>{{cartePar.uid}}</label></div>
</div>
<div class="col-md-12 text-center" id="dateFin">
<label>Valable jusqu'au: {{cartePar.dateFin | date:'dd/MM/yyyy'}}</label>
</div>
</div>
</div>
<!--<button class="btn btn-blue waves-light" (click)="sectionToImage()"> screen </button>-->
</div>

@ -58,10 +58,12 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
//endAt = new Subject();
/////
yearTest: number;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService,
private opComService: OpCommercialService, private route: ActivatedRoute) {
this.user = afAuth.authState;
this.radioParrain = '';
@ -71,7 +73,8 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.commercant = new Commercant();
this.cartePar = new CarteParrainage();
this.parrainAffList = null;
this.user = afAuth.authState;
this.yearTest = this.parrain.birthday.getFullYear();
this.databaseRef = firebase.database().ref();
this.user.subscribe(
(auth) => {
@ -192,11 +195,15 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
emailVerified: true
});
this.cartePar.parrainCarte = userCreate;
this.parrain.uid = userCreate.uid;
this.parrain.emailVerified = userCreate.emailVerified;
userRef.set(this.parrain);
// this.cartePar.parrainCarte = this.parrain;
this.getIdParrain(userCreate.uid);
this.creerCartePar();
firebase.auth().sendPasswordResetEmail(this.parrain.email);
userCreate.sendEmailVerification();
@ -229,15 +236,10 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.selectPar = true;
if (this.radioParrain === 'ParrainAffi'){
for (let i = 0; i < this.parrainAffListTemp.length; i++) {
if (this.parrainAffListTemp[i].uid === parUid) {
this.parSelect = ' à : '
+ this.parrainAffListTemp[i].familyname + ' '
+ this.parrainAffListTemp[i].firstname;
}
}
if (this.radioParrain === 'Newparrain') {
this.parSelect = ' à : '
+ this.cartePar.parrainCarte.familyname + ' '
+ this.cartePar.parrainCarte.firstname;
} else if (this.radioParrain === 'ParrainExist'){
this.parrainExistList.forEach(parEx => {
parEx.forEach(elementparEx => {
@ -275,12 +277,12 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
// this.opComService.creerCartePar(this.cartePar); inutile
this.sectionToImage(this.cartePar);
console.log(this.opComm.nbEnvoie);
console.log('this.opComm.nbEnvoie: ' + this.opComm.nbEnvoie);
this.opComm.nbEnvoie = ((+this.opComm.nbEnvoie) + 1).toString();
console.log(this.opComm.nbEnvoie);
console.log('this.opComm.nbEnvoie: ' + this.opComm.nbEnvoie);
const opEnvRef = this.databaseRef.child('OperationCommercial').child(this.opComm.uid.toString()).child('nbEnvoie');
opEnvRef.set(this.opComm.nbEnvoie);
opEnvRef.set('this.opComm.nbEnvoie: ' + this.opComm.nbEnvoie);
this.validC = 'ok';
@ -306,20 +308,26 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
canvas.id = 'canvas';
// document.body.appendChild(canvas);
console.log('avant blob');
canvas.toBlob(blob => {
var nouvelleImg = new Image();
let storageRef = firebase.storage().ref();
nouvelleImg.setAttribute('crossOrigin', 'anonymous');
nouvelleImg.src = blob;
console.log('blob : ' + blob);
console.log('maCarteP.uid: ' + maCarteP.uid);
storageRef.child('CarteParrainage/' + maCarteP.uid + '/carteTemplate').put(blob).then((snapshot) => {
let updates = {};
maCarteP.carteTemplate.path = 'CarteParrainage/' + maCarteP.uid + '/carteTemplate';
maCarteP.carteTemplate.filename = maCarteP.name;
maCarteP.carteTemplate.downloadURL = snapshot.downloadURL;
console.log('maCarteP.carteTemplate.filename : ' + maCarteP.carteTemplate.filename);
console.log('maCarteP.uid: ' + maCarteP.uid);
updates['CarteParrainage/' + maCarteP.uid] = maCarteP;
console.log('updates[\'CarteParrainage/\' + maCarteP.uid].name ' + updates['CarteParrainage/' + maCarteP.uid].name);
firebase.database().ref().update(updates);
console.log('fin du blob');
});
});
}
@ -333,14 +341,30 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
}
//////
ngOnInit() {
this.subscription = this.opComService.getParrains()
.subscribe(parrains => this.parrainsTest = parrains);
try {
this.user.subscribe(
(auth) => {
if (auth) {
this.subscription = this.opComService.getParrains()
.subscribe(parrains => this.parrainsTest = parrains);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
//////
ngOnDestroy() {
this.validC = '';
this.subscription.unsubscribe();
if(this.subscription){
this.subscription.unsubscribe();
}
this.radioParrain = '';
this.cartePar = {
uid: '',
@ -353,7 +377,8 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
avantageCumule: '',
avantageRecuperer: '',
carteTemplate: new FireImg(),
status: ''
status: '',
historique: []
};
this.localUser = {
uid: '',

@ -18,6 +18,7 @@
<!--<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Profil</button>-->
</div>
<div class="list-group">
<div class="card mainCard" *ngFor="let op of opCommData | async">
<div class="row" id="testt">
<div class="col-md-6 mb-1 subCard1" id="subCard1">

@ -97,6 +97,20 @@ export class OpCommercialComponent implements OnInit, OnDestroy {
this.router.navigate(['/historiqueCarte']);
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
ngOnDestroy() {}

@ -196,6 +196,21 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
const opEnvRef = this.databaseRef.child('OperationCommercial').child(this.opComm.uid.toString()).child('nbScan');
opEnvRef.set(this.opComm.nbScan);
//Historique carte
var elementCarteHist = 'Le ' + (this.scan.dateCreation).getDate() + '/' + (this.scan.dateCreation).getMonth()
+ '/' + (this.scan.dateCreation).getFullYear() + ' à ' + (this.scan.dateCreation).getHours() + ':'
+ (this.scan.dateCreation).getMinutes() + ', ' + ' la visite de : '
+ this.filleul.familyname.toUpperCase() + ' ' + this.filleul.firstname.toUpperCase() + ' (' + this.filleul.uid
+ ') 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);
console.log(this.cartePar.historique[0]);
}
getIdFilleul(filUid) {
@ -215,6 +230,20 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
this.subscription = this.opComService.getParrains()
.subscribe(parrains => this.filleulTest = parrains);
this.subscriptionCarte = this.opComService.getCartes()
@ -236,7 +265,8 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
avantageCumule: '',
avantageRecuperer: '',
carteTemplate: new FireImg(),
status: ''
status: '',
historique: []
};
this.localUser = {
uid: '',

@ -111,6 +111,20 @@ export class EditProfilComponent implements OnInit {
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
}

@ -41,7 +41,7 @@
<p class="text-left"><label class="text-uppercase">familyname </label>: {{localUser.familyname}}</p>
<p class="text-left"><label class="text-uppercase">firstname : </label> {{localUser.firstname}}</p>
<p class="text-left"><label class="text-uppercase">sex </label> : {{localUser.sex}}</p>
<p class="text-left"><label class="text-uppercase">birthday </label> : {{localUser.birthday}}</p>
<p class="text-left"><label class="text-uppercase">birthday </label> : {{localUser.birthday | date:'dd/MM/yyyy'}}</p>
<p class="text-left"><label class="text-uppercase"> telephone :</label> {{localUser.telephone}}</p>
<p class="text-left"><label class="text-uppercase"> idCard </label>: {{localUser.idCard}}</p>
<p class="text-left"><label class="text-uppase">secretCode </label> : {{localUser.secretCode}}</p>

@ -36,12 +36,14 @@ export class ProfilComponent implements OnInit, OnDestroy {
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService) {
this.user = afAuth.authState;
this.localUser = new User();
this.parrain = new Parrain();
this.commercant = new Commercant();
this.imageProfil = 'https://ssl.prcdn.com/uk/people/default-profile.png?1406639312';
this.user = afAuth.authState;
this.user.subscribe(
(auth) => {
if (auth) {
@ -93,7 +95,20 @@ export class ProfilComponent implements OnInit, OnDestroy {
}
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
ngOnDestroy() {

@ -15,7 +15,7 @@ export class CarteParrainage
avantageRecuperer: string;
carteTemplate: FireImg;
status: string;
historique: string[];
constructor() {
this.uid = '';
@ -29,6 +29,7 @@ export class CarteParrainage
this.avantageRecuperer = '';
this.carteTemplate = new FireImg();
this.status = '';
this.historique = [];
}
/*
addParrain(addStatus, addEmail, addFamilyname, addFirstname) {

Loading…
Cancel
Save