creation et affichage op comm carte et login regist perfectionner
parent
0b3df7fae3
commit
895ceea448
@ -0,0 +1,6 @@
|
||||
<div class="card">
|
||||
<div class="well">
|
||||
<p class="h5 text-center mb-4">Liste de vos cartes de parrainage</p>
|
||||
</div>
|
||||
</div>
|
||||
<button (click)="goToProfil()">Back</button>
|
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CarteParrainageComponent } from './carte-parrainage.component';
|
||||
|
||||
describe('CarteParrainageComponent', () => {
|
||||
let component: CarteParrainageComponent;
|
||||
let fixture: ComponentFixture<CarteParrainageComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CarteParrainageComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CarteParrainageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-carte-parrainage',
|
||||
templateUrl: './carte-parrainage.component.html',
|
||||
styleUrls: ['./carte-parrainage.component.scss']
|
||||
})
|
||||
export class CarteParrainageComponent implements OnInit {
|
||||
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
goToProfil(){
|
||||
this.router.navigate(['/profil']);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<div class="card">
|
||||
<div class="well">
|
||||
<p class="h5 text-center mb-4">creation-op-com</p>
|
||||
<div class="md-form">
|
||||
<i class="fa fa-address-card prefix grey-text"></i>
|
||||
<input type="text" id="orangeForm-Familyname" [(ngModel)]="opComm.name" placeholder="Name">
|
||||
</div>
|
||||
<div class="md-form">
|
||||
<i class="fa fa-calendar-check-o prefix grey-text"></i>
|
||||
<input type="date" id="orangeForm-Date" placeholder="Date debut">
|
||||
</div>
|
||||
<div class="md-form">
|
||||
<i class="fa fa-calendar-times-o prefix grey-text"></i>
|
||||
<input type="date" id="orangeForm-Date" placeholder="Date fin">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="md-form">
|
||||
<i class="fa fa-file-picture-o prefix grey-text"></i>
|
||||
<input type="file" id="orangeForm-File" [(ngModel)]="opComm.carteTemplate" placeholder="Carte vierge">
|
||||
</div>
|
||||
<div class="md-form">
|
||||
<i class="fa fa-euro prefix grey-text"></i>
|
||||
<input type="text" id="orangeForm-Avantage" [(ngModel)]="opComm.avantageParrain" placeholder="Avantage parrain">
|
||||
</div>
|
||||
<div class="md-form">
|
||||
<i class="fa fa-euro prefix grey-text"></i>
|
||||
<input type="text" id="orangeForm-Avantage" [(ngModel)]="opComm.avantageFilleul" placeholder="Avantage filleul">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button (click)="creerOpComm()">Creer opération</button>
|
||||
<button (click)="goToOpComm()">Back</button>
|
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CreationOpComComponent } from './creation-op-com.component';
|
||||
|
||||
describe('CreationOpComComponent', () => {
|
||||
let component: CreationOpComComponent;
|
||||
let fixture: ComponentFixture<CreationOpComComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CreationOpComComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CreationOpComComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,83 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { OperationCommerciale } from '../../../../models/OperationCommerciale';
|
||||
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
|
||||
|
||||
import * as firebase from 'firebase/app';
|
||||
import { AngularFireAuth } from 'angularfire2/auth';
|
||||
import { AuthService } from '../../../services/auth/auth.service';
|
||||
import { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-creation-op-com',
|
||||
templateUrl: './creation-op-com.component.html',
|
||||
styleUrls: ['./creation-op-com.component.scss'],
|
||||
providers: [AuthService, OpCommercialService]
|
||||
})
|
||||
export class CreationOpComComponent implements OnInit, OnDestroy {
|
||||
opComm: OperationCommerciale;
|
||||
|
||||
|
||||
user: Observable<firebase.User>;
|
||||
opCommData: FirebaseListObservable<any[]>;
|
||||
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
|
||||
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
|
||||
this.opComm = new OperationCommerciale();
|
||||
|
||||
this.user = afAuth.authState;
|
||||
}
|
||||
|
||||
creerOpComm() {
|
||||
|
||||
this.user.subscribe(
|
||||
(auth) => {
|
||||
if (auth) {
|
||||
this.opCommData = this.afDb.list('/' + auth.displayName + '/', {
|
||||
query: {
|
||||
orderByChild: 'uid',
|
||||
equalTo: auth.uid.toString()
|
||||
}
|
||||
}
|
||||
);
|
||||
this.opCommData.forEach(utilisateur => {
|
||||
utilisateur.forEach(element => {
|
||||
console.log('element.uid: ' + element.uid);
|
||||
this.opComm.idCommercant = element.uid;
|
||||
this.opComm.status = "Non active";
|
||||
|
||||
this.opComService.saveOpComm(element, this.opComm);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
goToOpComm(){
|
||||
this.router.navigate(['/opCommercial']);
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.opComm = {
|
||||
uid : '',
|
||||
name : '',
|
||||
idCommercant : '',
|
||||
dateDebut : new Date(),
|
||||
dateFin : new Date(),
|
||||
carteTemplate : '',
|
||||
avantageParrain : '',
|
||||
deviseAvantageParrain : '',
|
||||
tarifXJCParrain : '',
|
||||
avantageFilleul : '',
|
||||
deviseAvantageFilleul : '',
|
||||
tarifXJCFilleul : '',
|
||||
status : ''
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<div class="card">
|
||||
<div class="well">
|
||||
<p class="h5 text-center mb-4">Liste de vos operations commercials</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul *ngFor="let op of opCommData | async">
|
||||
<li>Operation Commerciale: {{op.name}}</li>
|
||||
</ul>
|
||||
<button (click)="goToCreaOpCom()">Nouvelle opération Commercial</button>
|
||||
<button (click)="goToProfil()">Back</button>
|
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { OpCommercialComponent } from './op-commercial.component';
|
||||
|
||||
describe('OpCommercialComponent', () => {
|
||||
let component: OpCommercialComponent;
|
||||
let fixture: ComponentFixture<OpCommercialComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ OpCommercialComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(OpCommercialComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,61 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { OperationCommerciale } from '../../../../models/OperationCommerciale';
|
||||
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
|
||||
|
||||
import * as firebase from 'firebase/app';
|
||||
import { AngularFireAuth } from 'angularfire2/auth';
|
||||
import { AuthService } from '../../../services/auth/auth.service';
|
||||
import { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-op-commercial',
|
||||
templateUrl: './op-commercial.component.html',
|
||||
styleUrls: ['./op-commercial.component.scss'],
|
||||
providers: [AuthService, OpCommercialService]
|
||||
})
|
||||
export class OpCommercialComponent implements OnInit, OnDestroy {
|
||||
opComm: OperationCommerciale;
|
||||
user: Observable<firebase.User>;
|
||||
opCommData: FirebaseListObservable<any[]>;
|
||||
|
||||
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
|
||||
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
|
||||
this.opComm = new OperationCommerciale();
|
||||
|
||||
this.user = afAuth.authState;
|
||||
|
||||
|
||||
|
||||
|
||||
this.user.subscribe(
|
||||
(auth) => {
|
||||
if (auth) {
|
||||
this.opCommData = this.afDb.list('/OperationCommercial/', {
|
||||
query: {
|
||||
orderByChild: 'idCommercant',
|
||||
equalTo: auth.uid.toString()
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
goToCreaOpCom(){
|
||||
this.router.navigate(['/creationOpCommercial']);
|
||||
}
|
||||
goToProfil(){
|
||||
this.router.navigate(['/profil']);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
ngOnDestroy() {}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { CarteParrainageService } from './carte-parrainage.service';
|
||||
|
||||
describe('CarteParrainageService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CarteParrainageService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should ...', inject([CarteParrainageService], (service: CarteParrainageService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class CarteParrainageService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { OpCommercialService } from './op-commercial.service';
|
||||
|
||||
describe('OpCommercialService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [OpCommercialService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should ...', inject([OpCommercialService], (service: OpCommercialService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpModule, Headers } from '@angular/http';
|
||||
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import * as firebase from 'firebase/app';
|
||||
|
||||
import { AngularFireAuth } from 'angularfire2/auth';
|
||||
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
|
||||
|
||||
import { User } from '../../../models/User';
|
||||
import { Parrain } from '../../../models/Parrain';
|
||||
import { Commercant } from '../../../models/Commercant';
|
||||
import { OperationCommerciale } from '../../../models/OperationCommerciale';
|
||||
|
||||
@Injectable()
|
||||
export class OpCommercialService {
|
||||
databaseRef: any;
|
||||
changeRequest: any;
|
||||
userModel: User;
|
||||
parrain: Parrain;
|
||||
commercant: Commercant;
|
||||
test: string;
|
||||
|
||||
constructor(private http: HttpModule, public router: Router) {
|
||||
this.databaseRef = firebase.database().ref();
|
||||
}
|
||||
|
||||
saveOpComm(user: firebase.User, infoOpComm: OperationCommerciale) {
|
||||
const userRef = this.databaseRef.child('OperationCommercial').child(user.uid);
|
||||
userRef.set(infoOpComm);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue