|
|
|
@ -70,8 +70,86 @@ export class OpCommercialService {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateOpCommStatus() {
|
|
|
|
|
const opComAll = this.getOpComs();
|
|
|
|
|
getScansOP(opCommUid): FirebaseListObservable<any> {
|
|
|
|
|
return this.afDb.list('/Scan/', {
|
|
|
|
|
query: {
|
|
|
|
|
orderByChild: 'operationCommercial/uid',
|
|
|
|
|
equalTo: opCommUid
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateNbCarteOpCom(opCommUid, nbCartesOpCom) {
|
|
|
|
|
|
|
|
|
|
nbCartesOpCom.subscribe(tabNbCartesOpCom => {
|
|
|
|
|
if (tabNbCartesOpCom.length > 0) {
|
|
|
|
|
console.log('');
|
|
|
|
|
// const upCartOpRef = firebase.database().ref().child('OperationCommercial').child('-KwlMJtE2d3WfrD5n94s').child('nbEnvoie');
|
|
|
|
|
// upCartOpRef.set(tabNbCartesOpCom.length);
|
|
|
|
|
// console.log('tabNbCartesOpCom.length: ' + tabNbCartesOpCom.length);
|
|
|
|
|
// const upCartOpRef = firebase.database().ref().child('OperationCommercial').child(opCommUid).child('nbEnvoie');
|
|
|
|
|
// upCartOpRef.set(tabNbCartesOpCom.length);
|
|
|
|
|
}else{
|
|
|
|
|
// console.log('tous mettre a 0');
|
|
|
|
|
console.log('');
|
|
|
|
|
// const upCartOpRef = firebase.database().ref().child('OperationCommercial').child('-KwlMJtE2d3WfrD5n94s').child('nbEnvoie');
|
|
|
|
|
// upCartOpRef.set('');
|
|
|
|
|
// const upCartOpRef = firebase.database().ref().child('OperationCommercial').child(opCommUid).child('nbEnvoie');
|
|
|
|
|
// upCartOpRef.set('');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateNbScanOpCom(opCommUid, scansOpCom) {
|
|
|
|
|
|
|
|
|
|
scansOpCom.subscribe(tabScansOpCom => {
|
|
|
|
|
if (tabScansOpCom.length > 0) {
|
|
|
|
|
|
|
|
|
|
// const uptabcanOpComOpRef = firebase.database().ref().child('OperationCommercial').child(opCommUid).child('nbEnvoie');
|
|
|
|
|
// upCartOpRef.set(tabCartesOpCom.length);
|
|
|
|
|
for (let i = 0; i < tabScansOpCom.length; ++i) {
|
|
|
|
|
//console.log('tabcansOpCom.length: ' + tabScansOpCom.length + ' ' + tabScansOpCom[i].name);
|
|
|
|
|
console.log('');
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
console.log('');
|
|
|
|
|
// const upCartOpRef = firebase.database().ref().child('OperationCommercial').child(opCommUid).child('nbEnvoie');
|
|
|
|
|
// upCartOpRef.set('');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateOpCommEnvScanDebi(opComAll) {
|
|
|
|
|
opComAll.subscribe(tabOpComs => {
|
|
|
|
|
if (tabOpComs.length > 0) {
|
|
|
|
|
for (let i = 0; i < tabOpComs.length; ++i) {
|
|
|
|
|
if (tabOpComs[i].name !== '') {
|
|
|
|
|
let monOpCom = tabOpComs[i];
|
|
|
|
|
if (monOpCom !== undefined) {
|
|
|
|
|
let nbCartesOpCom = this.getCartesOP(tabOpComs[i].uid);
|
|
|
|
|
let scansOpCom = this.getScansOP(tabOpComs[i].uid);
|
|
|
|
|
nbCartesOpCom.subscribe(tab => {
|
|
|
|
|
const upCartOpRef = firebase.database().ref().child('OperationCommercial').child(tabOpComs[i].uid).child('nbEnvoie');
|
|
|
|
|
let testEnv = (tab.length === 0 ? '' : tab.length.toString());
|
|
|
|
|
upCartOpRef.set(testEnv);
|
|
|
|
|
});
|
|
|
|
|
scansOpCom.subscribe(tabS => {
|
|
|
|
|
const upScanOpRef = firebase.database().ref().child('OperationCommercial').child(tabOpComs[i].uid).child('nbScan');
|
|
|
|
|
let testScan = (tabS.length === 0 ? '' : tabS.length.toString());
|
|
|
|
|
upScanOpRef.set(testScan);
|
|
|
|
|
});
|
|
|
|
|
// this.updateNbCarteOpCom(tabOpComs[i].uid, nbCartesOpCom);
|
|
|
|
|
// this.updateNbScanOpCom(tabOpComs[i].uid, scansOpCom);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateOpCommStatus(opComAll) {
|
|
|
|
|
|
|
|
|
|
opComAll.subscribe(tabOpComs => {
|
|
|
|
|
if (tabOpComs.length > 0) {
|
|
|
|
|
for (let i = 0; i < tabOpComs.length ; ++i){
|
|
|
|
@ -106,22 +184,19 @@ export class OpCommercialService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
opComAll.forEach(utilisateur => {
|
|
|
|
|
utilisateur.forEach(monOpCom => {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateCarteEtOpCom() {
|
|
|
|
|
this.updateOpCommStatus();
|
|
|
|
|
this.updateCarteStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateCarteStatus(){
|
|
|
|
|
const opComAll = this.getOpComs();
|
|
|
|
|
const carteAll = this.getCartes();
|
|
|
|
|
this.updateOpCommStatus(opComAll);
|
|
|
|
|
this.updateCarteStatus(carteAll);
|
|
|
|
|
this.updateOpCommEnvScanDebi(opComAll);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateCarteStatus(carteAll){
|
|
|
|
|
carteAll.subscribe(tabCarte => {
|
|
|
|
|
if (tabCarte.length > 0) {
|
|
|
|
|
for (let i = 0; i < tabCarte.length ; ++i){
|
|
|
|
@ -154,11 +229,6 @@ export class OpCommercialService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
carteAll.forEach(utilisateur => {
|
|
|
|
|
utilisateur.forEach(maCarte => {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveOpComm(user: firebase.User, infoOpCom: OperationCommerciale) {
|
|
|
|
|