trier opcom

thierry
Tmadkaud 7 years ago
parent 6fec7f2bf6
commit 49ff98d08e

@ -6,18 +6,25 @@ import { AngularFireAuth } from 'angularfire2/auth';
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { HomeService } from '../../services/home/home.service';
import { OpCommercialService } from '../../services/opCommercial/op-commercial.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
providers: [HomeService]
providers: [HomeService, OpCommercialService]
})
export class HomeComponent implements OnInit {
public loadComponentRegister = false;
public loadComponentLogin = false;
constructor(public afAuth: AngularFireAuth, private router: Router) { }
constructor(public afAuth: AngularFireAuth, private opComService: OpCommercialService, private router: Router) {
try{
opComService.updateCarteEtOpCom();
}catch (e){
console.log(e);
}
}
loadRegisterComponent(){
this.loadComponentRegister = !this.loadComponentRegister;

@ -13,11 +13,30 @@
<app-nav-commercant></app-nav-commercant>
<h4 class="mb-5 mt-1 font-bold wow fadeInDown text-center" style="padding-top: 5%;">Operations commerciales ({{(opCommData | async)?.length}})</h4>
<div class="btn-block flex-center align-middle" style="padding-top: 2%;">
<button class="btn btn-primary btn-rounded waves-light" id="nouvelleOp" (click)="goToCreaOpCom()">Nouvelle opération commerciale</button>
<!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToCarteEnvoyer()">Historique carte envoyer</button>-->
<!--<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Profil</button>-->
<div class="btn-block row" style="padding-top: 2%;">
<div class="col-md-12">
<div class="float-left">
<button class="btn btn-primary btn-rounded waves-light" id="nouvelleOp" (click)="goToCreaOpCom()">Nouvelle opération commerciale</button>
<!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToCarteEnvoyer()">Historique carte envoyer</button>-->
<!--<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Profil</button>-->
</div>
<div *ngIf="(opCommData | async)?.length != 0" class="float-right">
<div class="dropdown" dropdown>
<button dropdownToggle type="button" class="btn btn-info btn-rounded dropdown-toggle waves-light" mdbRippleRadius>
Filtres
</button>
<div class="dropdown-menu">
<a class="dropdown-item" id="opActive" (click)="activeOP('Active')">Actives</a>
<a class="dropdown-item" id="opToutes" (click)="activeOP('Toutes')">Toutes</a>
<a class="dropdown-item" id="opBloqué" (click)="activeOP('Bloqué')">Bloquées</a>
<a class="dropdown-item" id="opInactive" (click)="activeOP('Inactive')">Inactives</a>
</div>
</div>
</div>
</div>
</div>
<div *ngIf="(opCommData | async)?.length == 0" class="alert alert-danger">
Cher,<strong><i> {{commercant.commercialName}} </i></strong>
<p>Le principe est simple :</p>
@ -29,66 +48,67 @@
<p>N'attends plus, crées tes opérations commerciale et envoie les aux futurs parrains affiliés de ton choix !</p>
</div>
<div class="list-group wow fadeInUpBig">
<div class="card mainCard" *ngFor="let op of opCommData | async">
<div class="row no-margin" id="testt">
<div class="col-md-6 mb-1 subCard1" id="subCard1">
<img src="{{op.carteTemplate.downloadURL}}" id="image1" class="img-fluid mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
<div class="view">
<div class="mask pattern-6">
<div class="row no-margin firstRow">
<div class="col-md-6 flex-center card-block cardPart1"><p class="white-text info-text font-bold">{{commercant.commercialName}}</p></div>
<div class="col-md-6 flex-center card-block card-image mb-1 cardPart2 image2" [ngStyle]="{ 'background-image': 'url(' + commercant.image.downloadURL + ')'}">
<div *ngIf="(op.status == statutAffiche) || (statutAffiche == 'Toutes')">
<div class="row no-margin" id="testt">
<div class="col-md-6 mb-1 subCard1" id="subCard1">
<img src="{{op.carteTemplate.downloadURL}}" id="image1" class="img-fluid mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
<div class="view">
<div class="mask pattern-6">
<div class="row no-margin firstRow">
<div class="col-md-6 flex-center card-block cardPart1"><p class="white-text info-text font-bold">{{commercant.commercialName}}</p></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 no-margin secondRow">
<div class="col-md-6 flex-center cardPart3"><p class="white-text info-text font-bold">{{op.name}}</p></div>
<div class="col-md-6 flex-center cardPart4"><p class="white-text info-text font-bold">{{op.uid}}</p></div>
</div>
</div>
<div class="row no-margin secondRow">
<div class="col-md-6 flex-center cardPart3"><p class="white-text info-text font-bold">{{op.name}}</p></div>
<div class="col-md-6 flex-center cardPart4"><p class="white-text info-text font-bold">{{op.uid}}</p></div>
</div>
</div>
</div>
</div>
<div class="col-md-6 card subCard2">
<div class="card-block row no-margin">
<div class="col-md-8 col-sm-6" id="subCard2Part1">
<div id="opTitle">
<label>Operation Commerciale : {{op.name}}</label>
</div>
<div id="opAvantages">
<p *ngIf="op.avantageParrain == ''"></p>
<label>Avantage parrain : {{op.avantageParrain === ''? '0' : op.avantageParrain}} €</label>
<label>Avantage filleul : {{op.avantageFilleul === ''? '0' : op.avantageFilleul}} €</label>
<div class="col-md-6 card subCard2">
<div class="card-block row no-margin">
<div class="col-md-8 col-sm-6" id="subCard2Part1">
<div id="opTitle">
<label>Operation Commerciale : {{op.name}}</label>
</div>
<div id="opAvantages">
<p *ngIf="op.avantageParrain == ''"></p>
<label>Avantage parrain : {{op.avantageParrain === ''? '0' : op.avantageParrain}} €</label>
<label>Avantage filleul : {{op.avantageFilleul === ''? '0' : op.avantageFilleul}} €</label>
</div>
<div id="opLogs">
<label>Carte(s) envoyée(s): {{op.nbEnvoie === ''? '0' : op.nbEnvoie}}</label>
<label>Carte(s) scannée(s): {{op.nbScan === ''? '0' : op.nbScan}}</label>
<label>Carte(s) débitée(s): {{op.nbDebiter === ''? '0' : op.nbDebiter}}</label>
</div>
</div>
<div id="opLogs">
<label>Carte(s) envoyée(s): {{op.nbEnvoie === ''? '0' : op.nbEnvoie}}</label>
<label>Carte(s) scannée(s): {{op.nbScan === ''? '0' : op.nbScan}}</label>
<label>Carte(s) débitée(s): {{op.nbDebiter === ''? '0' : op.nbDebiter}}</label>
<div class="col-md-2" id="subCard2Part2">
<button class="btn btn-outline-primary btn-rounded" [disabled]="(op.validationXJC === 'En Cours') || (op.validationXJC === 'rejeté') || (op.validationXJC === 'bloqué')" (click)="goToEnCart(op.uid)">Envoyer</button>
<button class="btn btn-outline-default btn-rounded" [disabled]="(op.validationXJC === 'En Cours') || (op.validationXJC === 'rejeté') || (op.validationXJC === 'bloqué')" (click)="goToScanCart(op.uid)">Scanner</button>
<button class="btn btn-outline-info btn-rounded" [disabled]="(op.validationXJC === 'En Cours') || (op.validationXJC === 'rejeté') || (op.validationXJC === 'bloqué')" (click)="goToDebiterCart(op.uid)">Débiter</button>
</div>
</div>
<div class="col-md-2" id="subCard2Part2">
<button class="btn btn-outline-primary btn-rounded" [disabled]="(op.validationXJC === 'En Cours') || (op.validationXJC === 'rejeté') || (op.validationXJC === 'bloqué')" (click)="goToEnCart(op.uid)">Envoyer</button>
<button class="btn btn-outline-default btn-rounded" [disabled]="(op.validationXJC === 'En Cours') || (op.validationXJC === 'rejeté') || (op.validationXJC === 'bloqué')" (click)="goToScanCart(op.uid)">Scanner</button>
<button class="btn btn-outline-info btn-rounded" [disabled]="(op.validationXJC === 'En Cours') || (op.validationXJC === 'rejeté') || (op.validationXJC === 'bloqué')" (click)="goToDebiterCart(op.uid)">Débiter</button>
</div>
</div>
</div>
</div>
<!-- Card footer -->
<div class="card-data" id="footerCard">
<ul>
<li class="float-right"><i class="fa fa-check-square-o" aria-hidden="true"></i>Validation:
<label class="font-bold" *ngIf="op.validationXJC == 'Validé'" style="color:#00C851; margin-bottom: 0">{{op.validationXJC}}</label>
<label class="font-bold" *ngIf="op.validationXJC == 'En Cours'" style="color:#ffbb33; margin-bottom: 0">{{op.validationXJC}}</label>
<label class="font-bold" *ngIf="op.validationXJC == 'Rejeté'" style="color:#ff4444; margin-bottom: 0">{{op.validationXJC}}</label>
</li>
<li class="float-right" style="padding-right: 2%"><i class="fa fa-info-circle" aria-hidden="true"></i>Statut:
<label class="font-bold" *ngIf="op.status == 'Active'" style="color:#00C851; margin-bottom: 0">{{op.status}}</label>
<label class="font-bold" *ngIf="op.status == 'Inactive'" style="color:#ffbb33; margin-bottom: 0">{{op.status}}</label>
<label class="font-bold" *ngIf="op.status == 'Bloqué'" style="color:#ff4444; margin-bottom: 0">{{op.status}}</label>
</li>
<li class="float-left"><i class="fa fa-clock-o"></i>Valable du {{op.dateDebut | date:'dd/MM/yyyy'}} au {{op.dateFin | date:'dd/MM/yyyy'}}</li>
</ul>
<!-- Card footer -->
<div class="card-data" id="footerCard">
<ul>
<li class="float-right"><i class="fa fa-check-square-o" aria-hidden="true"></i>Validation:
<label class="font-bold" *ngIf="op.validationXJC == 'Validé'" style="color:#00C851; margin-bottom: 0">{{op.validationXJC}}</label>
<label class="font-bold" *ngIf="op.validationXJC == 'En Cours'" style="color:#ffbb33; margin-bottom: 0">{{op.validationXJC}}</label>
<label class="font-bold" *ngIf="op.validationXJC == 'Rejeté'" style="color:#ff4444; margin-bottom: 0">{{op.validationXJC}}</label>
</li>
<li class="float-right" style="padding-right: 2%"><i class="fa fa-info-circle" aria-hidden="true"></i>Statut:
<label class="font-bold" *ngIf="op.status == 'Active'" style="color:#00C851; margin-bottom: 0">{{op.status}}</label>
<label class="font-bold" *ngIf="op.status == 'Inactive'" style="color:#ffbb33; margin-bottom: 0">{{op.status}}</label>
<label class="font-bold" *ngIf="op.status == 'Bloqué'" style="color:#ff4444; margin-bottom: 0">{{op.status}}</label>
</li>
<li class="float-left"><i class="fa fa-clock-o"></i>Valable du {{op.dateDebut | date:'dd/MM/yyyy'}} au {{op.dateFin | date:'dd/MM/yyyy'}}</li>
</ul>
</div>
</div>
<!-- Card footer -->
</div>

@ -27,9 +27,10 @@ export class OpCommercialComponent implements OnInit, OnDestroy {
profileData: FirebaseListObservable<any[]>;
// Cas2Image: Observable<Canvas2Image>;
commercant: Commercant;
statutAffiche: string;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
this.statutAffiche = 'Toutes';
this.opComm = new OperationCommerciale();
this.user = afAuth.authState;
@ -64,6 +65,10 @@ export class OpCommercialComponent implements OnInit, OnDestroy {
);
}
activeOP(afficheStatus: string){
this.statutAffiche = afficheStatus;
}
goToCreaOpCom() {
this.router.navigate(['/creationOpCommercial']);
}

@ -106,7 +106,7 @@
<li class="list-group-item text-left"><label class="h5-responsive mt-1 font-bold">Raison sociale :</label> {{localUser.raisonSociale}}</li>
<li class="list-group-item text-left"><label class="h5-responsive mt-1 font-bold">Numéro de siret :</label> {{localUser.siret}}</li>
<li class="list-group-item text-left"><label class="h5-responsive mt-1 font-bold">Email :</label> {{localUser.email}}</li>
<li class="list-group-item text-left"><label class="h5-responsive mt-1 font-bold">Date d'inscription :</label> {{localUser.dateInscription}}</li>
<li class="list-group-item text-left"><label class="h5-responsive mt-1 font-bold">Date d'inscription :</label> {{localUser.dateInscription | date:'dd/MM/yyyy'}}</li>
<li class="list-group-item text-left"><label class="h5-responsive mt-1 font-bold">Statut :</label> {{localUser.status}}</li>
</ul>

@ -90,7 +90,8 @@ export class RegisterComponent implements OnInit, OnDestroy {
this.test = true;
}else if (this.currentUser.status === 'Commercant') {
this.commercant.status = this.currentUser.status;
this.commercant.dateInscription = new Date();
let dateTemp = new Date(Date.now());
this.commercant.dateInscription = new Date(dateTemp);
this.authService.signUp(this.commercant);
/*if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
this.clean();

@ -45,8 +45,6 @@ export class AuthService {
//fileList: FirebaseListObservable<Image[]>;
constructor(private http: HttpModule, private afAuth: AngularFireAuth, private afDb: AngularFireDatabase, private router: Router) {
this.parrain = new Parrain();
this.commercant = new Commercant();
@ -70,10 +68,12 @@ export class AuthService {
return true;
// this.router.navigate(['/carteParrainageComponent']);
}else if (infoUser.status === 'Commercant') {
var dateTemp = new Date(Date.now());
infoUser.dateInscription = dateTemp;
const userReff = this.databaseRef.child('Commercant').child(infoUser.uid);
// var commercantInfo = infoUser;
// infoUser.uid = user.uid;
userReff.set(infoUser);
const dateInsReff = this.databaseRef.child('Commercant').child(infoUser.uid).child('dateInscription');
dateInsReff.set(dateTemp.toString());
return true;
// this.router.navigate(['/opCommercial']);
}else {

@ -85,7 +85,7 @@ export class OpCommercialService {
creerCartePar(infoCartePar: CarteParrainage) {
console.log('ba');
//infoCartePar.uid = firebase.database().ref().child('CarteParrainage').push().key;
// infoCartePar.uid = firebase.database().ref().child('CarteParrainage').push().key;
let updates = {};
updates['/CarteParrainage/' + infoCartePar.uid] = infoCartePar;
firebase.database().ref().update(updates);
@ -93,7 +93,7 @@ export class OpCommercialService {
}
updateOpCommStatus(){
/*
const opComAll = this.getOpComs();
opComAll.forEach(utilisateur => {
@ -101,23 +101,24 @@ export class OpCommercialService {
var todayTemp = new Date(Date.now());
var debutTemp = new Date(monOpCom.dateDebut);
var finTemp = new Date(monOpCom.dateFin);
if (todayTemp.getTime() >= debutTemp.getTime() && todayTemp.getTime() <= finTemp.getTime()) {
monOpCom.status = 'Active';
} else {
monOpCom.status = 'Inactive';
if (monOpCom.status !== 'Bloqué') {
if (todayTemp.getTime() >= debutTemp.getTime() && todayTemp.getTime() <= finTemp.getTime()) {
monOpCom.status = 'Active';
} else {
monOpCom.status = 'Inactive';
}
const carteStatusRef = firebase.database().ref().child('OperationCommercial').child(monOpCom.uid.toString()).child('status');
carteStatusRef.set(monOpCom.status);
}
const carteStatusRef = firebase.database().ref().child('OperationCommercial').child(monOpCom.uid.toString()).child('status');
carteStatusRef.set(monOpCom.status);
});
});
*/
}
updateCarteEtOpCom(){
// this.updateOpCommStatus();
this.updateOpCommStatus();
this.updateCarteStatus();
}
updateCarteStatus(){
const carteAll = this.getCartes();

Loading…
Cancel
Save