Doppia modalità di Registrazione con lista extra utenti
This commit is contained in:
@@ -41,6 +41,8 @@ module.exports = {
|
||||
|
||||
LANGADMIN: 'it',
|
||||
|
||||
APORTADOR_NONE: '------',
|
||||
|
||||
TYPE_PROJECT: 1,
|
||||
TYPE_TODO: 2,
|
||||
|
||||
@@ -480,7 +482,7 @@ module.exports = {
|
||||
{
|
||||
$project: {
|
||||
count: 1,
|
||||
rows: { $slice: ['$results', params.startRow, params.endRow] }
|
||||
rows: { $slice: ['$results', params.startRow, params.endRow - params.startRow] }
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -513,6 +515,41 @@ module.exports = {
|
||||
});
|
||||
|
||||
},
|
||||
async DuplicateAllRecords(mythistable, idapporig, idappdest) {
|
||||
console.log(mythistable.name);
|
||||
|
||||
const numrec = await mythistable.findAllIdApp(idappdest).then((arrrec) => {
|
||||
if (arrrec && arrrec.length > 1) {
|
||||
return arrrec.length; // Has Already set
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
// Before check if exist more than 1 record in the destination,
|
||||
// if Yes don't copy
|
||||
if (numrec <= 0) {
|
||||
return await mythistable.findAllIdApp(idapporig).then(async (arrrec) => {
|
||||
let num = 0;
|
||||
|
||||
for (let ind = 0; ind < arrrec.length; ind++) {
|
||||
let newrec = new mythistable(arrrec[ind]._doc);
|
||||
newrec._id = new ObjectID();
|
||||
newrec.idapp = idappdest;
|
||||
|
||||
await newrec.save((err, rec) => {
|
||||
if (rec) {
|
||||
num++;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
return num;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
isBitActive(bit, whattofind) {
|
||||
return ((bit & whattofind) === whattofind)
|
||||
@@ -658,4 +695,38 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
extractNameAndSurnameByComplete(name_complete) {
|
||||
const suffissoCognome = ['Del', 'La', 'De', 'Lo'];
|
||||
|
||||
let campi = name_complete.split(" ");
|
||||
let namesurname = {
|
||||
name: '',
|
||||
surname: '',
|
||||
};
|
||||
|
||||
if (campi.length === 2) {
|
||||
namesurname.name = campi[0];
|
||||
namesurname.surname = campi[1];
|
||||
}else if (campi.length === 3) {
|
||||
if (suffissoCognome.includes(campi[1])) {
|
||||
namesurname.name = campi[0];
|
||||
namesurname.surname = campi[1] + " " + campi[2];
|
||||
} else {
|
||||
namesurname.name = campi[0] + " " + campi[1];
|
||||
namesurname.surname = campi[2];
|
||||
}
|
||||
}else if (campi.length === 4) {
|
||||
namesurname.name = campi[0] + " " + campi[1];
|
||||
namesurname.surname = campi[2] + " " + campi[3];
|
||||
}else if (campi.length > 4) {
|
||||
namesurname.name = campi[0] + " " + campi[1];
|
||||
namesurname.surname = " " + campi[2];
|
||||
for (const ind = 3; ind < campi.length; ind++) {
|
||||
namesurname.surname += " " + campi[ind];
|
||||
}
|
||||
}
|
||||
|
||||
return namesurname
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user